jef.dna.fieldsTable
Interface FieldsTable

All Superinterfaces:
java.lang.Cloneable
All Known Implementing Classes:
FTable

public interface FieldsTable
extends java.lang.Cloneable

This interface defines the methods every implementation class has to provide in order to grant access to the FieladInfoStructures contained within a Java class represented by the the Dna instance this FieldsTable belongs to.

Author:
Francesco Russo

Method Summary
 void addAll(FieldsTable ft)
          Appends the given FieldsTable to the current one.
 void addElement(FieldInfoStructure entry)
          Adds the specified FieldInfoStructure at the end of the table.
 void addElementAt(FieldInfoStructure entry, int index, boolean overwrite)
          Adds the specified FieldInfoStructure at the provided position, shifting of one index any subsequente entry (if exists) iff the overwrite parameter is set to false, otherwise the current entry at index index will be overwritten.
 java.lang.Object clone()
          Clone the current FieldsTable instance.
 void fromStream(java.io.DataInputStream dis, Dna dna, int fieldsCount)
          Reads the table from the given stream.
 FieldInfoStructure get(int index)
          Get a reference to the entry stored at the provided index.
 Dna getDna()
          Get the Dna container
 int getIndexOf(FieldInfoStructure entry)
          Return the index of the provided entry, if exists.
 int remove(FieldInfoStructure entry, boolean compact)
          Removes the specified entry, if exists, resizing the table if compact is true, otherwise the removed entry has to be replaced by null
 FieldInfoStructure remove(int index, boolean compact)
          Removes the entry at the specified index, if exists, resizing the table if compact is true, otherwise the removed entry has to be replaced by null
 void setDna(Dna dna)
          Set the Dna container
 int size()
          Returns the number of entries stored by the table
 void toStream(java.io.DataOutputStream dos)
          Writes the table to the given output stream.
 void validate()
          This method performs the validation over all the FieldsTable entries.
 

Method Detail

addElement

void addElement(FieldInfoStructure entry)
Adds the specified FieldInfoStructure at the end of the table.

Parameters:
entry - The entry to be added

addElementAt

void addElementAt(FieldInfoStructure entry,
                  int index,
                  boolean overwrite)
                  throws java.lang.IndexOutOfBoundsException,
                         java.lang.UnsupportedOperationException
Adds the specified FieldInfoStructure at the provided position, shifting of one index any subsequente entry (if exists) iff the overwrite parameter is set to false, otherwise the current entry at index index will be overwritten.

Parameters:
entry - The entry to be added
index - The position at which the entry should be placed
overwrite - Should any existing entry be overwritten?
Throws:
java.lang.IndexOutOfBoundsException - Trying to access to an invalid index
java.lang.UnsupportedOperationException - The method is not supported by the current implementation

get

FieldInfoStructure get(int index)
                       throws java.lang.IndexOutOfBoundsException
Get a reference to the entry stored at the provided index.

Parameters:
index - The index to access to
Returns:
FieldInfoStructure The entry located at the provided index, if any
Throws:
java.lang.IndexOutOfBoundsException - Tying to acces to an invalid index

getIndexOf

int getIndexOf(FieldInfoStructure entry)
               throws FieldInfoStructureNotFoundException,
                      java.lang.UnsupportedOperationException
Return the index of the provided entry, if exists.

Parameters:
entry - The entry whose index has to be returned
Returns:
int The index of the provided entry
Throws:
FieldInfoStructureNotFoundException - The provided entry is not stored within the current table
java.lang.UnsupportedOperationException - The method is not supported by the current implementation

remove

FieldInfoStructure remove(int index,
                          boolean compact)
                          throws java.lang.IndexOutOfBoundsException,
                                 java.lang.UnsupportedOperationException
Removes the entry at the specified index, if exists, resizing the table if compact is true, otherwise the removed entry has to be replaced by null

Parameters:
index - The index of the entry we want to remove
compact - Has the table to be resized?
Returns:
FieldInfoStructure The removed entry
Throws:
java.lang.IndexOutOfBoundsException - Tying to acces to an invalid index
java.lang.UnsupportedOperationException - The method is not supported by the current implementation

remove

int remove(FieldInfoStructure entry,
           boolean compact)
           throws FieldInfoStructureNotFoundException,
                  java.lang.UnsupportedOperationException
Removes the specified entry, if exists, resizing the table if compact is true, otherwise the removed entry has to be replaced by null

Parameters:
entry - The entry to be removede.
compact - Tells whether the table should be compacted or not.
Returns:
int The index of the removed entry
Throws:
FieldInfoStructureNotFoundException - The provided entry is not stored within the current table
java.lang.UnsupportedOperationException - The method is not supported by the current implementation

size

int size()
Returns the number of entries stored by the table

Returns:
int The number of entries

addAll

void addAll(FieldsTable ft)
Appends the given FieldsTable to the current one.

Parameters:
ft - The whole FieldsTable to be added to the current one.

clone

java.lang.Object clone()
                       throws java.lang.CloneNotSupportedException
Clone the current FieldsTable instance.

Returns:
Object The clone
Throws:
java.lang.CloneNotSupportedException

fromStream

void fromStream(java.io.DataInputStream dis,
                Dna dna,
                int fieldsCount)
                throws MissingDnaContainerException,
                       DnaDeserializationException
Reads the table from the given stream.

Parameters:
dis - The InputStream from which the FieldsTable has to be read
dna - The Dna this FieldsTable belongs to
fieldsCount - The number of expected fields
Throws:
DnaDeserializationException
MissingDnaContainerException - This exception is thrown iff no valid Dna instance has been set

toStream

void toStream(java.io.DataOutputStream dos)
              throws DnaSerializationException
Writes the table to the given output stream.

Parameters:
dos - The OutputStreamthe current FieldsTable should be written to.
Throws:
DnaSerializationException

setDna

void setDna(Dna dna)
Set the Dna container

Parameters:
dna - The Dna container.

getDna

Dna getDna()
Get the Dna container

Returns:
Dna The Dna container

validate

void validate()
              throws FieldInfoValidationException,
                     InfoStructureAttributeOutOfRangeException,
                     MissingDnaContainerException,
                     MissingCPTableException
This method performs the validation over all the FieldsTable entries.

Throws:
FieldInfoValidationException
InfoStructureAttributeOutOfRangeException
MissingDnaContainerException
MissingCPTableException