fulmine.model.field.containerdefinition
Class ContainerDefinitionField

java.lang.Object
  extended by fulmine.AbstractLifeCycle
      extended by fulmine.model.component.AbstractComponent
          extended by fulmine.model.field.AbstractField
              extended by fulmine.model.field.containerdefinition.ContainerDefinitionField
All Implemented Interfaces:
IEvent, IEventSource, IAddressable, IDescriptor, IDestroyable, ILifeCycle, IComponent, IContainerDefinitionField, IField, IWireIdentityRegistry, IWireState, Cloneable

public final class ContainerDefinitionField
extends AbstractField
implements IContainerDefinitionField

Default implementation of an IContainerDefinitionField. The definition is made up of DescriptorField fields. These descriptor fields provide the necessary meta data for a transmitting container to write an IField using its wire identity and provides the receiving container with the information to construct the correct field type.

The fields of this implementation have SWF wire identities. There is no way to send the definition using IWF as, by design, the IWF code maps to a field and this is one of the functions the definition provides.

Static definitions are 'singletons'; all containers of the same type share the same static definition. Static definitions are not sent on-the-wire or mutated.

Author:
Ramon Servadei

Constructor Summary
ContainerDefinitionField(AbstractDynamicContainer container)
          Constructor for a dynamic definition
ContainerDefinitionField(String definition, IField... fields)
          Constructor for a static definition
 
Method Summary
 void add(IField field)
          Add the field to the definition.
 Object clone()
          Clone this.
 boolean containsDefinition(int wireCode)
          Determines if the container definition contains a DescriptorField for a field identified by its integer wire identity.
 IField createField(int wireCode)
          Create the field identified by its wire code.
protected  void doComponentDestroy()
          The destroy method that is invoked on a non-cloned version of this.
protected  boolean doReadState(IOperationScope scope, byte[] buffer, int start, int numberOfBytes)
          Update the component state from the wire format state in the buffer.
protected  boolean doWriteState(IOperationScope scope, IWireIdentity wireId, byte[][] headerBuffer, int[] headerBufferPosition, byte[][] dataBuffer, int[] dataBufferPosition, boolean completeState)
          Write the component state in its wire form to the buffer.
 boolean equals(Object obj)
           
 byte getApplication(int wireCode)
          Get the application code for the field identified by its wire identity
 String[] getComponentIdentities()
           
 String getIdentityFor(IWireIdentity wireId)
          Get the identity assigned to the wire identity
 String getIdentityForWireCode(int wireCode)
          Get the IWF wire identity code
protected  AsyncLog getLog()
          Get the log to use for the object hierarchy
 short getPermission(int wireCode)
          Get the permission code for the field identified by its wire identity
 Object getValue()
          Get the field value
 String getValueAsString()
          Get the value of this field as a string.
 int getWireCodeForIdentity(String identity)
          Get the IWF wire identity code for the IField identified by the string
 IWireIdentity getWireIdentityFor(String identity)
          Get the wire identity assigned for an identity
 boolean isDynamic()
          Identify if the definition is dynamic (i.e.
 void populate(IContainer container)
          Create the fields in the container from this definition.
 void remove(IField field)
          Remove the DescriptorField with the same identity as the field argument from this definition.
 void resetChanges()
          Reset all changes.
 
Methods inherited from class fulmine.model.field.AbstractField
addedToContainer, getApplication, getContainer, getPermission, hashCode, notifyEvent, removedFromContainer, setApplication, setContainer, setPermission, setValueFromString, toDetailedString, toIdentityString, toString
 
Methods inherited from class fulmine.model.component.AbstractComponent
addEvent, addListener, checkClone, createIdentityString, doDestroy, doPostAddListener, doPostRemoveListener, doStart, getAddress, getAddressable, getDomain, getDrivingFrame, getEventSourceGroupId, getFrame, getIdentity, getIdentityString, getListeners, getSource, getTriggerEvent, getType, isClone, readState, removeListener, removeListeners, setDrivingFrame, setFrame, setTriggerEvent, writeState
 
Methods inherited from class fulmine.AbstractLifeCycle
checkActive, destroy, finalize, isActive, start
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface fulmine.model.field.IField
addedToContainer, getApplication, getContainer, getPermission, removedFromContainer, setValueFromString
 
Methods inherited from interface fulmine.protocol.wire.IWireState
readState, writeState
 
Methods inherited from interface fulmine.event.IEventSource
addEvent, addListener, getEventSourceGroupId, getListeners, removeListener, removeListeners
 
Methods inherited from interface fulmine.IDescriptor
toDetailedString, toIdentityString
 
Methods inherited from interface fulmine.ILifeCycle
isActive, start
 
Methods inherited from interface fulmine.IDestroyable
destroy
 
Methods inherited from interface fulmine.IAddressable
getAddress, getDomain, getIdentity, getType
 
Methods inherited from interface fulmine.event.IEvent
getDrivingFrame, getFrame, getSource, getTriggerEvent, setTriggerEvent
 
Methods inherited from interface fulmine.IDescriptor
toDetailedString, toIdentityString
 
Methods inherited from interface fulmine.IAddressable
getAddress, getDomain, getIdentity, getType
 

Constructor Detail

ContainerDefinitionField

public ContainerDefinitionField(String definition,
                                IField... fields)
Constructor for a static definition

Parameters:
definition - the unique name for the definition

ContainerDefinitionField

public ContainerDefinitionField(AbstractDynamicContainer container)
Constructor for a dynamic definition

Parameters:
container - a dynamic container (can have new fields added/removed)
Method Detail

getLog

protected AsyncLog getLog()
Description copied from class: AbstractLifeCycle
Get the log to use for the object hierarchy

Overrides:
getLog in class AbstractComponent
Returns:
the log to use for the object hierarchy

isDynamic

public boolean isDynamic()
Description copied from interface: IContainerDefinitionField
Identify if the definition is dynamic (i.e. mutable)

Specified by:
isDynamic in interface IContainerDefinitionField
Returns:
true if the definition is dynamic

add

public void add(IField field)
Description copied from interface: IContainerDefinitionField
Add the field to the definition. The field is inspected and a DescriptorField is constructed to represent the field. The descriptor field is held in the definition.

Specified by:
add in interface IContainerDefinitionField
Parameters:
field - the field to represent with a DescriptorField

remove

public void remove(IField field)
Description copied from interface: IContainerDefinitionField
Remove the DescriptorField with the same identity as the field argument from this definition.

Specified by:
remove in interface IContainerDefinitionField
Parameters:
field - the field representation to remove from the definition

getIdentityFor

public String getIdentityFor(IWireIdentity wireId)
Description copied from interface: IWireIdentityRegistry
Get the identity assigned to the wire identity

Specified by:
getIdentityFor in interface IWireIdentityRegistry
Parameters:
wireId - the wire identity to find the plain identity for
Returns:
the String identity assigned to this wire identity

getWireIdentityFor

public IWireIdentity getWireIdentityFor(String identity)
Description copied from interface: IWireIdentityRegistry
Get the wire identity assigned for an identity

Specified by:
getWireIdentityFor in interface IWireIdentityRegistry
Parameters:
identity - the identity to find the assigned wire identity for
Returns:
the IWireIdentity assigned to this identity

getIdentityForWireCode

public String getIdentityForWireCode(int wireCode)
Description copied from interface: IContainerDefinitionField
Get the IWF wire identity code

Specified by:
getIdentityForWireCode in interface IContainerDefinitionField
Parameters:
wireCode - the integer value of the IWF wire identity
Returns:
the string identity of the associated IField declared for this IWF wire identity

getWireCodeForIdentity

public int getWireCodeForIdentity(String identity)
Description copied from interface: IContainerDefinitionField
Get the IWF wire identity code for the IField identified by the string

Specified by:
getWireCodeForIdentity in interface IContainerDefinitionField
Parameters:
identity - the string identity of the IField to find
Returns:
the integer value of the IWF wire identity for the IField

doReadState

protected boolean doReadState(IOperationScope scope,
                              byte[] buffer,
                              int start,
                              int numberOfBytes)
                       throws Exception
Description copied from class: AbstractComponent
Update the component state from the wire format state in the buffer. Any nested fields must be read using their AbstractComponent.readState(IOperationScope, byte[], int, int) method.

Specified by:
doReadState in class AbstractComponent
Returns:
true if the read operation succeded.
Throws:
Exception
See Also:
IWireState.readState(IOperationScope, byte[], int, int)

doWriteState

protected boolean doWriteState(IOperationScope scope,
                               IWireIdentity wireId,
                               byte[][] headerBuffer,
                               int[] headerBufferPosition,
                               byte[][] dataBuffer,
                               int[] dataBufferPosition,
                               boolean completeState)
                        throws Exception
Description copied from class: AbstractComponent
Write the component state in its wire form to the buffer. Any nested fields must be written by calling their AbstractComponent.writeState(IOperationScope, IWireIdentity, byte[][], int[], byte[][], int[], boolean) method.

Specified by:
doWriteState in class AbstractComponent
Returns:
true if the write operation succeeded
Throws:
Exception
See Also:
IWireState.writeState(IOperationScope, IWireIdentity, byte[][], int[], byte[][], int[], boolean), for a discussion of the byte[][] usage

populate

public void populate(IContainer container)
Description copied from interface: IContainerDefinitionField
Create the fields in the container from this definition.

Specified by:
populate in interface IContainerDefinitionField
Parameters:
container - the container to populate

getComponentIdentities

public String[] getComponentIdentities()

doComponentDestroy

protected void doComponentDestroy()
Description copied from class: AbstractComponent
The destroy method that is invoked on a non-cloned version of this.

Overrides:
doComponentDestroy in class AbstractField

getValueAsString

public String getValueAsString()
Description copied from interface: IField
Get the value of this field as a string.

Specified by:
getValueAsString in interface IField
Returns:
a string representing the value of this field.

resetChanges

public void resetChanges()
Description copied from interface: IContainerDefinitionField
Reset all changes.

Specified by:
resetChanges in interface IContainerDefinitionField

containsDefinition

public boolean containsDefinition(int wireCode)
Description copied from interface: IContainerDefinitionField
Determines if the container definition contains a DescriptorField for a field identified by its integer wire identity.

Specified by:
containsDefinition in interface IContainerDefinitionField
Parameters:
wireCode - the integer wire identity for the field
Returns:
true if there is a DescriptorField for this integer wire identity

createField

public IField createField(int wireCode)
Description copied from interface: IContainerDefinitionField
Create the field identified by its wire code. This only works if there is a DescriptorField for the wire identity.

Specified by:
createField in interface IContainerDefinitionField
Parameters:
wireCode - the integer wire identity for the field
Returns:
the created IField or null if there was no DescriptorField for this integer wire identity
See Also:
IContainerDefinitionField.containsDefinition(int)

getValue

public Object getValue()
Description copied from interface: IField
Get the field value

Specified by:
getValue in interface IField
Returns:
the field type

getApplication

public byte getApplication(int wireCode)
Description copied from interface: IContainerDefinitionField
Get the application code for the field identified by its wire identity

Specified by:
getApplication in interface IContainerDefinitionField
Parameters:
wireCode - the integer wire identity for the field
Returns:
the application code for the field
See Also:
IPermissionProfile

getPermission

public short getPermission(int wireCode)
Description copied from interface: IContainerDefinitionField
Get the permission code for the field identified by its wire identity

Specified by:
getPermission in interface IContainerDefinitionField
Parameters:
wireCode - the integer wire identity for the field
Returns:
the permission code for the field
See Also:
IPermissionProfile

equals

public boolean equals(Object obj)
Overrides:
equals in class AbstractField

clone

public Object clone()
             throws CloneNotSupportedException
Description copied from interface: IEvent
Clone this.

Specified by:
clone in interface IEvent
Specified by:
clone in interface IField
Overrides:
clone in class AbstractComponent
Returns:
a clone of this
Throws:
CloneNotSupportedException
See Also:
Object#clone)_


Copyright © 2007-2009. All Rights Reserved.