jef.dna.attributesTable
Interface AttributesTable

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

public interface AttributesTable
extends java.lang.Cloneable

This interface defines the methods every attribute container class has to provide.

Author:
Francesco Russo

Method Summary
 void addAll(AttributesTable at)
          Appends the given AttributesTable to the current one.
 void addElement(Attribute entry)
          Adds the specified Attribute at the end of the table.
 void addElementAt(Attribute entry, int index, boolean overwrite)
          Adds the specified Attribute 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 AttributesTable instance.
 void fromStream(java.io.DataInputStream dis, Dna dna, int attributesCount)
          Reads the table from the given stream.
 Attribute get(int index)
          Get a reference to the entry stored at the provided index.
 Dna getDna()
          Get the Dna container
 int getIndexOf(Attribute entry)
          Return the index of the provided entry, if exists.
 int remove(Attribute 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
 Attribute 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()
          Validates all the AttributesTable entries.
 

Method Detail

addElement

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

Parameters:
entry - The entry to be added

addElementAt

void addElementAt(Attribute entry,
                  int index,
                  boolean overwrite)
                  throws java.lang.IndexOutOfBoundsException,
                         java.lang.UnsupportedOperationException
Adds the specified Attribute 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

Attribute 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:
Attribute The entry located at the provided index, if any
Throws:
java.lang.IndexOutOfBoundsException - Tying to acces to an invalid index

getIndexOf

int getIndexOf(Attribute entry)
               throws AttributeNotFoundException,
                      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:
AttributeNotFoundException - The provided entry is not stored within the current table
java.lang.UnsupportedOperationException - The method is not supported by the current implementation

remove

Attribute 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:
Attribute 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(Attribute entry,
           boolean compact)
           throws AttributeNotFoundException,
                  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 we want to remove
compact - Has the constant pool table to be resized?
Returns:
int The index of the removed entry
Throws:
AttributeNotFoundException - 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(AttributesTable at)
Appends the given AttributesTable to the current one.

Parameters:
at - The AttributesTable to be appended

clone

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

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

fromStream

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

Parameters:
dis - The stream for reading the table from
dna - The Dna container instance
attributesCount - The number of expected attributes
Throws:
MissingDnaContainerException - This exception is thrown iff no valid Dna instance has been set
DnaDeserializationException

toStream

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

Parameters:
dos - The stream for writing the AttributesTable instance 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 AttributeValidationException,
                     AttributeOutOfRangeException,
                     MissingDnaContainerException,
                     MissingCPTableException
Validates all the AttributesTable entries.

Throws:
AttributeValidationException
AttributeOutOfRangeException
MissingDnaContainerException
MissingCPTableException