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

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

public abstract class RecordDefinition
extends Object
implements Serializable

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
See Also:
Serialized Form

Field Summary
protected  IBuffer.TransportDirective directive
          The transport directive of the Record, initially set to IBuffer.TransportDirective.Inherit
protected  List<FieldDefinition> Fields
          The field definitions available for the hosted Fields
 
Constructor Summary
RecordDefinition()
          Creates a new instance
RecordDefinition(List<FieldDefinition> fieldDefinitions)
          Creates a new instance
 
Method Summary
 void copyFrom(RecordDefinition other)
           
 void deflate(DataOutput out)
          Deflates the state and information kept in the RecordDefinition.
 boolean equals(Object obj)
          
abstract  void extendDeflate(DataOutput out)
          Method that needs to be implemented by the RecordDefinition extenders to deflate any additional information kept
abstract  boolean extendEquals(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(Element element)
           
abstract  void extendInflate(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(Element element)
           
 void fromXML(Element element)
           
 FieldDefinition getDefinition(int index)
          Retrieves the field definition with the provided index
 int getDefinition(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(DataInput in)
          Inflates the previously deflated information of this RecordDefinition.
 void setTransportDirective(IBuffer.TransportDirective directive)
          Sets the transport directive for this Record
 Element toXML(Document doc)
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

Fields

protected List<FieldDefinition> Fields
The field definitions available for the hosted Fields


directive

protected IBuffer.TransportDirective directive
The transport directive of the Record, initially set to IBuffer.TransportDirective.Inherit

Constructor Detail

RecordDefinition

public RecordDefinition()
Creates a new instance


RecordDefinition

public RecordDefinition(List<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(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(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 Object
See Also:
Object.equals(java.lang.Object)

extendEquals

public abstract boolean extendEquals(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(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

toXML

public final Element toXML(Document doc)
                    throws GRS2RecordSerializationException,
                           GRS2RecordDefinitionException,
                           DOMException
Throws:
GRS2RecordSerializationException
GRS2RecordDefinitionException
DOMException

fromXML

public final void fromXML(Element element)
                   throws GRS2RecordSerializationException,
                          GRS2RecordDefinitionException,
                          DOMException
Throws:
GRS2RecordSerializationException
GRS2RecordDefinitionException
DOMException

extendDeflate

public abstract void extendDeflate(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(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(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(Element element)
                            throws GRS2RecordSerializationException
Throws:
GRS2RecordSerializationException

extendToXML

public abstract void extendToXML(Element element)
                          throws GRS2RecordSerializationException
Throws:
GRS2RecordSerializationException


Copyright © 2012. All Rights Reserved.