Top Description Inners Fields Constructors Methods
groovy.inspect

public Class Inspector

extends Object
Class Inheritance
Imports
groovy.lang.GroovyObject, .MetaClass, .MetaMethod, .PropertyValue, .Tuple2, org.codehaus.groovy.runtime.DefaultGroovyMethods, .InvokerHelper, java.io.PrintStream, .Serializable, java.lang.reflect.Constructor, .Field, .Method, .Modifier, java.util.Collection, .Comparator, .Iterator, .List

The Inspector provides a unified access to an object's information that can be determined by introspection.

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
public static class

Field Summary

Modifier and TypeField and Description
public static final int
public static final int
public static final int
public static final int
public static final int
public static final String
public static final String
public static final int
public static final int
public static final int
public static final int
public static final int
public static final int
public static final int
public static final int
public static final String
protected Object

Constructor Summary

AccessConstructor and Description
public
Inspector(Object
must not be null
objectUnderInspection
)

Method Summary

Modifier and TypeMethod and Description
protected String[]
protected String[]
protected Tuple2<Object, String[]>
protected Tuple2<Object, String[]>
public String[]

Returns:

String array to be indexed by the CLASS_xxx_IDX constants
getClassProps
()

Get the Class Properties of the object under inspection.

protected Class<T>
public Object[]

Returns:

Array of StringArrays that can be indexed with the MEMBER_xxx_IDX constants
getMetaMethods
()

Get info about instance and class Methods that are dynamically added through Groovy.

public Object[]

Returns:

Array of StringArrays that can be indexed with the MEMBER_xxx_IDX constants
getMethods
()

Get info about usual Java instance and class Methods as well as Constructors.

public Object

Returns:

the object
getObject
()

Gets the object being inspected.

public Object[]
public Object[]

Returns:

Array of StringArrays that can be indexed with the MEMBER_xxx_IDX constants
getPropertyInfo
()

Get info about Properties (Java and Groovy alike).

public Object[]

Returns:

Array of StringArrays that can be indexed with the MEMBER_xxx_IDX constants
getPublicFields
()

Get info about usual Java public fields incl.

public Object[]
public boolean
private static String
makeExceptionInfo(Class<T>[] exceptions)

private static String
makeParamsInfo(Class<T>[] params)

private static String
makeTypesInfo(Class<T>[] types)

protected String[]
protected String[]
protected String[]
public static String
shortName(Class<T> clazz)

public static Collection<E>
sort(List<Object> memberInfo)

public static Collection<E>
sort(List<Object> memberInfo, Comparator<Object> comparator)

protected String[]
withoutNulls(String[] toNormalize)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

CLASS_CLASS_IDXback to summary
public static final int CLASS_CLASS_IDX
CLASS_INTERFACE_IDXback to summary
public static final int CLASS_INTERFACE_IDX
CLASS_OTHER_IDXback to summary
public static final int CLASS_OTHER_IDX
CLASS_PACKAGE_IDXback to summary
public static final int CLASS_PACKAGE_IDX
CLASS_SUPERCLASS_IDXback to summary
public static final int CLASS_SUPERCLASS_IDX
GROOVYback to summary
public static final String GROOVY
JAVAback to summary
public static final String JAVA
MEMBER_DECLARER_IDXback to summary
public static final int MEMBER_DECLARER_IDX
MEMBER_EXCEPTIONS_IDXback to summary
public static final int MEMBER_EXCEPTIONS_IDX
MEMBER_MODIFIER_IDXback to summary
public static final int MEMBER_MODIFIER_IDX
MEMBER_NAME_IDXback to summary
public static final int MEMBER_NAME_IDX
MEMBER_ORIGIN_IDXback to summary
public static final int MEMBER_ORIGIN_IDX
MEMBER_PARAMS_IDXback to summary
public static final int MEMBER_PARAMS_IDX
MEMBER_TYPE_IDXback to summary
public static final int MEMBER_TYPE_IDX
MEMBER_VALUE_IDXback to summary
public static final int MEMBER_VALUE_IDX
NOT_APPLICABLEback to summary
public static final String NOT_APPLICABLE
objectUnderInspectionback to summary
protected Object objectUnderInspection

Constructor Detail

Inspectorback to summary
public Inspector(Object objectUnderInspection)
Parameters
objectUnderInspection:Object

must not be null

Method Detail

fieldInfoback to summary
protected String[] fieldInfo(Field field)
fieldInfoback to summary
protected String[] fieldInfo(PropertyValue pv)
fieldWithInfoback to summary
protected Tuple2<Object, String[]> fieldWithInfo(Field field)
fieldWithInfoback to summary
protected Tuple2<Object, String[]> fieldWithInfo(PropertyValue pv)
getClassPropsback to summary
public String[] getClassProps()

Get the Class Properties of the object under inspection.

Returns:String[]

String array to be indexed by the CLASS_xxx_IDX constants

getClassUnderInspectionback to summary
protected Class<T> getClassUnderInspection()
getMetaMethodsback to summary
public Object[] getMetaMethods()

Get info about instance and class Methods that are dynamically added through Groovy.

Returns:Object[]

Array of StringArrays that can be indexed with the MEMBER_xxx_IDX constants

getMethodsback to summary
public Object[] getMethods()

Get info about usual Java instance and class Methods as well as Constructors.

Returns:Object[]

Array of StringArrays that can be indexed with the MEMBER_xxx_IDX constants

getObjectback to summary
public Object getObject()

Gets the object being inspected.

Returns:Object

the object

getPropertiesWithInfoback to summary
public Object[] getPropertiesWithInfo()
getPropertyInfoback to summary
public Object[] getPropertyInfo()

Get info about Properties (Java and Groovy alike).

Returns:Object[]

Array of StringArrays that can be indexed with the MEMBER_xxx_IDX constants

getPublicFieldsback to summary
public Object[] getPublicFields()

Get info about usual Java public fields incl. constants.

Returns:Object[]

Array of StringArrays that can be indexed with the MEMBER_xxx_IDX constants

getPublicFieldsWithInfoback to summary
public Object[] getPublicFieldsWithInfo()
isGroovyback to summary
public boolean isGroovy()
makeExceptionInfoback to summary
private static String makeExceptionInfo(Class<T>[] exceptions)
makeParamsInfoback to summary
private static String makeParamsInfo(Class<T>[] params)
makeTypesInfoback to summary
private static String makeTypesInfo(Class<T>[] types)
methodInfoback to summary
protected String[] methodInfo(Method method)
methodInfoback to summary
protected String[] methodInfo(Constructor<T> ctor)
methodInfoback to summary
protected String[] methodInfo(MetaMethod method)
shortNameback to summary
public static String shortName(Class<T> clazz)
sortback to summary
public static Collection<E> sort(List<Object> memberInfo)
sortback to summary
public static Collection<E> sort(List<Object> memberInfo, Comparator<Object> comparator)
withoutNullsback to summary
protected String[] withoutNulls(String[] toNormalize)
groovy.inspect back to summary

public Class Inspector.MemberComparator

extends Object
implements Comparator<Object>, Serializable
Class Inheritance
All Implemented Interfaces
java.io.Serializable, java.util.Comparator

Field Summary

Modifier and TypeField and Description
private static final long

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public int
compare(Object
the first object to be compared.
a
,
Object
the second object to be compared.
b
)

Implements java.util.Comparator.compare.

Compares its two arguments for order.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

serialVersionUIDback to summary
private static final long serialVersionUID

Constructor Detail

MemberComparatorback to summary
public MemberComparator()

Method Detail

compareback to summary
public int compare(Object a, Object b)

Implements java.util.Comparator.compare.

Doc from java.util.Comparator.compare.

Compares its two arguments for order. Returns a negative integer, zero, or a positive integer as the first argument is less than, equal to, or greater than the second.

The implementor must ensure that signum(compare(x, y)) == -signum(compare(y, x)) for all x and y. (This implies that compare(x, y) must throw an exception if and only if compare(y, x) throws an exception.)

The implementor must also ensure that the relation is transitive: ((compare(x, y)>0) && (compare(y, z)>0)) implies compare(x, z)>0.

Finally, the implementor must ensure that compare(x, y)==0 implies that signum(compare(x, z))==signum(compare(y, z)) for all z.

Parameters
a:Object

the first object to be compared.

b:Object

the second object to be compared.

Returns:int

a negative integer, zero, or a positive integer as the first argument is less than, equal to, or greater than the second.

groovy.inspect back to summary

public Class Inspector.MemberComparatorWithValue

extends Object
implements Comparator<Object>, Serializable
Class Inheritance
All Implemented Interfaces
java.io.Serializable, java.util.Comparator

Field Summary

Modifier and TypeField and Description
private static final Inspector.MemberComparator
private static final long

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public int
compare(Object
the first object to be compared.
a
,
Object
the second object to be compared.
b
)

Implements java.util.Comparator.compare.

Compares its two arguments for order.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

delegateback to summary
private static final Inspector.MemberComparator delegate
serialVersionUIDback to summary
private static final long serialVersionUID

Constructor Detail

MemberComparatorWithValueback to summary
public MemberComparatorWithValue()

Method Detail

compareback to summary
public int compare(Object a, Object b)

Implements java.util.Comparator.compare.

Doc from java.util.Comparator.compare.

Compares its two arguments for order. Returns a negative integer, zero, or a positive integer as the first argument is less than, equal to, or greater than the second.

The implementor must ensure that signum(compare(x, y)) == -signum(compare(y, x)) for all x and y. (This implies that compare(x, y) must throw an exception if and only if compare(y, x) throws an exception.)

The implementor must also ensure that the relation is transitive: ((compare(x, y)>0) && (compare(y, z)>0)) implies compare(x, z)>0.

Finally, the implementor must ensure that compare(x, y)==0 implies that signum(compare(x, z))==signum(compare(y, z)) for all z.

Parameters
a:Object

the first object to be compared.

b:Object

the second object to be compared.

Returns:int

a negative integer, zero, or a positive integer as the first argument is less than, equal to, or greater than the second.

Annotations
@Override