OSMQ
v2.0.1

osmq.records
Class DataRecordBean

java.lang.Object
  extended byosmq.util.ImmutableImpl
      extended byosmq.records.DataRecordBean
All Implemented Interfaces:
ByteArray, java.lang.Cloneable, DataRecord, osmq.datarows.DataRow, Immutable, java.io.Serializable
Direct Known Subclasses:
KeyedDataRecordBean

public class DataRecordBean
extends ImmutableImpl
implements DataRecord, osmq.datarows.DataRow, java.lang.Cloneable, java.io.Serializable

Default implementation of a DataRecord. Uses a CoreRecord as an aggregate object container.

See Also:
Serialized Form

Field Summary
 
Fields inherited from interface osmq.records.DataRecord
DEFAULT_DELIMITER
 
Constructor Summary
DataRecordBean()
           
DataRecordBean(byte[] value)
           
DataRecordBean(CoreRecord c)
           
DataRecordBean(int sz)
           
DataRecordBean(java.lang.Object[] elements)
           
DataRecordBean(java.lang.String value)
           
 
Method Summary
 void clear(int posn)
          Clears the value of the designated position to null (or zero if numeric)
 void clearAll()
          Clear all the elements in the DataRecord object to null (or zero if numeric)
 java.lang.Object clone()
           
 java.lang.Object[] getAsArray()
          Returns an array that contains all element values in the DataRecord
 java.math.BigDecimal getBigDecimal(int p)
          Gets the value at the designated position in the DataRecord object as a BigDecimal
 boolean getBoolean(int posn)
          Gets the value at the designated position in the DataRecord object as a boolean
 byte getByte(int posn)
          Gets 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 posn)
          Gets the value at the designated position in the DataRecord object as a char
 DataRecord getClone()
           
 java.util.Date getDate(int posn)
          Gets the value at the designated position in the DataRecord object as a Date
 char getDefaultDelimiter()
          Returns the character that is used to delimit the various elements when the elements are strung together.
 double getDouble(int p)
          Gets the value at the designated position in the DataRecord object as a double
 int getElementCount()
          Returns the number of element positions (including those that are empty)
 float getFloat(int posn)
          Gets 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)
          Gets the value at the designated position in the DataRecord object as an integer
 long getLong(int p)
          Gets the value at the designated position in the DataRecord object as a long
 java.lang.Object getObject(int posn)
          Gets the value at the designated position in the DataRecord object as an Object
 int getOffsetIndex()
          Returns the base index currently used to reference elements in the DataRecord.
 short getShort(int n)
          Gets the value at the designated position in the DataRecord object as a short
 java.sql.Date getSQLDate(int posn)
          Returns the value at the designated position as a java.SQL.Date
 java.lang.String getString(int posn)
          Gets the value at the designated position in the DataRecord object as a String
 java.lang.String getText()
          Creates a delimited String from the DataRecord elements.
 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 n)
          Returns the value at the designated position as a String with all characters forced into upper case.
 boolean hasADelimiter()
           
 boolean hasAValue(int posn)
          Determines whether a position has a value (versus null)
 boolean isADataRecord()
           
 boolean isEmpty(int posn)
          Determines if a position has no value (is empty).
 boolean isNull(int posn)
          Determines if a position has no value (is empty).
static void main(java.lang.String[] vars)
           
 void resetSize(int newsize)
          Resets the size (number of elements) in the DataRecord object, and clears all the values
 void setBigDecimal(int posn, java.math.BigDecimal value)
          Sets the element of the designated position in the DataRecord object to a BigDecimal value
 void setBoolean(int posn, boolean value)
          Sets the element of the designated position in the DataRecord object to a boolean value
 void setByte(int posn, byte value)
          Sets the element of the designated position in the DataRecord object to a byte value
 void setBytes(byte[] value)
          Sets the value of element in the DataRecord to values found in a byte array
 void setChar(int posn, char value)
          Sets the element of the designated position in the DataRecord object to a char value
 void setDate(int posn, java.util.Date value)
          Sets the element of the designated position in the DataRecord object to a date/time value
 void setDateString(int posn, java.lang.String value)
           
 void setDecimalString(int posn, java.lang.String value)
          Sets the element at the designated position to a String value that represents a decimal value.
 void setDouble(int posn, double value)
          Sets the element of the designated position in the DataRecord object to a double value
 void setFloat(int posn, float value)
          Sets the element of 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 setInt(int posn, int value)
          Sets the element of the designated position in the DataRecord object to an integer value
 void setLong(int posn, long value)
          Sets the element of the designated position in the DataRecord object to a long value
 void setNull(int posn)
          Sets the element at the designated position in the DataRecord object to null
 void setObject(int posn, java.lang.Object value)
          Sets the element at the designated position in the DataRecord object to a Object value
 void setOffsetIndex(int value)
          Sets the indexing scheme by indicating the index of the first element in the DataRecord.
 void setShort(int posn, short value)
          Sets the element of the designated position in the DataRecord object to a short value
 void setString(int posn, java.lang.String s)
          Sets the element at the designated position in the DataRecord object to a String value
 void setText(java.lang.String text)
          Sets the value of element in the DataRecord to values found in a delimited String.
 void setTrimmedString(int posn, java.lang.String s)
          Sets the element at the designated position to a String value.
 void setUpperCaseString(int posn, java.lang.String s)
          Sets the element at the designated position 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 osmq.util.ImmutableImpl
