ch.elca.el4j.util.metadata
Class MetaDataCollector

java.lang.Object
  extended by ch.elca.el4j.util.metadata.MetaDataCollector
All Implemented Interfaces:
Attributes, InitializingBean

public class MetaDataCollector
extends Object
implements Attributes, InitializingBean

Depending to the used kind of metadata, it can be defined on a field, on a method, on a class, and on a package. The used kinds of metadata are the Commons Attributes and the Java 5 Annotations. Both can handle metadata defined on a field, on a method, and on a class.

This class collects metadata from different classes. The examples below show you how the metadata is collected.

 public interface X {
     public int getValue();
 }

 public interface Y {
     public int getValue();
 }

 public class A implements X {
     public int getValue() {...}
 }

 public class B extends A implements Y {
     public int getValue() {...}
 }

 public class C extends B {
     public int getValue() {...}
 }
 

If metadata for method getValue() of Class C is requested, the result will be a collection of metadata from class C and interfaces Y and X. Metadata defined in class A and B will be omitted.

The same behavior can be found with metadata on class level. The collection of metadata will also only contain metadata defined on class C and interfaces Y and X.

Always the most specific implementation and all interfaces will be inspected.

Author:
Martin Zeltner (MZE)
File-location:
MetaDataCollector
Last check-in date:
2010-01-15 12:21:07 +0100 (Fr, 15. Jan 2010) by jonasha for revision 4091

Constructor Summary
MetaDataCollector()
           
 
Method Summary
 void afterPropertiesSet()
          
 Collection getAttributes(Class targetClass)
          Return the class attributes of the target class.
 Collection getAttributes(Class targetClass, Class filter)
          Return the class attributes of the target class of a given type.
 Collection getAttributes(Field targetField)
          Directly calls the metadata delegator.
 Collection getAttributes(Field targetField, Class filter)
          Directly calls the metadata delegator.
 Collection getAttributes(Method targetMethod)
          Return the method attributes of the target method.
 Collection getAttributes(Method targetMethod, Class filter)
          Return the method attributes of the target method of a given type.
 Attributes getMetaDataDelegator()
           
 void setMetaDataDelegator(Attributes metaDataDelegator)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MetaDataCollector

public MetaDataCollector()
Method Detail

getMetaDataDelegator

public Attributes getMetaDataDelegator()
Returns:
Returns the metaDataDelegator.

setMetaDataDelegator

public void setMetaDataDelegator(Attributes metaDataDelegator)
Parameters:
metaDataDelegator - Is the metaDataDelegator to set.

getAttributes

public Collection getAttributes(Class targetClass)
Return the class attributes of the target class.

Specified by:
getAttributes in interface Attributes
Parameters:
targetClass - the class that contains attribute information
Returns:
a collection of attributes, possibly an empty collection, never null

getAttributes

public Collection getAttributes(Class targetClass,
                                Class filter)
Return the class attributes of the target class of a given type.

The class attributes are filtered by providing a Class reference to indicate the type to filter on. This is useful if you know the type of the attribute you are looking for and don't want to sort through the unfiltered Collection yourself.

Specified by:
getAttributes in interface Attributes
Parameters:
targetClass - the class that contains attribute information
filter - specify that only this type of class should be returned
Returns:
return only the Collection of attributes that are of the filter type

getAttributes

public Collection getAttributes(Method targetMethod)
Return the method attributes of the target method.

Specified by:
getAttributes in interface Attributes
Parameters:
targetMethod - the method that contains attribute information
Returns:
a Collection of attributes, possibly an empty Collection, never null

getAttributes

public Collection getAttributes(Method targetMethod,
                                Class filter)
Return the method attributes of the target method of a given type.

The method attributes are filtered by providing a Class reference to indicate the type to filter on. This is useful if you know the type of the attribute you are looking for and don't want to sort through the unfiltered Collection yourself.

Specified by:
getAttributes in interface Attributes
Parameters:
targetMethod - the method that contains attribute information
filter - specify that only this type of class should be returned
Returns:
a Collection of attributes, possibly an empty Collection, never null

getAttributes

public Collection getAttributes(Field targetField)
Directly calls the metadata delegator. Return the field attributes of the target field.

Specified by:
getAttributes in interface Attributes
Parameters:
targetField - the field that contains attribute information
Returns:
a Collection of attribute, possibly an empty Collection, never null

getAttributes

public Collection getAttributes(Field targetField,
                                Class filter)
Directly calls the metadata delegator. Return the field attributes of the target method of a given type.

The field attributes are filtered by providing a Class reference to indicate the type to filter on. This is useful if you know the type of the attribute you are looking for and don't want to sort through the unfiltered Collection yourself.

Specified by:
getAttributes in interface Attributes
Parameters:
targetField - the field that contains attribute information
filter - specify that only this type of class should be returned
Returns:
a Collection of attributes, possibly an empty Collection, never null

afterPropertiesSet

public void afterPropertiesSet()
                        throws Exception

Specified by:
afterPropertiesSet in interface InitializingBean
Throws:
Exception


Copyright © 2005-2011 ELCA. All Rights Reserved.