jef.dna.methodsTable
Interface MethodsTable

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

public interface MethodsTable
extends java.lang.Cloneable

This interface defines the methods every MethodInfoStructure containerimplementation has to provide.

Author:
Francesco Russo

Method Summary
 void addAll(MethodsTable ft)
          Appends the given MethodsTable to the current one.
 void addElement(MethodInfoStructure entry)
          Adds the specified MethodInfoStructure at the end of the table.
 void addElementAt(MethodInfoStructure entry, int index, boolean overwrite)
          Adds the specified MethodInfoStructure 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 MethodsTable instance.
 void fromStream(java.io.DataInputStream dis, Dna dna, int methodsCount)
          Reads the table from the given stream.
 MethodInfoStructure get(int index)
          Get a reference to the entry stored at the provided index.
 Dna getDna()
          Get the Dna container
 int getIndexOf(MethodInfoStructure entry)
          Return the index of the provided entry, if exists.
 MethodInfoStructure 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
 int remove(MethodInfoStructure 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
 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()
          Perform the validation process over each MethodsTable entry.
 

Method Detail

addElement

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

Parameters:
entry - The new entry to be added

addElementAt

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

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

getIndexOf

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

Parameters:
entry - The entry whose index inside the MethodsTable we are interested in
Returns:
int The index of the provided entry
Throws:
MethodInfoStructureNotFoundException - The provided entry is not stored within the current table
java.lang.UnsupportedOperationException - The method is not supported by the current implementation

remove

MethodInfoStructure 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 - Tells whether the table should be compacted or not
Returns:
MethodInfoStructure 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(MethodInfoStructure entry,
           boolean compact)
           throws MethodInfoStructureNotFoundException,
                  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 - Tells whether the table should be compacted or not
Returns:
int The index of the removed entry
Throws:
MethodInfoStructureNotFoundException - 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(MethodsTable ft)
Appends the given MethodsTable to the current one.

Parameters:
ft -

clone

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

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

fromStream

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

Parameters:
dis - The stream the table should be read from
dna - The Dna instance this MethodsTable belogs to
methodsCount - The number of expected methods
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 OutputStream
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
Perform the validation process over each MethodsTable entry.

Throws:
FieldInfoValidationException
InfoStructureAttributeOutOfRangeException
MissingDnaContainerException
MissingCPTableException