gumbo.util.route
Class AbstractObjectField

java.lang.Object
  |
  +--gumbo.util.AbstractDisposable
        |
        +--gumbo.util.route.EventNode
              |
              +--gumbo.util.route.EventDataNode
                    |
                    +--gumbo.util.route.AbstractObjectField
All Implemented Interfaces:
Disposable, EventNodeMarker
Direct Known Subclasses:
AbstractObjectField.EventIn, AbstractObjectField.EventOut, ClassField, CollectionField, ConnectionField, InteractorField, ObjectField, PartModelField, PickResultField, Point3Field, RelationField, SpaceNodeField, StateSetField, Vector3Field

public abstract class AbstractObjectField
extends EventDataNode

An abstract base class for an event data node that maintains and transfers data as an Object, and whose data type is specified explicitly. As such, this node can only receive an event from another AbstractObjectField whose data type is assignable to that of this field.

Unless otherwise noted, received data objects should be handled as a snapshot object (use or copy it immediately). The safest way to send a data object is as an immutable object or, at least as an immutable snapshot object.

Version:
$Revision: 1.2 $
Author:
Jon Barrilleaux (jonb@jmbaai.com) of JMB and Associates Inc.

Nested Class Summary
static class AbstractObjectField.EventIn
           
static class AbstractObjectField.EventOut
           
 
Constructor Summary
AbstractObjectField(java.lang.Class dataType)
          Creates an instance, with a null initial value and the specified data type.
AbstractObjectField(java.lang.Class dataType, java.lang.Object init)
          Creates an instance, with an initial value and the specified data type.
 
Method Summary
protected  void checkSender(EventDataNode sender)
          Called by the system (subclasses) to check a sender before connecting it to this node.
protected  void checkValue(java.lang.Object value)
          Called by the system to check new data values.
 java.lang.Class getDataType()
          Gets the type of this field's data object.
protected  java.lang.String getDataValue()
          Get this node's data value as a string.
 java.lang.Object getObject()
          Gets this field's data value, as an Object.
 boolean implSend(java.lang.Object value)
          Checks and sets this field's data value and sends it to its receivers, without event processing and regardless of event relaying.
 void implSet(java.lang.Object value)
          Checks and sets this field's data value, without event processing or event relaying.
 boolean set(java.lang.Object value)
          Equivalent to receiving an event with the specified data value.
 
Methods inherited from class gumbo.util.route.EventDataNode
checkRouter, enableDebug, getReceivers, getRelayType, getSenders, implDispose, implSend, implSysProcess, isReceiver, isSender, process, setDebug, setDebug, setRelayType, sync
 
Methods inherited from class gumbo.util.route.EventNode
isLocked
 
Methods inherited from class gumbo.util.AbstractDisposable
dispose, isDisposed
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractObjectField

public AbstractObjectField(java.lang.Class dataType)
Creates an instance, with a null initial value and the specified data type.


AbstractObjectField

public AbstractObjectField(java.lang.Class dataType,
                           java.lang.Object init)
Creates an instance, with an initial value and the specified data type. Master constructor.

Method Detail

getDataType

public final java.lang.Class getDataType()
Gets the type of this field's data object.


getObject

public final java.lang.Object getObject()
Gets this field's data value, as an Object. Subclasses can follow this naming convention for getting a specific data type, or can implement a generic "get()" method for a data subtype, which will prevent its use by sub-subclasses for sub-subtypes.


set

public final boolean set(java.lang.Object value)
Equivalent to receiving an event with the specified data value. Checks and sets this field's data value, processes the event and, if enabled, relays the event to receivers.


implSend

public final boolean implSend(java.lang.Object value)
Checks and sets this field's data value and sends it to its receivers, without event processing and regardless of event relaying.


implSet

public final void implSet(java.lang.Object value)
Checks and sets this field's data value, without event processing or event relaying. Throws an exception if value is not an instance of this field's data type. Calls checkValue() for value checking.


checkValue

protected void checkValue(java.lang.Object value)
Called by the system to check new data values. Implementers should throw an exception if the value is invalid, and can assume that the value, if non-null, is an instance of this field's data type. The default implementation does nothing.


checkSender

protected void checkSender(EventDataNode sender)
Description copied from class: EventDataNode
Called by the system (subclasses) to check a sender before connecting it to this node. Implementers should throw an exception if the sender is invalid, and can assume that the sender is non-null.

Specified by:
checkSender in class EventDataNode

getDataValue

protected java.lang.String getDataValue()
Description copied from class: EventDataNode
Get this node's data value as a string. Used by the system to contruct a debug message.

Specified by:
getDataValue in class EventDataNode
Returns:
The data value. Empty if no value (NotifyNode). Never null.