isImmutable, setImmutable
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface osmq.util.Immutable
isImmutable, setImmutable
 

Constructor Detail

DataRecordBean

public DataRecordBean()

DataRecordBean

public DataRecordBean(java.lang.Object[] elements)

DataRecordBean

public DataRecordBean(int sz)

DataRecordBean

public DataRecordBean(CoreRecord c)

DataRecordBean

public DataRecordBean(java.lang.String value)

DataRecordBean

public DataRecordBean(byte[] value)
Method Detail

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

clearAll

public void clearAll()
              throws ImmutableException
Clear all the elements in the DataRecord object to null (or zero if numeric)

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

clear

public void clear(int posn)
           throws ImmutableException
Clears the value of the designated position to null (or zero if numeric)

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

getClone

public DataRecord getClone()

toString

public java.lang.String toString()

setOffsetIndex

public void setOffsetIndex(int value)
Sets the indexing scheme by indicating the index of the first element in the DataRecord.

Typical values:

0 indicates a scheme of 0 thru n-0,

1 indicates a scheme of 1 thru n.

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

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

getText

public java.lang.String getText()
Creates a delimited String from the DataRecord elements. The first character in the String is 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 posn)
Gets the value at the designated position in the DataRecord object as an Object

Specified by:
getObject in interface DataRecord
Parameters:
posn - the relative position, based on the indexing scheme
Returns:
the position value as a char, or '\0' if the position is empty.
Throws:
java.lang.ArrayIndexOutOfBoundsException - if positionIndex is not a valid position.

getAsArray

public java.lang.Object[] getAsArray()
Returns an array that contains all element values in the DataRecord

Specified by:
getAsArray in interface DataRecord

getChar

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

Specified by:
getChar in interface DataRecord
Parameters:
posn - the relative position, based on the indexing scheme
Returns:
the position 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 posn)
Gets the value at the designated position in the DataRecord object as a byte

Specified by:
getByte in interface DataRecord
Parameters:
posn - the relative position, based on the indexing scheme
Returns:
the position value as a byte, or binary 0 if the position is empty.
Throws:
java.lang.ArrayIndexOutOfBoundsException - if positionIndex is not a valid position.

getBoolean

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

Specified by:
getBoolean in interface DataRecord
Parameters:
posn - the relative position, based on the indexing scheme
Returns:
the position value as a boolean (true or false), or false if the position is empty.
Throws:
java.lang.ArrayIndexOutOfBoundsException - if positionIndex is not a valid position.

getFloat

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

Specified by:
getFloat in interface DataRecord
Parameters:
posn - the relative position, based on the indexing scheme
Returns:
the position value as a float, 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)
Gets 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)
Gets 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()
Description copied from interface: DataRecord
Returns the number of element positions (including those that are empty)

Specified by:
getElementCount in interface DataRecord
Returns:
the number of DataRecord elements

getInt

public int getInt(int p)
Gets 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 position value as an int, or 0 if the position is empty.
Throws:
java.lang.ArrayIndexOutOfBoundsException - if positionIndex is not a valid position.

getLong

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

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

getShort

public short getShort(int n)
Gets the value at the designated position in the DataRecord object as a short

Specified by:
getShort in interface DataRecord
Parameters:
n - 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 positionIndex is not a valid position.

getString

public java.lang.String getString(int posn)
Gets the value at the designated position in the DataRecord object as a String

Specified by:
getString in interface DataRecord
Parameters:
posn - the relative position, based on the indexing scheme
Returns:
the position value as a String or null if the position is empty.
Throws:
java.lang.ArrayIndexOutOfBoundsException - if positionIndex is not a valid position.

