jef.dna.attributes.impl
Class ExceptionTableEntry

java.lang.Object
  extended by jef.dna.attributes.impl.ExceptionTableEntry
All Implemented Interfaces:
java.lang.Cloneable, ExceptionTableEntry, BytesCountable

@ContainedInCodeAttribute(containerPropertyName="attributeContainer")
public class ExceptionTableEntry
extends java.lang.Object
implements ExceptionTableEntry

Class representing an ExceptionTable generic entry. These entries describe the exception handlers behaviour in the code array of a Code attribute. An entry is made up of four elements: start_pc, end_pc, handler_pc, catch_type. These entries are stored within a Code attribute ExceptionTable.

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

Field Summary
protected static Logger logger
           
 
Constructor Summary
ExceptionTableEntry()
          Constructor.
 
Method Summary
 java.lang.Object clone()
          The clone() method will return a new instance whose reference to the containing CodeAttribute is not modified.
 void fromStream(java.io.DataInputStream dis)
          Reads the entry from the given inputstream.
 CodeAttribute getAttributeContainer()
          Get the reference to the CodeAttribute this ExceptionTableEntry is held by.
 int getBytesCount()
          This method must return the overall number of bytes required by the component implementing this interface.
 int getCatchType()
          If the value of type is non zero, it must refer to an entry of the constant pool table of type ConstantClass (ConstantClassInfo).
 int getEndPc()
          Gets the index at which the exception handler becomes inactive.
 int getHandlerPc()
          Gets the start of the exception handler.
 int getStartPc()
          Gets the index at which the exception handler begins being active.
 void setAttributeContainer(CodeAttribute attribute)
          Set the reference to the CodeAttribute this ExceptionTableEntry is held by.
 void setCatchType(int type)
          If the value of type is non zero, it must refer to an entry of the constant pool table of type ConstantClass (ConstantClassInfo).
 void setEndPc(int end)
          Sets the index at which the exception handler becomes inactive.
 void setHandlerPc(int handler)
          Sets the start of the exception handler.
 void setStartPc(int start)
          Sets the index at which the exception handler begins being active.
 void toStream(java.io.DataOutputStream dos)
          Writes this entry to the given output stream.
 void updateRefs(int offset)
          Updates all the reference to the constant pool table
 boolean validate()
          This method has to perform a validation process over the ExceptionTableEntry according to what specified by the JVM Official Specification.
 
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

ExceptionTableEntry

public ExceptionTableEntry()
Constructor. It requires no parameters since all the attributes are populated calling the fromStream method. Appropriate getters and setters are provided as well.

Method Detail

setStartPc

public void setStartPc(int start)
Sets the index at which the exception handler begins being active. This value has to be a valid index into the code array of Code attribute instance.

Specified by:
setStartPc in interface ExceptionTableEntry
Parameters:
start - The index at which the exc. handler becomes active

getStartPc

public int getStartPc()
Gets the index at which the exception handler begins being active. This value has to be a valid index into the code array of Code attribute instance.

Specified by:
getStartPc in interface ExceptionTableEntry
Returns:
int The index at which the exc. handler becomes active

setEndPc

public void setEndPc(int end)
Sets the index at which the exception handler becomes inactive. This value has to be a valid index into the code array of Code attribute instance.

Specified by:
setEndPc in interface ExceptionTableEntry
Parameters:
end - The index at which the exc. handler gets deactivated

getEndPc

public int getEndPc()
Gets the index at which the exception handler becomes inactive. This value has to be a valid index into the code array of Code attribute instance.

Specified by:
getEndPc in interface ExceptionTableEntry
Returns:
int The index at which the exc. handler gets deactivated

setHandlerPc

public void setHandlerPc(int handler)
Sets the start of the exception handler. This value has to be a valid index into the code array of Code attribute instance.

Specified by:
setHandlerPc in interface ExceptionTableEntry
Parameters:
handler - The start of the exception handler

getHandlerPc

public int getHandlerPc()
Gets the start of the exception handler. This value has to be a valid index into the code array of Code attribute instance.

Specified by:
getHandlerPc in interface ExceptionTableEntry
Returns:
int The start of the exception handler

setCatchType

public void setCatchType(int type)
If the value of type is non zero, it must refer to an entry of the constant pool table of type ConstantClass (ConstantClassInfo).

Specified by:
setCatchType in interface ExceptionTableEntry
Parameters:
type - Valid index into the constant pool table

getCatchType

public int getCatchType()
If the value of type is non zero, it must refer to an entry of the constant pool table of type ConstantClass (ConstantClassInfo).

Specified by:
getCatchType in interface ExceptionTableEntry
Returns:
int Valid index into the constant pool table

setAttributeContainer

public void setAttributeContainer(CodeAttribute attribute)
Description copied from interface: ExceptionTableEntry
Set the reference to the CodeAttribute this ExceptionTableEntry is held by.

Specified by:
setAttributeContainer in interface ExceptionTableEntry
Parameters:
attribute - The CodeAttribute container

getAttributeContainer

public CodeAttribute getAttributeContainer()
Description copied from interface: ExceptionTableEntry
Get the reference to the CodeAttribute this ExceptionTableEntry is held by.

Specified by:
getAttributeContainer in interface ExceptionTableEntry
Returns:
CodeAttribute The CodeAttribute container

toStream

public void toStream(java.io.DataOutputStream dos)
              throws java.io.IOException
Writes this entry to the given output stream.

Specified by:
toStream in interface ExceptionTableEntry
Parameters:
dos - Output stream to write the entry to
Throws:
java.io.IOException - Thrown should something go wrong with the provided output stream

fromStream

public void fromStream(java.io.DataInputStream dis)
                throws java.io.IOException
Reads the entry from the given inputstream.

Specified by:
fromStream in interface ExceptionTableEntry
Parameters:
dis - Input stream to read the entry from
Throws:
java.io.IOException - Thrown should something go wrong with the provided input stream

updateRefs

public void updateRefs(int offset)
Updates all the reference to the constant pool table

Specified by:
updateRefs in interface ExceptionTableEntry
Parameters:
offset - The offset to be applied

validate

public boolean validate()
                 throws ExceptionTableEntryValidationException,
                        MissingDnaContainerException,
                        MissingAttributeContainerException,
                        MissingCPTableException
Description copied from interface: ExceptionTableEntry
This method has to perform a validation process over the ExceptionTableEntry according to what specified by the JVM Official Specification.

Specified by:
validate in interface ExceptionTableEntry
Returns:
boolean The validation outcome
Throws:
ExceptionTableEntryValidationException - The validation failed
MissingDnaContainerException - Is missing the reference to the Dna instance this ExceptionTableEntry belongs to
MissingAttributeContainerException - Is missing the reference to the Attribute this ExceptionTableEntry belongs to
MissingCPTableException - Cannot access the constant pool table

clone

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

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

getBytesCount

public int getBytesCount()
Description copied from interface: BytesCountable
This method must return the overall number of bytes required by the component implementing this interface.

Specified by:
getBytesCount in interface BytesCountable