|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.ObjectTranslatableAnalyzer
com.ibm.dtfj.analyzer.base.SimpleAnalyzerBean
com.ibm.dtfj.analyzer.helpers.ValueWrapper
public abstract class ValueWrapper
Utility class to contain the value of an arbitrary Java field or object extracted from the DTFJ image, that corresponds to either an object reference or one of the primitive types.
In methods like JavaField.get()
in the DTFJ API, this is sometimes represented
as a java.lang.Object
that must then be cast explicitly to an instance of JavaObject or
Integer, Character, Boolean, etc. But this approach does not provide much flexibility for error handling
and compile-time type checking, and it also does not provide a simple mechanism to
deal with other common types of objects like java.lang.String
, etc.
This utility class attempts to encapsulate this concept and provide a more user-friendly representation. Note however that we cannot ever completely eliminate the need for runtime type checking for this functionality. But at least, encapsulating into a single class should make it more explicit and maintainable.
For completeness, and for use when reading static fields through ObjectWrapper, this class also be used to wrap an instance of JavaClass (though of course that would never be returned from code>JavaField.get())
Constructor Summary | |
---|---|
ValueWrapper()
|
Method Summary | |
---|---|
boolean |
equals(java.lang.Object obj)
|
boolean |
getBooleanValue()
|
byte |
getByteValue()
|
int |
getCachingPriority()
Never cache ValueWrapper objects. |
char |
getCharacterValue()
|
double |
getDoubleValue()
|
float |
getFloatValue()
|
int |
getIntegerValue()
|
com.ibm.dtfj.java.JavaClass |
getJavaClassValue()
|
com.ibm.dtfj.java.JavaObject |
getJavaObjectValue()
|
long |
getLongValue()
|
ObjectWrapper |
getObjectWrapper()
Convert an instance of ValueWrapper into an ObjectWrapper |
ObjectWrapper |
getObjectWrapper(java.lang.String wrapperName)
Convert an instance of ValueWrapper into an arbitrary object wrapper type |
OneJavaClass |
getOneJavaClassValue()
|
OneJavaObject |
getOneJavaObjectValue()
|
java.lang.Object |
getRawValue()
Return the internal value wrapped by this container. |
short |
getShortValue()
|
java.lang.String |
getStringValue()
|
java.lang.String |
getTypeSignature()
|
static ValueWrapper |
getValueWrapperInstance(IAnalyzerContext context,
java.lang.Object parent)
Create a ValueWrapper bean instance associated with a given parent object. |
java.lang.String |
getVersion()
Get version information for this analyser. |
int |
hashCode()
|
boolean |
isBoolean()
|
boolean |
isByte()
|
boolean |
isCharacter()
|
boolean |
isDouble()
|
boolean |
isFloat()
|
boolean |
isInstanceOf(java.lang.String clsname)
Determine if this value is an instance of a specified class (or any of its subclasses) |
boolean |
isInteger()
|
boolean |
isJavaClass()
|
boolean |
isJavaObject()
|
boolean |
isLong()
|
boolean |
isShort()
|
boolean |
isString()
|
void |
setParent(java.lang.Object parent)
Set the parent Object underlying this analyzer bean. |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ValueWrapper()
Method Detail |
---|
public int getCachingPriority()
getCachingPriority
in interface IAnalyzerBase
getCachingPriority
in class SimpleAnalyzerBean
SimpleAnalyzerBean.getCachingPriority()
public java.lang.String getVersion()
IAnalyzerBase
getVersion
in interface IAnalyzerBase
getVersion
in class SimpleAnalyzerBean
Override the default from SimpleAnalyzerBean ("EXPERIMENTAL").
The version number is typically not defined for small wrappers.
public static ValueWrapper getValueWrapperInstance(IAnalyzerContext context, java.lang.Object parent)
This method actually creates a subclass of ValueWrapper, of the type specified in the option "com.ibm.dtfj.analyzer.helpers.ValueWrapper.actualClass".
context
- the AnalyzerContext in which to locate this bean instanceparent
- the parent Object underlying this analyzer bean
public ObjectWrapper getObjectWrapper()
public ObjectWrapper getObjectWrapper(java.lang.String wrapperName)
wrapperName
- the name of an analyzer to use as a wrapper for this value (must be a subclass of ObjectWrapper)
public void setParent(java.lang.Object parent)
setParent
in interface IWrapper
setParent
in class SimpleAnalyzerBean
parent
- The parent object to set. Must be of type JavaMethod.
compatible with the type of analyzer bean that receives itIWrapper.setParent(java.lang.Object)
public final boolean isJavaObject()
public final com.ibm.dtfj.java.JavaObject getJavaObjectValue() throws com.ibm.dtfj.image.DTFJException
com.ibm.dtfj.image.DTFJException
- if this container does not contain a JavaObjectpublic final OneJavaObject getOneJavaObjectValue() throws com.ibm.dtfj.image.DTFJException
com.ibm.dtfj.image.DTFJException
- if this container does not contain a JavaObjectpublic final boolean isJavaClass()
public final com.ibm.dtfj.java.JavaClass getJavaClassValue() throws com.ibm.dtfj.image.DTFJException
com.ibm.dtfj.image.DTFJException
- if this container does not contain a JavaClasspublic final OneJavaClass getOneJavaClassValue() throws com.ibm.dtfj.image.DTFJException
com.ibm.dtfj.image.DTFJException
- if this container does not contain a JavaClasspublic boolean isString()
public java.lang.String getStringValue() throws com.ibm.dtfj.image.DTFJException
com.ibm.dtfj.image.DTFJException
- if this container does not contain a valid Stringpublic boolean isInteger()
public int getIntegerValue() throws com.ibm.dtfj.image.DTFJException
com.ibm.dtfj.image.DTFJException
- if this container does not contain a valid Integerpublic boolean isBoolean()
public boolean getBooleanValue() throws com.ibm.dtfj.image.DTFJException
com.ibm.dtfj.image.DTFJException
- if this container does not contain a valid Booleanpublic boolean isLong()
public long getLongValue() throws com.ibm.dtfj.image.DTFJException
com.ibm.dtfj.image.DTFJException
- if this container does not contain a valid Longpublic boolean isByte()
public byte getByteValue() throws com.ibm.dtfj.image.DTFJException
com.ibm.dtfj.image.DTFJException
- if this container does not contain a valid Bytepublic boolean isCharacter()
public char getCharacterValue() throws com.ibm.dtfj.image.DTFJException
com.ibm.dtfj.image.DTFJException
- if this container does not contain a valid Characterpublic boolean isDouble()
public double getDoubleValue() throws com.ibm.dtfj.image.DTFJException
com.ibm.dtfj.image.DTFJException
- if this container does not contain a valid Doublepublic boolean isFloat()
public float getFloatValue() throws com.ibm.dtfj.image.DTFJException
com.ibm.dtfj.image.DTFJException
- if this container does not contain a valid Floatpublic boolean isShort()
public short getShortValue() throws com.ibm.dtfj.image.DTFJException
com.ibm.dtfj.image.DTFJException
- if this container does not contain a valid Floatpublic java.lang.String getTypeSignature()
public boolean isInstanceOf(java.lang.String clsname)
clsname
- the class name to check
public boolean equals(java.lang.Object obj)
Object.equals(java.lang.Object)
public int hashCode()
Object.hashCode()
public java.lang.Object getRawValue()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |