public abstract class DatabaseEntryObject extends Object implements DatabaseEntry
Modifier and Type | Field and Description |
---|---|
protected DatabaseObject |
database |
protected boolean |
isDeleted |
protected Locale |
locale |
protected FoundEntries |
modifyingInside |
protected ByteArray |
myData |
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, OPTION_ERROR_ON_NEED_REINDEX, PLAIN_DATE, PLAIN_TIME, 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
Modifier | Constructor and Description |
---|---|
protected |
DatabaseEntryObject(DatabaseObject database)
If the value is a String, convert it to an Object suitable for the specified type.
|
Modifier and Type | Method and Description |
---|---|
boolean |
_getSetField(String fieldName,
Wrapper value,
boolean isGet)
This is used as a mechanism for automatic data transfer between a DatabaseEntry and
a user interface object.
|
boolean |
_getSetValue(String fieldName,
Wrapper value,
boolean isGet)
This is used as a mechanism for automatic data transfer between a DatabaseEntry and an
object that has the same field names.
|
int |
compareTo(DatabaseEntry other,
int sortID)
Compare this entry with another based on the sortID stored in the database (ignoring
the SORT_DESCENDING option).
|
boolean |
decode(byte[] source,
int offset,
int length) |
void |
delete()
This will delete the entry from the database.
|
protected abstract int |
discoverType(int field) |
protected String |
dump() |
void |
duplicateFrom(DatabaseEntry other)
Duplicate all set fields in this DatabaseEntry with those from the other.
|
byte[] |
encode() |
void |
erase()
This will erase the entry from the database.
|
protected int |
fieldToID(String fieldName) |
protected int |
fieldToType(int field) |
int[] |
getAssignedFields() |
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) |
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) |
PlainDate |
getField(int fieldID,
PlainDate dest) |
PlainTime |
getField(int fieldID,
PlainTime dest) |
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) |
protected int |
getFieldInfo(String fieldName)
Return the field info as the id|type.
|
protected String |
getFieldName(int id) |
abstract Wrapper |
getFieldValue(int fieldID,
int type,
Object data)
Get the data stored in a Wrapper.
|
Wrapper |
getFieldValue(int fieldID,
Object data)
Get the data stored in a Wrapper, assuming that the type of the field will be known
to the DatabaseEntry.
|
void |
getFieldValues(int[] fieldIDs,
Object[] destinationObjectsAndWrappers)
Get a set of fields from the DatabaseEntry.
|
DatabaseEntry |
getNew() |
Object |
getObjectField(int fieldID,
Object dest) |
boolean |
isADeletedEntry() |
protected void |
load() |
protected void |
markAsDeleted() |
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,
BigDecimal value) |
void |
setField(int fieldID,
boolean value) |
void |
setField(int fieldID,
byte[] bytes) |
void |
setField(int fieldID,
ByteArray bytes) |
void |
setField(int fieldID,
ByteEncodable value) |
void |
setField(int fieldID,
CharArray chars) |
void |
setField(int fieldID,
DayOfYear date) |
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,
PlainDate time) |
void |
setField(int fieldID,
PlainTime time) |
void |
setField(int fieldID,
String chars) |
void |
setField(int fieldID,
SubString chars) |
void |
setField(int fieldID,
Time time) |
void |
setField(int fieldID,
TimeOfDay time) |
void |
setField(int fieldID,
TimeStamp timestamp) |
void |
setFieldValue(int fieldID,
Object data) |
void |
setFieldValues(int[] fieldIDs,
Object[] sourceObjectsAndWrappers)
set a set of fields from the DatabaseEntry.
|
void |
setObjectField(int fieldID,
Object value) |
void |
store()
This will store and add (if necessary) the entry into the database with no modifications.
|
String |
toString()
Return a String representation of this object.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
clearDataAndSpecialFields, clearField, clearFields, compareTo, countAssignedFields, decode, encode, getAssignedFields, hasField, isPointingTo, isSaved, pointTo, setFieldValue
protected ByteArray myData
protected DatabaseObject database
protected boolean isDeleted
protected FoundEntries modifyingInside
protected Locale locale
protected DatabaseEntryObject(DatabaseObject database)
value
- the provided Object value, which may be a String.type
- the type of the field being set.public abstract Wrapper getFieldValue(int fieldID, int type, Object data)
DatabaseEntry
getFieldValue
in interface DatabaseEntry
fieldID
- the field ID.type
- the expected type of the field.data
- this can be a destination Wrapper, which itself
may have a destination object already set, or it can be a destination Object
itself. The destination Object is NOT used for primitive types such as INTEGER, LONG,
DOUBLE or BOOLEAN, but a destination Wrapper can be used. The acceptable destination objects for other types are:
BYTE_ARRAY - eve.util.ByteArray STRING - eve.util.CharArray PLAIN_DATE - eve.data.PlainDate PLAIN_TIME - eve.data.PlainTime DATE_TIME - eve.sys.Time DATE - eve.sys.DayOfYear TIME - eve.sys.TimeOfDay DECIMAL - eve.sys.Decimal TIMESTAMP - eve.database.TimeStamp
protected abstract int discoverType(int field)
public Database getDatabase()
getDatabase
in interface DatabaseEntry
public boolean isADeletedEntry()
isADeletedEntry
in interface DatabaseEntry
public void reset()
DatabaseEntry
reset
in interface DatabaseEntry
public void save() throws IllegalStateException, IOException
DatabaseEntry
save
in interface DatabaseEntry
IllegalStateException
- if the entry is a deleted entry or otherwise cannot be saved.IOException
- on error.public void delete() throws IOException
DatabaseEntry
delete
in interface DatabaseEntry
IOException
- on error.protected void markAsDeleted() throws IOException
IOException
public void store() throws IllegalStateException, IOException
DatabaseEntry
store
in interface DatabaseEntry
IllegalStateException
- if the entry is a deleted entry or otherwise cannot be saved.IOException
- on error.public void erase() throws IOException
DatabaseEntry
erase
in interface DatabaseEntry
IOException
public void revert() throws IllegalStateException, IOException
DatabaseEntry
revert
in interface DatabaseEntry
IllegalStateException
- if the entry's data could not be reloaded, because
it was deleted, erased or reset.IOException
protected void load() throws IOException
IOException
public Object getData(Object destination) throws IllegalArgumentException, IllegalStateException
getData
in interface DatabaseEntry
destination
- a destination object. If this is null a new one will be created if
possible.IllegalArgumentException
- if the destination object is not the right type.IllegalStateException
- if a new object was requested but could not be created.public Object getData() throws IllegalStateException
getData
in interface DatabaseEntry
IllegalStateException
- if a new object could not be created.public void setData(Object data) throws IllegalArgumentException
setData
in interface DatabaseEntry
data
- the data to set.IllegalArgumentException
- if the data object is the wrong type.public DatabaseEntry getNew()
public int compareTo(DatabaseEntry other, int sortID) throws IllegalArgumentException
DatabaseEntry
compareTo
in interface DatabaseEntry
IllegalArgumentException
public boolean _getSetField(String fieldName, Wrapper value, boolean isGet)
public boolean _getSetValue(String fieldName, Wrapper value, boolean isGet)
public void setFieldValue(int fieldID, Object data)
setFieldValue
in interface DatabaseEntry
public Wrapper getFieldValue(int fieldID, Object data)
DatabaseEntry
getFieldValue
in interface DatabaseEntry
fieldID
- the field ID.data
- this can be a destination Wrapper, which itself
may have a destination object already set, or it can be a destination Object
itself. The destination Object is NOT used for primitive types such as INTEGER, LONG,
DOUBLE or BOOLEAN, but a destination Wrapper can be used. The acceptable destination objects for other types are:
BYTE_ARRAY - eve.util.ByteArray STRING - eve.util.CharArray PLAIN_DATE - eve.data.PlainDate PLAIN_TIME - eve.data.PlainTime DATE_TIME - eve.sys.Time DATE - eve.sys.DayOfYear TIME - eve.sys.TimeOfDay DECIMAL - eve.sys.Decimal TIMESTAMP - eve.database.TimeStamp
public void setField(int fieldID, int value)
setField
in interface DatabaseEntry
public void setField(int fieldID, long value)
setField
in interface DatabaseEntry
public void setField(int fieldID, boolean value)
setField
in interface DatabaseEntry
public void setField(int fieldID, double value)
setField
in interface DatabaseEntry
public void setField(int fieldID, PlainTime time)
public void setField(int fieldID, PlainDate time)
public void setField(int fieldID, Time time)
setField
in interface DatabaseEntry
public void setField(int fieldID, TimeOfDay time)
setField
in interface DatabaseEntry
public void setField(int fieldID, DayOfYear date)
setField
in interface DatabaseEntry
public void setField(int fieldID, TimeStamp timestamp)
setField
in interface DatabaseEntry
public void setField(int fieldID, BigDecimal value)
setField
in interface DatabaseEntry
public void setField(int fieldID, Decimal value)
setField
in interface DatabaseEntry
public void setField(int fieldID, ByteArray bytes)
setField
in interface DatabaseEntry
public void setField(int fieldID, byte[] bytes)
setField
in interface DatabaseEntry
public void setField(int fieldID, SubString chars)
setField
in interface DatabaseEntry
public void setField(int fieldID, CharArray chars)
setField
in interface DatabaseEntry
public void setField(int fieldID, String chars)
setField
in interface DatabaseEntry
public void setField(int fieldID, ByteEncodable value)
public void setField(int fieldID, BigDecimal value)
setField
in interface DatabaseEntry
public void setObjectField(int fieldID, Object value)
setObjectField
in interface DatabaseEntry
public Object getObjectField(int fieldID, Object dest)
getObjectField
in interface DatabaseEntry
public int getField(int fieldID, int defaultValue)
getField
in interface DatabaseEntry
public long getField(int fieldID, long defaultValue)
getField
in interface DatabaseEntry
public boolean getField(int fieldID, boolean defaultValue)
getField
in interface DatabaseEntry
public double getField(int fieldID, double defaultValue)
getField
in interface DatabaseEntry
public Time getField(int fieldID, Time dest)
getField
in interface DatabaseEntry
public String getField(int fieldID, String defaultValue)
getField
in interface DatabaseEntry
public CharArray getField(int fieldID, CharArray dest)
getField
in interface DatabaseEntry
public byte[] getFieldBytes(int fieldID)
getFieldBytes
in interface DatabaseEntry
public ByteArray getField(int fieldID, ByteArray dest)
getField
in interface DatabaseEntry
public DayOfYear getField(int fieldID, DayOfYear dest)
getField
in interface DatabaseEntry
public TimeOfDay getField(int fieldID, TimeOfDay dest)
getField
in interface DatabaseEntry
public TimeStamp getField(int fieldID, TimeStamp dest)
getField
in interface DatabaseEntry
public BigDecimal getField(int fieldID, BigDecimal defaultValue)
getField
in interface DatabaseEntry
public BigDecimal getField(int fieldID, BigDecimal defaultValue)
getField
in interface DatabaseEntry
public Decimal getField(int fieldID, Decimal dest)
getField
in interface DatabaseEntry
public int[] getAssignedFields()
getAssignedFields
in interface DatabaseEntry
protected int getFieldInfo(String fieldName)
protected int fieldToID(String fieldName)
protected String getFieldName(int id)
protected int fieldToType(int field)
protected String dump()
public String toString()
Object
public void duplicateFrom(DatabaseEntry other)
DatabaseEntry
duplicateFrom
in interface DatabaseEntry
public byte[] encode()
encode
in interface DatabaseEntry
public boolean decode(byte[] source, int offset, int length)
decode
in interface DatabaseEntry
public void getFieldValues(int[] fieldIDs, Object[] destinationObjectsAndWrappers)
getFieldValues
in interface DatabaseEntry
fieldIDs
- the field IDs.destinationObjectsAndWrappers
- the destination Object and/or Wrappers
to hold the data. See getFieldValue() to see the destination types to use.public void setFieldValues(int[] fieldIDs, Object[] sourceObjectsAndWrappers)
setFieldValues
in interface DatabaseEntry
fieldIDs
- the field IDs.sourceObjectsAndWrappers
- the source Object and/or Wrappers
to hold the data. See getFieldValue() to see the destination types to use.