jef.dna.methodsTable.impl.def
Class MTable

java.lang.Object
  extended by jef.dna.methodsTable.impl.def.MTable
All Implemented Interfaces:
java.lang.Cloneable, MethodsTable

public class MTable
extends java.lang.Object
implements MethodsTable

This is the default implementation of the MethodsTable interface.

Author:
Francesco Russo

Field Summary
protected static Logger logger
           
 
Constructor Summary
MTable()
          Creates a new instance of MTable
 
Method Summary
 void addAll(MethodsTable mt)
          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) if 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 dim)
          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.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

protected static Logger logger
Constructor Detail

MTable

public MTable()
Creates a new instance of MTable

Method Detail

addAll

public void addAll(MethodsTable mt)
Appends the given MethodsTable to the current one.

Specified by:
addAll in interface MethodsTable
Parameters:
mt - The MethodsTable to be appended

addElement

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

Specified by:
addElement in interface MethodsTable
Parameters:
entry - The entry to be added

addElementAt

public 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) if the overwrite parameter is set to false, otherwise the current entry at index index will be overwritten.

Specified by:
addElementAt in interface MethodsTable
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

fromStream

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

Specified by:
fromStream in interface MethodsTable
Parameters:
dis - The stream for reading the table from
dna - The Dna container instance
dim - The number of expected methods
Throws:
MissingDnaContainerException - This exception is thrown iff no valid Dna instance has been set
DnaDeserializationException

get

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

Specified by:
get in interface MethodsTable
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

getDna

public Dna getDna()
Get the Dna container

Specified by:
getDna in interface MethodsTable
Returns:
Dna The Dna container

getIndexOf

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

Specified by:
getIndexOf in interface MethodsTable
Parameters:
entry - The entry whose index has to be returned
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

public 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

Specified by:
remove in interface MethodsTable
Parameters:
index - The index of the entry we want to remove
compact - Has the table to be resized?
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

public 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

Specified by:
remove in interface MethodsTable
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:
MethodInfoStructureNotFoundException - The provided entry is not stored within the current table
java.lang.UnsupportedOperationException - The method is not supported by the current implementation

setDna

public void setDna(Dna dna)
Set the Dna container

Specified by:
setDna in interface MethodsTable
Parameters:
dna - The Dna container

size

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

Specified by:
size in interface MethodsTable
Returns:
int The number of entries

toStream

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

Specified by:
toStream in interface MethodsTable
Parameters:
dos - The stream for writing the MethodsTable instance to
Throws:
DnaSerializationException

validate

public void validate()
              throws FieldInfoValidationException,
                     InfoStructureAttributeOutOfRangeException,
                     MissingDnaContainerException,
                     MissingCPTableException
Description copied from interface: MethodsTable
Perform the validation process over each MethodsTable entry.

Specified by:
validate in interface MethodsTable
Throws:
FieldInfoValidationException
InfoStructureAttributeOutOfRangeException
MissingDnaContainerException
MissingCPTableException

clone

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

Specified by:
clone in interface MethodsTable
Overrides:
clone in class java.lang.Object
Returns:
Object The clone
Throws:
java.lang.CloneNotSupportedException