org.apache.commons.digester.annotations
Class FromAnnotationsRuleSet

java.lang.Object
  extended by org.apache.commons.digester.annotations.FromAnnotationsRuleSet
All Implemented Interfaces:
RuleSet

public final class FromAnnotationsRuleSet
extends Object
implements RuleSet

A RuleSet implementation that's able to inject Rules created with the annotations analysis.

Since:
2.1

Constructor Summary
protected FromAnnotationsRuleSet(DigesterLoader digesterLoader)
          Created a new FromAnnotationsRuleSet instance.
 
Method Summary
protected  void addMappedClass(Class<?> clazz)
          Remember that this RuleSet is able to build Digester mapping rules for the input type.
 void addRuleInstances(Digester digester)
          Add the set of Rule instances defined in this RuleSet to the specified Digester instance, associating them with our namespace URI (if any).
 void addRuleProvider(String pattern, AnnotationRuleProvider<? extends Annotation,? extends AnnotatedElement,? extends Rule> ruleProvider)
          Register an AnnotationRuleProvider for a specific pattern.
<A extends Annotation,E extends AnnotatedElement,R extends Rule,T extends AnnotationRuleProvider<A,E,R>>
void
addRuleProvider(String pattern, Class<T> klass, A annotation, E element)
          Builds and register an AnnotationRuleProvider for a specific pattern.
 void addRules(Class<?> target)
          Analyzes the target class and adds the AnnotationRuleProviders to this FromAnnotationsRuleSet.
 void addRulesProviderFrom(FromAnnotationsRuleSet ruleSet)
          Add created AnnotationRuleProviders created in another analysis session.
 String getNamespaceURI()
          Return the namespace URI that will be applied to all Rule instances created from this RuleSet.
<T extends AnnotationRuleProvider<? extends Annotation,? extends AnnotatedElement,? extends Rule>>
T
getProvider(String pattern, Class<T> providerClass)
          Retrieves a specific instance of the AnnotationRuleProvider for the input pattern.
protected  boolean mapsClass(Class<?> clazz)
          Checks if this RuleSet builds Digester mapping rules for the input type.
 void setNamespaceURI(String namespaceURI)
          Sets the namespace URI that will be applied to all Rule instances created from this RuleSet.
 String toString()
          
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

FromAnnotationsRuleSet

protected FromAnnotationsRuleSet(DigesterLoader digesterLoader)
Created a new FromAnnotationsRuleSet instance.

Parameters:
digesterLoader - the parent DigesterLoader.
Method Detail

addRuleInstances

public void addRuleInstances(Digester digester)
Add the set of Rule instances defined in this RuleSet to the specified Digester instance, associating them with our namespace URI (if any). This method should only be called by a Digester instance.

Specified by:
addRuleInstances in interface RuleSet
Parameters:
digester - Digester instance to which the new Rule instances should be added.

addRules

public void addRules(Class<?> target)
Analyzes the target class and adds the AnnotationRuleProviders to this FromAnnotationsRuleSet.

Parameters:
target - the class has to be analyzed.

addRuleProvider

public <A extends Annotation,E extends AnnotatedElement,R extends Rule,T extends AnnotationRuleProvider<A,E,R>> void addRuleProvider(String pattern,
                                                                                                                                     Class<T> klass,
                                                                                                                                     A annotation,
                                                                                                                                     E element)
Builds and register an AnnotationRuleProvider for a specific pattern.

Type Parameters:
T - the AnnotationRuleProvider type.
Parameters:
pattern - the pattern has to be associated to the rule provider.
klass - the AnnotationRuleProvider type has to be instantiated.
annotation - the current visited annotation.
element - the current visited element.

addRuleProvider

public void addRuleProvider(String pattern,
                            AnnotationRuleProvider<? extends Annotation,? extends AnnotatedElement,? extends Rule> ruleProvider)
Register an AnnotationRuleProvider for a specific pattern.

Parameters:
pattern - the pattern has to be associated to the rule provider.
ruleProvider - the provider that builds the digester rule.

getProvider

public <T extends AnnotationRuleProvider<? extends Annotation,? extends AnnotatedElement,? extends Rule>> T getProvider(String pattern,
                                                                                                                        Class<T> providerClass)
Retrieves a specific instance of the AnnotationRuleProvider for the input pattern.

Type Parameters:
T - the AnnotationRuleProvider type
Parameters:
pattern - the input pattern
providerClass - the AnnotationRuleProvider class
Returns:
an AnnotationRuleProvider for the input pattern if found, null otherwise.

addRulesProviderFrom

public void addRulesProviderFrom(FromAnnotationsRuleSet ruleSet)
Add created AnnotationRuleProviders created in another analysis session.

Parameters:
ruleSet - the RuleSet created in another analysis session.

mapsClass

protected boolean mapsClass(Class<?> clazz)
Checks if this RuleSet builds Digester mapping rules for the input type.

Parameters:
clazz - the input type.
Returns:
true, if this RuleSet builds Digester mapping rules for the input type, false otherwise.

addMappedClass

protected void addMappedClass(Class<?> clazz)
Remember that this RuleSet is able to build Digester mapping rules for the input type.

Parameters:
clazz - the input type.

getNamespaceURI

public String getNamespaceURI()
Return the namespace URI that will be applied to all Rule instances created from this RuleSet.

Specified by:
getNamespaceURI in interface RuleSet

setNamespaceURI

public void setNamespaceURI(String namespaceURI)
Sets the namespace URI that will be applied to all Rule instances created from this RuleSet.

Parameters:
namespaceURI - the namespace URI that will be applied to all Rule instances created from this RuleSet.

toString

public String toString()

Overrides:
toString in class Object


Copyright © 2001-2010 The Apache Software Foundation. All Rights Reserved.