gr.uoa.di.madgik.grs.record.field
Class Field

java.lang.Object
  extended by gr.uoa.di.madgik.grs.record.field.Field
All Implemented Interfaces:
IPumpable
Direct Known Subclasses:
FileField, ObjectField, StringField, URLField

public abstract class Field
extends java.lang.Object
implements IPumpable

This class is the base class for all Fields that are handled by the gRS2 set of components. All implementations of this abstract class must define a default constructor without arguments as instances of these classes will be instantiated using reflection based on the existence of a default no arguments constructor

Author:
gpapanikos

Constructor Summary
Field()
           
 
Method Summary
 void bind(Record record)
          Binds the Field to a specific Record that hsots it
 void deflate(java.io.DataOutput out)
          Deflates the state and data of the implementor in a from capable of reconstructing the exact same instance
 void dispose()
          Disposes all internal state and invokes extendDispose()
abstract  void extendDeflate(java.io.DataOutput out)
          Method that needs to be implemented by the class extenders to deflate the information they keep
abstract  void extendDispose()
          Method to be implemented by class extenders to dispose their internal state
abstract  void extendFromXML(org.w3c.dom.Element element, boolean reset)
           
abstract  void extendInflate(java.io.DataInput in, boolean reset)
          Method that needs to be implemented by the Field extenders to inflate their internal information
abstract  void extendReceive(java.io.DataInput in, IBuffer.TransportOverride override)
          Method that needs to be implemented by the Field extenders to receive their priveously send information
abstract  void extendReceiveFromXML(org.w3c.dom.Element element, IBuffer.TransportOverride override)
           
abstract  void extendSend(java.io.DataOutput out, IBuffer.TransportOverride override)
          Method that needs to be implemented by the class extenders to send the information they keep
abstract  void extendSendToXML(org.w3c.dom.Document doc, org.w3c.dom.Element element, IBuffer.TransportOverride override)
           
abstract  void extendToXML(org.w3c.dom.Document doc, org.w3c.dom.Element element)
           
 void fromXML(org.w3c.dom.Element element)
           
 void fromXML(org.w3c.dom.Element element, boolean reset)
           
 int getDefinitionIndex()
          Retrieves the index of the FieldDefinition within the RecordDefinition of the bound Record
 FieldDefinition getFieldDefinition()
          Retrieves the FieldDefinition based on the definition index and the bound Record RecordDefinition
abstract  java.io.InputStream getInputStream()
          Provides an InputStream over the locally available payload of the Field
 MediatingInputStream getMediatingInputStream()
          Retrieves an MediatingInputStream over this Field
 void inflate(java.io.DataInput in)
          Inflate the state and data of the implementor as was previously deflated using IPumpable.deflate(DataOutput)
 void inflate(java.io.DataInput in, boolean reset)
          Inflate the state and data of the implementor as was previously deflated using IPumpable.deflate(DataOutput)
abstract  boolean isAvailable()
          Method that needs to be implemented by class extenders to indicate in case of a remote field copy when the field is not expecting any more data from its original instance.
 boolean isRemoteCopy()
          Checks if the instance is a remote copy of the original
 void makeAvailable()
          Makes fully available the content of the Field by invoking Field#makeAvailable(TransportOverride) with a IBuffer.TransportOverride.Override value
 void makeAvailable(IBuffer.TransportOverride override)
          Invokes the bound Record's Record#requestPartial(TransportOverride, int) method with the provided IBuffer.TransportOverride value
 void makeLocal()
          Called by Record.makeLocal().
 void prebind(Record record)
          Pre-binds the Field to the provided Record
 void receive(java.io.DataInput in)
          Receives the information send by a respective call to send(DataOutput).
 void receiveFromXML(org.w3c.dom.Element element)
           
 IBuffer.TransportDirective resolveTransportDirective()
          Resolves the transport directive that needs to be used by this Field.
 void send(java.io.DataOutput out)
          Sets the state and information of this Field in the provided stream.
 org.w3c.dom.Element sendToXML(org.w3c.dom.Document doc)
           
 void setDefinitionIndex(int index)
          Sets the index of the FieldDefinition within the RecordDefinition of the bound Record
 void setRemoteCopy(boolean remoteCopy)
          Sets whether this instance of the Field is a remote copy of the original Field
 org.w3c.dom.Element toXML(org.w3c.dom.Document doc)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Field

public Field()
Method Detail

setDefinitionIndex

public void setDefinitionIndex(int index)
Sets the index of the FieldDefinition within the RecordDefinition of the bound Record

Parameters:
index - the index

getDefinitionIndex

public int getDefinitionIndex()
Retrieves the index of the FieldDefinition within the RecordDefinition of the bound Record

Returns:
the index

bind

public void bind(Record record)
Binds the Field to a specific Record that hsots it

