patterntesting.runtime.util
Class ObjectInspector

Package class diagram package ObjectInspector
java.lang.Object
  extended by patterntesting.runtime.util.ObjectInspector

public final class ObjectInspector
extends Object

This class lets you examine an object and dump its internal attributes. It was introduced to find some secrets of IBM's classloader.

Since:
1.2.10-YEARS (24.01.2012)
Author:
oboehm

Field Summary
static String NOTHING_FOUND
          The value for "nothing found".
 
Constructor Summary
ObjectInspector(Object obj)
          Instantiates a new object inspector.
 
Method Summary
 void dump(Writer writer)
          Dump the inspected class.
 String findValue(Object value)
          Find the value in of the attributes of the inspected object.
 Collection<Field> getAllFields()
          Gets all fields of the wrapped object.
 Class<?> getType()
          Gets the type (class) of the stored object.
 boolean isArrayType()
          Checks if the wrapped object is an array type.
static boolean isArrayType(Object obj)
          Checks if the given object is an array.
 boolean isComplexType()
          Checks if the wrapped object is complex type.
static boolean isComplexType(Object obj)
          Checks if the given object is of complex type.
 boolean isIterable()
          Checks if the type of the wrapped object could be iterated.
static boolean isIterable(Object obj)
          Checks if the type of the given object could be iterated.
 String toLongString()
          To long string.
 String toString()
          Dumps all attributes of the inspected object in the form attribute=value.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

NOTHING_FOUND

public static final String NOTHING_FOUND
The value for "nothing found".

Constructor Detail

ObjectInspector

public ObjectInspector(Object obj)
Instantiates a new object inspector.

Parameters:
obj - the object to be inspected
Method Detail

getType

public Class<?> getType()
Gets the type (class) of the stored object.

Returns:
the type

findValue

public String findValue(Object value)
                 throws ValueNotFoundException
Find the value in of the attributes of the inspected object. You can give a Pattern as parameter if you want to use wildcards for the search.

Parameters:
value - the value or the pattern you want to look for
Returns:
the string
Throws:
ValueNotFoundException - the value not found exception

getAllFields

public Collection<Field> getAllFields()
Gets all fields of the wrapped object. Not only the (public) class fields but also the private and protected fields of the superclass.

Returns:
the all fields

dump

public void dump(Writer writer)
          throws IOException
Dump the inspected class.

Parameters:
writer - the writer
Throws:
IOException - Signals that an I/O exception has occurred.

isComplexType

public boolean isComplexType()
Checks if the wrapped object is complex type.

Returns:
true, if is complex type

isComplexType

public static boolean isComplexType(Object obj)
Checks if the given object is of complex type. These are all types which

Parameters:
obj - the obj
Returns:
true, if is complex type

isArrayType

public boolean isArrayType()
Checks if the wrapped object is an array type.

Returns:
true, if is array type

isArrayType

public static boolean isArrayType(Object obj)
Checks if the given object is an array.

Parameters:
obj - the obj
Returns:
true, if is array type

isIterable

public boolean isIterable()
Checks if the type of the wrapped object could be iterated. This is the case e.g. for Collections and its subclasses.

Returns:
true, if is iterable

isIterable

public static boolean isIterable(Object obj)
Checks if the type of the given object could be iterated. This is the case e.g. for Collections and its subclasses.

Parameters:
obj - the object
Returns:
true, if is iterable

toString

public String toString()
Dumps all attributes of the inspected object in the form attribute=value.

Overrides:
toString in class Object
Returns:
the string
See Also:
Object.toString()

toLongString

public String toLongString()
To long string.

Returns:
the string


Copyright © 2002–2014 PatternTesting Team. All rights reserved.