|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.revusky.oreo.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
|
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)
|
void |
freeze()
make this record immutable. |
java.lang.Object |
get(FieldDescriptor field)
Low-level method to query the value of a field in a Record. |
java.lang.Object |
get(java.lang.String fieldName)
Method to get the value of a field by name. |
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()
|
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,
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(java.lang.String fieldName,
java.lang.Object o)
Method to set the value of a field by name. |
void |
setMetadata(RecordDescriptor desc)
Method only used internally. |
void |
setPrimaryKey(java.lang.Object o)
set the value of this record's primary key. |
java.lang.String |
toString()
|
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, java.lang.Object primaryKey)
protected void updateCacheInfo(Record rec)
public java.lang.Object get(java.lang.String fieldName)
Record
get
in interface Record
com.revusky.oreo.Record
fieldname
- InvalidFieldException
- if there is no field of that name.public java.lang.Object get(FieldDescriptor field)
Record
get
in interface Record
com.revusky.oreo.Record
field
- to query.public void set(java.lang.String fieldName, java.lang.Object o)
Record
set
in interface Record
com.revusky.oreo.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(FieldDescriptor field, java.lang.Object o)
Record
set
in interface Record
com.revusky.oreo.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.revusky.oreo.Record
ImmutableDataException
- if this record
is immutable @see #getMutableCopy()public RecordDescriptor getMetadata()
getMetadata
in interface Record
com.revusky.oreo.Record
RecordDescriptor
public Record getMutableCopy()
Record
getMutableCopy
in interface Record
public boolean isStale()
Record
isStale
in interface Record
public java.lang.Object getPrimaryKey()
Record
getPrimaryKey
in interface Record
com.revusky.oreo.Record
public void setPrimaryKey(java.lang.Object o)
Record
setPrimaryKey
in interface Record
public boolean isImmutable()
Record
isImmutable
in interface Record
public java.lang.String getType()
getType
in interface Record
com.revusky.oreo.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 freeze() throws java.io.IOException
Record
freeze
in interface Record
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 |