ewe.database
Interface DatabaseEntry

All Superinterfaces:
DatabaseTypes
All Known Implementing Classes:
DatabaseEntryObject

public interface DatabaseEntry
extends DatabaseTypes


Field Summary
 
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
 
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 other, int sortID)
          Compare this entry with another based on the sortID stored in the database (ignoring the SORT_DESCENDING option).
 int compareTo(DatabaseEntry other, int[] sortCriteria, boolean hasWildCards)
          Compare this entry with another based on an arbitrary sort criteria.
 int countAssignedFields()
           
 boolean decode(byte[] data, int offset, int length)
           
 void decode(byte[] data, int offset, int length, DataProcessor decryptor)
          Decode an encoded DatabaseEntry.
 void delete()
          This will delete the entry from the database.
 void duplicateFrom(DatabaseEntry other)
          Duplicate all set fields in this DatabaseEntry with those from the other.
 byte[] encode()
           
 ByteArray encode(ByteArray dest, DataProcessor encryptor)
          Encode and append the data to the supplied ByteArray object.
 void erase()
          This will erase the entry from the database.
 int[] getAssignedFields()
           
 int getAssignedFields(int[] dest, int offset)
           
 Object getData()
          Get the data from the entry, creating a new data object.
 Object getData(Object destination)
          Get the data from the entry into a data object.
 Database getDatabase()
          Get the database associated with the FoundEntries.
 BigDecimal getField(int fieldID, BigDecimal defaultValue)
           
 boolean getField(int fieldID, boolean defaultValue)
           
 ByteArray getField(int fieldID, ByteArray dest)
           
 CharArray getField(int fieldID, CharArray dest)
           
 DayOfYear getField(int fieldID, DayOfYear dest)
           
 Decimal getField(int fieldID, Decimal dest)
           
 double getField(int fieldID, double defaultValue)
           
 int getField(int fieldID, int defaultValue)
           
 long getField(int fieldID, long defaultValue)
           
 String getField(int fieldID, String defaultValue)
           
 Time getField(int fieldID, Time dest)
           
 TimeOfDay getField(int fieldID, TimeOfDay dest)
           
 TimeStamp getField(int fieldID, TimeStamp dest)
           
 byte[] getFieldBytes(int fieldID)
           
 Object getFieldValue(int fieldID, int type, Object data)
           
 Object getFieldValue(int fieldID, Object data)
           
 Object getObjectField(int fieldID, Object dest)
           
 boolean hasField(int ID)
           
 boolean isADeletedEntry()
           
 boolean isPointingTo(DatabaseEntry other)
           
 boolean isSaved()
           
 void pointTo(DatabaseEntry other)
           
 void reset()
          Reset the entry to be an empty entry, as if it had just been returned by Database.getNewData()
 void revert()
          Reload the entries data.
 void save()
          This will save or add the entry into the database.
 void setData(Object data)
          Set the data in the entry from the data object.
 void setField(int fieldID, BigDecimal value)
           
 void setField(int fieldID, boolean value)
           
 void setField(int fieldID, byte[] bytes)
           
 void setField(int fieldID, ByteArray bytes)
           
 void setField(int fieldID, CharArray chars)
           
 void setField(int fieldID, DayOfYear value)
           
 void setField(int fieldID, Decimal value)
           
 void setField(int fieldID, double value)
           
 void setField(int fieldID, int value)
           
 void setField(int fieldID, long value)
           
 void setField(int fieldID, String chars)
           
 void setField(int fieldID, SubString chars)
           
 void setField(int fieldID, Time time)
           
 void setField(int fieldID, TimeOfDay value)
           
 void setField(int fieldID, TimeStamp value)
           
 void setFieldValue(int fieldID, int type, Object data)
           
 void setFieldValue(int fieldID, Object data)
           
 void setObjectField(int fieldID, Object value)
           
 void store()
          This will store and add (if necessary) the entry into the database with no modifications.
 

Method Detail

getDatabase

public Database getDatabase()
Get the database associated with the FoundEntries.


isSaved

public boolean isSaved()

isADeletedEntry

public boolean isADeletedEntry()

hasField

public boolean hasField(int ID)

countAssignedFields

public int countAssignedFields()

getAssignedFields

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

getAssignedFields

public int[] getAssignedFields()

setField

public void setField(int fieldID,
                     int value)

setField

public void setField(int fieldID,
                     long value)

setField

public void setField(int fieldID,
                     boolean value)

setField

public void setField(int fieldID,
                     double value)

setField

public void setField(int fieldID,
                     TimeOfDay value)

setField

public void setField(int fieldID,
                     DayOfYear value)

setField

public void setField(int fieldID,
                     TimeStamp value)

setField

public void setField(int fieldID,
                     Time time)

setField

public void setField(int fieldID,
                     ByteArray bytes)

setField

public void setField(int fieldID,
                     byte[] bytes)

setField

public void setField(int fieldID,
                     SubString chars)

setField

public void setField(int fieldID,
                     CharArray chars)

setField

public void setField(int fieldID,
                     String chars)

setField

public void setField(int fieldID,
                     BigDecimal value)

setField

public void setField(int fieldID,
                     Decimal value)

setObjectField

public void setObjectField(int fieldID,
                           Object value)

setFieldValue

public void setFieldValue(int fieldID,
                          int type,
                          Object data)

setFieldValue

public void setFieldValue(int fieldID,
                          Object data)

getFieldValue

public Object getFieldValue(int fieldID,
                            int type,
                            Object data)

getFieldValue

public Object getFieldValue(int fieldID,
                            Object data)

getField

public int getField(int fieldID,
                    int defaultValue)

getField

public long getField(int fieldID,
                     long defaultValue)

getField

public boolean getField(int fieldID,
                        boolean defaultValue)

getField

public double getField(int fieldID,
                       double defaultValue)

getField

public Time getField(int fieldID,
                     Time dest)

getField

public DayOfYear getField(int fieldID,
                          DayOfYear dest)

getField

public TimeOfDay getField(int fieldID,
                          TimeOfDay dest)

getField

public TimeStamp getField(int fieldID,
                          TimeStamp dest)

getField

public BigDecimal getField(int fieldID,
                           BigDecimal defaultValue)

getField

public Decimal getField(int fieldID,
                        Decimal dest)

getField

public String getField(int fieldID,
                       String defaultValue)

getField

public CharArray getField(int fieldID,
                          CharArray dest)

getField

public ByteArray getField(int fieldID,
                          ByteArray dest)

getObjectField

public Object getObjectField(int fieldID,
                             Object dest)

getFieldBytes

public byte[] getFieldBytes(int fieldID)

save

public void save()
          throws IllegalStateException,
                 IOException
This will save or add the entry into the database. The database may decide to add or alter fields within the entry (e.g. the modified time field).

Throws:
IllegalStateException - if the entry is a deleted entry or otherwise cannot be saved.
IOException - on error.

store

public void store()
           throws IllegalStateException,
                  IOException
This will store and add (if necessary) the entry into the database with no modifications.

Throws:
IllegalStateException - if the entry is a deleted entry or otherwise cannot be saved.
IOException - on error.

delete

public void delete()
            throws IOException
This will delete the entry from the database. The database may decide to mark the entry as deleted, saving the object ID and delete time.

Throws:
IOException - on error.

erase

public void erase()
           throws IOException
This will erase the entry from the database. The database will not mark it as deleted.

Throws:
IOException

revert

public void revert()
            throws IllegalStateException,
                   IOException
Reload the entries data.

Throws:
IllegalStateException - if the entry's data could not be reloaded, because it was deleted, erased or reset.
IOException

reset

public void reset()
Reset the entry to be an empty entry, as if it had just been returned by Database.getNewData()


clearField

public void clearField(int fieldID)
Set the specified field to be unassigned.


clearFields

public void clearFields()
Clears the data fields but not the special fields.


clearDataAndSpecialFields

public void clearDataAndSpecialFields()
Clears the data fields and the special fields. Use this with care.


compareTo

public int compareTo(DatabaseEntry other,
                     int sortID)
              throws IllegalArgumentException
Compare this entry with another based on the sortID stored in the database (ignoring the SORT_DESCENDING option).

Throws:
IllegalArgumentException

compareTo

public int compareTo(DatabaseEntry other,
                     int[] sortCriteria,
                     boolean hasWildCards)
              throws IllegalArgumentException
Compare this entry with another based on an arbitrary sort criteria.

Throws:
IllegalArgumentException

getData

public Object getData(Object destination)
               throws IllegalArgumentException,
                      IllegalStateException
Get the data from the entry into a data object.

Parameters:
destination - a destination object. If this is null a new one will be created if possible.
Returns:
the destination or new object.
Throws:
IllegalArgumentException - if the destination object is not the right type.
IllegalStateException - if a new object was requested but could not be created.

getData

public Object getData()
               throws IllegalStateException
Get the data from the entry, creating a new data object.

Returns:
the new data object.
Throws:
IllegalStateException - if a new object could not be created.

setData

public void setData(Object data)
             throws IllegalArgumentException
Set the data in the entry from the data object.

Parameters:
data - the data to set.
Throws:
IllegalArgumentException - if the data object is the wrong type.

pointTo

public void pointTo(DatabaseEntry other)
             throws IllegalArgumentException
Throws:
IllegalArgumentException

isPointingTo

public boolean isPointingTo(DatabaseEntry other)
                     throws IllegalArgumentException
Throws:
IllegalArgumentException

decode

public void decode(byte[] data,
                   int offset,
                   int length,
                   DataProcessor decryptor)
            throws IOException
Decode an encoded DatabaseEntry.

Parameters:
data - 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.

encode

public ByteArray encode(ByteArray dest,
                        DataProcessor encryptor)
                 throws IOException
Encode and append the data to the supplied ByteArray object.

Parameters:
dest - the destination ByteArray object.
encryptor - an optional encryptor for encrypting the data.
Returns:
the destination ByteArray object or a new one if dest is null.
Throws:
IOException - if the encryptor failed during decryption.

decode

public boolean decode(byte[] data,
                      int offset,
                      int length)

encode

public byte[] encode()

duplicateFrom

public void duplicateFrom(DatabaseEntry other)
Duplicate all set fields in this DatabaseEntry with those from the other.