ewe.database
Class ByteArrayDatabaseEntry

java.lang.Object
  extended byewe.database.DatabaseEntryObject
      extended byewe.database.ByteArrayDatabaseEntry
All Implemented Interfaces:
DatabaseEntry, DatabaseTypes
Direct Known Subclasses:
RecordDatabaseEntry

public abstract class ByteArrayDatabaseEntry
extends DatabaseEntryObject


Field Summary
protected static int TYPE_MASK
           
 
Fields inherited from class ewe.database.DatabaseEntryObject
database, isDeleted, locale, modifyingInside, myData
 
Fields inherited from interface ewe.database.DatabaseTypes
BOOLEAN, BYTE_ARRAY, CREATED_FIELD, DATE, DATE_TIME, DECIMAL, DOUBLE, FIRST_SPECIAL_FIELD, FLAG_SYNCHRONIZED, FLAGS_FIELD, INTEGER, JAVA_OBJECT, LONG, MAX_ID, MODIFIED_BY_FIELD, MODIFIED_FIELD, NAME_FIELD, OBJECT_BYTES_FIELD, OBJECT_TEXT_FIELD, OID_FIELD, reservedFieldHeaders, reservedFieldIDs, reservedFieldNames, reservedFieldTypes, SORT_DATE_ONLY, SORT_IGNORE_CASE, SORT_TIME_ONLY, SORT_UNKNOWN_IS_GREATER_THAN_KNOWN, SORT_UNKNOWN_IS_LESS_THAN_KNOWN, STRING, TIME, TIMESTAMP
 
Constructor Summary
protected ByteArrayDatabaseEntry(DatabaseObject database)
           
 
Method Summary
 void clearDataAndSpecialFields()
          Clears the data fields and the special fields.
 void clearField(int fieldID)
          Set the specified field to be unassigned.
 void clearFields()
          Clears the data fields but not the special fields.
 int compareTo(DatabaseEntry otherEntry, int[] criteria, boolean hasWildCards)
          Compare this DatabaseEntry to another.
 int countAssignedFields()
           
 void decode(byte[] source, int offset, int length, DataProcessor decryptor)
          Decode an encoded DatabaseEntry.
protected  int discoverType(int id)
           
 ByteArray encode(ByteArray destination, DataProcessor encryptor)
          This will place the encoded record data in the destination ByteArray, clearing it first and possibly encrypting it first (if encryptor is not null).
 int getAssignedFields(int[] dest, int offset)
           
protected  ByteArray getDataForLoading()
          Get the ByteArray that holds the record's encoded data.
protected  ByteArray getDataForSaving()
          Get the ByteArray that holds the record's encoded data.
 Object getFieldValue(int id, int type, Object dest)
           
 boolean hasField(int fieldID)
           
protected  int locateField(int id, int idType)
           
 void reset()
          Compare this object against a set of search objects.
 void setFieldValue(int id, int type, Object value)
           
 
Methods inherited from class ewe.database.DatabaseEntryObject
_getSetField, _getSetValue, compareTo, convertStringToStaticObjectValue, decode, delete, dump, duplicateFrom, encode, erase, fieldToID, fieldToType, getAssignedFields, getData, getData, getDatabase, getField, getField, getField, getField, getField, getField, getField, getField, getField, getField, getField, getField, getField, getFieldBytes, getFieldInfo, getFieldName, getFieldValue, getNew, getObjectField, isADeletedEntry, load, markAsDeleted, revert, save, setData, setField, setField, setField, setField, setField, setField, setField, setField, setField, setField, setField, setField, setField, setField, setField, setField, setFieldValue, setObjectField, store, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode
 
Methods inherited from interface ewe.database.DatabaseEntry
isPointingTo, isSaved, pointTo
 

Field Detail

TYPE_MASK

protected static final int TYPE_MASK
See Also:
Constant Field Values
Constructor Detail

ByteArrayDatabaseEntry

protected ByteArrayDatabaseEntry(DatabaseObject database)
Method Detail

decode

public void decode(byte[] source,
                   int offset,
                   int length,
                   DataProcessor decryptor)
            throws IOException
Description copied from interface: DatabaseEntry
Decode an encoded DatabaseEntry.

Parameters:
source - the encoded data bytes.
offset - the start of the data.
length - the number of data bytes.
decryptor - an optional decryptor for decoding.
Throws:
IOException - if the data is invalid or if the decryptor failed during decryption.

locateField

protected int locateField(int id,
                          int idType)

clearFields

public void clearFields()
Description copied from interface: DatabaseEntry
Clears the data fields but not the special fields.


clearField

public void clearField(int fieldID)
Description copied from interface: DatabaseEntry
Set the specified field to be unassigned.


hasField

public boolean hasField(int fieldID)

countAssignedFields

public int countAssignedFields()

getAssignedFields

public int getAssignedFields(int[] dest,
                             int offset)

discoverType

protected int discoverType(int id)
Specified by:
discoverType in class DatabaseEntryObject

clearDataAndSpecialFields

public void clearDataAndSpecialFields()
Description copied from interface: DatabaseEntry
Clears the data fields and the special fields. Use this with care.


setFieldValue

public void setFieldValue(int id,
                          int type,
                          Object value)

getFieldValue

public Object getFieldValue(int id,
                            int type,
                            Object dest)
Specified by:
getFieldValue in interface DatabaseEntry
Specified by:
getFieldValue in class DatabaseEntryObject

encode

public ByteArray encode(ByteArray destination,
                        DataProcessor encryptor)
                 throws IOException
This will place the encoded record data in the destination ByteArray, clearing it first and possibly encrypting it first (if encryptor is not null). The returned value is always a copy of the record's data.

Parameters:
destination - The destination for the data. If it is null a new one will be created.
encryptor - An optional encryptor for the data.
Returns:
The destination byte array with the data for the record starting at index 0.
Throws:
IOException - if there is an error encrypting the data.

compareTo

public int compareTo(DatabaseEntry otherEntry,
                     int[] criteria,
                     boolean hasWildCards)
Compare this DatabaseEntry to another.

Parameters:
criteria - a list of criteria (as returned by toCriteria(field,type,options)).
Returns:
less than 0 if this entry is less than the other, greater than 0 if this entry is greater than the other, 0 if this entry is equal to the other.

reset

public void reset()
Compare this object against a set of search objects.

Specified by:
reset in interface DatabaseEntry
Overrides:
reset in class DatabaseEntryObject
Returns:
less than 0 if this entry is less than the searchObjects, greater than 0 if this entry is greater than the searchObject, 0 if this entry is equal to the searchObjects.

getDataForSaving

protected ByteArray getDataForSaving()
Get the ByteArray that holds the record's encoded data. This is used for saving the data. This is the records actual data, not a copy of it, so do not write to the returned ByteArray.


getDataForLoading

protected ByteArray getDataForLoading()
Get the ByteArray that holds the record's encoded data. This is used for reading in data to the Entry and will clear the current data. After placing the data in the ByteArray, call decode() to decode and validate the data.