com.ibm.dtfj.analyzer.helpers.objectwrapper
Class ObjectWrapper

java.lang.Object
  extended by TranslatableAnalyzer
      extended by com.ibm.dtfj.analyzer.base.SimpleAnalyzerBean
          extended by com.ibm.dtfj.analyzer.helpers.ValueWrapper
              extended by com.ibm.dtfj.analyzer.helpers.objectwrapper.ObjectWrapper
All Implemented Interfaces:
IAnalyzerBase, IReport, IWrapper
Direct Known Subclasses:
CharArrayWrapper, CollectionWrapperBase, DateWrapper, LongTimestampWrapper, LookupObjectByAddress, MapWrapperBase, ObjectNavigator, StringWrapper

public class ObjectWrapper
extends ValueWrapper

Represent one object or primitive field value extracted from the dump, and allow navigation through the object tree starting at this object instance
Print the values of field of various objects in the tree, specified through an XPath like syntax.


Field Summary
static int MODE_ALL
          Options to print full info at the end of a startPrintGroup() / endPrintGroup()
static int MODE_DEFAULT
          Default options for the info at the end of a startPrintGroup() / endPrintGroup()
static int MODE_INCLUDE_HEADER
          Include a header for the "omitted fields" section
static int MODE_INCLUDE_SIGNATURE
          Include the signature of the field
static int MODE_NONE
          Place-holder option to indicate that no additional information should be generated at the end of a startPrintGroup() / endPrintGroup() block.
static int MODE_SHOW_INSTANCE_FINAL_FIELDS
          Include a printout at the end of a startPrintGroup() / endPrintGroup() block of all the non-final instance fields from the object represented by this ObjectWrapper that have not been otherwise printed or traversed by calls within that startPrintGroup() / endPrintGroup() block.
static int MODE_SHOW_INSTANCE_NONFINAL_FIELDS
          Include a printout at the end of a startPrintGroup() / endPrintGroup() block of all the non-final instance fields from the object represented by this ObjectWrapper that have not been otherwise printed or traversed by calls within that startPrintGroup() / endPrintGroup() block.
static int MODE_SHOW_STATIC_FINAL_FIELDS
          Include a printout at the end of a startPrintGroup() / endPrintGroup() block of all the final static fields from the object represented by this ObjectWrapper that have not been otherwise printed or traversed by calls within that startPrintGroup() / endPrintGroup() block.
static int MODE_SHOW_STATIC_NONFINAL_FIELDS
          Include a printout at the end of a startPrintGroup() / endPrintGroup() block of all the final static fields from the object represented by this ObjectWrapper that have not been otherwise printed or traversed by calls within that startPrintGroup() / endPrintGroup() block.
static int MODE_SPECIAL_FULL_REPORT
          Print a complete object report for this object.
 
Constructor Summary
ObjectWrapper()
           
 
Method Summary
 boolean checkMaskedField(java.lang.String fieldName)
          Check if a given field should be masked (because it contains a password)
 void endPrintGroup()
          Mark the end of a group of fields started with startPrintGroup(IAnalysisReport, String, Object, int, String).
 int getCachingPriority()
          Avoid caching ObjectWrapper objects (there are too many of them, and they are cheap to re-create)
