|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.codehaus.metaclass.Attributes
Utility class to make it easy to access attributes for classes and methods. The utility class makes it possible to access attributes for methods and fields by using one method call such as;
//Get all Class attributes for 'MyClass' Attribute[] attributes = Attributes.getAttributes( MyClass.class ); //Get all Class attributes for 'MyClass' //that have name 'dna.service' Attribute[] attributes = Attributes.getAttributes( MyClass.class, "dna.service" ); //Get attribute named 'dna.component' for 'MyClass' //Note: that this may return null Attribute attribute = Attributes.getAttribute( MyClass.class, "dna.component" );
Note that none of the methods in this class throw an exception. If an error occurs retrieving attributes for a particular artefact (such as being unable to load ClassDescriptor for class) then either an empty array or a null will be returned depending on the method.
Constructor Summary | |
Attributes()
|
Method Summary | |
static Attribute |
getAttribute(java.lang.Class clazz,
java.lang.String name)
Return the attribute for specified Class that has the specified name. |
static Attribute |
getAttribute(java.lang.reflect.Constructor constructor,
java.lang.String name)
Return the attribute for specified Constructor that has the specified name. |
static Attribute |
getAttribute(java.lang.reflect.Field field,
java.lang.String name)
Return the attribute for specified Field that has the specified name. |
static Attribute |
getAttribute(java.lang.reflect.Method method,
java.lang.String name)
Return the attribute for specified Method that has the specified name. |
static Attribute |
getAttributeByName(Attribute[] attributes,
java.lang.String name)
Return the Attributes with specified name from specified attributes. |
static Attribute[] |
getAttributes(java.lang.Class clazz)
Return the attributes for specified Class. |
static Attribute[] |
getAttributes(java.lang.Class clazz,
java.lang.String name)
Return the attributes for specified Class that have specified name. |
static Attribute[] |
getAttributes(java.lang.reflect.Constructor constructor)
Return the attributes for specified Constructor. |
static Attribute[] |
getAttributes(java.lang.reflect.Constructor constructor,
java.lang.String name)
Return the attributes for specified Constructor that have specified name. |
static Attribute[] |
getAttributes(java.lang.reflect.Field field)
Return the attributes for specified Class. |
static Attribute[] |
getAttributes(java.lang.reflect.Field field,
java.lang.String name)
Return the attributes for specified Field that have specified name. |
static Attribute[] |
getAttributes(java.lang.reflect.Method method)
Return the attributes for specified Method. |
static Attribute[] |
getAttributes(java.lang.reflect.Method method,
java.lang.String name)
Return the attributes for specified Method that have specified name. |
static Attribute[] |
getAttributesByName(Attribute[] attributes,
java.lang.String name)
Return the set of Attributes with specified name from specified attributes. |
static MethodDescriptor |
getConstructor(java.lang.reflect.Constructor constructor)
Get the MethodDescriptor for specified Constructor. |
static FieldDescriptor |
getField(java.lang.reflect.Field field)
Get the FieldDescriptor with specified name for specified Class. |
static MethodDescriptor |
getMethod(java.lang.reflect.Method method)
Get the MethodDescriptor for specified method. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public Attributes()
Method Detail |
public static Attribute getAttributeByName(Attribute[] attributes, java.lang.String name)
attributes
- the attributesname
- the name of attribute to collect
public static Attribute[] getAttributesByName(Attribute[] attributes, java.lang.String name)
attributes
- the attributesname
- the name of attributes to collect
public static Attribute[] getAttributes(java.lang.Class clazz)
clazz
- the class
public static Attribute[] getAttributes(java.lang.Class clazz, java.lang.String name)
clazz
- the classname
- the attribute name
public static Attribute getAttribute(java.lang.Class clazz, java.lang.String name)
clazz
- the classname
- the attribute name
public static Attribute[] getAttributes(java.lang.reflect.Field field)
field
- the field
public static Attribute[] getAttributes(java.lang.reflect.Field field, java.lang.String name)
field
- the fieldname
- the attribute name
public static Attribute getAttribute(java.lang.reflect.Field field, java.lang.String name)
field
- the fieldname
- the attribute name
public static Attribute[] getAttributes(java.lang.reflect.Method method)
method
- the method
public static Attribute[] getAttributes(java.lang.reflect.Method method, java.lang.String name)
method
- the Methodname
- the attribute name
public static Attribute getAttribute(java.lang.reflect.Method method, java.lang.String name)
method
- the methodname
- the attribute name
public static Attribute[] getAttributes(java.lang.reflect.Constructor constructor)
constructor
- the constructor
public static Attribute[] getAttributes(java.lang.reflect.Constructor constructor, java.lang.String name)
constructor
- the Constructorname
- the attribute name
public static Attribute getAttribute(java.lang.reflect.Constructor constructor, java.lang.String name)
constructor
- the constructorname
- the attribute name
public static FieldDescriptor getField(java.lang.reflect.Field field) throws MetaClassException
field
- the field
MetaClassException
- if unable to locate FieldDescriptor for Fieldpublic static MethodDescriptor getMethod(java.lang.reflect.Method method) throws MetaClassException
method
- the method
MetaClassException
- if unable to locate MethodDescriptor for Methodpublic static MethodDescriptor getConstructor(java.lang.reflect.Constructor constructor) throws MetaClassException
constructor
- the Constructor
MetaClassException
- if unable to locate MethodDescriptor for Constructor
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |