jef.dna.attributes.impl
Class GenericAttribute

java.lang.Object
  extended by jef.dna.attributes.impl.GenericAttribute
All Implemented Interfaces:
java.lang.Cloneable, Attribute, BytesCountable
Direct Known Subclasses:
Code, ConstantValue, DeprecatedAttribute, EnclosingMethod, ExceptionAttr, InnerClasses, LineNumberTableAttribute, LocalVariableTableAttribute, Signature, SourceDebugExtension, SourceFileAttribute, SyntheticAttribute

public abstract class GenericAttribute
extends java.lang.Object
implements Attribute

Ancestor class for every Attribute class.

About cloning instances extending the GenericAttribute 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.


Field Summary
protected  AttribFactory attribFactory
           
protected  int attributeNameIndex
           
protected static java.lang.String className
           
protected  Dna dna
           
protected  InstructionFactory instrFactory
           
protected  int length
           
protected static Logger logger
           
 
Constructor Summary
GenericAttribute()
          Constructor.
 
Method Summary
 java.lang.Object clone()
          The clone() method will return a new instance whose reference to the containing Dna instance is not modified.
 Dna getDna()
          Get the Dna instance which will contain the current Attribute
 int getLength()
          Returns the length expressed in bytes of the attribute's payload.
 int getNameIndex()
          Returns the attribute's name index,
protected  void innerValidations(ConstantPoolTable cpt)
           
 void setDna(Dna dna)
          Set the Dna instance which will contain the current Attribute
 void setNameIndex(int index)
          Set a valid index into the constant pool table.
abstract  void updateRefs(int offset)
          This method updates all the references pointing to constant pool table's entries this attributes holds.
 boolean validate()
          This method has to perform a validation process over the Attribute according to what specified by the JVM Official Specification.
protected  void validateNameIndex(ConstantPoolTable cpt)
           
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface jef.dna.attributes.Attribute
fromStream, toStream
 
Methods inherited from interface jef.dna.util.BytesCountable
getBytesCount
 

Field Detail

dna

protected Dna dna

attributeNameIndex

protected int attributeNameIndex

length

protected int length

attribFactory

protected AttribFactory attribFactory

instrFactory

protected InstructionFactory instrFactory

className

protected static java.lang.String className

logger

protected static Logger logger
Constructor Detail

GenericAttribute

public GenericAttribute()
Constructor.

Method Detail

getNameIndex

public int getNameIndex()
Description copied from interface: Attribute
Returns the attribute's name index,

Specified by:
getNameIndex in interface Attribute
Returns:
int The index into the constant pool table at which the attribute's logical name can be found

setNameIndex

public void setNameIndex(int index)
Description copied from interface: Attribute
Set a valid index into the constant pool table. This index has to point to an entry of type ConstantUtf8 exposing as value, the literal representation of the current Attribute. I.e., should the attribute be a Code attribute, the constant pool table entry at the provided index would be of type ConstantUtf8, with the string Code as value.

Specified by:
setNameIndex in interface Attribute
Parameters:
index - A valid index in the constant pool table

getLength

public int getLength()
Description copied from interface: Attribute
Returns the length expressed in bytes of the attribute's payload.

Specified by:
getLength in interface Attribute
Returns:
int The length (in bytes) of the attribute's payload

setDna

public void setDna(Dna dna)
Set the Dna instance which will contain the current Attribute

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

getDna

public Dna getDna()
Get the Dna instance which will contain the current Attribute

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

updateRefs

public abstract void updateRefs(int offset)
Description copied from interface: Attribute
This method updates all the references pointing to constant pool table's entries this attributes holds.

Specified by:
updateRefs in interface Attribute
Parameters:
offset - The offset

validate

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

Specified by:
validate in interface Attribute
Returns:
boolean Exit status
Throws:
AttributeValidationException - Something failed with the validation process; further information are stored within the raised exception
AttributeOutOfRangeException - Something failed with the validation process; further information are stored within the raised exception
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

innerValidations

protected void innerValidations(ConstantPoolTable cpt)
                         throws AttributeValidationException,
                                AttributeOutOfRangeException,
                                MissingDnaContainerException,
                                MissingCPTableException
Throws:
AttributeValidationException
AttributeOutOfRangeException
MissingDnaContainerException
MissingCPTableException

validateNameIndex

protected void validateNameIndex(ConstantPoolTable cpt)
                          throws AttributeValidationException,
                                 AttributeOutOfRangeException
Throws:
AttributeValidationException
AttributeOutOfRangeException

clone

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

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