static ObjectWrapper getInstance(IAnalyzerContext context, java.lang.Object parent)
          Create a ObjectWrapper bean instance associated with a given parent object.
 ObjectWrapper getValueAtPath(java.lang.String path)
          Return the object found at the end of a sequence of field references starting with the current object or static class, as an ObjectWrapper
 ObjectWrapper getValueAtPath(java.lang.String path, java.lang.String wrapperName)
          Return the object found at the end of a sequence of field references starting with the current object or static class, as an arbitrary wrapper type.
 java.lang.String getVersion()
          Get version information for this analyser.
 ObjectWrapper printCollectionEntriesAtPath(IAnalysisReport out, java.lang.String collectionLabel, java.lang.String entryLabel, java.lang.String path, java.lang.String collectionAnalyzerName)
          Print a list of all the entries inside a collection object found at the end of a sequence of field references, starting with the current object, using the default format for an ObjectWrapper.
 ObjectWrapper printCollectionEntriesAtPath(IAnalysisReport out, java.lang.String collectionLabel, java.lang.String entryLabel, java.lang.String path, java.lang.String collectionAnalyzerName, java.lang.String entryWrapperName)
          Print a list of all the entries inside a collection object found at the end of a sequence of field references, starting with the current object, using an arbitrary wrapper type to control the format.
 ObjectWrapper printCollectionMapEntryReportsAtPath(IAnalysisReport out, java.lang.String collectionLabel, java.lang.String entryLabel, java.lang.String path, java.lang.String collectionAnalyzerName, java.lang.String entryAnalyzerName)
          Print a report on each of the entries inside a map object found at the end of a sequence of field references, starting with the current object.
 ObjectWrapper printCollectionSizeAtPath(IAnalysisReport out, java.lang.String collectionLabel, java.lang.String path, java.lang.String collectionAnalyzerName)
          Print the size of a collection of entries represented by a collection object found at the end of a sequence of field references, starting with the current object.
 ObjectWrapper printCollectionValueReportsAtPath(IAnalysisReport out, java.lang.String collectionLabel, java.lang.String entryLabel, java.lang.String path, java.lang.String collectionAnalyzerName, java.lang.String entryAnalyzerName)
          Print a report on each of the entries inside a collection object found at the end of a sequence of field references, starting with the current object.
 ObjectWrapper printReportAtPath(IAnalysisReport out, java.lang.String label, java.lang.String path, java.lang.String wrapperName)
          Print a report on the object found at the end of a sequence of field references, starting with the current object.
 ObjectWrapper printValueAtPath(IAnalysisReport out, java.lang.String label, java.lang.String path)
          Print the object or value found at the end of a sequence of field references starting with the current object, using the default format for an ObjectWrapper.
 ObjectWrapper printValueAtPath(IAnalysisReport out, java.lang.String label, java.lang.String path, java.lang.String wrapperName)
          Print the object or value found at the end of a sequence of field references, starting with the current object, using an arbitrary wrapper type to control the format.
 IAnalysisReport produceReport()
          Generate a report which will be encapsulated in the IAnalysisReport object for later use by some formatter.
 void setMaskedFieldPattern(java.lang.String pattern)
          Set a non-default pattern for determining the names of fields that should be masked because they contain a password.
 IAnalysisReport startPrintGroup(IAnalysisReport out, java.lang.String label, java.lang.Object refKey, int mode, java.lang.String formatTag)
          Mark the start of a group of fields printed through a sequence calls to printValueAtPath(),etc.
 java.lang.String toString()
           
 
Methods inherited from class com.ibm.dtfj.analyzer.helpers.ValueWrapper
equals, getBooleanValue, getByteValue, getCharacterValue, getDoubleValue, getFloatValue, getIntegerValue, getJavaClassValue, getJavaObjectValue, getLongValue, getObjectWrapper, getObjectWrapper, getOneJavaClassValue, getOneJavaObjectValue, getRawValue, getShortValue, getStringValue, getTypeSignature, getValueWrapperInstance, hashCode, isBoolean, isByte, isCharacter, isDouble, isFloat, isInstanceOf, isInteger, isJavaClass, isJavaObject, isLong, isShort, isString, setParent
 
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, isPrimaryAnalyzer, printEmbeddedReport, printEmbeddedReport, printEmbeddedReportWithOptions, printEmbeddedReportWithOptions, printReportInfoHeader, recordInternalExceptionStatic, setContext
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

MODE_SHOW_INSTANCE_NONFINAL_FIELDS

public static final int MODE_SHOW_INSTANCE_NONFINAL_FIELDS
Include a printout at the end of a startPrintGroup() / endPrintGroup() block of all the non-final instance fields from the object represented by this ObjectWrapper that have not been otherwise printed or traversed by calls within that startPrintGroup() / endPrintGroup() block.

See Also:
Constant Field Values

MODE_SHOW_STATIC_NONFINAL_FIELDS

public static final int MODE_SHOW_STATIC_NONFINAL_FIELDS
Include a printout at the end of a startPrintGroup() / endPrintGroup() block of all the final static fields from the object represented by this ObjectWrapper that have not been otherwise printed or traversed by calls within that startPrintGroup() / endPrintGroup() block.

See Also:
Constant Field Values

MODE_SHOW_INSTANCE_FINAL_FIELDS

public static final int MODE_SHOW_INSTANCE_FINAL_FIELDS
Include a printout at the end of a startPrintGroup() / endPrintGroup() block of all the non-final instance fields from the object represented by this ObjectWrapper that have not been otherwise printed or traversed by calls within that startPrintGroup() / endPrintGroup() block.

