|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.niggle.data.RecordReference
An object that represents a weak or soft reference to an underlying Record object. This object implements the Record interface by delegating calls to an underlying record. Most likely this class will be subclassed, since it will be necessary to implement the restoreReferent() method. However, this could still be useful on its own, since if the underlying record gets gc'ed, then the calls to the various get/set methods simply "page-fault" and the client code could simply catch the condition and recover. In any case, the presence of this base class should avoid the need to repeat the same delegation bubble-gum code all over the place.
Field Summary | |
protected java.lang.ref.Reference |
ref
|
Fields inherited from interface com.niggle.data.Record |
INVALID_ID, STATUS_KEY, TYPE_KEY |
Constructor Summary | |
RecordReference(Record underlying)
|
|
RecordReference(Record underlying,
java.lang.ref.ReferenceQueue queue)
|
Method Summary | |
void |
clearFields()
reset the fields to their default state The record must be in a mutable state. |
java.lang.ref.Reference |
createReference(Record rec,
java.lang.ref.ReferenceQueue queue)
|
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()
|
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()
|
Record |
getUnderlyingRecord()
|
int |
getVersion()
a hook to be used by versioning schemes. |
boolean |
isImmutable()
Have the fields all been set? Once a record is put in a DataSource, its fields are immutable. |
boolean |
isStale()
Has this record been deleted or superseded in the associated DataSource? |
Record |
restoreReferent(java.lang.String type,
int version,
java.lang.Object primaryKey)
A method that should restore the referent (i.e. |
void |
set(FieldDescriptor field,
java.lang.Object o)
Low-level method to set an individual field value concrete implementations will probably wrap this. |
void |
set(int i,
java.lang.Object o)
Low-level method to set the value of a field. |
void |
set(java.lang.String fieldName,
java.lang.Object o)
Low-level method to set the value of a field. |
void |
setMetadata(RecordDescriptor desc)
Method only used internally by niggle. |
void |
setPrimaryKey(java.lang.Object o)
set the value of this record's primary key. |
java.lang.String |
toString()
|
void |
touch()
mark this record as having just been modified. |
protected void |
updateCacheInfo(Record rec)
updates the information held in the reference wrapper. |
Methods inherited from class java.lang.Object |
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
protected java.lang.ref.Reference ref
Constructor Detail |
public RecordReference(Record underlying)
public RecordReference(Record underlying, java.lang.ref.ReferenceQueue queue)
Method Detail |
public java.lang.ref.Reference createReference(Record rec, java.lang.ref.ReferenceQueue queue)
public Record getUnderlyingRecord()
public Record restoreReferent(java.lang.String type, int version, java.lang.Object primaryKey)
protected void updateCacheInfo(Record rec)
public 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 java.lang.Object get(int i)
Record
get
in interface Record
public java.lang.Object get(FieldDescriptor field)
Record
get
in interface Record
com.niggle.data.Record
field
- to query.public void set(java.lang.String fieldName, java.lang.Object o)
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 void set(int i, java.lang.Object o)
Record
set
in interface Record
com.niggle.data.Record
ImmutableDataException
- if this record
is immutable @see #getMutableCopy()public void set(FieldDescriptor field, java.lang.Object o)
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 void clearFields()
Record
clearFields
in interface Record
com.niggle.data.Record
ImmutableDataException
- if this record
is immutable @see #getMutableCopy()public java.util.Locale getDisplayLocale()
getDisplayLocale
in interface Record
com.niggle.data.Record
public RecordDescriptor getMetadata()
getMetadata
in interface Record
com.niggle.data.Record
RecordDescriptor
public Record getMutableCopy()
Record
getMutableCopy
in interface Record
public boolean isStale()
Record
isStale
in interface Record
public java.util.Date getCreationDate()
Record
getCreationDate
in interface Record
public java.util.Date getLastModified()
Record
getLastModified
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 int getVersion()
Record
getVersion
in interface Record
public boolean isImmutable()
Record
isImmutable
in interface Record
public java.lang.String getType()
getType
in interface Record
com.niggle.data.Record
public void touch()
Record
touch
in interface Record
public java.lang.String toString()
toString
in class java.lang.Object
public boolean equals(java.lang.Object o)
equals
in class java.lang.Object
public void setMetadata(RecordDescriptor desc)
Record
setMetadata
in interface Record
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |