Class FromAnnotationsRuleSet
- java.lang.Object
-
- org.apache.commons.digester.annotations.FromAnnotationsRuleSet
-
-
Field Summary
Fields Modifier and Type Field Description private DigesterLoader
digesterLoader
private java.util.Set<java.lang.Class<?>>
mappedClasses
Maintains all the classes that this RuleSet produces mapping for.private java.lang.String
namespaceURI
The namespace URI.private java.util.Map<java.lang.String,java.util.List<AnnotationRuleProvider<java.lang.annotation.Annotation,java.lang.reflect.AnnotatedElement,Rule>>>
rules
The data structure that stores the patterns/AnnotationRuleProvider
pairs.
-
Constructor Summary
Constructors Modifier Constructor Description protected
FromAnnotationsRuleSet(DigesterLoader digesterLoader)
Created a newFromAnnotationsRuleSet
instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
addMappedClass(java.lang.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 specifiedDigester
instance, 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 anAnnotationRuleProvider
for a specific pattern.void
addRuleProvider(java.lang.String pattern, AnnotationRuleProvider<? extends java.lang.annotation.Annotation,? extends java.lang.reflect.AnnotatedElement,? extends Rule> ruleProvider)
Register anAnnotationRuleProvider
for a specific pattern.void
addRules(java.lang.Class<?> target)
Analyzes the target class and adds theAnnotationRuleProvider
s to thisFromAnnotationsRuleSet
.void
addRulesProviderFrom(FromAnnotationsRuleSet ruleSet)
Add createdAnnotationRuleProvider
s created in another analysis session.java.lang.String
getNamespaceURI()
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 theAnnotationRuleProvider
for the input pattern.private java.util.Map<java.lang.String,java.util.List<AnnotationRuleProvider<java.lang.annotation.Annotation,java.lang.reflect.AnnotatedElement,Rule>>>
getRules()
Returns the data structure the patterns/AnnotationRuleProvider
pairs.protected boolean
mapsClass(java.lang.Class<?> clazz)
Checks if this RuleSet builds Digester mapping rules for the input type.void
setNamespaceURI(java.lang.String namespaceURI)
Sets the namespace URI that will be applied to all Rule instances created from this RuleSet.java.lang.String
toString()
-
-
-
Field Detail
-
rules
private final java.util.Map<java.lang.String,java.util.List<AnnotationRuleProvider<java.lang.annotation.Annotation,java.lang.reflect.AnnotatedElement,Rule>>> rules
The data structure that stores the patterns/AnnotationRuleProvider
pairs.
-
mappedClasses
private final java.util.Set<java.lang.Class<?>> mappedClasses
Maintains all the classes that this RuleSet produces mapping for.
-
digesterLoader
private final DigesterLoader digesterLoader
-
namespaceURI
private volatile java.lang.String namespaceURI
The namespace URI.
-
-
Constructor Detail
-
FromAnnotationsRuleSet
protected FromAnnotationsRuleSet(DigesterLoader digesterLoader)
Created a newFromAnnotationsRuleSet
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 specifiedDigester
instance, associating them with our namespace URI (if any). This method should only be called by a Digester instance.- Specified by:
addRuleInstances
in 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 theAnnotationRuleProvider
s 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 anAnnotationRuleProvider
for a specific pattern.- Type Parameters:
T
- theAnnotationRuleProvider
type.- Parameters:
pattern
- the pattern has to be associated to the rule provider.klass
- theAnnotationRuleProvider
type 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 anAnnotationRuleProvider
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 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 theAnnotationRuleProvider
for the input pattern.- Type Parameters:
T
- theAnnotationRuleProvider
type- Parameters:
pattern
- the input patternproviderClass
- theAnnotationRuleProvider
class- Returns:
- an
AnnotationRuleProvider
for the input pattern if found, null otherwise.
-
addRulesProviderFrom
public void addRulesProviderFrom(FromAnnotationsRuleSet ruleSet)
Add createdAnnotationRuleProvider
s created in another analysis session.- Parameters:
ruleSet
- theRuleSet
created 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.
-
getRules
private java.util.Map<java.lang.String,java.util.List<AnnotationRuleProvider<java.lang.annotation.Annotation,java.lang.reflect.AnnotatedElement,Rule>>> getRules()
Returns the data structure the patterns/AnnotationRuleProvider
pairs.- Returns:
- the data structure the patterns/
AnnotationRuleProvider
pairs.
-
getNamespaceURI
public java.lang.String getNamespaceURI()
Return the namespace URI that will be applied to all Rule instances created from this RuleSet.- Specified by:
getNamespaceURI
in 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:
toString
in classjava.lang.Object
-
-