com.ibm.dtfj.analyzer.helpers
Class OneJavaClass

java.lang.Object
  extended by TranslatableAnalyzer
      extended by com.ibm.dtfj.analyzer.base.SimpleAnalyzerBean
          extended by com.ibm.dtfj.analyzer.helpers.OneJavaClass
All Implemented Interfaces:
IAnalyzerBase, IReport, IWrapper

public class OneJavaClass
extends SimpleAnalyzerBean

Print and extract basic information about one DTFJ JavaClass object
List all the fields, list all the object references, lookup a given field
Determine other attributes of the class (e.g. isPrimitive(), getTypeSignature(), etc.).


Constructor Summary
OneJavaClass()
          Null constructor for use as JavaBean
 
Method Summary
 java.util.Iterator getAllVisibleFields()
           
 int getCachingPriority()
          Return an indication of how desirable it is for the AnalyzerContext to cache instances of this analyzer, so that multiple calls to loadAnalyzer() will return the cached instance instead of allocating and initializing a new one each time.
 long getChecksum()
          Generate a checksum of this class, to help distinguish between different implementations of the same class loaded in the same image
 com.ibm.dtfj.java.JavaObject[] getConstantPoolReferences(boolean includeSuperclasses)
          Find all the constant pools references from this JavaClass.
static OneJavaClass getInstance(IAnalyzerContext context, com.ibm.dtfj.java.JavaClass parent)
          Find the OneJavaClass bean instance associated with a given parent JavaClass (create it if necessary)
 com.ibm.dtfj.java.JavaField getJavaField(java.lang.String name, boolean includeSuperclasses)
          Find the JavaField object associated with a given field name for this class
 java.util.Iterator getLocalFields()
           
 ValueWrapper getStaticFieldValue(java.lang.String name, boolean includeSuperclasses)
          Return the value of a given static field in this class, as an arbitrary Object type encapsulated in a ValueWrapper.
 com.ibm.dtfj.java.JavaObject[] getStaticReferences(boolean includeSuperclasses)
          Find all the static references from this JavaClass.
 java.lang.String getTypeSignature()
          Get the canonical type signature for this JavaClass.
static java.lang.String getTypeSignature(com.ibm.dtfj.java.JavaClass cls)
          Get the canonical type signature of a given JavaClass.
 boolean isClass()
          Check if this JavaClass represents the java.lang.Class object type.
static boolean isClass(com.ibm.dtfj.java.JavaClass cls)
          Check if a given JavaClass represents the java.lang.Class object type.
 boolean isPrimitive()
          Check if this JavaClass represents a primitive type.
static boolean isPrimitive(com.ibm.dtfj.java.JavaClass cls)
          Check if a given JavaClass represents a primitive type.
 void printOneFieldInfo(IAnalysisReport out, com.ibm.dtfj.java.JavaField f)
          Print a summary of the information about a field (signature + modifiers)
 void printStaticFields(IAnalysisReport out)
          Print all the static fields defined in this JavaClass and their value, as a segment of a report
 IAnalysisReport produceReport()
          Generate a report which will be encapsulated in the IAnalysisReport object for later use by some formatter.
 void setParent(java.lang.Object parent)
          Set the parent JavaClass underlying this analyzer bean.
 
Methods inherited from class com.ibm.dtfj.analyzer.base.SimpleAnalyzerBean
allocateReport, allocateReportOptions, allocateSecondaryReport, getCategories, getContext, getIdentityString, getInstance, getLogger, getLongDescription, getName, getNextValidObject, getParent, getReportExtensionHelper, getResourceBundleName, getShortDescription, getVersion, isPrimaryAnalyzer, printEmbeddedReport, printEmbeddedReport, printEmbeddedReportWithOptions, printEmbeddedReportWithOptions, printReportInfoHeader, recordInternalExceptionStatic, setContext
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

OneJavaClass

public OneJavaClass()
Null constructor for use as JavaBean

Method Detail

getInstance

public static OneJavaClass getInstance(IAnalyzerContext context,
                                       com.ibm.dtfj.java.JavaClass parent)
Find the OneJavaClass bean instance associated with a given parent JavaClass (create it if necessary)

Parameters:
context - the AnalyzerContext in which to locate this bean instance
parent - the parent JavaClass underlying this analyzer bean
Returns:
the desired OneJavaClass analyzer bean

setParent

public void setParent(java.lang.Object parent)
Set the parent JavaClass underlying this analyzer bean.

Specified by:
setParent in interface IWrapper
Overrides:
setParent in class SimpleAnalyzerBean
Parameters:
parent - The parent object to set. Must be of type JavaClass. compatible with the type of analyzer bean that receives it
See Also:
IWrapper.setParent(java.lang.Object)

getCachingPriority

public int getCachingPriority()
Description copied from interface: IAnalyzerBase
Return an indication of how desirable it is for the AnalyzerContext to cache instances of this analyzer, so that multiple calls to loadAnalyzer() will return the cached instance instead of allocating and initializing a new one each time. The caching priority is represented as a number between 0 and 10, where 0 means never cache instances of this analyzer, 10 means always cache all instances, and any number in-between indicates that we should try to cache it as long as there is enough memory available and that we give precedence to higher-priority analyzers when memory is scarce.

Specified by:
getCachingPriority in interface IAnalyzerBase
Overrides:
getCachingPriority in class SimpleAnalyzerBean
Returns:
the caching priority, as a number between 0 and 10
See Also:
This method returns a high value, to encourage caching of this type of analyzer.

isPrimitive

public static boolean isPrimitive(com.ibm.dtfj.java.JavaClass cls)
Check if a given JavaClass represents a primitive type. Static method to avoid the overhead of allocating an object.

Parameters:
cls - the JavaClass instance to check
Returns:
true if this represents a primitive type, false otherwise

isPrimitive

public boolean isPrimitive()
Check if this JavaClass represents a primitive type.

Returns:
true if this represents a primitive type, false otherwise

getTypeSignature

public static java.lang.String getTypeSignature(com.ibm.dtfj.java.JavaClass cls)
Get the canonical type signature of a given JavaClass. Static method to avoid the overhead of allocating an object.

Parameters:
cls - the JavaClass instance for which we want the type signatur
Returns:
the type signature, as a string

getTypeSignature

public java.lang.String getTypeSignature()
Get the canonical type signature for this JavaClass.

Returns:
the type signature, as a string

isClass

public static boolean isClass(com.ibm.dtfj.java.JavaClass cls)
Check if a given JavaClass represents the java.lang.Class object type. Static method to avoid the overhead of allocating an object.

Parameters:
cls - the JavaClass instance to check
Returns:
true if cls represents java.lang.Class, false otherwise

isClass

public boolean isClass()
Check if this JavaClass represents the java.lang.Class object type.

Returns:
true if cls represents java.lang.Class, false otherwise

getJavaField

public com.ibm.dtfj.java.JavaField getJavaField(java.lang.String name,
                                                boolean includeSuperclasses)
                                         throws com.ibm.dtfj.image.DTFJException
Find the JavaField object associated with a given field name for this class

Parameters:
name - the field name that we are looking for
includeSuperclasses - if true look for fields in this class and all its superclasses; if false, only look for fields declared in this class itself.
Returns:
the desired JavaField object
Throws:
com.ibm.dtfj.image.DTFJException - if the field is not found

getStaticFieldValue

public ValueWrapper getStaticFieldValue(java.lang.String name,
                                        boolean includeSuperclasses)
                                 throws com.ibm.dtfj.image.DTFJException
Return the value of a given static field in this class, as an arbitrary Object type encapsulated in a ValueWrapper.

Parameters:
name - the field name that we are looking for
includeSuperclasses - if true look for fields in this class and all its superclasses; if false, only look for fields declared in this class itself.
Returns:
the value of the field, as a ValueWrapper
Throws:
com.ibm.dtfj.image.DTFJException - if the field is not found

getStaticReferences

public com.ibm.dtfj.java.JavaObject[] getStaticReferences(boolean includeSuperclasses)
                                                   throws com.ibm.dtfj.image.DTFJException
Find all the static references from this JavaClass.

Parameters:
includeSuperclasses - if true look for fields in this class and all its superclasses; if false, only look for fields declared in this class itself.
Returns:
an array of JavaObjects, representing all the desired object references
Throws:
com.ibm.dtfj.image.DTFJException

getConstantPoolReferences

public com.ibm.dtfj.java.JavaObject[] getConstantPoolReferences(boolean includeSuperclasses)
                                                         throws com.ibm.dtfj.image.DTFJException
Find all the constant pools references from this JavaClass.

Parameters:
includeSuperclasses - if true look for fields in this class and all its superclasses; if false, only look for fields declared in this class itself.
Returns:
an array of JavaObjects, representing all the desired object references
Throws:
com.ibm.dtfj.image.DTFJException

getAllVisibleFields

public java.util.Iterator getAllVisibleFields()
                                       throws com.ibm.dtfj.image.DTFJException
Returns:
an iterator of JavaField objects that represent all the visible fields within this class, including all fields from superclasses that are not masked by a subclass
Throws:
com.ibm.dtfj.image.DTFJException

getLocalFields

public java.util.Iterator getLocalFields()
                                  throws com.ibm.dtfj.image.DTFJException
Returns:
an iterator of JavaField objects that represent all the local fields within this class, not including any fields from superclasses.
Throws:
com.ibm.dtfj.image.DTFJException

produceReport

public IAnalysisReport produceReport()
Description copied from interface: IReport
Generate a report which will be encapsulated in the IAnalysisReport object for later use by some formatter.

Specified by:
produceReport in interface IReport
Overrides:
produceReport in class SimpleAnalyzerBean
Returns:
- the generic report object which will be given to some formatter
See Also:
IReport.produceReport()

printStaticFields

public void printStaticFields(IAnalysisReport out)
Print all the static fields defined in this JavaClass and their value, as a segment of a report

Parameters:
out - a AnalysisReport object to which to write the output

printOneFieldInfo

public void printOneFieldInfo(IAnalysisReport out,
                              com.ibm.dtfj.java.JavaField f)
Print a summary of the information about a field (signature + modifiers)

Parameters:
out - a AnalysisReport object to which to write the output
f - the JavaField for which we want information

getChecksum

public long getChecksum()
                 throws com.ibm.dtfj.image.DTFJException
Generate a checksum of this class, to help distinguish between different implementations of the same class loaded in the same image

Returns:
the checksum, as a CRC32
Throws:
com.ibm.dtfj.image.DTFJException


© Copyright IBM Corp. 2007, 2008 All Rights Reserved. US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.