|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.apache.commons.attributes.Attributes
API for accessing attributes.
RepositoryError
or subclasses thereof.
This Error is thrown if an attribute repository can not be loaded for some Exceptional
reason.
Error
s instead of Exception
s.
This rationale behind this is that:
Class myClass = ...;
for (int i = 0; i < 10000; i++) {
if (Attributes.hasAttributeType (myClass, MyAttribute.class)) {
doThis(myClass);
} else {
doThat(myClass);
}
}
do:
Class myClass = ...;
boolean shouldDoThis = Attributes.hasAttributeType (myClass, MyAttribute.class);
for (int i = 0; i < 10000; i++) {
if (shouldDoThis) {
doThis(myClass);
} else {
doThat(myClass);
}
}
if the loop should run at maximum speed.
Constructor Summary | |
Attributes()
|
Method Summary | |
static Object |
getAttribute(Class clazz,
Class attributeClass)
Get one attributes of a given type from a class. |
static Object |
getAttribute(Constructor ctor,
Class attributeClass)
Get one attributes of a given type from a constructor. |
static Object |
getAttribute(Field field,
Class attributeClass)
Get one attributes of a given type from a field. |
static Object |
getAttribute(Method method,
Class attributeClass)
Get one attributes of a given type from a method. |
static Collection |
getAttributes(Class clazz)
Gets all attributes for a class. |
static Collection |
getAttributes(Class clazz,
Class attributeClass)
Get all attributes of a given type from a class. |
static Collection |
getAttributes(Constructor cons)
Gets all attributes for a constructor. |
static Collection |
getAttributes(Constructor ctor,
Class attributeClass)
Get all attributes of a given type from a constructor. |
static Collection |
getAttributes(Field field)
Gets all attributes for a field. |
static Collection |
getAttributes(Field field,
Class attributeClass)
Get all attributes of a given type from a field. |
static Collection |
getAttributes(Method method)
Gets all attributes for a method. |
static Collection |
getAttributes(Method method,
Class attributeClass)
Get all attributes of a given type from a method. |
static Object |
getParameterAttribute(Constructor constructor,
int parameter,
Class attributeClass)
Get one attributes of a given type from a constructor's parameter. |
static Object |
getParameterAttribute(Method method,
int parameter,
Class attributeClass)
Get one attributes of a given type from a parameter. |
static Collection |
getParameterAttributes(Constructor constructor,
int parameter)
Gets all attributes for a parameter of a constructor. |
static Collection |
getParameterAttributes(Constructor constructor,
int parameter,
Class attributeClass)
Get all attributes of a given type from a method's parameter. |
static Collection |
getParameterAttributes(Method method,
int parameter)
Gets all attributes for a parameter of a method. |
static Collection |
getParameterAttributes(Method method,
int parameter,
Class attributeClass)
Get all attributes of a given type from a method's parameter. |
static Object |
getReturnAttribute(Method method,
Class attributeClass)
Get one attributes of a given type from a method's return value. |
static Collection |
getReturnAttributes(Method method)
Gets all attributes for the return value of a method. |
static Collection |
getReturnAttributes(Method method,
Class attributeClass)
Get all attributes of a given type from a method's return value. |
static boolean |
hasAttribute(Class clazz,
Object attribute)
Tests if a class has an attribute. |
static boolean |
hasAttribute(Constructor ctor,
Object attribute)
Tests if a constructor has an attribute. |
static boolean |
hasAttribute(Field field,
Object attribute)
Tests if a field has an attribute. |
static boolean |
hasAttribute(Method method,
Object attribute)
Tests if a method has an attribute. |
static boolean |
hasAttributeType(Class clazz,
Class attributeClass)
Tests if a class has an attribute of a given type. |
static boolean |
hasAttributeType(Constructor ctor,
Class attributeClass)
Tests if a constructor has an attribute of a given type. |
static boolean |
hasAttributeType(Field field,
Class attributeClass)
Tests if a field has an attribute of a given type. |
static boolean |
hasAttributeType(Method method,
Class attributeClass)
Tests if a method has an attribute of a given type. |
static boolean |
hasParameterAttribute(Constructor constructor,
int parameter,
Object attribute)
Tests if a constructor's parameter has an attribute. |
static boolean |
hasParameterAttribute(Method method,
int parameter,
Object attribute)
Tests if a method's parameter has an attribute. |
static boolean |
hasParameterAttributeType(Constructor constructor,
int parameter,
Class attributeClass)
Tests if a constructor's parameter has an attribute of a given type. |
static boolean |
hasParameterAttributeType(Method method,
int parameter,
Class attributeClass)
Tests if a method's parameter has an attribute of a given type. |
static boolean |
hasReturnAttribute(Method method,
Object attribute)
Tests if a method's return value has an attribute. |
static boolean |
hasReturnAttributeType(Method method,
Class attributeClass)
Tests if a method's return value has an attribute of a given type. |
static void |
setAttributes(RuntimeAttributeRepository repo)
Set attributes for a given class. |
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 Object getAttribute(Class clazz, Class attributeClass) throws RepositoryError, MultipleAttributesError
MultipleAttributesError
- if the collection contains more than one
instance of the specified class.
RepositoryError
public static Object getAttribute(Field field, Class attributeClass) throws RepositoryError, MultipleAttributesError
MultipleAttributesError
- if the collection contains more than one
instance of the specified class.
RepositoryError
public static Object getAttribute(Constructor ctor, Class attributeClass) throws RepositoryError, MultipleAttributesError
MultipleAttributesError
- if the collection contains more than one
instance of the specified class.
RepositoryError
public static Object getAttribute(Method method, Class attributeClass) throws RepositoryError, MultipleAttributesError
MultipleAttributesError
- if the collection contains more than one
instance of the specified class.
RepositoryError
public static Object getParameterAttribute(Method method, int parameter, Class attributeClass) throws RepositoryError, MultipleAttributesError
MultipleAttributesError
- if the collection contains more than one
instance of the specified class.
RepositoryError
public static Object getParameterAttribute(Constructor constructor, int parameter, Class attributeClass) throws RepositoryError, MultipleAttributesError
MultipleAttributesError
- if the collection contains more than one
instance of the specified class.
RepositoryError
public static Object getReturnAttribute(Method method, Class attributeClass) throws RepositoryError, MultipleAttributesError
MultipleAttributesError
- if the collection contains more than one
instance of the specified class.
RepositoryError
public static Collection getAttributes(Class clazz) throws RepositoryError
RepositoryError
public static Collection getAttributes(Method method) throws RepositoryError
RepositoryError
public static Collection getParameterAttributes(Method method, int parameter) throws RepositoryError
RepositoryError
public static Collection getParameterAttributes(Constructor constructor, int parameter) throws RepositoryError
RepositoryError
public static Collection getReturnAttributes(Method method) throws RepositoryError
RepositoryError
public static Collection getAttributes(Field field) throws RepositoryError
RepositoryError
public static Collection getAttributes(Constructor cons) throws RepositoryError
RepositoryError
public static Collection getAttributes(Class clazz, Class attributeClass) throws RepositoryError
o.getClass() == attributeClass
.
RepositoryError
public static Collection getAttributes(Field field, Class attributeClass) throws RepositoryError
o.getClass() == attributeClass
.
RepositoryError
public static Collection getAttributes(Constructor ctor, Class attributeClass) throws RepositoryError
o.getClass() == attributeClass
.
RepositoryError
public static Collection getAttributes(Method method, Class attributeClass) throws RepositoryError
o.getClass() == attributeClass
.
RepositoryError
public static Collection getParameterAttributes(Method method, int parameter, Class attributeClass) throws RepositoryError
o.getClass() == attributeClass
.
RepositoryError
public static Collection getParameterAttributes(Constructor constructor, int parameter, Class attributeClass) throws RepositoryError
o.getClass() == attributeClass
.
RepositoryError
public static Collection getReturnAttributes(Method method, Class attributeClass) throws RepositoryError
o.getClass() == attributeClass
.
RepositoryError
public static boolean hasAttributeType(Class clazz, Class attributeClass) throws RepositoryError
attr
such that attr.getClass() == attributeClass
?
RepositoryError
public static boolean hasAttributeType(Field field, Class attributeClass) throws RepositoryError
attr
such that attr.getClass() == attributeClass
?
RepositoryError
public static boolean hasAttributeType(Constructor ctor, Class attributeClass) throws RepositoryError
attr
such that attr.getClass() == attributeClass
?
RepositoryError
public static boolean hasAttributeType(Method method, Class attributeClass) throws RepositoryError
attr
such that attr.getClass() == attributeClass
?
RepositoryError
public static boolean hasParameterAttributeType(Method method, int parameter, Class attributeClass) throws RepositoryError
attr
such that attr.getClass() == attributeClass
?
RepositoryError
public static boolean hasParameterAttributeType(Constructor constructor, int parameter, Class attributeClass) throws RepositoryError
attr
such that attr.getClass() == attributeClass
?
RepositoryError
public static boolean hasReturnAttributeType(Method method, Class attributeClass) throws RepositoryError
attr
such that attr.getClass() == attributeClass
?
RepositoryError
public static boolean hasAttribute(Class clazz, Object attribute) throws RepositoryError
attr
such that attr.equals(attribute)
?
RepositoryError
public static boolean hasAttribute(Field field, Object attribute) throws RepositoryError
attr
such that attr.equals(attribute)
?
RepositoryError
public static boolean hasAttribute(Constructor ctor, Object attribute) throws RepositoryError
attr
such that attr.equals(attribute)
?
RepositoryError
public static boolean hasAttribute(Method method, Object attribute) throws RepositoryError
attr
such that attr.equals(attribute)
?
RepositoryError
public static boolean hasParameterAttribute(Method method, int parameter, Object attribute) throws RepositoryError
attr
such that attr.equals(attribute)
?
RepositoryError
public static boolean hasParameterAttribute(Constructor constructor, int parameter, Object attribute) throws RepositoryError
attr
such that attr.equals(attribute)
?
RepositoryError
public static boolean hasReturnAttribute(Method method, Object attribute) throws RepositoryError
attr
such that attr.equals(attribute)
?
RepositoryError
public static void setAttributes(RuntimeAttributeRepository repo) throws IllegalStateException
repo
- The repository. The repository will be sealed before any attributes are
set. This to guarantee that the repository remains constant
during setting.
IllegalStateException
- if the class whose attributes are defined already have
attributes defined for it (even if it has no attributes).
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |