|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.niggle.data.DefaultRecord
A concrete implementation of the Record interface In this implementation, the records can be written out as a human-readable string. This is the scheme used for serialization. DefaultRecord implements the java.io.Externalizable interface in order to avoid the general-purpose serialization scheme. The goal was that the resulting storage format should be human-readable and modifiable in a text editor in a pinch.
Fields inherited from interface com.niggle.data.Record |
INVALID_ID, STATUS_KEY, TYPE_KEY |
Constructor Summary | |
DefaultRecord()
|
Method Summary | |
void |
checkValidity()
Check if the record's data is valid. |
void |
clearFields()
set the fields to their default values. |
boolean |
equals(java.lang.Object o)
|
java.lang.Object |
get(FieldDescriptor field)
Low-level method to query the value of a field in a Record. |
java.lang.Object |
get(int i)
Low-level method to get the value of a field. |
java.lang.Object |
get(java.lang.String fieldname)
Low-level method to set the value of a field. |
java.util.Date |
getCreationDate()
convenience method that returns the value of the field that holds the record's creation timestamp. |
java.util.Locale |
getDisplayLocale()
Simply returns the default locale, subclasses can override this to do something more useful. |
java.util.Date |
getLastModified()
convenience method that returns the value of the field that holds the record's last modified timestamp. |
RecordDescriptor |
getMetadata()
|
Record |
getMutableCopy()
create a clone. |
java.lang.Object |
getPrimaryKey()
Retrieve the value of the record's primary key. |
java.lang.String |
getType()
|
int |
getVersion()
a hook to be used by versioning schemes. |
boolean |
isImmutable()
Once a record is immutable, attempts to change data will result in an ImmutableDataException being thrown. |
boolean |
isStale()
Has this record been deleted or superseded in the associated DataSource? |
protected void |
postCheck()
Called after checking the fields. |
protected void |
preCheck()
Called before checking the fields. |
void |
readExternal(java.io.ObjectInput in)
|
void |
set(FieldDescriptor field,
java.lang.Object value)
Low-level method to set an individual field value concrete implementations will probably wrap this. |
void |
set(int i,
java.lang.Object value)
Low-level method to set the value of a field. |
void |
set(java.lang.String fieldname,
java.lang.Object value)
Low-level method to set the value of a field. |
void |
setMetadata(RecordDescriptor descriptor)
Method only used internally by niggle. |
void |
setPrimaryKey(java.lang.Object o)
set the value of this record's primary key. |
java.lang.String |
setValuesFromTable(java.util.Map table)
Set the values of the record's fields from a key-value mapping of the fields (or field names) to values. |
java.lang.String |
toString()
Provides a default string representation of the record for a human-readable flat-file persistence scheme. |
void |
touch()
mark this record as having just been modified. |
void |
writeExternal(java.io.ObjectOutput out)
|
Methods inherited from class java.lang.Object |
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public DefaultRecord()
Method Detail |
public boolean isImmutable()
isImmutable
in interface Record
public final void checkValidity() throws java.io.IOException
java.io.IOException
- if any of the fields are not valid.
The appropriate error message is encoded in the exception.public boolean isStale()
Record
isStale
in interface Record
public java.lang.Object getPrimaryKey()
Record
getPrimaryKey
in interface Record
com.niggle.data.Record
public void setPrimaryKey(java.lang.Object o)
Record
setPrimaryKey
in interface Record
public java.lang.String toString()
toString
in class java.lang.Object
protected void preCheck() throws java.io.IOException
protected void postCheck() throws java.io.IOException
public java.lang.String setValuesFromTable(java.util.Map table) throws java.io.IOException
table
- key-value string pairs to set values of fields.public java.util.Locale getDisplayLocale()
getDisplayLocale
in interface Record
com.niggle.data.Record
public final java.lang.Object get(java.lang.String fieldname)
Record
get
in interface Record
com.niggle.data.Record
fieldname
- InvalidFieldException
- if there is no field of that name.public final void set(java.lang.String fieldname, java.lang.Object value)
Record
set
in interface Record
com.niggle.data.Record
fieldname
- the name of the field to set.InvalidFieldException
- if there is no field of that name.ImmutableDataException
- if this record
is immutable @see #getMutableCopy()public final java.lang.Object get(FieldDescriptor field)
Record
get
in interface Record
com.niggle.data.Record
field
- to query.public final void set(FieldDescriptor field, java.lang.Object value)
Record
set
in interface Record
com.niggle.data.Record
field
- to set.value
- Object wrapping the valueInvalidFieldException
- if there is no field of that name.ImmutableDataException
- if this record
is immutable @see #getMutableCopy()public final RecordDescriptor getMetadata()
getMetadata
in interface Record
com.niggle.data.Record
RecordDescriptor
public void readExternal(java.io.ObjectInput in) throws java.io.IOException, java.lang.ClassNotFoundException
readExternal
in interface java.io.Externalizable
public void writeExternal(java.io.ObjectOutput out) throws java.io.IOException
writeExternal
in interface java.io.Externalizable
public Record getMutableCopy()
getMutableCopy
in interface Record
public final void set(int i, java.lang.Object value)
Record
set
in interface Record
com.niggle.data.Record
ImmutableDataException
- if this record
is immutable @see #getMutableCopy()public final java.lang.Object get(int i)
Record
get
in interface Record
public void clearFields()
clearFields
in interface Record
com.niggle.data.Record
ImmutableDataException
- if this record
is immutable @see #getMutableCopy()public final java.util.Date getLastModified()
Record
getLastModified
in interface Record
public final void touch()
Record
touch
in interface Record
public final java.util.Date getCreationDate()
Record
getCreationDate
in interface Record
public boolean equals(java.lang.Object o)
equals
in class java.lang.Object
public final void setMetadata(RecordDescriptor descriptor)
Record
setMetadata
in interface Record
public final java.lang.String getType()
getType
in interface Record
com.niggle.data.Record
public final int getVersion()
Record
getVersion
in interface Record
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |