gr.uoa.di.madgik.grs.record
Class RecordDefinition

java.lang.Object
  extended by gr.uoa.di.madgik.grs.record.RecordDefinition
Direct Known Subclasses:
GenericRecordDefinition

public abstract class RecordDefinition
extends java.lang.Object

The record definition represents the scheme of a single Record along with the respective FieldDefinition holds all the metadata available for the Record and the hoste4d Fields. All extending classes of this class must define a default no arguments constructor

Author:
gpapanikos

Constructor Summary
RecordDefinition()
          Creates a new instance
RecordDefinition(FieldDefinition[] fieldDefinitions)
          Creates a new instance
 
Method Summary
 void copyFrom(RecordDefinition other)
           
 void deflate(java.io.DataOutput out)
          Deflates the state and information kept in the RecordDefinition.
 boolean equals(java.lang.Object obj)
          
abstract  void extendDeflate(java.io.DataOutput out)
          Method that needs to be implemented by the RecordDefinition extenders to deflate any additional information kept
abstract  boolean extendEquals(java.lang.Object obj)
          Method that needs to be implemented by the RecordDefinition extenders to extend the equality logic based on additional logic contained in the implementations
abstract  void extendFromXML(org.w3c.dom.Element element)
           
abstract  void extendInflate(java.io.DataInput in)
          Method that needs to be implemented by the RecordDefinition extenders to inflate any additional information previously deflated by the respective extender method
abstract  void extendToXML(org.w3c.dom.Document out, org.w3c.dom.Element element)
           
 void fromXML(org.w3c.dom.Element element)
           
 FieldDefinition getDefinition(int index)
          Retrieves the field definition with the provided index
 int getDefinition(java.lang.String name)
          Retrieves the field definition with the provided name
 int getDefinitionSize()
          Retrieves the length of the field definitions
 IBuffer.TransportDirective getTransportDirective()
          Retrieves the transport directive
 void inflate(java.io.DataInput in)
          Inflates the previously deflated information of this RecordDefinition.
 void setTransportDirective(IBuffer.TransportDirective directive)
          Sets the transport directive for this Record
 org.w3c.dom.Element toXML(org.w3c.dom.Document doc)
           
 
Methods inherited from class java.lang.Object
getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RecordDefinition

public RecordDefinition()
Creates a new instance


RecordDefinition

public RecordDefinition(FieldDefinition[] fieldDefinitions)
Creates a new instance

Parameters:
fieldDefinitions - the field definitions
Method Detail

copyFrom

public void copyFrom(RecordDefinition other)
              throws GRS2RecordSerializationException
Throws:
GRS2RecordSerializationException

getDefinition

public FieldDefinition getDefinition(int index)
Retrieves the field definition with the provided index

Parameters:
index - the index of the definition
Returns:
the Filed definition

getDefinition

public int getDefinition(java.lang.String name)
Retrieves the field definition with the provided name

Parameters:
name - the name of the definition
Returns:
the field definition

getDefinitionSize

public int getDefinitionSize()
Retrieves the length of the field definitions

Returns:
the length of the field definitions

setTransportDirective

public void setTransportDirective(IBuffer.TransportDirective directive)
Sets the transport directive for this Record

Parameters:
directive - the directive

getTransportDirective

public IBuffer.TransportDirective getTransportDirective()
Retrieves the transport directive

Returns:
the directive

equals

public boolean equals(java.lang.Object obj)

To check for equality, the type of the argument is checked. The field definitions length in both definitions must be the same as well as the defined IBuffer.TransportDirective. For each field definition hosted, FieldDefinition.equals(Object) is invoked and finally the extendEquals(Object) is consulted. If any of the above conditions are not met, the two instances are not equal

Overrides:
equals in class java.lang.Object
See Also:
Object.equals(java.lang.Object)

extendEquals

public abstract boolean extendEquals(java.lang.Object obj)
Method that needs to be implemented by the RecordDefinition extenders to extend the equality logic based on additional logic contained in the implementations

Parameters:
obj - the object to check equality for
Returns:
true if the two instances are equal, false otherwise

deflate

public void deflate(java.io.DataOutput out)
             throws GRS2RecordSerializationException
Deflates the state and information kept in the RecordDefinition. After deflating the locally maintained information, for each field definition hosted, FieldDefinition.deflate(DataOutput) is invoked and finally, Field.extendDeflate(java.io.DataOutput)

Parameters:
out - the stream to deflate the information to
Throws:
GRS2RecordSerializationException - there was a problem serializing the definition state

extendToXML

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

toXML

public final org.w3c.dom.Element toXML(org.w3c.dom.Document doc)
                                throws GRS2RecordSerializationException,
                                       GRS2RecordDefinitionException,
                                       org.w3c.dom.DOMException
Throws:
GRS2RecordSerializationException
GRS2RecordDefinitionException
org.w3c.dom.DOMException

fromXML

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

extendDeflate

public abstract void extendDeflate(java.io.DataOutput out)
                            throws GRS2RecordSerializationException
Method that needs to be implemented by the RecordDefinition extenders to deflate any additional information kept

Parameters:
out - the stream to deflate to
Throws:
GRS2RecordSerializationException - there was a serialization error

inflate

public void inflate(java.io.DataInput in)
             throws GRS2RecordSerializationException
Inflates the previously deflated information of this RecordDefinition. After retrieving the locally maintained information, for all the hosted fields, the FieldDefinition.inflate(DataInput) is called, and finally extendInflate(DataInput) is invoked

Parameters:
in - the stream to inflate from
Throws:
GRS2RecordSerializationException - there was a problem deserializing the definition state

extendInflate

public abstract void extendInflate(java.io.DataInput in)
                            throws GRS2RecordSerializationException
Method that needs to be implemented by the RecordDefinition extenders to inflate any additional information previously deflated by the respective extender method

Parameters:
in - the stream to inflate from
Throws:
GRS2RecordSerializationException - there was a problem deserializing the definition state

extendFromXML

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