Parameters:
record - the record

prebind

public void prebind(Record record)
Pre-binds the Field to the provided Record

Parameters:
record -

setRemoteCopy

public void setRemoteCopy(boolean remoteCopy)
Sets whether this instance of the Field is a remote copy of the original Field

Parameters:
remoteCopy - whether or not it is a remote copy

isRemoteCopy

public boolean isRemoteCopy()
Checks if the instance is a remote copy of the original

Returns:
whether or not it is a remote copy

getFieldDefinition

public FieldDefinition getFieldDefinition()
                                   throws GRS2RecordDefinitionException
Retrieves the FieldDefinition based on the definition index and the bound Record RecordDefinition

Returns:
the field definition
Throws:
GRS2RecordDefinitionException - if the Field is not bound to a Record or no usable definition has been found

resolveTransportDirective

public IBuffer.TransportDirective resolveTransportDirective()
                                                     throws GRS2RecordDefinitionException,
                                                            GRS2BufferException
Resolves the transport directive that needs to be used by this Field. If the defined IBuffer.TransportDirective is set to IBuffer.TransportDirective.Inherit, the bound record's Record.resolveTransportDirective() is used

Returns:
the resolved IBuffer.TransportDirective
Throws:
GRS2RecordDefinitionException - The bound Record's definition could not be retrieved
GRS2BufferException - the IBuffer state does not allow for this operation to be completed

deflate

public final void deflate(java.io.DataOutput out)
                   throws GRS2RecordSerializationException
Deflates the state and data of the implementor in a from capable of reconstructing the exact same instance Deflates the state and information of this Field in the provided stream. After deflating the internally kept information, extendDeflate(DataOutput) is invoked for class extenders to persist their information

Specified by:
deflate in interface IPumpable
Parameters:
out - the stream to writer information to
Throws:
GRS2RecordSerializationException - There was a problem in the serialization

toXML

public final org.w3c.dom.Element toXML(org.w3c.dom.Document doc)
                                throws GRS2RecordSerializationException
Specified by:
toXML in interface IPumpable
Throws:
GRS2RecordSerializationException

fromXML

public final void fromXML(org.w3c.dom.Element element)
                   throws GRS2RecordSerializationException
Specified by:
fromXML in interface IPumpable
Throws:
GRS2RecordSerializationException

fromXML

public final void fromXML(org.w3c.dom.Element element,
                          boolean reset)
                   throws GRS2RecordSerializationException
Throws:
GRS2RecordSerializationException

send

public final void send(java.io.DataOutput out)
                throws GRS2RecordSerializationException
Sets the state and information of this Field in the provided stream. After sending the internally kept information, Field#extendSend(DataOutput, TransportOverride) is invoked for class extenders to persist their information

Parameters:
out - the stream to send information to
Throws:
GRS2RecordSerializationException - There was a problem in the serialization

sendToXML

public final org.w3c.dom.Element sendToXML(org.w3c.dom.Document doc)
                                    throws GRS2RecordSerializationException
Throws:
GRS2RecordSerializationException

receiveFromXML

public final void receiveFromXML(org.w3c.dom.Element element)
                          throws GRS2RecordSerializationException
Throws:
GRS2RecordSerializationException

makeLocal

public final void makeLocal()
Called by Record.makeLocal(). External use is unnecessary and discouraged.

Resets any information which indicate previous executed transfers and makes the Field behave as if it were local. If partial transfers are involved makeAvailable() should be invoked beforehand in case the full payload is needed. This method has no effect if the Field is created locally or retrieved by the same IBuffer instance the producer used


extendDeflate

public abstract void extendDeflate(java.io.DataOutput out)
                            throws GRS2RecordSerializationException
Method that needs to be implemented by the class extenders to deflate the information they keep

Parameters:
out - the stream to deflate to
Throws:
GRS2RecordSerializationException - There was a problem in the serialization

extendToXML

public abstract void extendToXML(org.w3c.dom.Document doc,
                                 org.w3c.dom.Element element)
                          throws GRS2RecordSerializationException
Throws:
GRS2RecordSerializationException

extendFromXML

public abstract void extendFromXML(org.w3c.dom.Element element,
                                   boolean reset)
                            throws GRS2RecordSerializationException
Throws:
GRS2RecordSerializationException

extendSend

public abstract void extendSend(java.io.DataOutput out,
                                IBuffer.TransportOverride override)
                         throws GRS2RecordSerializationException
Method that needs to be implemented by the class extenders to send the information they keep

Parameters:
out - the stream to send information to
override - the IBuffer.TransportOverride directive
Throws:
GRS2RecordSerializationException - There was a problem in the serialization

inflate

public final void inflate(java.io.DataInput in)
                   throws GRS2RecordSerializationException
