OSMQ
v2.0.1

osmq.records
Class DataRecordWrapper

java.lang.Object
  extended byosmq.records.DataRecordWrapper
All Implemented Interfaces:
ByteArray, java.lang.Cloneable, DataRecord, osmq.datarows.DataRow, Immutable, java.io.Serializable

public class DataRecordWrapper
extends java.lang.Object
implements DataRecord, java.lang.Cloneable, java.io.Serializable

See Also:
Serialized Form

Field Summary
 
Fields inherited from interface osmq.records.DataRecord
DEFAULT_DELIMITER
 
Constructor Summary
DataRecordWrapper(DataRecord ds)
           
 
Method Summary
 void clear(int p)
          Clears the value at the designated position, setting it to null (or zero if numeric)
 void clearAll()
          Clears all the elements in the DataRecord object, setting them to null (or zero if numeric)
 java.lang.Object clone()
           
 java.lang.Object[] getAsArray()
          Returns an array that contains all element values
 java.math.BigDecimal getBigDecimal(int p)
          Returns the value at the designated position in the DataRecord object as a BigDecimal
 boolean getBoolean(int p)
          Returns the value at the designated position in the DataRecord object as a boolean
 byte getByte(int p)
          Returns the value at the designated position in the DataRecord object as a byte
 byte[] getBytes()
          Returns the dataset elements as an array of bytes.
 char getChar(int p)
          Returns the value at the designated position in the DataRecord object as a char
 java.util.Date getDate(int p)
          Returns the value at the designated position in the DataRecord object as a Java Date
 char getDefaultDelimiter()
          Returns the character that is used to delimit the various elements when the elements are strung together.
 double getDouble(int p)
          Returns the value at the designated position in the DataRecord object as a double
 int getElementCount()
          Returns the number of positions in the DataRecord (including those that are empty)
 float getFloat(int p)
          Returns the value at the designated position in the DataRecord object as a float
 java.lang.String getFormattedDateString(int posn)
          Returns the value at the designated position as a formatted date string in CCYY-MM-DD format.
 int getInt(int p)
          Returns the value at the designated position in the DataRecord object as an integer.
 long getLong(int p)
          Returns the value at the designated position in the DataRecord object as a long integer
 java.lang.Object getObject(int p)
          Returns the value of the designated position in the DataRecord.
 int getOffsetIndex()
          Returns the base index currently used to reference elements in the DataRecord.
 short getShort(int p)
          Returns the value at the designated position in the DataRecord object as a short integer
 java.sql.Date getSQLDate(int posn)
          Returns the value at the designated position as a java.SQL.Date
 java.lang.String getString(int p)
          Returns the value of the designated position in the DataRecord object as a String
 java.lang.String getText()
          Creates a delimited String from the DataRecord elements The first character in the String is assumed to be the delimiting character.
 java.lang.String getUnformattedDateString(int posn)
          Returns the value at the designated position as an unformatted date string in CCYYMMDD format.
 java.lang.String getUpperCaseString(int p)
          Returns the value at the designated position in the DataRecord object as a String with all characters forced into upper case.
 boolean hasADelimiter()
           
 boolean hasAValue(int p)
          Determines whether a position has a value (versus null)
 boolean isADataRecord()
           
 boolean isEmpty(int p)
          Determines if a position has no value (is empty).
 boolean isImmutable()
          Returns true if this is an immutable message.
 boolean isNull(int p)
          Determines if a position has no value (is a null value).
 void resetSize(int newsize)
          Resets the size (number of elements) in the DataRecord object, and clears all the values
 void setBigDecimal(int p, java.math.BigDecimal value)
          Sets the element at the designated position in the DataRecord object to a BigDecimal value
 void setBoolean(int p, boolean value)
          Sets the element at the designated position in the DataRecord object to a boolean value
 void setByte(int p, byte value)
          Sets the element at the designated position in the DataRecord object to a byte value
 void setBytes(byte[] value)
          Sets the DataRecord elements to the values found in a delimited array of bytes.
 void setChar(int p, char value)
          Sets the element at the designated position in the DataRecord object to a char value
 void setDate(int p, java.util.Date value)
          Sets the element at the designated position in the DataRecord object to a Date value
 void setDateString(int posn, java.lang.String value)
           
 void setDecimalString(int p, java.lang.String value)
          Sets the element at the designated position in the DataRecord object to a decimal String value
 void setDouble(int p, double value)
          Sets the element at the designated position in the DataRecord object to a double value
 void setFloat(int p, float value)
          Sets the element at the designated position in the DataRecord object to a float value
 void setFromArray(java.lang.Object[] s)
          Sets the data elements from the values in an array.
 void setImmutable()
          Sets the DataRecord's state to immutable. The values of an immutable DataRecord cannot be modified.
 void setInt(int p, int value)
          Sets the element at the designated position in the DataRecord object to an int value
 void setLong(int p, long value)
          Sets the element at the designated position in the DataRecord object to a long value
 void setNull(int p)
          Sets the value at the designated position in the DataRecord to null
 void setObject(int p, java.lang.Object value)
          Sets the value at the designated position in the DataRecord object
 void setOffsetIndex(int value)
          Sets the base index used to reference elements in the DataRecord.
 void setShort(int p, short value)
          Sets the element at the designated position in the DataRecord object to a short value
 void setString(int p, java.lang.String s)
          Sets the element at the designated position in the DataRecord object to a String value
 void setText(java.lang.String value)
          Sets the DataRecord elements to the values found in a delimited String.
 void setTrimmedString(int p, java.lang.String s)
          Sets the element at the designated position to a String value.
 void setUpperCaseString(int p, java.lang.String value)
          Sets the element at the designated position in the DataRecord object to an upper-case String value
 java.lang.String toString()
           
 boolean wasNull()
          Returns true if the lastfetched element was a null object, or an object with a string length of zero.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DataRecordWrapper

public DataRecordWrapper(DataRecord ds)
Method Detail

isImmutable

public boolean isImmutable()
Returns true if this is an immutable message.

Specified by:
isImmutable in interface Immutable
See Also:
setImmutable()

setImmutable

public void setImmutable()
Sets the DataRecord's state to immutable. The values of an immutable DataRecord cannot be modified. Any attempt to modify those values will result in an ImmutableException being thrown.

Specified by:
setImmutable in interface Immutable
See Also:
ImmutableException

clearAll

public void clearAll()
Clears all the elements in the DataRecord object, setting them to null (or zero if numeric)

Specified by:
clearAll in interface DataRecord
Throws:
ImmutableDataException - if the DataRecord object is immutable.

clear

public void clear(int p)
Clears the value at the designated position, setting it to null (or zero if numeric)

Specified by:
clear in interface DataRecord
Throws:
ImmutableDataException - if the DataRecord object is immutable.
See Also:
clearAll()

toString

public java.lang.String toString()

getText

public java.lang.String getText()
Creates a delimited String from the DataRecord elements The first character in the String is assumed to be the delimiting character.

Specified by:
getText in interface DataRecord

getBytes

public byte[] getBytes()
Returns the dataset elements as an array of bytes. The first byte in the array is the element delimiter.

Specified by:
getBytes in interface DataRecord

getObject

public java.lang.Object getObject(int p)
Returns the value of the designated position in the DataRecord.

Specified by:
getObject in interface DataRecord
Parameters:
p - the first position is 1, the second is 2, ...
Returns:
the value as an Object or null if the position is empty.
Throws:
java.lang.ArrayIndexOutOfBoundsException - if positionIndex is not a valid position.

getAsArray

public java.lang.Object[] getAsArray()
Description copied from interface: DataRecord
Returns an array that contains all element values

Specified by:
getAsArray in interface DataRecord

getChar

public char getChar(int p)
Returns the value at the designated position in the DataRecord object as a char

Specified by:
getChar in interface DataRecord
Parameters:
p - the first position is 1, the second is 2, ...
Returns:
the value as a char or 0 if the position is empty.
Throws:
java.lang.ArrayIndexOutOfBoundsException - if positionIndex is not a valid position.

getByte

public byte getByte(int p)
Returns the value at the designated position in the DataRecord object as a byte

Specified by:
getByte in interface DataRecord
Parameters:
p - the first position is 1, the second is 2, ...
Returns:
the value as a byte or 0 if the position is empty.
Throws:
java.lang.ArrayIndexOutOfBoundsException - if positionIndex is not a valid position.

getBoolean

public boolean getBoolean(int p)
Returns the value at the designated position in the DataRecord object as a boolean

Specified by:
getBoolean in interface DataRecord
Parameters:
p - the first position is 1, the second is 2, ...
Returns:
the value as a boolean or a null if the position is empty.
Throws:
java.lang.ArrayIndexOutOfBoundsException - if positionIndex is not a valid position.

getFloat

public float getFloat(int p)
Returns the value at the designated position in the DataRecord object as a float

Specified by:
getFloat in interface DataRecord
Parameters:
p - the first position is 1, the second is 2, ...
Returns:
the position value as a double or 0.0 if the position is empty.
Throws:
java.lang.ArrayIndexOutOfBoundsException - if positionIndex is not a valid position.

getDouble

public double getDouble(int p)
Returns the value at the designated position in the DataRecord object as a double

Specified by:
getDouble in interface DataRecord
Parameters:
p - the first position is 1, the second is 2, ...
Returns:
the position value as a double or 0.0 if the position is empty.
Throws:
java.lang.ArrayIndexOutOfBoundsException - if positionIndex is not a valid position.

getBigDecimal

public java.math.BigDecimal getBigDecimal(int p)
Returns the value at the designated position in the DataRecord object as a BigDecimal

Specified by:
getBigDecimal in interface DataRecord
Parameters:
p - the first position is 1, the second is 2, ...
Returns:
the position value as a BigDecimal or null if the position is empty.
Throws:
java.lang.ArrayIndexOutOfBoundsException - if positionIndex is not a valid position.

getElementCount

public int getElementCount()
Returns the number of positions in the DataRecord (including those that are empty)

Specified by:
getElementCount in interface DataRecord
Returns:
the number of DataRecord elements
Throws:
java.lang.ArrayIndexOutOfBoundsException - if positionIndex is not a valid position.

getInt

public int getInt(int p)
Returns the value at the designated position in the DataRecord object as an integer.

Specified by:
getInt in interface DataRecord
Parameters:
p - the first position is 1, the second is 2, ...
Returns:
the value as an int or a 0 if the position is empty.
Throws:
java.lang.ArrayIndexOutOfBoundsException - if positionIndex is not a valid position.

getLong

public long getLong(int p)
Returns the value at the designated position in the DataRecord object as a long integer

Specified by:
getLong in interface DataRecord
Parameters:
p - the first position is 1, the second is 2, ...
Returns:
the position value as a short or 0 if the position is empty.
Throws:
java.lang.ArrayIndexOutOfBoundsException - if columnIndex is not a valid element position.

getShort

public short getShort(int p)
Returns the value at the designated position in the DataRecord object as a short integer

Specified by:
getShort in interface DataRecord
Parameters:
p - the first position is 1, the second is 2, ...
Returns:
the position value as a short or 0 if the position is empty.
Throws:
java.lang.ArrayIndexOutOfBoundsException - if columnIndex is not a valid element position.

getString

public java.lang.String getString(int p)
Returns the value of the designated position in the DataRecord object as a String

Specified by:
getString in interface DataRecord
Parameters:
p - the first position is 1, the second is 2, ...
Returns:
the position value as a String or a null String if the position is empty.
Throws:
java.lang.ArrayIndexOutOfBoundsException - if positionIndex is not a valid position.

getUpperCaseString

public java.lang.String getUpperCaseString(int p)
Returns the value at the designated position in the DataRecord object as a String with all characters forced into upper case.

Specified by:
getUpperCaseString in interface DataRecord
Parameters:
p - the first position is 1, the second is 2, ...
Returns:
the value as a String or a null if the position is empty.
Throws:
java.lang.ArrayIndexOutOfBoundsException - if positionIndex is not a valid element position.

getDate

public java.util.Date getDate(int p)
Returns the value at the designated position in the DataRecord object as a Java Date

Specified by:
getDate in interface DataRecord
Parameters:
p - the first position is 1, the second is 2, ...
Returns:
the position value as a short or 0 if the position is empty.
Throws:
java.lang.ArrayIndexOutOfBoundsException - if columnIndex is not a valid element position.

hasAValue

public boolean hasAValue(int p)
Determines whether a position has a value (versus null)

Specified by:
hasAValue in interface DataRecord
Parameters:
p - the position containing the value to be tested
Returns:
true of there is a non-null value at position p, else false
Throws:
java.lang.ArrayIndexOutOfBoundsException - if positionIndex is not a valid position.

isEmpty

public boolean isEmpty(int p)
Determines if a position has no value (is empty). Alias for isNull(int)

Specified by:
isEmpty in interface DataRecord
Parameters:
p - the position containing the value to be tested
Returns:
true if there is a null value (no value) at position p, else false
Throws:
java.lang.ArrayIndexOutOfBoundsException - if positionIndex is not a valid position.

isNull

public boolean isNull(int p)
Determines if a position has no value (is a null value). Alias for isEmpty(int)

Specified by:
isNull in interface DataRecord
Parameters:
p - the position containing the value to be tested
Returns:
true if there is a null value (no value) at position p, else false
Throws:
java.lang.ArrayIndexOutOfBoundsException - if positionIndex is not a valid position.

resetSize

public void resetSize(int newsize)
Resets the size (number of elements) in the DataRecord object, and clears all the values

Specified by:
resetSize in interface DataRecord
Parameters:
newsize - the number of elements in the resized object
Throws:
ImmutableDataException - if the DataRecord object is immutable

setText

public void setText(java.lang.String value)
Sets the DataRecord elements to the values found in a delimited String. The first character in the String is assumed to be the delimiting character.

Specified by:
setText in interface DataRecord
Throws:
ImmutableDataException - if the DataRecord object is immutable.

setBytes

public void setBytes(byte[] value)
Sets the DataRecord elements to the values found in a delimited array of bytes. The first byte in the array is assumed to be the delimiting character.

Specified by:
setBytes in interface DataRecord
Throws:
ImmutableDataException - if the DataRecord object is immutable.

setObject

public void setObject(int p,
                      java.lang.Object value)
Sets the value at the designated position in the DataRecord object

Specified by:
setObject in interface DataRecord
Parameters:
value - the element's new value
p - the first position is 1, the second is 2, ...
Throws:
java.lang.ArrayIndexOutOfBoundsException - if p is not a valid element position.
ImmutableException - if the DataRecord object is immutable.

setString

public void setString(int p,
                      java.lang.String s)
Sets the element at the designated position in the DataRecord object to a String value

Specified by:
setString in interface DataRecord
Parameters:
p - the element's relative position (1 to n)
s - the element's new value
Throws:
java.lang.ArrayIndexOutOfBoundsException - if p is not a valid element position.
ImmutableException - if the DataRecord object is immutable.

setTrimmedString

public void setTrimmedString(int p,
                             java.lang.String s)
Description copied from interface: DataRecord
Sets the element at the designated position to a String value. Setting the value also eliminates any leading or trailing spaces.

Specified by:
setTrimmedString in interface DataRecord
Parameters:
p - the first position is 1, the second is 2, ...
s - the element's new value

setNull

