org.nodal.util
Class GetterUtil

java.lang.Object
  extended byorg.nodal.util.TxnMonitorableUtil
      extended byorg.nodal.util.GetterUtil
All Implemented Interfaces:
Getter, TxnHandler, TxnMonitorable
Direct Known Subclasses:
BooleanGetterUtil, ByteGetterUtil, CharGetterUtil, DoubleGetterUtil, FloatGetterUtil, IntGetterUtil, LongGetterUtil, ShortGetterUtil

public abstract class GetterUtil
extends TxnMonitorableUtil
implements Getter

General implementation platform for Getter interface.

An implementation of Getter derived from this class must provide an implementation of the get() method. Type-specific implementations will also override a selection of the type-specific getFoo() methods to avoid unnecessary "boxing" of primitive values.

Author:
Lee Iverson

Field Summary
protected  Type getterType
           
 
Fields inherited from class org.nodal.util.TxnMonitorableUtil
handlers
 
Constructor Summary
protected GetterUtil(Type t)
           
 
Method Summary
protected abstract  Path createPath()
          A Path that will be bound to this Getter.
abstract  java.lang.Object get()
          Recover the value of this Getter as an Object.
 boolean getBoolean()
          Return the value of this Getter as a boolean if possible
 byte getByte()
          Return the value of this Getter as a byte if possible
 char getChar()
          Return the value of this Getter as a char if possible
 double getDouble()
          Return the value of this Getter as a double if possible
 float getFloat()
          Return the value of this Getter as a float if possible
 int getInt()
          Return the value of this Getter as an int if possible
 long getLong()
          Return the value of this Getter as a long if possible
 Node getNode()
          Return the value of this Getter as a Node if possible
 short getShort()
          Return the value of this Getter as a short if possible
 java.lang.String getString()
          Return the value of this Getter as a String.
 Path path()
          A Path to this Getter.
 Type type()
          The NODAL Type of this object.
 boolean valueEquals(java.lang.Object v)
          Compare this value with the argument.
 
Methods inherited from class org.nodal.util.TxnMonitorableUtil
addNotifier, addTxnHandler, notifyInsertAfter, notifyInsertBefore, notifyRemoveKey, notifyRemoveRange, notifyReplaceRange, notifySetValue, removeNotifier, removeTxnHandler
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.nodal.model.TxnMonitorable
addTxnHandler, removeTxnHandler
 

Field Detail

getterType

protected Type getterType
Constructor Detail

GetterUtil

protected GetterUtil(Type t)
Method Detail

get

public abstract java.lang.Object get()
                              throws PropertyConstraintFailure
Recover the value of this Getter as an Object.

Must override to implement.

Specified by:
get in interface Getter
Throws:
PropertyConstraintFailure

createPath

protected abstract Path createPath()
                            throws Path.Failure
A Path that will be bound to this Getter.

Must override to implement.

Throws:
Path.Failure

path

public Path path()
Description copied from interface: Getter
A Path to this Getter. For a Getter that is Node.Property, the Path is normally the Node.path() extended with the property name.

Specified by:
path in interface Getter
Returns:
a bound Path that accesses this Getter

type

public Type type()
The NODAL Type of this object.

Specified by:
type in interface Getter
Returns:
the Type of value returned by a get() call

getBoolean

public boolean getBoolean()
                   throws PropertyConstraintFailure
Return the value of this Getter as a boolean if possible

Specified by:
getBoolean in interface Getter
Throws:
PropertyConstraintFailure

getChar

public char getChar()
             throws PropertyConstraintFailure
Return the value of this Getter as a char if possible

Specified by:
getChar in interface Getter
Throws:
PropertyConstraintFailure

getByte

public byte getByte()
             throws PropertyConstraintFailure
Return the value of this Getter as a byte if possible

Specified by:
getByte in interface Getter
Throws:
PropertyConstraintFailure

getShort

public short getShort()
               throws PropertyConstraintFailure
Return the value of this Getter as a short if possible

Specified by:
getShort in interface Getter
Throws:
PropertyConstraintFailure

getInt

public int getInt()
           throws PropertyConstraintFailure
Return the value of this Getter as an int if possible

Specified by:
getInt in interface Getter
Throws:
PropertyConstraintFailure

getLong

public long getLong()
             throws PropertyConstraintFailure
Return the value of this Getter as a long if possible

Specified by:
getLong in interface Getter
Throws:
PropertyConstraintFailure

getFloat

public float getFloat()
               throws PropertyConstraintFailure
Return the value of this Getter as a float if possible

Specified by:
getFloat in interface Getter
Throws:
PropertyConstraintFailure

getDouble

public double getDouble()
                 throws PropertyConstraintFailure
Return the value of this Getter as a double if possible

Specified by:
getDouble in interface Getter
Throws:
PropertyConstraintFailure

getNode

public Node getNode()
             throws PropertyConstraintFailure
Return the value of this Getter as a Node if possible

Specified by:
getNode in interface Getter
Throws:
PropertyConstraintFailure

getString

public java.lang.String getString()
                           throws PropertyConstraintFailure
Return the value of this Getter as a String.

Unlike the other type-specific get methods, this must always succeed.

Specified by:
getString in interface Getter
Throws:
PropertyConstraintFailure

valueEquals

public boolean valueEquals(java.lang.Object v)
                    throws PropertyConstraintFailure
Compare this value with the argument.

This method is provided so that comparison can be done without the overhead of a full get in some cases. This should thus be overriden with a more efficient implementation when possible.

Specified by:
valueEquals in interface Getter
Throws:
PropertyConstraintFailure