See Also:
Constant Field Values

MODE_SHOW_STATIC_FINAL_FIELDS

public static final int MODE_SHOW_STATIC_FINAL_FIELDS
Include a printout at the end of a startPrintGroup() / endPrintGroup() block of all the final static fields from the object represented by this ObjectWrapper that have not been otherwise printed or traversed by calls within that startPrintGroup() / endPrintGroup() block.

See Also:
Constant Field Values

MODE_INCLUDE_SIGNATURE

public static final int MODE_INCLUDE_SIGNATURE
Include the signature of the field

See Also:
Constant Field Values

MODE_INCLUDE_HEADER

public static final int MODE_INCLUDE_HEADER
Include a header for the "omitted fields" section

See Also:
Constant Field Values

MODE_SPECIAL_FULL_REPORT

public static final int MODE_SPECIAL_FULL_REPORT
Print a complete object report for this object. WARNING: THIS MODE DOES NOT MASK PASSWORDS

See Also:
Constant Field Values

MODE_NONE

public static final int MODE_NONE
Place-holder option to indicate that no additional information should be generated at the end of a startPrintGroup() / endPrintGroup() block.

See Also:
Constant Field Values

MODE_DEFAULT

public static final int MODE_DEFAULT
Default options for the info at the end of a startPrintGroup() / endPrintGroup()

See Also:
Constant Field Values

MODE_ALL

public static final int MODE_ALL
Options to print full info at the end of a startPrintGroup() / endPrintGroup()

See Also:
Constant Field Values
Constructor Detail

ObjectWrapper

public ObjectWrapper()
Method Detail

getVersion

public java.lang.String getVersion()
Description copied from interface: IAnalyzerBase
Get version information for this analyser.

Specified by:
getVersion in interface IAnalyzerBase
Overrides:
getVersion in class ValueWrapper
Returns:
- a String containing the version information
See Also:
Override the default from SimpleAnalyzerBean ("EXPERIMENTAL"). The version number is typically not defined for small wrappers.

getInstance

public static ObjectWrapper getInstance(IAnalyzerContext context,
                                        java.lang.Object parent)
Create a ObjectWrapper bean instance associated with a given parent object.

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

getCachingPriority

public int getCachingPriority()
Avoid caching ObjectWrapper objects (there are too many of them, and they are cheap to re-create)

Specified by:
getCachingPriority in interface IAnalyzerBase
Overrides:
getCachingPriority in class ValueWrapper
Returns:
the caching priority, as a number between 0 and 10
See Also:
SimpleAnalyzerBean.getCachingPriority()

getValueAtPath

public ObjectWrapper getValueAtPath(java.lang.String path)
                             throws com.ibm.dtfj.image.DTFJException
Return the object found at the end of a sequence of field references starting with the current object or static class, as an ObjectWrapper

Parameters:
path - a path-like string that represents the sequence of field names, separated by "/"
Returns:
the value of the field, as a new ObjectWrapper, or null if any field along the path was null
Throws:
com.ibm.dtfj.image.DTFJException - if the field is not found

getValueAtPath

public ObjectWrapper getValueAtPath(java.lang.String path,
                                    java.lang.String wrapperName)
                             throws com.ibm.dtfj.image.DTFJException
Return the object found at the end of a sequence of field references starting with the current object or static class, as an arbitrary wrapper type.

Parameters:
path - a path-like string that represents the sequence of field names, separated by "/"
wrapperName - the name of an analyzer to use as a wrapper for the target value (must be a subclass of ObjectWrapper)
Returns:
the value of the field, as a new ObjectWrapper or a subclass as specified by wrapperName, or null if any field along the path was null
Throws:
com.ibm.dtfj.image.DTFJException - if the field is not found

printValueAtPath

public ObjectWrapper printValueAtPath(IAnalysisReport out,
                                      java.lang.String label,
                                      java.lang.String path)
Print the object or value found at the end of a sequence of field references starting with the current object, using the default format for an ObjectWrapper.

Parameters:
out - a AnalysisReport object to which to write the output
label - a name to use for this field in the report
path - a path-like string that represents the sequence of field names, separated by "/"
Returns:
an ObjectWrapper representing the value at the end of the path, or null if there was an error

printValueAtPath

