Package groovy.inspect
Class Inspector
java.lang.Object
groovy.inspect.Inspector
public class Inspector
extends java.lang.Object
The Inspector provides a unified access to an object's
 information that can be determined by introspection.
- 
Nested Class SummaryNested Classes Modifier and Type Class Description static classInspector.MemberComparatorstatic classInspector.MemberComparatorWithValue
- 
Field SummaryFields Modifier and Type Field Description static intCLASS_CLASS_IDXstatic intCLASS_INTERFACE_IDXstatic intCLASS_OTHER_IDXstatic intCLASS_PACKAGE_IDXstatic intCLASS_SUPERCLASS_IDXstatic java.lang.StringGROOVYstatic java.lang.StringJAVAstatic intMEMBER_DECLARER_IDXstatic intMEMBER_EXCEPTIONS_IDXstatic intMEMBER_MODIFIER_IDXstatic intMEMBER_NAME_IDXstatic intMEMBER_ORIGIN_IDXstatic intMEMBER_PARAMS_IDXstatic intMEMBER_TYPE_IDXstatic intMEMBER_VALUE_IDXstatic java.lang.StringNOT_APPLICABLEprotected java.lang.ObjectobjectUnderInspection
- 
Constructor SummaryConstructors Constructor Description Inspector(java.lang.Object objectUnderInspection)
- 
Method SummaryModifier and Type Method Description protected java.lang.String[]fieldInfo(PropertyValue pv)protected java.lang.String[]fieldInfo(java.lang.reflect.Field field)protected Tuple2<java.lang.Object,java.lang.String[]>fieldWithInfo(PropertyValue pv)protected Tuple2<java.lang.Object,java.lang.String[]>fieldWithInfo(java.lang.reflect.Field field)java.lang.String[]getClassProps()Get the Class Properties of the object under inspection.protected java.lang.ClassgetClassUnderInspection()java.lang.Object[]getMetaMethods()Get info about instance and class Methods that are dynamically added through Groovy.java.lang.Object[]getMethods()Get info about usual Java instance and class Methods as well as Constructors.java.lang.ObjectgetObject()Gets the object being inspected.java.lang.Object[]getPropertiesWithInfo()java.lang.Object[]getPropertyInfo()Get info about Properties (Java and Groovy alike).java.lang.Object[]getPublicFields()Get info about usual Java public fields incl.java.lang.Object[]getPublicFieldsWithInfo()booleanisGroovy()protected java.lang.String[]methodInfo(MetaMethod method)protected java.lang.String[]methodInfo(java.lang.reflect.Constructor ctor)protected java.lang.String[]methodInfo(java.lang.reflect.Method method)static voidprint(java.lang.Object[] memberInfo)static java.lang.StringshortName(java.lang.Class clazz)static java.util.Collectionsort(java.util.List<java.lang.Object> memberInfo)static java.util.Collectionsort(java.util.List<java.lang.Object> memberInfo, java.util.Comparator<java.lang.Object> comparator)protected java.lang.String[]withoutNulls(java.lang.String[] toNormalize)Methods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
- 
Field Details- 
objectUnderInspectionprotected java.lang.Object objectUnderInspection
- 
CLASS_PACKAGE_IDXpublic static final int CLASS_PACKAGE_IDX- See Also:
- Constant Field Values
 
- 
CLASS_CLASS_IDXpublic static final int CLASS_CLASS_IDX- See Also:
- Constant Field Values
 
- 
CLASS_INTERFACE_IDXpublic static final int CLASS_INTERFACE_IDX- See Also:
- Constant Field Values
 
- 
CLASS_SUPERCLASS_IDXpublic static final int CLASS_SUPERCLASS_IDX- See Also:
- Constant Field Values
 
- 
CLASS_OTHER_IDXpublic static final int CLASS_OTHER_IDX- See Also:
- Constant Field Values
 
- 
MEMBER_ORIGIN_IDXpublic static final int MEMBER_ORIGIN_IDX- See Also:
- Constant Field Values
 
- 
MEMBER_MODIFIER_IDXpublic static final int MEMBER_MODIFIER_IDX- See Also:
- Constant Field Values
 
- 
MEMBER_DECLARER_IDXpublic static final int MEMBER_DECLARER_IDX- See Also:
- Constant Field Values
 
- 
MEMBER_TYPE_IDXpublic static final int MEMBER_TYPE_IDX- See Also:
- Constant Field Values
 
- 
MEMBER_NAME_IDXpublic static final int MEMBER_NAME_IDX- See Also:
- Constant Field Values
 
- 
MEMBER_PARAMS_IDXpublic static final int MEMBER_PARAMS_IDX- See Also:
- Constant Field Values
 
- 
MEMBER_VALUE_IDXpublic static final int MEMBER_VALUE_IDX- See Also:
- Constant Field Values
 
- 
MEMBER_EXCEPTIONS_IDXpublic static final int MEMBER_EXCEPTIONS_IDX- See Also:
- Constant Field Values
 
- 
NOT_APPLICABLEpublic static final java.lang.String NOT_APPLICABLE- See Also:
- Constant Field Values
 
- 
GROOVYpublic static final java.lang.String GROOVY- See Also:
- Constant Field Values
 
- 
JAVApublic static final java.lang.String JAVA- See Also:
- Constant Field Values
 
 
- 
- 
Constructor Details- 
Inspectorpublic Inspector(java.lang.Object objectUnderInspection)- Parameters:
- objectUnderInspection- must not be null
 
 
- 
- 
Method Details- 
getClassPropspublic java.lang.String[] getClassProps()Get the Class Properties of the object under inspection.- Returns:
- String array to be indexed by the CLASS_xxx_IDX constants
 
- 
isGroovypublic boolean isGroovy()
- 
getObjectpublic java.lang.Object getObject()Gets the object being inspected.- Returns:
- the object
 
- 
getMethodspublic java.lang.Object[] getMethods()Get info about usual Java instance and class Methods as well as Constructors.- Returns:
- Array of StringArrays that can be indexed with the MEMBER_xxx_IDX constants
 
- 
getMetaMethodspublic java.lang.Object[] getMetaMethods()Get info about instance and class Methods that are dynamically added through Groovy.- Returns:
- Array of StringArrays that can be indexed with the MEMBER_xxx_IDX constants
 
- 
getPublicFieldspublic java.lang.Object[] getPublicFields()Get info about usual Java public fields incl. constants.- Returns:
- Array of StringArrays that can be indexed with the MEMBER_xxx_IDX constants
 
- 
getPublicFieldsWithInfopublic java.lang.Object[] getPublicFieldsWithInfo()
- 
getPropertyInfopublic java.lang.Object[] getPropertyInfo()Get info about Properties (Java and Groovy alike).- Returns:
- Array of StringArrays that can be indexed with the MEMBER_xxx_IDX constants
 
- 
fieldInfoprotected java.lang.String[] fieldInfo(java.lang.reflect.Field field)
- 
fieldWithInfoprotected Tuple2<java.lang.Object,java.lang.String[]> fieldWithInfo(java.lang.reflect.Field field)
- 
fieldInfo
- 
fieldWithInfo
- 
getPropertiesWithInfopublic java.lang.Object[] getPropertiesWithInfo()
- 
getClassUnderInspectionprotected java.lang.Class getClassUnderInspection()
- 
shortNamepublic static java.lang.String shortName(java.lang.Class clazz)
- 
methodInfoprotected java.lang.String[] methodInfo(java.lang.reflect.Method method)
- 
methodInfoprotected java.lang.String[] methodInfo(java.lang.reflect.Constructor ctor)
- 
methodInfo
- 
withoutNullsprotected java.lang.String[] withoutNulls(java.lang.String[] toNormalize)
- 
printpublic static void print(java.lang.Object[] memberInfo)
- 
sortpublic static java.util.Collection sort(java.util.List<java.lang.Object> memberInfo)
- 
sortpublic static java.util.Collection sort(java.util.List<java.lang.Object> memberInfo, java.util.Comparator<java.lang.Object> comparator)
 
-