getUpperCaseString

public java.lang.String getUpperCaseString(int n)
Description copied from interface: DataRecord
Returns the value at the designated position as a String with all characters forced into upper case.

Specified by:
getUpperCaseString in interface DataRecord
Parameters:
n - the first position is 1, the second is 2, ...
Returns:
the value as a String or a null if the position is empty.

getDate

public java.util.Date getDate(int posn)
Gets the value at the designated position in the DataRecord object as a Date

Specified by:
getDate in interface DataRecord
Parameters:
posn - the relative position, based on the indexing scheme
Returns:
the position value as a Date or null if the position is empty.
Throws:
java.lang.ArrayIndexOutOfBoundsException - if positionIndex is not a valid position.

hasAValue

public boolean hasAValue(int posn)
Description copied from interface: DataRecord
Determines whether a position has a value (versus null)

Specified by:
hasAValue in interface DataRecord
Returns:
true of there is a non-null value at position p, else false

isEmpty

public boolean isEmpty(int posn)
Description copied from interface: DataRecord
Determines if a position has no value (is empty). Alias method for isNull(int)

Specified by:
isEmpty in interface DataRecord
Returns:
true if there is a null value (no value) at position p, else false

isNull

public boolean isNull(int posn)
Description copied from interface: DataRecord
Determines if a position has no value (is empty). Alias method for isEmpty(int)

Specified by:
isNull in interface DataRecord
Returns:
true if there is a null value (no value) at position p, else false

resetSize

public void resetSize(int newsize)
               throws ImmutableException
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:
ImmutableException - if the DataRecord object is immutable

setObject

public void setObject(int posn,
                      java.lang.Object value)
               throws ImmutableException
Sets the element at the designated position in the DataRecord object to a Object value

Specified by:
setObject in interface DataRecord
Parameters:
posn - the relative position of the element, based on the indexing scheme
value - the element's new value
Throws:
java.lang.ArrayIndexOutOfBoundsException - if posn is not a valid position.
ImmutableException - if the DataRecord object is immutable.

setText

public void setText(java.lang.String text)
Sets the value of element in the DataRecord to values found in a delimited String.

Specified by:
setText in interface DataRecord
Parameters:
text - the delimited String of elements. The first character in the String is assumed to be the delimiter.
Throws:
ImmutableException - if the DataRecord object is immutable

setBytes

public void setBytes(byte[] value)
Sets the value of element in the DataRecord to values found in a byte array

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

setString

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

Specified by:
setString in interface DataRecord
Parameters:
posn - the relative position of the element, based on the indexing scheme
s - the element's new value
Throws:
java.lang.ArrayIndexOutOfBoundsException - if posn is not a valid position.
ImmutableException - if the DataRecord object is immutable.

setTrimmedString

public void setTrimmedString(int posn,
                             java.lang.String s)
                      throws ImmutableException
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:
posn - the first position is 1, the second is 2, ...
s - the element's new value
Throws:
ImmutableException - if the DataRecord object is immutable.

setNull

public void setNull(int posn)
             throws ImmutableException
Sets the element at the designated position in the DataRecord object to null

Specified by:
setNull in interface DataRecord
Parameters:
posn - the relative position of the element, based on the indexing scheme
Throws:
java.lang.ArrayIndexOutOfBoundsException - if posn is not a valid position.
ImmutableException - if the DataRecord object is immutable.

setByte

public void setByte(int posn,
                    byte value)
             throws ImmutableException
Sets the element of the designated position in the DataRecord object to a byte value

Specified by:
setByte in interface DataRecord
Parameters:
posn - the relative position of the element, based on the indexing scheme
value - the element's new value
Throws:
java.lang.ArrayIndexOutOfBoundsException - if posn is not a valid position.
ImmutableException - if the DataRecord object is immutable.

setBoolean

public void setBoolean(int posn,
                       boolean value)
                throws ImmutableException
Sets the element of the designated position in the DataRecord object to a boolean value

Specified by:
setBoolean in interface DataRecord
Parameters:
posn - the relative position of the element, based on the indexing scheme
value - the element's new value, either true or false.
Throws:
java.lang.ArrayIndexOutOfBoundsException - if posn is not a valid position.
ImmutableException - if the DataRecord object is immutable.

setChar

public void setChar(int posn,
                    char value)
             throws ImmutableException
Sets the element of the designated position in the DataRecord object to a char value

Specified by:
setChar in interface DataRecord
Parameters:
posn - the relative position of the element, based on the indexing scheme
value - the element's new value
Throws:
java.lang.ArrayIndexOutOfBoundsException - if posn is not a valid position.
ImmutableException - if the DataRecord object is immutable.

setFloat

public void setFloat(int posn,
                     float value)
              throws ImmutableException
Sets the element of the designated position in the DataRecord object to a float value

Specified by:
setFloat in interface DataRecord
Parameters:
posn - the element's relative position, based on the indexing scheme
value - the element's new value
Throws:
java.lang.ArrayIndexOutOfBoundsException - if posn is not a valid position.
ImmutableException - if the DataRecord object is immutable.

setDouble

public void setDouble(int posn,
                      double value)
               throws ImmutableException
Sets the element of the designated position in the DataRecord object to a double value

Specified by:
setDouble in interface DataRecord
Parameters:
posn - the element's relative position, based on the indexing scheme
value - the element's new value
Throws:
java.lang.ArrayIndexOutOfBoundsException - if posn is not a valid position.
ImmutableException - if the DataRecord object is immutable.

setDecimalString

public void setDecimalString(int posn,
                             java.lang.String value)
                      throws ImmutableException
Description copied from interface: DataRecord
Sets the element at the designated position to a String value that represents a decimal value. Setting the element ensures that the string has a decimal component, and excessive non-significant decimal values (trailing zeros) are dropped. A value of "5" will result in a string value of "5.0" and a value of "5.400" will result in a string value of "5.4".

Specified by:
setDecimalString in interface DataRecord
Parameters:
value - the element's new value
Throws:
ImmutableException - if the DataRecord object is immutable.

setBigDecimal

public void setBigDecimal(int posn,
                          java.math.BigDecimal value)
                   throws ImmutableException
Sets the element of the designated position in the DataRecord object to a BigDecimal value

Specified by:
setBigDecimal in interface DataRecord
Parameters:
posn - the element's relative position, based on the indexing scheme
value - the element's new value
Throws:
java.lang.ArrayIndexOutOfBoundsException - if posn is not a valid position.
ImmutableException - if the DataRecord object is immutable.

setDate

public void setDate(int posn,
                    java.util.Date value)
             throws ImmutableException
Sets the element of the designated position in the DataRecord object to a date/time value

Specified by:
setDate in interface DataRecord
Parameters:
posn - the element's relative position, based on the indexing scheme
value - the element's new value as a Java Date object
Throws:
java.lang.ArrayIndexOutOfBoundsException - if posn is not a valid position.
ImmutableException - if the DataRecord object is immutable.

setDateString

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

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)

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.

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)

setFromArray

public void setFromArray(java.lang.Object[] s)
                  throws ImmutableException
Description copied from interface: DataRecord
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 posn,
                   int value)
            throws ImmutableException
Sets the element of the designated position in the DataRecord object to an integer value

Specified by:
setInt in interface DataRecord
Parameters:
posn - the element's relative position, based on the indexing scheme
value - the element's new value
Throws:
java.lang.ArrayIndexOutOfBoundsException - if posn is not a valid position.
ImmutableException - if the DataRecord object is immutable.

setLong

public void setLong(int posn,
                    long value)
             throws ImmutableException
Sets the element of the designated position in the DataRecord object to a long value

Specified by:
setLong in interface DataRecord
Parameters:
posn - the element's relative position, based on the indexing scheme
value - the element's new value
Throws:
java.lang.ArrayIndexOutOfBoundsException - if posn is not a valid position.
ImmutableException - if the DataRecord object is immutable.

setShort

public void setShort(int posn,
                     short value)
              throws ImmutableException
Sets the element of the designated position in the DataRecord object to a short value

Specified by:
setShort in interface DataRecord
Parameters:
posn - the element's relative position, based on the indexing scheme
value - the element's new value
Throws:
java.lang.ArrayIndexOutOfBoundsException - if posn is not a valid position.
ImmutableException - if the DataRecord object is immutable.

setUpperCaseString

public void setUpperCaseString(int posn,
                               java.lang.String s)
                        throws ImmutableException
Description copied from interface: DataRecord
Sets the element at the designated position to an upper-case String value

Specified by:
setUpperCaseString in interface DataRecord
Parameters:
posn - the first position is 1, the second is 2, ...
s - the element's new value
Throws:
ImmutableException - if the DataRecord object is immutable.

isADataRecord

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

clone

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

main

public static void main(java.lang.String[] vars)

(c) 2000 - 2003 MQue Systems
All Rights Reserved