public ObjectWrapper printValueAtPath(IAnalysisReport out,
                                      java.lang.String label,
                                      java.lang.String path,
                                      java.lang.String wrapperName)
Print the object or value found at the end of a sequence of field references, starting with the current object, using an arbitrary wrapper type to control the format.

Parameters:
out - a AnalysisReport object to which to write the output
label - a name to use for this field in the report
path - a path-like string that represents the sequence of field names, separated by "/"
wrapperName - the name of an analyzer to use as a wrapper for the target value (must be a subclass of ObjectWrapper)
Returns:
an ObjectWrapper representing the value at the end of the path, or null if there was an error or null if it could not be obtained

printReportAtPath

public ObjectWrapper printReportAtPath(IAnalysisReport out,
                                       java.lang.String label,
                                       java.lang.String path,
                                       java.lang.String wrapperName)
Print a report on the object found at the end of a sequence of field references, starting with the current object.

This method loads a specified analyzer and invokes its produceReport() method on the target object to generate a new report, which is then embedded in the main report.

Parameters:
out - a AnalysisReport object to which to write the output
label - a name to use as title for the report being generated
path - a path-like string that represents the sequence of field names, separated by "/"
wrapperName - the name of an analyzer that should generate the report to be printed (must be a subclass of ObjectWrapper)
Returns:
an ObjectWrapper representing the value at the end of the path, or null if there was an error

printCollectionEntriesAtPath

public ObjectWrapper printCollectionEntriesAtPath(IAnalysisReport out,
                                                  java.lang.String collectionLabel,
                                                  java.lang.String entryLabel,
                                                  java.lang.String path,
                                                  java.lang.String collectionAnalyzerName)
Print a list of all the entries inside a collection object found at the end of a sequence of field references, starting with the current object, using the default format for an ObjectWrapper.

This method loads a specified analyzer to analyze the target object and extract a list of entries from it. This analyzer is expected to implement the Collection interface to provide access to all the entries in the target object (e.g. HashMapWrapper, VectorWrapper, etc.)

Parameters:
out - a AnalysisReport object to which to write the output
collectionLabel - a name to use as title for list of entries
entryLabel - a name to use as title for individual entries in the list
path - a path-like string that represents the sequence of field names, separated by "/"
collectionAnalyzerName - the name of an analyzer to use to extract the list of entries from the target object
Returns:
an ObjectWrapper representing the collection, or null if there was an error

printCollectionEntriesAtPath

public ObjectWrapper printCollectionEntriesAtPath(IAnalysisReport out,
                                                  java.lang.String collectionLabel,
                                                  java.lang.String entryLabel,
                                                  java.lang.String path,
                                                  java.lang.String collectionAnalyzerName,
                                                  java.lang.String entryWrapperName)
Print a list of all the entries inside a collection object found at the end of a sequence of field references, starting with the current object, using an arbitrary wrapper type to control the format.

This method loads a specified analyzer to analyze the target object and extract a list of entries from it. This analyzer is expected to implement the Collection interface to provide access to all the entries in the target object (e.g. HashMapWrapper, VectorWrapper, etc.)

Parameters:
out - a AnalysisReport object to which to write the output
collectionLabel - a name to use as title for list of entries
entryLabel - a name to use as title for individual entries in the list
path - a path-like string that represents the sequence of field names, separated by "/"
collectionAnalyzerName - the name of an analyzer to use to extract the list of entries from the target object
entryWrapperName - the name of an analyzer to use as a wrapper for the target value (must be a subclass of ObjectWrapper)
Returns:
an ObjectWrapper representing the collection, or null if there was an error

printCollectionMapEntryReportsAtPath

public ObjectWrapper printCollectionMapEntryReportsAtPath(IAnalysisReport out,
                                                          java.lang.String collectionLabel,
                                                          java.lang.String entryLabel,
                                                          java.lang.String path,
                                                          java.lang.String collectionAnalyzerName,
                                                          java.lang.String entryAnalyzerName)
Print a report on each of the entries inside a map object found at the end of a sequence of field references, starting with the current object.

This method first loads a specified analyzer to analyze the target object and extract a list of entries from it. It then loads a second analyzer for each entry and invokes its produceReport() method. That second analyzer gets passed a Map.Entry for each entry in the map; it is responsible for printing both the key and value for each entry.