Inflate the state and data of the implementor as was previously deflated using IPumpable.deflate(DataOutput) Similar as calling inflate(DataInput, boolean) with a reset parameter of false

Specified by:
inflate in interface IPumpable
Parameters:
in - the stream to inflate from
Throws:
GRS2RecordSerializationException - the inflate could not be completed
See Also:
inflate(DataInput), IPumpable.inflate(DataInput)

inflate

public final void inflate(java.io.DataInput in,
                          boolean reset)
                   throws GRS2RecordSerializationException
Inflate the state and data of the implementor as was previously deflated using IPumpable.deflate(DataOutput) Inflates a Field that was previously deflated using deflate(DataOutput). After the Field deflate's its internal information, the extendInflate(DataInput, boolean) is invoked

Specified by:
inflate in interface IPumpable
Parameters:
in - the stream to inflate from
reset - whether or not the inflated information needs to be reset to clear any indication of previous executed transfers
Throws:
GRS2RecordSerializationException - There was a problem in the deserialization

receive

public final void receive(java.io.DataInput in)
                   throws GRS2RecordSerializationException
Receives the information send by a respective call to send(DataOutput). After the internally kept information are read, the stream is passed to Field#extendReceive(DataInput, TransportOverride)

Parameters:
in - the stream to read from
Throws:
GRS2RecordSerializationException - There was a problem in the deserialization

extendInflate

public abstract void extendInflate(java.io.DataInput in,
                                   boolean reset)
                            throws GRS2RecordSerializationException
Method that needs to be implemented by the Field extenders to inflate their internal information

Parameters:
in - the stream to inflate from
reset - whether or not the inflated information needs to be reset to clear any indication of previous executed transfers
Throws:
GRS2RecordSerializationException - There was a problem in the deserialization

extendReceive

public abstract void extendReceive(java.io.DataInput in,
                                   IBuffer.TransportOverride override)
                            throws GRS2RecordSerializationException
Method that needs to be implemented by the Field extenders to receive their priveously send information

Parameters:
in - the stream to receive from
override - the IBuffer.TransportOverride to use
Throws:
GRS2RecordSerializationException - There was a problem in the deserialization

dispose

public void dispose()
Disposes all internal state and invokes extendDispose()


extendDispose

public abstract void extendDispose()
Method to be implemented by class extenders to dispose their internal state


isAvailable

public abstract boolean isAvailable()
Method that needs to be implemented by class extenders to indicate in case of a remote field copy when the field is not expecting any more data from its original instance. For an instance that is not remote, the field is always available

Returns:
whether or not the remote copy is available

makeAvailable

public void makeAvailable()
                   throws GRS2RecordDefinitionException,
                          GRS2BufferException,
                          GRS2ProxyMirrorException
Makes fully available the content of the Field by invoking Field#makeAvailable(TransportOverride) with a IBuffer.TransportOverride.Override value

Throws:
GRS2RecordDefinitionException - the definition of the bound record could not be utilized
GRS2BufferException - the state of the IBuffer does not permit this operation to be completed
GRS2ProxyMirrorException - The state of the mirroring protocol does not permit for this operation to be completed

makeAvailable

public void makeAvailable(IBuffer.TransportOverride override)
                   throws GRS2RecordDefinitionException,
                          GRS2BufferException,
                          GRS2ProxyMirrorException
Invokes the bound Record's Record#requestPartial(TransportOverride, int) method with the provided IBuffer.TransportOverride value

Parameters:
override - the IBuffer.TransportOverride to use
Throws:
GRS2RecordDefinitionException - the definition of the bound record could not be utilized
GRS2BufferException - the state of the IBuffer does not permit this operation to be completed
GRS2ProxyMirrorException - The state of the mirroring protocol does not permit for this operation to be completed

getInputStream

public abstract java.io.InputStream getInputStream()
                                            throws java.io.IOException
Provides an InputStream over the locally available payload of the Field

Returns:
the input stream
Throws:
java.io.IOException - The input stream could not be created

getMediatingInputStream

public MediatingInputStream getMediatingInputStream()
                                             throws java.io.IOException,
                                                    GRS2RecordMediationException
Retrieves an MediatingInputStream over this Field

Returns:
the stream to be used
Throws:
java.io.IOException - the stream could not be created
GRS2RecordMediationException - the mediated stream could not be created

extendSendToXML

public abstract void extendSendToXML(org.w3c.dom.Document doc,
                                     org.w3c.dom.Element element,
                                     IBuffer.TransportOverride override)
                              throws GRS2RecordSerializationException
Throws:
GRS2RecordSerializationException

extendReceiveFromXML

public abstract void extendReceiveFromXML(org.w3c.dom.Element element,
                                          IBuffer.TransportOverride override)
                                   throws GRS2RecordSerializationException
Throws:
GRS2RecordSerializationException