public void setNull(int p)
Sets the value at the designated position in the DataRecord to null

Specified by:
setNull in interface DataRecord
Parameters:
p - the first position is 1, the second is 2, ...
Throws:
java.lang.ArrayIndexOutOfBoundsException - if p is not a valid element position.
ImmutableException - if the DataRecord object is immutable.

setByte

public void setByte(int p,
                    byte value)
Sets the element at the designated position in the DataRecord object to a byte value

Specified by:
setByte in interface DataRecord
Parameters:
value - the element's new value
p - the first position is 1, the second is 2, ...
Throws:
java.lang.ArrayIndexOutOfBoundsException - if positionIndex is not a valid position.
ImmutableException - if the DataRecord object is immutable.

setBoolean

public void setBoolean(int p,
                       boolean value)
Sets the element at the designated position in the DataRecord object to a boolean value

Specified by:
setBoolean in interface DataRecord
Parameters:
value - the element's new value
p - the first position is 1, the second is 2, ...
Throws:
java.lang.ArrayIndexOutOfBoundsException - if positionIndex is not a valid position.
ImmutableException - if the DataRecord object is immutable.

setChar

public void setChar(int p,
                    char value)
Sets the element at the designated position in the DataRecord object to a char value

Specified by:
setChar in interface DataRecord
Parameters:
value - the element's new value
p - the first position is 1, the second is 2, ...
Throws:
java.lang.ArrayIndexOutOfBoundsException - if positionIndex is not a valid position.
ImmutableException - if the DataRecord object is immutable.

setFloat

public void setFloat(int p,
                     float value)
Sets the element at the designated position in the DataRecord object to a float value

Specified by:
setFloat in interface DataRecord
Parameters:
value - the element's new value
p - the first position is 1, the second is 2, ...
Throws:
java.lang.ArrayIndexOutOfBoundsException - if positionIndex is not a valid position.
ImmutableException - if the DataRecord object is immutable.

setDouble

public void setDouble(int p,
                      double value)
Sets the element at the designated position in the DataRecord object to a double value

Specified by:
setDouble in interface DataRecord
Parameters:
value - the element's new value
p - the first position is 1, the second is 2, ...
Throws:
java.lang.ArrayIndexOutOfBoundsException - if positionIndex is not a valid position.
ImmutableException - if the DataRecord object is immutable.

setDecimalString

public void setDecimalString(int p,
                             java.lang.String value)
Sets the element at the designated position in the DataRecord object to a decimal String value

Specified by:
setDecimalString in interface DataRecord
Parameters:
value - the element's new value
Throws:
java.lang.ArrayIndexOutOfBoundsException - if positionIndex is not a valid position.
ImmutableException - if the DataRecord object is immutable.

setBigDecimal

public void setBigDecimal(int p,
                          java.math.BigDecimal value)
Sets the element at the designated position in the DataRecord object to a BigDecimal value

Specified by:
setBigDecimal in interface DataRecord
Parameters:
value - the element's new value
p - the first position is 1, the second is 2, ...
Throws:
java.lang.ArrayIndexOutOfBoundsException - if positionIndex is not a valid position.
ImmutableException - if the DataRecord object is immutable.

setDate

public void setDate(int p,
                    java.util.Date value)
Sets the element at the designated position in the DataRecord object to a Date value

Specified by:
setDate in interface DataRecord
Parameters:
value - the element's new value
p - the first position is 1, the second is 2, ...
Throws:
java.lang.ArrayIndexOutOfBoundsException - if positionIndex is not a valid position.
ImmutableException - if the DataRecord object is immutable.

setFromArray

public void setFromArray(java.lang.Object[] s)
Sets the data elements from the values in an array.

Specified by:
setFromArray in interface DataRecord
Throws:
ImmutableException - if the data elements are immutable.

setInt

public void setInt(int p,
                   int value)
Sets the element at the designated position in the DataRecord object to an int value

Specified by:
setInt in interface DataRecord
Parameters:
value - the element's new value
p - the first position is 1, the second is 2, ...
Throws:
java.lang.ArrayIndexOutOfBoundsException - if positionIndex is not a valid position.
ImmutableException - if the DataRecord object is immutable.

setLong

public void setLong(int p,
                    long value)
Sets the element at the designated position in the DataRecord object to a long value

Specified by:
setLong in interface DataRecord
Parameters:
value - the element's new value
p - the first position is 1, the second is 2, ...
Throws:
java.lang.ArrayIndexOutOfBoundsException - if positionIndex is not a valid position.
ImmutableException - if the DataRecord object is immutable.

setShort

public void setShort(int p,
                     short value)
Sets the element at the designated position in the DataRecord object to a short value

Specified by:
setShort in interface DataRecord
Parameters:
value - the element's new value
p - the first position is 1, the second is 2, ...
Throws:
java.lang.ArrayIndexOutOfBoundsException - if positionIndex is not a valid position.
ImmutableException - if the DataRecord object is immutable.

setUpperCaseString

public void setUpperCaseString(int p,
                               java.lang.String value)
Sets the element at the designated position in the DataRecord object to an upper-case String value

Specified by:
setUpperCaseString in interface DataRecord
Parameters:
value - the element's new value
p - the first position is 1, the second is 2, ...
Throws:
java.lang.ArrayIndexOutOfBoundsException - if positionIndex is not a valid position.
ImmutableException - if the DataRecord object is immutable.

setOffsetIndex

public void setOffsetIndex(int value)
Sets the base index used to reference elements in the DataRecord. If not set explicitly, this index defaults to 1.

Specified by:
setOffsetIndex in interface DataRecord
Parameters:
value - the new base index value

getOffsetIndex

public int getOffsetIndex()
Returns the base index currently used to reference elements in the DataRecord.

Specified by:
getOffsetIndex in interface DataRecord
See Also:
setOffsetIndex(int)

wasNull

public boolean wasNull()
Returns true if the lastfetched element was a null object, or an object with a string length of zero. (The last fetched is the element referenced by the last getXXX() method call.)

Specified by:
wasNull in interface DataRecord

setDateString

public void setDateString(int posn,
                          java.lang.String value)
Specified by:
setDateString in interface DataRecord

getFormattedDateString

public java.lang.String getFormattedDateString(int posn)
Description copied from interface: DataRecord
Returns the value at the designated position as a formatted date string in CCYY-MM-DD format.

Specified by:
getFormattedDateString in interface DataRecord
Returns:
the position value as a String or null if the position is empty.

getUnformattedDateString

public java.lang.String getUnformattedDateString(int posn)
Description copied from interface: DataRecord
Returns the value at the designated position as an unformatted date string in CCYYMMDD format. (This is the normal physical storage format for a date).

Specified by:
getUnformattedDateString in interface DataRecord
Returns:
the position value as a String or null if the position is empty.
See Also:
DataRecord.setDateString(int, String)

getSQLDate

public java.sql.Date getSQLDate(int posn)
Description copied from interface: DataRecord
Returns the value at the designated position as a java.SQL.Date

Specified by:
getSQLDate in interface DataRecord
Returns:
the position value as an sql Date or null if the position is empty.
See Also:
DataRecord.setDateString(int, String)

getDefaultDelimiter

public char getDefaultDelimiter()
Description copied from interface: DataRecord
Returns the character that is used to delimit the various elements when the elements are strung together. The string of elements is accessible by calling the getText() method.

Specified by:
getDefaultDelimiter in interface DataRecord

hasADelimiter

public boolean hasADelimiter()
Specified by:
hasADelimiter in interface ByteArray

clone

public java.lang.Object clone()
Specified by:
clone in interface DataRecord

isADataRecord

public boolean isADataRecord()
Specified by:
isADataRecord in interface ByteArray

(c) 2000 - 2003 MQue Systems
All Rights Reserved