jef.dna.infoStructures.impl
Class InfoStructureAncestor

java.lang.Object
  extended by jef.dna.infoStructures.impl.InfoStructureAncestor
All Implemented Interfaces:
java.lang.Cloneable, InfoStructure
Direct Known Subclasses:
FieldInfo, MethodInfo

public abstract class InfoStructureAncestor
extends java.lang.Object
implements InfoStructure

This is the ancestor class of both the FieldInfo and the MethodInfo implementation classes.

About cloning instances extending the InfoStructureAncestor abstract class:
the clone() method will return a new instance whose reference to the containing Dna instance is set to null. It is up to you appropriately setting it to the correct value.

Author:
Francesco Russo (frusso@dev.java.net)

Field Summary
protected  int accessFlags
           
protected  AttribFactory attribFactory
           
protected  int attributeCount
           
protected  java.util.List<Attribute> attributes
           
protected  int descriptorIndex
           
protected  Dna dna
           
protected  int nameIndex
           
 
Constructor Summary
InfoStructureAncestor()
          Creates a new instance of InfoStructureAncestor
 
Method Summary
 java.lang.Object clone()
          The clone() method will return a new instance whose reference to the containing Dna is not modified.
abstract  void fromStream(java.io.DataInputStream dis, Dna dna)
          Initialize the current InfoStructure from the provided stream.
 int getAccessFlags()
          Get the method's access flags defining which access modifiers are applied to the current method.
 int getAttributeCount()
          Get the number of the additional attributes of the current method.
 java.util.List<Attribute> getAttributes()
          Instances contained within the input List have to be valid implementations of the interfaces defined in the package dna.attributes.
 int getDescriptorIndex()
          Set a valid index pointing to a constant pool table's entry of type ConstantUtf8 representing the description of the current method.
 Dna getDna()
          Get a reference to the Dna instance this infoStructure entity belongs to.
 int getNameIndex()
          Set a valid index pointing to a constant pool table's entry of type ConstantUtf8.
 void setAccessFlags(int accessFlags)
          Set the method's access flags defining which access modifiers are applied to the current method
 void setAttributeCount(int count)
          Set the number of the additional attributes of the current method.
 void setAttributes(java.util.List<Attribute> attributes)
          Instances contained within the input List have to be valid implementations of the interfaces defined in the package dna.attributes.
 void setDescriptorIndex(int index)
          Set a valid index pointing to a constant pool table's entry of type ConstantUtf8 representing the description of the current method.
 void setDna(Dna dna)
          Set a reference to the Dna instance this infoStructure entity belongs to.
 void setNameIndex(int nameIndex)
          Set a valid index pointing to constant pool table's entry of type ConstantUtf8.
abstract  void toStream(java.io.DataOutputStream dos)
          Serialize the InfoStructure to a stream.
 void updateRefs(int offset)
          This method reorganizes all the references to constant pool table entries
 boolean validate()
          This method has to perform a validation process over the FieldInfo according to what specified by the JVM Official Specification.
protected abstract  void validateAccessFlags(ConstantPoolTable cpt)
           
protected  void validateAttributeCount(ConstantPoolTable cpt)
           
protected  void validateAttributes(ConstantPoolTable cpt)
           
protected  void validateDescriptorIndex(ConstantPoolTable cpt)
           
protected  void validateNameIndex(ConstantPoolTable cpt)
           
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

accessFlags

protected int accessFlags

nameIndex

protected int nameIndex

descriptorIndex

protected int descriptorIndex

attributeCount

protected int attributeCount

attributes

protected java.util.List<Attribute> attributes

dna

protected Dna dna

attribFactory

protected AttribFactory attribFactory
Constructor Detail

InfoStructureAncestor

public InfoStructureAncestor()
Creates a new instance of InfoStructureAncestor

Method Detail

setAccessFlags

public void setAccessFlags(int accessFlags)
Description copied from interface: InfoStructure
Set the method's access flags defining which access modifiers are applied to the current method

Specified by:
setAccessFlags in interface InfoStructure
Parameters:
accessFlags - The mask of flags as defined by the Java VM Specification section 4.6

getAccessFlags

public int getAccessFlags()
Description copied from interface: InfoStructure
Get the method's access flags defining which access modifiers are applied to the current method.

Specified by:
getAccessFlags in interface InfoStructure
Returns:
int The mask of flags as defined by the Java VM Specification section 4.6

setNameIndex

public void setNameIndex(int nameIndex)
Description copied from interface: InfoStructure
Set a valid index pointing to constant pool table's entry of type ConstantUtf8. This entry has to represent either one of the special method names , or a valid method name in the Java progr. language.

Specified by:
setNameIndex in interface InfoStructure
Parameters:
nameIndex - The index pointin to a constant pool table entry

getNameIndex

public int getNameIndex()
Description copied from interface: InfoStructure
Set a valid index pointing to a constant pool table's entry of type ConstantUtf8. This entry has to represent either one of the special method names , or a valid method name in the Java progr. language.

Specified by:
getNameIndex in interface InfoStructure
Returns:
int The index pointin to a constant pool table entry

setDescriptorIndex

public void setDescriptorIndex(int index)
Description copied from interface: InfoStructure
Set a valid index pointing to a constant pool table's entry of type ConstantUtf8 representing the description of the current method.

Specified by:
setDescriptorIndex in interface InfoStructure
Parameters:
index - A valid index as described above

getDescriptorIndex

public int getDescriptorIndex()
Description copied from interface: InfoStructure
Set a valid index pointing to a constant pool table's entry of type ConstantUtf8 representing the description of the current method.

Specified by:
getDescriptorIndex in interface InfoStructure
Returns:
int A valid index as described above

setAttributeCount

public void setAttributeCount(int count)
Description copied from interface: InfoStructure
Set the number of the additional attributes of the current method.

Specified by:
setAttributeCount in interface InfoStructure
Parameters:
count - The number of this method's attributes

getAttributeCount

public int getAttributeCount()
Description copied from interface: InfoStructure
Get the number of the additional attributes of the current method.

Specified by:
getAttributeCount in interface InfoStructure
Returns:
int The number of this method's attributes

setAttributes

public void setAttributes(java.util.List<Attribute> attributes)
Description copied from interface: InfoStructure
Instances contained within the input List have to be valid implementations of the interfaces defined in the package dna.attributes.

Specified by:
setAttributes in interface InfoStructure
Parameters:
attributes - The attributes associated with the current method

getAttributes

public java.util.List<Attribute> getAttributes()
Description copied from interface: InfoStructure
Instances contained within the input List have to be valid implementations of the interfaces defined in the package dna.attributes.

Specified by:
getAttributes in interface InfoStructure
Returns:
List The attributes associated with the current method

setDna

public void setDna(Dna dna)
Description copied from interface: InfoStructure
Set a reference to the Dna instance this infoStructure entity belongs to.

Specified by:
setDna in interface InfoStructure

getDna

public Dna getDna()
Description copied from interface: InfoStructure
Get a reference to the Dna instance this infoStructure entity belongs to.

Specified by:
getDna in interface InfoStructure
Returns:
Dna The Dna "container"

updateRefs

public void updateRefs(int offset)
Description copied from interface: InfoStructure
This method reorganizes all the references to constant pool table entries

Specified by:
updateRefs in interface InfoStructure
Parameters:
offset - offset

fromStream

public abstract void fromStream(java.io.DataInputStream dis,
                                Dna dna)
                         throws DnaDeserializationException,
                                MissingDnaContainerException
Description copied from interface: InfoStructure
Initialize the current InfoStructure from the provided stream. The provided Dna instance, if not null, will replace the one set by a formerly invoked setDna() method. Otherwise, should the both the provided Dna instance and the one set by the setDna method be null, this method will throw a MissingDnaContainerException.

Specified by:
fromStream in interface InfoStructure
Parameters:
dis - The input stream the InfoStructure should be read from
dna - The Dna instance which will contain this InfoStructure instance
Throws:
DnaDeserializationException
MissingDnaContainerException

toStream

public abstract void toStream(java.io.DataOutputStream dos)
                       throws DnaSerializationException
Description copied from interface: InfoStructure
Serialize the InfoStructure to a stream.

Specified by:
toStream in interface InfoStructure
Parameters:
dos - The output stream to write to
Throws:
DnaSerializationException

validate

public boolean validate()
                 throws FieldInfoValidationException,
                        InfoStructureAttributeOutOfRangeException,
                        MissingDnaContainerException,
                        MissingCPTableException
This method has to perform a validation process over the FieldInfo according to what specified by the JVM Official Specification.

Specified by:
validate in interface InfoStructure
Returns:
boolean true iff the validation is successful, false otherwise
Throws:
ValidationExceptionAncestor - Something failed with the validation process; further information are stored within the raised exception. This exception might be a FieldInfo|MethodInfo|AttributeInfoValidationException
MissingDnaContainerException - The validation process cannot be accomplished since any of the examined entities is missing its own Dna container
MissingCPTableException - The validation process cannot be accomplished since there is no reference to the ConstantPoolTable in the current Dna instance
FieldInfoValidationException - Something failed with the validation process; further information are stored within the raised exception. This exception might be a FieldInfo|MethodInfo|AttributeInfoValidationException
InfoStructureAttributeOutOfRangeException - The InfoStructure contains some attribute pointing to an invalid index of the Constant Pool Table

validateAccessFlags

protected abstract void validateAccessFlags(ConstantPoolTable cpt)
                                     throws FieldInfoValidationException,
                                            InfoStructureAttributeOutOfRangeException
Throws:
FieldInfoValidationException
InfoStructureAttributeOutOfRangeException

validateNameIndex

protected void validateNameIndex(ConstantPoolTable cpt)
                          throws FieldInfoValidationException,
                                 InfoStructureAttributeOutOfRangeException
Throws:
FieldInfoValidationException
InfoStructureAttributeOutOfRangeException

validateDescriptorIndex

protected void validateDescriptorIndex(ConstantPoolTable cpt)
                                throws FieldInfoValidationException,
                                       InfoStructureAttributeOutOfRangeException
Throws:
FieldInfoValidationException
InfoStructureAttributeOutOfRangeException

validateAttributeCount

protected void validateAttributeCount(ConstantPoolTable cpt)
                               throws FieldInfoValidationException
Throws:
FieldInfoValidationException

validateAttributes

protected void validateAttributes(ConstantPoolTable cpt)
                           throws FieldInfoValidationException,
                                  MissingDnaContainerException,
                                  MissingCPTableException
Throws:
FieldInfoValidationException
MissingDnaContainerException
MissingCPTableException

clone

public java.lang.Object clone()
                       throws java.lang.CloneNotSupportedException
The clone() method will return a new instance whose reference to the containing Dna is not modified.

Specified by:
clone in interface InfoStructure
Overrides:
clone in class java.lang.Object
Throws:
java.lang.CloneNotSupportedException