org.apache.commons.attributes
Class AttributeIndex

java.lang.Object
  extended byorg.apache.commons.attributes.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.


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  java.lang.ClassLoader classLoader
           
private  java.util.HashMap index
           
 
Constructor Summary
AttributeIndex(java.lang.ClassLoader cl)
          Creates a new AttributeIndex for the given ClassLoader.
 
Method Summary
private  void addClass(java.lang.String clazzName)
          Add a class to the index.
private  void addIndex(java.util.Collection attributes, java.lang.Class clazz)
           
private  void addIndex(java.util.Collection attributes, java.lang.reflect.Constructor constructor)
           
private  void addIndex(java.util.Collection attributes, java.lang.reflect.Constructor ctor, int parameter)
           
private  void addIndex(java.util.Collection attributes, java.lang.reflect.Field field)
           
private  void addIndex(java.util.Collection attributes, java.lang.reflect.Method method)
           
private  void addIndex(java.util.Collection attributes, java.lang.reflect.Method method, int parameter)
           
private  void addReturnIndex(java.util.Collection attributes, java.lang.reflect.Method method)
           
 java.util.Collection getClasses(java.lang.Class attributeClass)
          Gets a Collection of the Classes that have an attribute of the specified class.
 java.util.Collection getClassesWithAttribute(java.lang.Class attributeClass)
          Deprecated. Use the getClasses(Class) method instead.
 java.util.Collection getClassesWithAttribute(java.lang.String attributeClass)
          Deprecated. Use the getClasses(Class) method instead.
 java.util.Collection getConstructorParameters(java.lang.Class attributeClass)
          Gets a Collection of the ConstructorParameters that have an attribute of the specified class.
 java.util.Collection getConstructors(java.lang.Class attributeClass)
          Gets a Collection of the Constructors that have an attribute of the specified class.
 java.util.Collection getFields(java.lang.Class attributeClass)
          Gets a Collection of the Fields that have an attribute of the specified class.
 java.util.Collection getMethodParameters(java.lang.Class attributeClass)
          Gets a Collection of the MethodParameters that have an attribute of the specified class.
 java.util.Collection getMethods(java.lang.Class attributeClass)
          Gets a Collection of the Methods that have an attribute of the specified class.
 java.util.Collection getMethodsReturning(java.lang.Class attributeClass)
          Gets a Collection of the Methods whose return value has an attribute of the specified class.
private  AttributeIndex.IndexNode getNode(java.lang.Class attributeClass)
           
private  void loadFromURL(java.net.URL url)
          Load the attrs.index from a given URL.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

index

private final java.util.HashMap index

classLoader

private final java.lang.ClassLoader classLoader
Constructor Detail

AttributeIndex

public AttributeIndex(java.lang.ClassLoader cl)
               throws java.lang.Exception
Creates a new AttributeIndex for the given ClassLoader.

Method Detail

getNode

private AttributeIndex.IndexNode getNode(java.lang.Class attributeClass)

addIndex

private void addIndex(java.util.Collection attributes,
                      java.lang.Class clazz)

addIndex

private void addIndex(java.util.Collection attributes,
                      java.lang.reflect.Field field)

addIndex

private void addIndex(java.util.Collection attributes,
                      java.lang.reflect.Method method)

addIndex

private void addIndex(java.util.Collection attributes,
                      java.lang.reflect.Constructor constructor)

addReturnIndex

private void addReturnIndex(java.util.Collection attributes,
                            java.lang.reflect.Method method)

addIndex

private void addIndex(java.util.Collection attributes,
                      java.lang.reflect.Method method,
                      int parameter)

addIndex

private void addIndex(java.util.Collection attributes,
                      java.lang.reflect.Constructor ctor,
                      int parameter)

addClass

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

Throws:
java.lang.Exception

loadFromURL

private void loadFromURL(java.net.URL url)
                  throws java.lang.Exception
Load the attrs.index from a given URL.

Throws:
java.lang.Exception

getClassesWithAttribute

public java.util.Collection getClassesWithAttribute(java.lang.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).


getClassesWithAttribute

public java.util.Collection getClassesWithAttribute(java.lang.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).


getClasses

public java.util.Collection getClasses(java.lang.Class attributeClass)
Gets a Collection of the Classes that have an attribute of the specified class. The Collection contains the classes (Class).


getMethods

public java.util.Collection getMethods(java.lang.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).


getMethodsReturning

public java.util.Collection getMethodsReturning(java.lang.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).


getFields

public java.util.Collection getFields(java.lang.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).


getConstructors

public java.util.Collection getConstructors(java.lang.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).


getConstructorParameters

public java.util.Collection getConstructorParameters(java.lang.Class attributeClass)
Gets a Collection of the ConstructorParameters that have an attribute of the specified class. The Collection contains the methods (AttributeIndex.ConstructorParameter).


getMethodParameters

public java.util.Collection getMethodParameters(java.lang.Class attributeClass)
Gets a Collection of the MethodParameters that have an attribute of the specified class. The Collection contains the methods (AttributeIndex.MethodParameter).