org.apache.commons.attributes

Class AttributeIndex


public class AttributeIndex
extends java.lang.Object

An index providing a list of elements with given attributes. This requires that the attribute is Indexed and that the attribute indexer tool has been run on the jar file containing the classes.
Since:
2.1

Nested Class Summary

static class
AttributeIndex.ConstructorParameter
A constructor parameter.
private static class
AttributeIndex.IndexNode
static class
AttributeIndex.MethodParameter
Reference to a method parameter.

Field Summary

private ClassLoader
classLoader
private HashMap
index

Constructor Summary

AttributeIndex(ClassLoader cl)
Creates a new AttributeIndex for the given ClassLoader.

Method Summary

private void
addClass(String clazzName)
Add a class to the index.
private void
addIndex(Collection attributes, Class clazz)
private void
addIndex(Collection attributes, Constructor constructor)
private void
addIndex(Collection attributes, Constructor ctor, int parameter)
private void
addIndex(Collection attributes, Field field)
private void
addIndex(Collection attributes, Method method)
private void
addIndex(Collection attributes, Method method, int parameter)
private void
addReturnIndex(Collection attributes, Method method)
Collection
getClasses(Class attributeClass)
Gets a Collection of the Classes that have an attribute of the specified class.
Collection
getClassesWithAttribute(Class attributeClass)
Deprecated. Use the getClasses(Class) method instead.
Collection
getClassesWithAttribute(String attributeClass)
Deprecated. Use the getClasses(Class) method instead.
Collection
getConstructorParameters(Class attributeClass)
Gets a Collection of the ConstructorParameters that have an attribute of the specified class.
Collection
getConstructors(Class attributeClass)
Gets a Collection of the Constructors that have an attribute of the specified class.
Collection
getFields(Class attributeClass)
Gets a Collection of the Fields that have an attribute of the specified class.
Collection
getMethodParameters(Class attributeClass)
Gets a Collection of the MethodParameters that have an attribute of the specified class.
Collection
getMethods(Class attributeClass)
Gets a Collection of the Methods that have an attribute of the specified class.
Collection
getMethodsReturning(Class attributeClass)
Gets a Collection of the Methods whose return value has an attribute of the specified class.
private AttributeIndex.IndexNode
getNode(Class attributeClass)
private void
loadFromURL(URL url)
Load the attrs.index from a given URL.

Field Details

classLoader

private final ClassLoader classLoader

index

private final HashMap index

Constructor Details

AttributeIndex

public AttributeIndex(ClassLoader cl)
            throws Exception
Creates a new AttributeIndex for the given ClassLoader.
Since:
2.1

Method Details

addClass

private void addClass(String clazzName)
            throws Exception
Add a class to the index.

addIndex

private void addIndex(Collection attributes,
                      Class clazz)

addIndex

private void addIndex(Collection attributes,
                      Constructor constructor)

addIndex

private void addIndex(Collection attributes,
                      Constructor ctor,
                      int parameter)

addIndex

private void addIndex(Collection attributes,
                      Field field)

addIndex

private void addIndex(Collection attributes,
                      Method method)

addIndex

private void addIndex(Collection attributes,
                      Method method,
                      int parameter)

addReturnIndex

private void addReturnIndex(Collection attributes,
                            Method method)

getClasses

public Collection getClasses(Class attributeClass)
Gets a Collection of the Classes that have an attribute of the specified class. The Collection contains the classes (Class).
Since:
2.1

getClassesWithAttribute

public Collection getClassesWithAttribute(Class attributeClass)

Deprecated. Use the getClasses(Class) method instead.

Gets a Collection of the classes that have an attribute of the specified class. The Collection contains the class names (String).

getClassesWithAttribute

public Collection getClassesWithAttribute(String attributeClass)

Deprecated. Use the getClasses(Class) method instead.

Gets a Collection of the classes that have an attribute of the specified class. The Collection contains the class names (String).
Since:
2.1

getConstructorParameters

public Collection getConstructorParameters(Class attributeClass)
Since:
2.1

getConstructors

public Collection getConstructors(Class attributeClass)
Gets a Collection of the Constructors that have an attribute of the specified class. The Collection contains the methods (java.lang.reflect.Constructor).
Since:
2.1

getFields

public Collection getFields(Class attributeClass)
Gets a Collection of the Fields that have an attribute of the specified class. The Collection contains the methods (java.lang.reflect.Field).
Since:
2.1

getMethodParameters

public Collection getMethodParameters(Class attributeClass)
Since:
2.1

getMethods

public Collection getMethods(Class attributeClass)
Gets a Collection of the Methods that have an attribute of the specified class. The Collection contains the methods (java.lang.reflect.Method).
Since:
2.1

getMethodsReturning

public Collection getMethodsReturning(Class attributeClass)
Gets a Collection of the Methods whose return value has an attribute of the specified class. The Collection contains the methods (java.lang.reflect.Method).
Since:
2.1

getNode

private AttributeIndex.IndexNode getNode(Class attributeClass)

loadFromURL

private void loadFromURL(URL url)
            throws Exception
Load the attrs.index from a given URL.
Since:
2.1