jMobileCore toolkit

com.jmobilecore.dstore
Class Record

java.lang.Object
  extended by com.jmobilecore.dstore.Record

public class Record
extends java.lang.Object

A Record represents a database record

Author:
Greg Gridin

Field Summary
protected static Record buffer
          The buffer used for current Record compacting
 byte[] data
          The data for the current Record
 int length
          The length of the data
static int MAX_SIZE
          The maximum size for the record's data
 RecordStructure struct
          The RecordStructure for the current Record
 
Constructor Summary
Record(RecordStructure rStructure)
          Creates an Record instance
Record(RecordStructure rStructure, byte[] data)
          Creates an Record instance
 
Method Summary
protected  void calcLength()
           
protected  void compact()
           
 byte[] getBinaryField(int fIndex)
          Retrieves the value of the designated column in the current Record as a byte[]
 byte[] getBinaryField(java.lang.String fName)
          Retrieves the value of the designated column in the current Record as a byte[]
 boolean getBooleanField(int fIndex)
          Retrieves the value of the designated column in the current Record as a boolean
 boolean getBooleanField(java.lang.String fName)
          Retrieves the value of the designated column in the current Record as a boolean
protected  int getDescriptor(int fIndex)
          Get descriptor for the specified field
 int getIntegerField(int fIndex)
          Retrieves the value of the designated column in the current Record as a int
 int getIntegerField(java.lang.String fName)
          Retrieves the value of the designated column in the current Record as a int
 java.lang.String getStringField(int fIndex)
          Retrieves the value of the designated column in the current Record as a String
 java.lang.String getStringField(java.lang.String fName)
          Retrieves the value of the designated column in the current Record as a String
 boolean isNull(int fIndex)
          Reports whether the field has NULL value.
 boolean isNull(java.lang.String fName)
          Retrieves whether the field has NULL value.
 void reset()
          Reset data for current Record
protected  void setBinaryData(int fIndex, byte[] value, int offset, int numBytes)
          Sets specified column to byte[] value Compacts storage if necessary
 void setBinaryField(int fIndex, byte[] value, int offset, int numBytes)
          Sets specified column to byte[] value
 void setBinaryField(java.lang.String fName, byte[] value, int offset, int numBytes)
          Sets specified column to byte[] value
 void setBooleanField(int fIndex, boolean value)
          Sets specified column to boolean value
 void setBooleanField(java.lang.String fName, boolean value)
          Sets specified column to boolean value
protected  void setDescriptor(int fIndex, int desc)
          Set descriptor for the specified field
 void setIntegerField(int fIndex, int value)
          Sets specified column to int value
 void setIntegerField(java.lang.String fName, int value)
          Sets specified column to int value
 void setNull(int fIndex)
          Sets specified column to NULL value
 void setNull(java.lang.String fName)
          Sets specified column to NULL value
 void setStringField(int fIndex, java.lang.String value)
          Sets specified column to String value
 void setStringField(java.lang.String fName, java.lang.String value)
          Sets specified column to String value
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

buffer

protected static Record buffer
The buffer used for current Record compacting


data

public byte[] data
The data for the current Record


length

public int length
The length of the data


MAX_SIZE

public static int MAX_SIZE
The maximum size for the record's data


struct

public RecordStructure struct
The RecordStructure for the current Record

Constructor Detail

Record

public Record(RecordStructure rStructure)
Creates an Record instance

Parameters:
rStructure - the RecordStructure for the record.

Record

public Record(RecordStructure rStructure,
              byte[] data)
Creates an Record instance

Parameters:
rStructure - the RecordStructure for the record.
data - the input data for the record.
Method Detail

calcLength

protected void calcLength()

compact

protected void compact()

getBinaryField

public byte[] getBinaryField(int fIndex)
Retrieves the value of the designated column in the current Record as a byte[]

Parameters:
fIndex - the field index, the first field is 0, second is 1.
Returns:
the column value; if the value is NULL, the value returned is null if the field index is not valid, the value returned is null
Throws:
java.lang.IndexOutOfBoundsException - if an invalid field index was given

getBinaryField

public byte[] getBinaryField(java.lang.String fName)
Retrieves the value of the designated column in the current Record as a byte[]

Parameters:
fName - the field name.
Returns:
the column value; if the value is NULL, the value returned is null if the field name is not valid, the value returned is null
Throws:
java.lang.IndexOutOfBoundsException - if an invalid field name was given

getBooleanField

public boolean getBooleanField(int fIndex)
Retrieves the value of the designated column in the current Record as a boolean

Parameters:
fIndex - the field index, the first field is 0, second is 1.
Returns:
the column value; if the value is NULL, the value returned is true if the field index is not valid, the value returned is false
Throws:
java.lang.IndexOutOfBoundsException - if an invalid field index was given
See Also:
FieldStructure.NULL

getBooleanField

public boolean getBooleanField(java.lang.String fName)
Retrieves the value of the designated column in the current Record as a boolean

Parameters:
fName - the field name.
Returns:
the column value; if the value is NULL, the value returned is true if the field name is not valid, the value returned is false
Throws:
java.lang.IndexOutOfBoundsException - if an invalid field name was given
See Also:
FieldStructure.NULL

getDescriptor

protected int getDescriptor(int fIndex)
Get descriptor for the specified field

Parameters:
fIndex - the field index, the first field is 0, second is 1.
Returns:
field descriptor
Throws:
java.lang.IndexOutOfBoundsException - if an invalid field index was given

getIntegerField

public int getIntegerField(int fIndex)
Retrieves the value of the designated column in the current Record as a int

Parameters:
fIndex - the field index, the first field is 0, second is 1.
Returns:
the column value; if the value is NULL, the value returned is NULL if the field index is not valid, the value returned is NULL
Throws:
java.lang.IndexOutOfBoundsException - if an invalid field index was given
See Also:
FieldStructure.NULL

getIntegerField

public int getIntegerField(java.lang.String fName)
Retrieves the value of the designated column in the current Record as a int

Parameters:
fName - the field name.
Returns:
the column value; if the value is NULL, the value returned is NULL if the field name is not valid, the value returned is NULL
Throws:
java.lang.IndexOutOfBoundsException - if an invalid field name was given
See Also:
FieldStructure.NULL

getStringField

public java.lang.String getStringField(int fIndex)
Retrieves the value of the designated column in the current Record as a String

Parameters:
fIndex - the field index, the first field is 0, second is 1.
Returns:
the column value; if the value is NULL, the value returned is null; if the field index is not valid, the value returned is null
Throws:
java.lang.IndexOutOfBoundsException - if an invalid field index was given
See Also:
FieldStructure.NULL

getStringField

public java.lang.String getStringField(java.lang.String fName)
Retrieves the value of the designated column in the current Record as a String

Parameters:
fName - the field name.
Returns:
the column value; if the value is NULL, the value returned is null; if the field name is not valid, the value returned is null
Throws:
java.lang.IndexOutOfBoundsException - if an invalid field name was given
See Also:
FieldStructure.NULL

isNull

public boolean isNull(int fIndex)
Reports whether the field has NULL value.

Parameters:
fIndex - the field index, the first field is 0, second is 1.
Returns:
true if the field has NULL value, false otherwise
Throws:
java.lang.IndexOutOfBoundsException - if an invalid field index was given
See Also:
FieldStructure.NULL

isNull

public boolean isNull(java.lang.String fName)
Retrieves whether the field has NULL value.

Parameters:
fName - the field name.
Returns:
true if the field has NULL value, false otherwise
Throws:
java.lang.IndexOutOfBoundsException - if an invalid field name was given
See Also:
FieldStructure.NULL

reset

public void reset()
Reset data for current Record


setBinaryData

protected void setBinaryData(int fIndex,
                             byte[] value,
                             int offset,
                             int numBytes)
Sets specified column to byte[] value Compacts storage if necessary

Parameters:
fIndex - the field index.
value - the field value.
Throws:
java.lang.IndexOutOfBoundsException - if an invalid field index was given
java.lang.ArrayStoreException - if an invalid value cannot be stored in Record
See Also:
FieldStructure.NULL

setBinaryField

public void setBinaryField(int fIndex,
                           byte[] value,
                           int offset,
                           int numBytes)
Sets specified column to byte[] value

Parameters:
fIndex - the field index.
value - the field value.
Throws:
java.lang.IndexOutOfBoundsException - if an invalid field index was given
See Also:
FieldStructure.NULL

setBinaryField

public void setBinaryField(java.lang.String fName,
                           byte[] value,
                           int offset,
                           int numBytes)
Sets specified column to byte[] value

Parameters:
fName - the field name.
value - the field value.
Throws:
java.lang.IndexOutOfBoundsException - if an invalid field name was given
See Also:
FieldStructure.NULL

setBooleanField

public void setBooleanField(int fIndex,
                            boolean value)
Sets specified column to boolean value

Parameters:
fIndex - the field index.
value - the field value.
Throws:
java.lang.IndexOutOfBoundsException - if an invalid field index was given
See Also:
FieldStructure.NULL

setBooleanField

public void setBooleanField(java.lang.String fName,
                            boolean value)
Sets specified column to boolean value

Parameters:
fName - the field name.
value - the field value.
Throws:
java.lang.IndexOutOfBoundsException - if an invalid field name was given
See Also:
FieldStructure.NULL

setDescriptor

protected void setDescriptor(int fIndex,
                             int desc)
Set descriptor for the specified field

Parameters:
fIndex - the field index, the first field is 0, second is 1.
desc - the descriptor value.
Throws:
java.lang.IndexOutOfBoundsException - if an invalid field index was given

setIntegerField

public void setIntegerField(int fIndex,
                            int value)
Sets specified column to int value

Parameters:
fIndex - the field index.
value - the field value.
Throws:
java.lang.IndexOutOfBoundsException - if an invalid field index was given
See Also:
FieldStructure.NULL

setIntegerField

public void setIntegerField(java.lang.String fName,
                            int value)
Sets specified column to int value

Parameters:
fName - the field name.
value - the field value.
Throws:
java.lang.IndexOutOfBoundsException - if an invalid field name was given
See Also:
FieldStructure.NULL

setNull

public void setNull(int fIndex)
Sets specified column to NULL value

Parameters:
fIndex - the field index.
Throws:
java.lang.IndexOutOfBoundsException - if an invalid field index was given
See Also:
FieldStructure.NULL

setNull

public void setNull(java.lang.String fName)
Sets specified column to NULL value

Parameters:
fName - the field name.
Throws:
java.lang.IndexOutOfBoundsException - if an invalid field name was given
See Also:
FieldStructure.NULL

setStringField

public void setStringField(int fIndex,
                           java.lang.String value)
Sets specified column to String value

Parameters:
fIndex - the field index.
value - the field value.
Throws:
java.lang.IndexOutOfBoundsException - if an invalid field index was given
See Also:
FieldStructure.NULL

setStringField

public void setStringField(java.lang.String fName,
                           java.lang.String value)
Sets specified column to String value

Parameters:
fName - the field name.
value - the field value.
Throws:
java.lang.IndexOutOfBoundsException - if an invalid field name was given
See Also:
FieldStructure.NULL

jMobileCore toolkit