org.oreodata.ref
Class RecordProxy

java.lang.Object
  |
  +--org.oreodata.ref.RecordProxy
All Implemented Interfaces:
Record, RecordPointer
Direct Known Subclasses:
RecordReference, SimpleRecordProxy

public abstract class RecordProxy
extends java.lang.Object
implements Record, RecordPointer

An object that implements the Record interface by delegating calls to an underlying record.

Author:
Jonathan Revusky

Constructor Summary
RecordProxy()
           
 
Method Summary
 void clearFields()
          reset the fields to their default state The record must be in a mutable state.
 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.
 java.util.List getChildren()
           
 RecordDescriptor getMetadata()
           
 Record getMutableCopy()
          create a clone.
 Record getParent()
           
 java.lang.Object getPrimaryKey()
          Retrieve the value of the record's primary key.
 java.lang.String getType()
           
 boolean hasChildren()
          Does this record have children? This should return the same as (!getChildren().isEmpty()) would.
 boolean isImmutable()
          Have the fields all been set? Once a record is put in a DataSource, its fields are immutable.
 boolean isRootElement()
          Does this record have a parent? This should return the same as (getParent() == null) but it is worth having a separate method, since, with some schemes, it could be more efficient to ask whether there is a root element or not, as opposed to actually fishing it out.
 boolean isStale()
          Has this record been deleted or superseded in the associated DataSource?
 void set(FieldDescriptor field, java.lang.Object o)
          Low-level method to set an individual field value
 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()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.oreodata.ref.RecordPointer
getUnderlyingRecord, wipeCachedInfo
 

Constructor Detail

RecordProxy

public RecordProxy()
Method Detail

get

public java.lang.Object get(java.lang.String fieldName)
Description copied from interface: Record
Method to get the value of a field by name. Subclasses may wrap this with a higher-level get/set API.

Specified by:
get in interface Record
Parameters:
fieldName -

get

public java.lang.Object get(FieldDescriptor field)
Description copied from interface: Record
Low-level method to query the value of a field in a Record.

Specified by:
get in interface Record
Parameters:
field - to query.
Returns:
an Object wrapper around field value.

set

public void set(java.lang.String fieldName,
                java.lang.Object o)
Description copied from interface: Record
Method to set the value of a field by name. Concrete implementations may wrap this with a higher-level get/set API.

Specified by:
set in interface Record
Parameters:
fieldName - the name of the field to set.

set

public void set(FieldDescriptor field,
                java.lang.Object o)
Description copied from interface: Record
Low-level method to set an individual field value

Specified by:
set in interface Record
Parameters:
field - to set.
o - Object wrapping the value

clearFields

public void clearFields()
Description copied from interface: Record
reset the fields to their default state The record must be in a mutable state.

Specified by:
clearFields in interface Record

getMetadata

public RecordDescriptor getMetadata()
Specified by:
getMetadata in interface Record
Returns:
an object that describes the data held in this record.
See Also:
RecordDescriptor

getMutableCopy

public Record getMutableCopy()
Description copied from interface: Record
create a clone. A shallow copy of the record values should be enough for immutable records Note that a newly cloned object is in a mutable state, so that you can modify it.

Specified by:
getMutableCopy in interface Record

isStale

public boolean isStale()
Description copied from interface: Record
Has this record been deleted or superseded in the associated DataSource?

Specified by:
isStale in interface Record

getPrimaryKey

public java.lang.Object getPrimaryKey()
Description copied from interface: Record
Retrieve the value of the record's primary key.

Specified by:
getPrimaryKey in interface Record
Returns:
the value of this record's primary key, or null if it has not been set.

setPrimaryKey

public void setPrimaryKey(java.lang.Object o)
Description copied from interface: Record
set the value of this record's primary key. The record must be in a mutable state AND the primary key must be unset.

Specified by:
setPrimaryKey in interface Record

isImmutable

public boolean isImmutable()
Description copied from interface: Record
Have the fields all been set? Once a record is put in a DataSource, its fields are immutable.

Specified by:
isImmutable in interface Record

getType

public java.lang.String getType()
Specified by:
getType in interface Record
Returns:
the name of this record type subclasses must implement this. e.g. "reminder"

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

freeze

public void freeze()
            throws DataException
Description copied from interface: Record
make this record immutable. This will typically only be called by an OreoDataSource object.

Specified by:
freeze in interface Record
DataException

setMetadata

public void setMetadata(RecordDescriptor desc)
Description copied from interface: Record
Method only used internally.

Specified by:
setMetadata in interface Record

getParent

public Record getParent()
                 throws MissingContextException
Specified by:
getParent in interface Record
Returns:
the parent element or null if there is none.
MissingContextException

getChildren

public java.util.List getChildren()
                           throws MissingContextException
Specified by:
getChildren in interface Record
Returns:
a List of children.
MissingContextException

isRootElement

public boolean isRootElement()
                      throws MissingContextException
Description copied from interface: Record
Does this record have a parent? This should return the same as (getParent() == null) but it is worth having a separate method, since, with some schemes, it could be more efficient to ask whether there is a root element or not, as opposed to actually fishing it out.

Specified by:
isRootElement in interface Record
MissingContextException

hasChildren

public boolean hasChildren()
                    throws MissingContextException
Description copied from interface: Record
Does this record have children? This should return the same as (!getChildren().isEmpty()) would. But it can be worth having a separate method for this, since, with some schemes, it could be a lot more efficient to simply ask whether child elements are present, as opposed to actually attempting to fish them out.

Specified by:
hasChildren in interface Record
MissingContextException

equals

public boolean equals(java.lang.Object o)
Overrides:
equals in class java.lang.Object