com.ideanest.attributes
Class Attributes

java.lang.Object
  extended bycom.ideanest.attributes.Attributes
Direct Known Subclasses:
AttributesImpl

public abstract class Attributes
extends java.lang.Object

The singleton access point to attributes set on various program elements.

Note that there are two matching sets of accessor methods: one takes reflected objects, the other strings. The two sets are roughly equivalent, however it is best to use the reflected versions of the accessors whenever possible, since it is impossible to pass an illegal argument to them. The string set is provided in case it is necessary to retrieve attributes for elements without forcing the containing class to be loaded. Accessors from this set will not check whether the specified element actually exists, since that would require loading it. They may also be unable to resolve attribute inheritance.

All implementations must be thread-safe.

Version:
$Revision: 1.2 $ ($Date: 2003/07/31 07:47:23 $)
Author:
Piotr Kaminski

Field Summary
static java.lang.String DEFAULT_IMPL_CLASS_NAME
           
static java.lang.String IMPL_CLASS_NAME_PROPKEY
           
 
Constructor Summary
Attributes()
           
 
Method Summary
abstract  Bundle get(java.lang.Class klass)
          Get the attributes bundle for the given class.
abstract  Bundle get(java.lang.reflect.Constructor constructor)
          Get the attributes bundle for the given constructor.
abstract  Bundle get(java.lang.reflect.Field field)
          Get the attributes bundle for the given field.
abstract  Bundle get(java.lang.reflect.Method method)
          Get the attributes bundle for the given method.
abstract  Bundle getClass(java.lang.String className, java.lang.ClassLoader classLoader)
          Get the bundle of attributes for the given class.
abstract  Bundle getConstructor(java.lang.String className, java.lang.String constructorSignature, java.lang.ClassLoader classLoader)
          Get the bundle of attributes for the given constructor.
abstract  Bundle getField(java.lang.String className, java.lang.String fieldName, java.lang.ClassLoader classLoader)
          The the bundle of attributes for the given field.
static Attributes getInstance()
          Get the singleton instance of the Attributes class.
abstract  Bundle getMethod(java.lang.String className, java.lang.String methodSignature, java.lang.ClassLoader classLoader)
          Get the bundle of attributes for the given method.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_IMPL_CLASS_NAME

public static final java.lang.String DEFAULT_IMPL_CLASS_NAME
See Also:
Constant Field Values

IMPL_CLASS_NAME_PROPKEY

public static final java.lang.String IMPL_CLASS_NAME_PROPKEY
See Also:
Constant Field Values
Constructor Detail

Attributes

public Attributes()
Method Detail

get

public abstract Bundle get(java.lang.Class klass)
Get the attributes bundle for the given class.

Parameters:
klass - the class for which attributes are needed
Returns:
the attributes for the desired class, possibly an empty bundle if none were found

get

public abstract Bundle get(java.lang.reflect.Constructor constructor)
Get the attributes bundle for the given constructor.

Parameters:
constructor - the constructor for which attributes are needed
Returns:
the attributes for the desired constructor, possibly an empty bundle if none were found

get

public abstract Bundle get(java.lang.reflect.Field field)
Get the attributes bundle for the given field.

Parameters:
field - the field for which attributes are needed
Returns:
the attributes for the desired field, possibly an empty bundle if none were found

get

public abstract Bundle get(java.lang.reflect.Method method)
Get the attributes bundle for the given method.

Parameters:
method - the method for which attributes are needed
Returns:
the attributes for the desired method, possibly an empty bundle if none were found

getClass

public abstract Bundle getClass(java.lang.String className,
                                java.lang.ClassLoader classLoader)
Get the bundle of attributes for the given class. The class name must be fully qualified with the class' package. For nested classes, use '$' to separate the parent and nested class names.

Parameters:
className - the fully qualified name of the class
classLoader - the class loader to use when fetching attribute descriptors, if null use the thread's context class loader
Returns:
the bundle of attributes for the class matching the given name

getConstructor

public abstract Bundle getConstructor(java.lang.String className,
                                      java.lang.String constructorSignature,
                                      java.lang.ClassLoader classLoader)
Get the bundle of attributes for the given constructor. The name of the class to which the constructor belongs must be provided as for @link{#getClass}. The parameter type list must be provided as for @link{#getMethod}, but with the method name omitted. For example, "java.lang.Thread.<init>(java.lang.Runnable,java.lang.String)".

Parameters:
className - the fully qualified name of the constructor's class
constructorSignature - the parameter types of the desired constructor
classLoader - the class loader to use when fetching attribute descriptors, if null use the thread's context class loader
Returns:
the bundle of attributes for the constructor matching the given name

getField

public abstract Bundle getField(java.lang.String className,
                                java.lang.String fieldName,
                                java.lang.ClassLoader classLoader)
The the bundle of attributes for the given field.

Parameters:
className - the fully qualified name of the field's class
fieldName - the name of the desired field
classLoader - the class loader to use when fetching attribute descriptors, if null use the thread's context class loader
Returns:
the bundle of attributes for the field matching the given name

getInstance

public static Attributes getInstance()
                              throws java.lang.InstantiationException,
                                     java.lang.IllegalAccessException,
                                     java.lang.ClassNotFoundException
Get the singleton instance of the Attributes class. The first time this method is called, the class specified by the value of the system property keyed with IMPL_CLASS_NAME_PROPKEY will be instantiated. If not such property is defined, the default class will be instantiated.

Returns:
the singleton instance of Attributes
Throws:
java.lang.InstantiationException - if unable to instantiate the implementation class
java.lang.IllegalAccessException - if unable to access the implementation class
java.lang.ClassNotFoundException - if unable to find the implementation class

getMethod

public abstract Bundle getMethod(java.lang.String className,
                                 java.lang.String methodSignature,
                                 java.lang.ClassLoader classLoader)
Get the bundle of attributes for the given method. The name of the class to which the method belongs must be provided as for @link{#getClass}. The method's signature consists of the method name and the parameter type list in parentheses. Each parameter type is a fully qualified type name encoded according to the rules of Class.getName(). The parameter types are separated by commas, with no spaces. The return type is not listed. Methods with no parameters must include an empty parameter list, '()'.

Parameters:
className - the fully qualified name of the method's class
methodSignature - the name and parameter types of the desired method
classLoader - the class loader to use when fetching attribute descriptors, if null use the thread's context class loader
Returns:
the bundle of attributes for the method matching the given name
See Also:
getClass(String,ClassLoader)