Parameters:
out - a AnalysisReport object to which to write the output
collectionLabel - a name to use as title for list of entries
entryLabel - a name to use as title for individual entries in the list
path - a path-like string that represents the sequence of field names, separated by "/"
collectionAnalyzerName - the name of an analyzer to use to extract the list of entries from the target object
entryAnalyzerName - the name of an analyzer that should generate the report for each entry in the collection. Must take a Map.Entry as a parent.
Returns:
an ObjectWrapper representing the collection, or null if there was an error

printCollectionValueReportsAtPath

public ObjectWrapper printCollectionValueReportsAtPath(IAnalysisReport out,
                                                       java.lang.String collectionLabel,
                                                       java.lang.String entryLabel,
                                                       java.lang.String path,
                                                       java.lang.String collectionAnalyzerName,
                                                       java.lang.String entryAnalyzerName)
Print a report on each of the entries inside a collection object found at the end of a sequence of field references, starting with the current object.

This method first loads a specified analyzer to analyze the target object and extract a list of entries from it. It then loads a second analyzer for the value in each entry and invokes its produceReport() method. That second analyzer gets passed only the value (as an ObjectWrapper); if the collection is a map, the keys are printed automatically by this method itself.

Parameters:
out - a AnalysisReport object to which to write the output
collectionLabel - a name to use as title for list of entries
entryLabel - a name to use as title for individual entries in the list
path - a path-like string that represents the sequence of field names, separated by "/"
collectionAnalyzerName - the name of an analyzer to use to extract the list of entries from the target object
entryAnalyzerName - the name of an analyzer that should generate the report for each entry in the collection. Must take a single ObjectWrapper as a parent (for the entry values).
Returns:
an ObjectWrapper representing the collection, or null if there was an error

printCollectionSizeAtPath

public ObjectWrapper printCollectionSizeAtPath(IAnalysisReport out,
                                               java.lang.String collectionLabel,
                                               java.lang.String path,
                                               java.lang.String collectionAnalyzerName)
Print the size of a collection of entries represented by a collection object found at the end of a sequence of field references, starting with the current object.

This method loads a specified analyzer to analyze the target object and extract a list of entries from it. This analyzer is expected to implement the Collection interface to provide access to all the entries in the target object (e.g. HashMapWrapper, VectorWrapper, etc.)

Parameters:
out - a AnalysisReport object to which to write the output
collectionLabel - a name to use as title for the report entry showing the size of the collection
path - a path-like string that represents the sequence of field names, separated by "/"
collectionAnalyzerName - the name of an analyzer to use to extract the list of entries from the target object
Returns:
an ObjectWrapper representing the collection, or null if there was an error

startPrintGroup

public IAnalysisReport startPrintGroup(IAnalysisReport out,
                                       java.lang.String label,
                                       java.lang.Object refKey,
                                       int mode,
                                       java.lang.String formatTag)
Mark the start of a group of fields printed through a sequence calls to printValueAtPath(),etc. in this ObjectWrapper. This group is wrapped in a report embedded into the main report, so that it appears as a block in the main report, and so that it can be referenced through printIdent() elsewhere in the main report. In addition, the mode parameter can be used to force printing of additional information at the end of this group (see #MODE_OBJECT_REPORT, #MODE_SHOW_OMITTED_FIELDS).

Parameters:
out - a IAnalysisReport representing the main report that receives the output
label - a title for the secondary report being generated by this group
refKey - a reference key that can be used in calls to printIdent() that reference this secondary report associated with this group
mode - a set of options controlling additional information to be generated at the end of the group
formatTag - any special formatting tags to apply to this group
Returns:
a secondary IAnalysisReport to which all output within this group should be written

endPrintGroup

public void endPrintGroup()
Mark the end of a group of fields started with startPrintGroup(IAnalysisReport, String, Object, int, String). Generate any additional output as specified by the mode parameter to startPrintGroup().


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()

toString

public java.lang.String toString()
See Also:
Object.toString()

checkMaskedField

public boolean checkMaskedField(java.lang.String fieldName)
Check if a given field should be masked (because it contains a password)

Parameters:
fieldName - the name of the field
Returns:
true if the field should be masked, false otherwise

setMaskedFieldPattern

public void setMaskedFieldPattern(java.lang.String pattern)
Set a non-default pattern for determining the names of fields that should be masked because they contain a password. Note: the default is ".*password.*".

Parameters:
pattern - the new pattern, in java.util.regex syntax


© 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.