Class FromAnnotationsRuleSet
- java.lang.Object
-
- org.apache.commons.digester.annotations.FromAnnotationsRuleSet
-
- All Implemented Interfaces:
RuleSet
public final class FromAnnotationsRuleSet extends java.lang.Object implements RuleSet
- Since:
- 2.1
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedFromAnnotationsRuleSet(DigesterLoader digesterLoader)Created a newFromAnnotationsRuleSetinstance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidaddMappedClass(java.lang.Class<?> clazz)Remember that this RuleSet is able to build Digester mapping rules for the input type.voidaddRuleInstances(Digester digester)Add the set of Rule instances defined in this RuleSet to the specifiedDigesterinstance, associating them with our namespace URI (if any).<A extends java.lang.annotation.Annotation,E extends java.lang.reflect.AnnotatedElement,R extends Rule,T extends AnnotationRuleProvider<A,E,R>>
voidaddRuleProvider(java.lang.String pattern, java.lang.Class<T> klass, A annotation, E element)Builds and register anAnnotationRuleProviderfor a specific pattern.voidaddRuleProvider(java.lang.String pattern, AnnotationRuleProvider<? extends java.lang.annotation.Annotation,? extends java.lang.reflect.AnnotatedElement,? extends Rule> ruleProvider)Register anAnnotationRuleProviderfor a specific pattern.voidaddRules(java.lang.Class<?> target)Analyzes the target class and adds theAnnotationRuleProviders to thisFromAnnotationsRuleSet.voidaddRulesProviderFrom(FromAnnotationsRuleSet ruleSet)Add createdAnnotationRuleProviders created in another analysis session.java.lang.StringgetNamespaceURI()Return the namespace URI that will be applied to all Rule instances created from this RuleSet.<T extends AnnotationRuleProvider<? extends java.lang.annotation.Annotation,? extends java.lang.reflect.AnnotatedElement,? extends Rule>>
TgetProvider(java.lang.String pattern, java.lang.Class<T> providerClass)Retrieves a specific instance of theAnnotationRuleProviderfor the input pattern.protected booleanmapsClass(java.lang.Class<?> clazz)Checks if this RuleSet builds Digester mapping rules for the input type.voidsetNamespaceURI(java.lang.String namespaceURI)Sets the namespace URI that will be applied to all Rule instances created from this RuleSet.java.lang.StringtoString()
-
-
-
Constructor Detail
-
FromAnnotationsRuleSet
protected FromAnnotationsRuleSet(DigesterLoader digesterLoader)
Created a newFromAnnotationsRuleSetinstance.- 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 specifiedDigesterinstance, associating them with our namespace URI (if any). This method should only be called by a Digester instance.- Specified by:
addRuleInstancesin interfaceRuleSet- Parameters:
digester- Digester instance to which the new Rule instances should be added.
-
addRules
public void addRules(java.lang.Class<?> target)
Analyzes the target class and adds theAnnotationRuleProviders to thisFromAnnotationsRuleSet.- Parameters:
target- the class has to be analyzed.
-
addRuleProvider
public <A extends java.lang.annotation.Annotation,E extends java.lang.reflect.AnnotatedElement,R extends Rule,T extends AnnotationRuleProvider<A,E,R>> void addRuleProvider(java.lang.String pattern, java.lang.Class<T> klass, A annotation, E element)
Builds and register anAnnotationRuleProviderfor a specific pattern.- Type Parameters:
T- theAnnotationRuleProvidertype.- Parameters:
pattern- the pattern has to be associated to the rule provider.klass- theAnnotationRuleProvidertype has to be instantiated.annotation- the current visited annotation.element- the current visited element.
-
addRuleProvider
public void addRuleProvider(java.lang.String pattern, AnnotationRuleProvider<? extends java.lang.annotation.Annotation,? extends java.lang.reflect.AnnotatedElement,? extends Rule> ruleProvider)
Register anAnnotationRuleProviderfor 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 java.lang.annotation.Annotation,? extends java.lang.reflect.AnnotatedElement,? extends Rule>> T getProvider(java.lang.String pattern, java.lang.Class<T> providerClass)
Retrieves a specific instance of theAnnotationRuleProviderfor the input pattern.- Type Parameters:
T- theAnnotationRuleProvidertype- Parameters:
pattern- the input patternproviderClass- theAnnotationRuleProviderclass- Returns:
- an
AnnotationRuleProviderfor the input pattern if found, null otherwise.
-
addRulesProviderFrom
public void addRulesProviderFrom(FromAnnotationsRuleSet ruleSet)
Add createdAnnotationRuleProviders created in another analysis session.- Parameters:
ruleSet- theRuleSetcreated in another analysis session.
-
mapsClass
protected boolean mapsClass(java.lang.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(java.lang.Class<?> clazz)
Remember that this RuleSet is able to build Digester mapping rules for the input type.- Parameters:
clazz- the input type.
-
getNamespaceURI
public java.lang.String getNamespaceURI()
Return the namespace URI that will be applied to all Rule instances created from this RuleSet.- Specified by:
getNamespaceURIin interfaceRuleSet
-
setNamespaceURI
public void setNamespaceURI(java.lang.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 java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-