You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by si...@apache.org on 2011/05/12 20:03:33 UTC
svn commit: r1102402 [7/20] - in /commons/sandbox/digester3/trunk/src:
main/java/org/apache/commons/digester3/
main/java/org/apache/commons/digester3/annotations/
main/java/org/apache/commons/digester3/annotations/handlers/
main/java/org/apache/commons...
Modified: commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/SimpleRegexMatcher.java
URL: http://svn.apache.org/viewvc/commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/SimpleRegexMatcher.java?rev=1102402&r1=1102401&r2=1102402&view=diff
==============================================================================
--- commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/SimpleRegexMatcher.java (original)
+++ commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/SimpleRegexMatcher.java Thu May 12 18:03:26 2011
@@ -22,133 +22,153 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/**
- * <p>Simple regex pattern matching algorithm.</p>
- *
- * <p>This uses just two wildcards:
+ * <p>
+ * Simple regex pattern matching algorithm.
+ * </p>
+ * <p>
+ * This uses just two wildcards:
* <ul>
- * <li><code>*</code> matches any sequence of none, one or more characters
- * <li><code>?</code> matches any one character
+ * <li><code>*</code> matches any sequence of none, one or more characters
+ * <li><code>?</code> matches any one character
* </ul>
- * Escaping these wildcards is not supported .</p>
- *
+ * Escaping these wildcards is not supported .
+ * </p>
+ *
* @since 1.5
*/
-public class SimpleRegexMatcher extends RegexMatcher {
-
+public class SimpleRegexMatcher
+ extends RegexMatcher
+{
+
// --------------------------------------------------------- Fields
-
+
/** Default log (class wide) */
- private static final Log baseLog = LogFactory.getLog(SimpleRegexMatcher.class);
-
+ private static final Log baseLog = LogFactory.getLog( SimpleRegexMatcher.class );
+
/** Custom log (can be set per object) */
private Log log = baseLog;
-
+
// --------------------------------------------------------- Properties
-
- /**
+
+ /**
* Gets the <code>Log</code> implementation.
*/
- public Log getLog() {
+ public Log getLog()
+ {
return log;
}
-
+
/**
* Sets the current <code>Log</code> implementation used by this class.
*/
- public void setLog(Log log) {
+ public void setLog( Log log )
+ {
this.log = log;
}
-
+
// --------------------------------------------------------- Public Methods
-
- /**
+
+ /**
* Matches using simple regex algorithm.
*
- *
* @param basePattern the standard digester path representing the element
* @param regexPattern the regex pattern the path will be tested against
* @return true if the given pattern matches the given path
*/
@Override
- public boolean match(String basePattern, String regexPattern) {
+ public boolean match( String basePattern, String regexPattern )
+ {
// check for nulls
- if (basePattern == null || regexPattern == null) {
+ if ( basePattern == null || regexPattern == null )
+ {
return false;
}
- return match(basePattern, regexPattern, 0, 0);
+ return match( basePattern, regexPattern, 0, 0 );
}
-
+
// --------------------------------------------------------- Implementations Methods
-
+
/**
- * Implementation of regex matching algorithm.
- * This calls itself recursively.
+ * Implementation of regex matching algorithm. This calls itself recursively.
*/
- private boolean match(String basePattern, String regexPattern, int baseAt, int regexAt) {
- if (log.isTraceEnabled()) {
- log.trace("Base: " + basePattern);
- log.trace("Regex: " + regexPattern);
- log.trace("Base@" + baseAt);
- log.trace("Regex@" + regexAt);
+ private boolean match( String basePattern, String regexPattern, int baseAt, int regexAt )
+ {
+ if ( log.isTraceEnabled() )
+ {
+ log.trace( "Base: " + basePattern );
+ log.trace( "Regex: " + regexPattern );
+ log.trace( "Base@" + baseAt );
+ log.trace( "Regex@" + regexAt );
}
-
+
// check bounds
- if (regexAt >= regexPattern.length()) {
+ if ( regexAt >= regexPattern.length() )
+ {
// maybe we've got a match
- if (baseAt >= basePattern.length()) {
+ if ( baseAt >= basePattern.length() )
+ {
// ok!
return true;
}
// run out early
return false;
-
+
}
- if (baseAt >= basePattern.length()) {
+ if ( baseAt >= basePattern.length() )
+ {
// run out early
return false;
}
-
+
// ok both within bounds
- char regexCurrent = regexPattern.charAt(regexAt);
- switch (regexCurrent) {
+ char regexCurrent = regexPattern.charAt( regexAt );
+ switch ( regexCurrent )
+ {
case '*':
// this is the tricky case
- // check for terminal
- if (++regexAt >= regexPattern.length()) {
+ // check for terminal
+ if ( ++regexAt >= regexPattern.length() )
+ {
// this matches anything let - so return true
return true;
}
// go through every subsequent apperance of the next character
// and so if the rest of the regex matches
- char nextRegex = regexPattern.charAt(regexAt);
- if (log.isTraceEnabled()) {
- log.trace("Searching for next '" + nextRegex + "' char");
+ char nextRegex = regexPattern.charAt( regexAt );
+ if ( log.isTraceEnabled() )
+ {
+ log.trace( "Searching for next '" + nextRegex + "' char" );
}
- int nextMatch = basePattern.indexOf(nextRegex, baseAt);
- while (nextMatch != -1) {
- if (log.isTraceEnabled()) {
- log.trace("Trying '*' match@" + nextMatch);
+ int nextMatch = basePattern.indexOf( nextRegex, baseAt );
+ while ( nextMatch != -1 )
+ {
+ if ( log.isTraceEnabled() )
+ {
+ log.trace( "Trying '*' match@" + nextMatch );
}
- if (match(basePattern, regexPattern, nextMatch, regexAt)) {
+ if ( match( basePattern, regexPattern, nextMatch, regexAt ) )
+ {
return true;
}
- nextMatch = basePattern.indexOf(nextRegex, nextMatch + 1);
+ nextMatch = basePattern.indexOf( nextRegex, nextMatch + 1 );
}
- log.trace("No matches found.");
+ log.trace( "No matches found." );
return false;
-
+
case '?':
// this matches anything
- return match(basePattern, regexPattern, ++baseAt, ++regexAt);
-
+ return match( basePattern, regexPattern, ++baseAt, ++regexAt );
+
default:
- if (log.isTraceEnabled()) {
- log.trace("Camparing " + regexCurrent + " to " + basePattern.charAt(baseAt));
+ if ( log.isTraceEnabled() )
+ {
+ log.trace( "Camparing " + regexCurrent + " to " + basePattern.charAt( baseAt ) );
}
- if (regexCurrent == basePattern.charAt(baseAt)) {
+ if ( regexCurrent == basePattern.charAt( baseAt ) )
+ {
// still got more to go
- return match(basePattern, regexPattern, ++baseAt, ++regexAt);
+ return match( basePattern, regexPattern, ++baseAt, ++regexAt );
}
return false;
}
Modified: commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/StackAction.java
URL: http://svn.apache.org/viewvc/commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/StackAction.java?rev=1102402&r1=1102401&r2=1102402&view=diff
==============================================================================
--- commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/StackAction.java (original)
+++ commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/StackAction.java Thu May 12 18:03:26 2011
@@ -16,63 +16,51 @@
* limitations under the License.
*/
-
package org.apache.commons.digester3;
/**
- * An interface that can be implemented in order to get notifications of
- * objects being pushed onto a digester stack or popped from one.
+ * An interface that can be implemented in order to get notifications of objects being pushed onto a digester stack or
+ * popped from one.
* <p>
- * Because objects are pushed onto the main object stack when a rule
- * has created a new object, this gives the ability to intercept such
- * operations and perform modifications on created objects.
+ * Because objects are pushed onto the main object stack when a rule has created a new object, this gives the ability to
+ * intercept such operations and perform modifications on created objects.
* <p>
- * One use expected for this interface is to store information about the xml
- * line that a particular object was created from. An implementation of this
- * interface can detect whenever an object is pushed onto the digester object
- * stack, call Digester.getDocumentLocator() to get the location within the
- * current xml file, and store this either on the object on the stack (if it
- * supports some user-specific interface for this purpose), or build a map of
+ * One use expected for this interface is to store information about the xml line that a particular object was created
+ * from. An implementation of this interface can detect whenever an object is pushed onto the digester object stack,
+ * call Digester.getDocumentLocator() to get the location within the current xml file, and store this either on the
+ * object on the stack (if it supports some user-specific interface for this purpose), or build a map of
* (object->locationinfo) separately.
* <p>
- * It is recommended that objects implementing this interface provide
- * a method to set a "next" action, and invoke it from the callback
- * methods. This allows multiple actions to be "chained" together.
+ * It is recommended that objects implementing this interface provide a method to set a "next" action, and invoke it
+ * from the callback methods. This allows multiple actions to be "chained" together.
* <p>
* See also Digester.setStackAction.
*
* @since 1.8
*/
-public interface StackAction {
+public interface StackAction
+{
/**
* Invoked just before an object is to be pushed onto a digester stack.
*
* @param d is the digester instance.
- *
- * @param stackName is the name of the stack onto which the object
- * has been pushed. Null is passed to indicate the default stack.
- *
- * @param o is the object that has just been pushed. Calling peek on the
- * specified stack will return the same object.
- *
- * @return the object to be pushed. Normally, parameter o is returned
- * but this method could return an alternate object to be pushed
- * instead (eg a proxy for the provided object).
+ * @param stackName is the name of the stack onto which the object has been pushed. Null is passed to indicate the
+ * default stack.
+ * @param o is the object that has just been pushed. Calling peek on the specified stack will return the same object.
+ * @return the object to be pushed. Normally, parameter o is returned but this method could return an alternate
+ * object to be pushed instead (eg a proxy for the provided object).
*/
- <T> T onPush(Digester d, String stackName, T o);
+ <T> T onPush( Digester d, String stackName, T o );
/**
* Invoked just after an object has been popped from a digester stack.
*
* @param d is the digester instance.
- *
- * @param stackName is the name of the stack from which the object
- * has been popped. Null is passed to indicate the default stack.
- *
+ * @param stackName is the name of the stack from which the object has been popped. Null is passed to indicate the
+ * default stack.
* @param o is the object that has just been popped.
- *
- * @return the object to be returned to the called. Normally, parameter
- * o is returned but this method could return an alternate object.
+ * @return the object to be returned to the called. Normally, parameter o is returned but this method could return an
+ * alternate object.
*/
- <T> T onPop(Digester d, String stackName, T o);
+ <T> T onPop( Digester d, String stackName, T o );
}
Modified: commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/Substitutor.java
URL: http://svn.apache.org/viewvc/commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/Substitutor.java?rev=1102402&r1=1102401&r2=1102402&view=diff
==============================================================================
--- commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/Substitutor.java (original)
+++ commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/Substitutor.java Thu May 12 18:03:26 2011
@@ -21,47 +21,47 @@ package org.apache.commons.digester3;
import org.xml.sax.Attributes;
/**
- * <p>(Logical) Interface for substitution strategies.
- * (It happens to be implemented as a Java abstract class to allow
+ * <p>
+ * (Logical) Interface for substitution strategies. (It happens to be implemented as a Java abstract class to allow
* future additions to be made without breaking backwards compatibility.)
* </p>
* <p>
- * Usage: When {@link Digester#setSubstitutor} is set, <code>Digester</code>
- * calls the methods in this interface to create substitute values which will
- * be passed into the Rule implementations.
- * Of course, it is perfectly acceptable for implementations not to make
- * substitutions and simply return the inputs.
+ * Usage: When {@link Digester#setSubstitutor} is set, <code>Digester</code> calls the methods in this interface to
+ * create substitute values which will be passed into the Rule implementations. Of course, it is perfectly acceptable
+ * for implementations not to make substitutions and simply return the inputs.
+ * </p>
+ * <p>
+ * Different strategies are supported for attributes and body text.
* </p>
- * <p>Different strategies are supported for attributes and body text.</p>
- *
- * @since 1.6
+ *
+ * @since 1.6
*/
-public abstract class Substitutor {
-
+public abstract class Substitutor
+{
+
/**
- * <p>Substitutes the attributes (before they are passed to the
- * <code>Rule</code> implementations's).</p>
- *
- * <p><code>Digester</code> will only call this method a second time
- * once the original <code>Attributes</code> instance can be safely reused.
- * The implementation is therefore free to reuse the same <code>Attributes</code> instance
- * for all calls.</p>
- *
- * @param attributes the <code>Attributes</code> passed into <code>Digester</code> by the SAX parser,
- * not null (but may be empty)
- * @return <code>Attributes</code> to be passed to the <code>Rule</code> implementations.
- * This method may pass back the Attributes passed in.
- * Not null but possibly empty.
+ * <p>
+ * Substitutes the attributes (before they are passed to the <code>Rule</code> implementations's).
+ * </p>
+ * <p>
+ * <code>Digester</code> will only call this method a second time once the original <code>Attributes</code> instance
+ * can be safely reused. The implementation is therefore free to reuse the same <code>Attributes</code> instance for
+ * all calls.
+ * </p>
+ *
+ * @param attributes the <code>Attributes</code> passed into <code>Digester</code> by the SAX parser, not null (but
+ * may be empty)
+ * @return <code>Attributes</code> to be passed to the <code>Rule</code> implementations. This method may pass back
+ * the Attributes passed in. Not null but possibly empty.
*/
- public abstract Attributes substitute(Attributes attributes);
-
+ public abstract Attributes substitute( Attributes attributes );
+
/**
- * Substitutes for the body text.
- * This method may substitute values into the body text of the
- * elements that Digester parses.
- *
+ * Substitutes for the body text. This method may substitute values into the body text of the elements that Digester
+ * parses.
+ *
* @param bodyText the body text (as passed to <code>Digester</code>)
* @return the body text to be passed to the <code>Rule</code> implementations
*/
- public abstract String substitute(String bodyText);
+ public abstract String substitute( String bodyText );
}
Modified: commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/WithDefaultsRulesWrapper.java
URL: http://svn.apache.org/viewvc/commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/WithDefaultsRulesWrapper.java?rev=1102402&r1=1102401&r2=1102402&view=diff
==============================================================================
--- commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/WithDefaultsRulesWrapper.java (original)
+++ commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/WithDefaultsRulesWrapper.java Thu May 12 18:03:26 2011
@@ -22,14 +22,18 @@ import java.util.ArrayList;
import java.util.List;
/**
- * <p><code>Rules</code> <em>Decorator</em> that returns default rules
- * when no matches are returned by the wrapped implementation.</p>
- *
- * <p>This allows default <code>Rule</code> instances to be added to any
- * existing <code>Rules</code> implementation. These default <code>Rule</code>
- * instances will be returned for any match for which the wrapped
- * implementation does not return any matches.</p>
- * <p> For example,
+ * <p>
+ * <code>Rules</code> <em>Decorator</em> that returns default rules when no matches are returned by the wrapped
+ * implementation.
+ * </p>
+ * <p>
+ * This allows default <code>Rule</code> instances to be added to any existing <code>Rules</code> implementation. These
+ * default <code>Rule</code> instances will be returned for any match for which the wrapped implementation does not
+ * return any matches.
+ * </p>
+ * <p>
+ * For example,
+ *
* <pre>
* Rule alpha;
* ...
@@ -39,123 +43,145 @@ import java.util.List;
* digester.setRules(rules);
* ...
* </pre>
+ *
* when a pattern does not match any other rule, then rule alpha will be called.
* </p>
- * <p><code>WithDefaultsRulesWrapper</code> follows the <em>Decorator</em> pattern.</p>
- *
+ * <p>
+ * <code>WithDefaultsRulesWrapper</code> follows the <em>Decorator</em> pattern.
+ * </p>
+ *
* @since 1.6
*/
-public class WithDefaultsRulesWrapper implements Rules {
+public class WithDefaultsRulesWrapper
+ implements Rules
+{
// --------------------------------------------------------- Fields
-
+
/** The Rules implementation that this class wraps. */
private Rules wrappedRules;
+
/** Rules to be fired when the wrapped implementations returns none. */
private List<Rule> defaultRules = new ArrayList<Rule>();
+
/** All rules (preserves order in which they were originally added) */
private List<Rule> allRules = new ArrayList<Rule>();
-
+
// --------------------------------------------------------- Constructor
-
- /**
+
+ /**
* Base constructor.
- *
+ *
* @param wrappedRules the wrapped <code>Rules</code> implementation, not null
* @throws IllegalArgumentException when <code>wrappedRules</code> is null
*/
- public WithDefaultsRulesWrapper(Rules wrappedRules) {
- if (wrappedRules == null) {
- throw new IllegalArgumentException("Wrapped rules must not be null");
+ public WithDefaultsRulesWrapper( Rules wrappedRules )
+ {
+ if ( wrappedRules == null )
+ {
+ throw new IllegalArgumentException( "Wrapped rules must not be null" );
}
this.wrappedRules = wrappedRules;
}
// --------------------------------------------------------- Properties
-
+
/** Gets digester using these Rules */
- public Digester getDigester() {
+ public Digester getDigester()
+ {
return wrappedRules.getDigester();
}
-
+
/** Sets digeseter using these Rules */
- public void setDigester(Digester digester) {
- wrappedRules.setDigester(digester);
- for (Rule rule : defaultRules) {
- rule.setDigester(digester);
+ public void setDigester( Digester digester )
+ {
+ wrappedRules.setDigester( digester );
+ for ( Rule rule : defaultRules )
+ {
+ rule.setDigester( digester );
}
}
-
+
/** Gets namespace to apply to Rule's added */
- public String getNamespaceURI() {
+ public String getNamespaceURI()
+ {
return wrappedRules.getNamespaceURI();
}
-
+
/** Sets namespace to apply to Rule's added subsequently */
- public void setNamespaceURI(String namespaceURI) {
- wrappedRules.setNamespaceURI(namespaceURI);
+ public void setNamespaceURI( String namespaceURI )
+ {
+ wrappedRules.setNamespaceURI( namespaceURI );
}
-
+
/** Gets Rule's which will be fired when the wrapped implementation returns no matches */
- public List<Rule> getDefaults() {
+ public List<Rule> getDefaults()
+ {
return defaultRules;
}
-
+
// --------------------------------------------------------- Public Methods
-
- public List<Rule> match(String pattern) {
- return match("", pattern);
+
+ public List<Rule> match( String pattern )
+ {
+ return match( "", pattern );
}
-
+
/**
- * Return list of rules matching given pattern.
- * If wrapped implementation returns any matches return those.
+ * Return list of rules matching given pattern. If wrapped implementation returns any matches return those.
* Otherwise, return default matches.
*/
- public List<Rule> match(String namespaceURI, String pattern) {
- List<Rule> matches = wrappedRules.match(namespaceURI, pattern);
- if (matches == null || matches.isEmpty()) {
+ public List<Rule> match( String namespaceURI, String pattern )
+ {
+ List<Rule> matches = wrappedRules.match( namespaceURI, pattern );
+ if ( matches == null || matches.isEmpty() )
+ {
// a little bit of defensive programming
- return new ArrayList<Rule>(defaultRules);
+ return new ArrayList<Rule>( defaultRules );
}
// otherwise
return matches;
}
-
+
/** Adds a rule to be fired when wrapped implementation returns no matches */
- public void addDefault(Rule rule) {
+ public void addDefault( Rule rule )
+ {
// set up rule
- if (wrappedRules.getDigester() != null) {
- rule.setDigester(wrappedRules.getDigester());
+ if ( wrappedRules.getDigester() != null )
+ {
+ rule.setDigester( wrappedRules.getDigester() );
}
-
- if (wrappedRules.getNamespaceURI() != null) {
- rule.setNamespaceURI(wrappedRules.getNamespaceURI());
+
+ if ( wrappedRules.getNamespaceURI() != null )
+ {
+ rule.setNamespaceURI( wrappedRules.getNamespaceURI() );
}
-
- defaultRules.add(rule);
- allRules.add(rule);
+
+ defaultRules.add( rule );
+ allRules.add( rule );
}
-
+
/** Gets all rules */
- public List<Rule> rules() {
+ public List<Rule> rules()
+ {
return allRules;
}
-
+
/** Clears all Rule's */
- public void clear() {
+ public void clear()
+ {
wrappedRules.clear();
allRules.clear();
defaultRules.clear();
}
-
- /**
- * Adds a Rule to be fired on given pattern.
- * Pattern matching is delegated to wrapped implementation.
+
+ /**
+ * Adds a Rule to be fired on given pattern. Pattern matching is delegated to wrapped implementation.
*/
- public void add(String pattern, Rule rule) {
- wrappedRules.add(pattern, rule);
- allRules.add(rule);
+ public void add( String pattern, Rule rule )
+ {
+ wrappedRules.add( pattern, rule );
+ allRules.add( rule );
}
}
Modified: commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/annotations/AnnotationRuleProvider.java
URL: http://svn.apache.org/viewvc/commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/annotations/AnnotationRuleProvider.java?rev=1102402&r1=1102401&r2=1102402&view=diff
==============================================================================
--- commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/annotations/AnnotationRuleProvider.java (original)
+++ commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/annotations/AnnotationRuleProvider.java Thu May 12 18:03:26 2011
@@ -24,24 +24,23 @@ import org.apache.commons.digester3.Rule
/**
* An object capable of providing instances of {@link Rule}.
- *
+ *
* @since 2.1
*/
-public interface AnnotationRuleProvider<A extends Annotation, E extends AnnotatedElement, R extends Rule> {
+public interface AnnotationRuleProvider<A extends Annotation, E extends AnnotatedElement, R extends Rule>
+{
/**
* Initializes the provider.
- *
+ *
* @param annotation the annotation instance.
* @param element the annotated element reference.
*/
- void init(A annotation, E element);
+ void init( A annotation, E element );
/**
- * Provides an instance of {@link Rule}.
- *
- * Must never return null.
- *
+ * Provides an instance of {@link Rule}. Must never return null.
+ *
* @return an instance of {@link Rule}.
*/
R get();
Modified: commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/annotations/CreationRule.java
URL: http://svn.apache.org/viewvc/commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/annotations/CreationRule.java?rev=1102402&r1=1102401&r2=1102402&view=diff
==============================================================================
--- commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/annotations/CreationRule.java (original)
+++ commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/annotations/CreationRule.java Thu May 12 18:03:26 2011
@@ -24,14 +24,14 @@ import java.lang.annotation.RetentionPol
import java.lang.annotation.Target;
/**
- * Marks a Digester rule as a creation rule, that's crucial for the
- * {@code setNext} rule.
- *
+ * Marks a Digester rule as a creation rule, that's crucial for the {@code setNext} rule.
+ *
* @since 2.1
*/
@Documented
-@Target(ElementType.ANNOTATION_TYPE)
-@Retention(RetentionPolicy.RUNTIME)
-public @interface CreationRule {
+@Target( ElementType.ANNOTATION_TYPE )
+@Retention( RetentionPolicy.RUNTIME )
+public @interface CreationRule
+{
}
Modified: commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/annotations/DigesterLoader.java
URL: http://svn.apache.org/viewvc/commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/annotations/DigesterLoader.java?rev=1102402&r1=1102401&r2=1102402&view=diff
==============================================================================
--- commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/annotations/DigesterLoader.java (original)
+++ commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/annotations/DigesterLoader.java Thu May 12 18:03:26 2011
@@ -37,16 +37,15 @@ import org.apache.commons.digester3.anno
import org.apache.commons.digester3.annotations.utils.AnnotationUtils;
/**
- * This class manages the creation of Digester instances analyzing target classes
- * annotated with digester annotations.
- *
+ * This class manages the creation of Digester instances analyzing target classes annotated with digester annotations.
+ *
* @since 2.1
*/
-public final class DigesterLoader {
+public final class DigesterLoader
+{
/**
- * In-memory LRU cache that stores already analyzed classes and relative
- * {@link RuleSet}.
+ * In-memory LRU cache that stores already analyzed classes and relative {@link RuleSet}.
*/
private final RuleSetCache cachedRuleSet = new RuleSetCache();
@@ -56,181 +55,198 @@ public final class DigesterLoader {
/**
* Creates a new {@link DigesterLoader} instance.
- *
+ *
* @param annotationRuleProviderFactory
* @param digesterLoaderHandlerFactory
*/
- protected DigesterLoader(AnnotationRuleProviderFactory annotationRuleProviderFactory,
- DigesterLoaderHandlerFactory digesterLoaderHandlerFactory) {
+ protected DigesterLoader( AnnotationRuleProviderFactory annotationRuleProviderFactory,
+ DigesterLoaderHandlerFactory digesterLoaderHandlerFactory )
+ {
this.annotationRuleProviderFactory = annotationRuleProviderFactory;
this.digesterLoaderHandlerFactory = digesterLoaderHandlerFactory;
}
- protected AnnotationRuleProviderFactory getAnnotationRuleProviderFactory() {
+ protected AnnotationRuleProviderFactory getAnnotationRuleProviderFactory()
+ {
return annotationRuleProviderFactory;
}
- protected DigesterLoaderHandlerFactory getDigesterLoaderHandlerFactory() {
+ protected DigesterLoaderHandlerFactory getDigesterLoaderHandlerFactory()
+ {
return digesterLoaderHandlerFactory;
}
/**
- * Creates a new digester which rules are defined by analyzing the digester
- * annotations in the target class.
- *
+ * Creates a new digester which rules are defined by analyzing the digester annotations in the target class.
+ *
* @param target the class has to be analyzed.
* @return a new Digester instance.
*/
- public Digester createDigester(final Class<?> target) {
+ public Digester createDigester( final Class<?> target )
+ {
Digester digester = new Digester();
- digester.setClassLoader(target.getClassLoader());
- addRules(target, digester);
+ digester.setClassLoader( target.getClassLoader() );
+ addRules( target, digester );
return digester;
}
/**
- * Add rules to an already created Digester instance, analyzing the digester
- * annotations in the target class.
- *
+ * Add rules to an already created Digester instance, analyzing the digester annotations in the target class.
+ *
* @param target the class has to be analyzed.
* @param digester the Digester instance reference.
*/
- public void addRules(final Class<?> target, final Digester digester) {
- RuleSet ruleSet = getRuleSet(target);
- ruleSet.addRuleInstances(digester);
+ public void addRules( final Class<?> target, final Digester digester )
+ {
+ RuleSet ruleSet = getRuleSet( target );
+ ruleSet.addRuleInstances( digester );
}
/**
- * Builds a new {@link RuleSet} analyzing the digester annotations in the
- * target class.
- *
- * It avoids iterate the annotations analysis for already analyzed classes,
- * using an in-memory LRU cache.
- *
+ * Builds a new {@link RuleSet} analyzing the digester annotations in the target class. It avoids iterate the
+ * annotations analysis for already analyzed classes, using an in-memory LRU cache.
+ *
* @param target the class has to be analyzed.
* @return a new {@link RuleSet}.
*/
- public RuleSet getRuleSet(final Class<?> target) {
- if (this.cachedRuleSet.containsKey(target)) {
- return this.cachedRuleSet.get(target);
+ public RuleSet getRuleSet( final Class<?> target )
+ {
+ if ( this.cachedRuleSet.containsKey( target ) )
+ {
+ return this.cachedRuleSet.get( target );
}
- FromAnnotationsRuleSet ruleSet = new FromAnnotationsRuleSet(this);
- addRulesTo(target, ruleSet);
- this.cachedRuleSet.put(target, ruleSet);
+ FromAnnotationsRuleSet ruleSet = new FromAnnotationsRuleSet( this );
+ addRulesTo( target, ruleSet );
+ this.cachedRuleSet.put( target, ruleSet );
return ruleSet;
}
/**
- * Analyzes the target class and adds the {@link AnnotationRuleProvider}s to
- * the existing {@link FromAnnotationsRuleSet}.
- *
+ * Analyzes the target class and adds the {@link AnnotationRuleProvider}s to the existing
+ * {@link FromAnnotationsRuleSet}.
+ *
* @param target the class has to be analyzed.
* @param ruleSet the RuleSet where adding the providers.
*/
- public void addRulesTo(final Class<?> target, FromAnnotationsRuleSet ruleSet) {
- if (target == Object.class
- || target.isInterface()
- || ruleSet.mapsClass(target)) {
+ public void addRulesTo( final Class<?> target, FromAnnotationsRuleSet ruleSet )
+ {
+ if ( target == Object.class || target.isInterface() || ruleSet.mapsClass( target ) )
+ {
return;
}
- if (this.cachedRuleSet.containsKey(target)) {
- ruleSet.addRulesProviderFrom(this.cachedRuleSet.get(target));
- ruleSet.addMappedClass(target);
+ if ( this.cachedRuleSet.containsKey( target ) )
+ {
+ ruleSet.addRulesProviderFrom( this.cachedRuleSet.get( target ) );
+ ruleSet.addMappedClass( target );
return;
}
// current analyzed class
- handle(target, ruleSet);
+ handle( target, ruleSet );
// class fields
- for (Field field : run(new GetDeclaredFieldsPrivilegedAction(target))) {
- handle(field, ruleSet);
+ for ( Field field : run( new GetDeclaredFieldsPrivilegedAction( target ) ) )
+ {
+ handle( field, ruleSet );
}
// class methods
- for (Method method : run(new GetDeclaredMethodsPrivilegedAction(target))) {
- handle(method, ruleSet);
+ for ( Method method : run( new GetDeclaredMethodsPrivilegedAction( target ) ) )
+ {
+ handle( method, ruleSet );
// method args
Annotation[][] parameterAnnotations = method.getParameterAnnotations();
Class<?>[] parameterTypes = method.getParameterTypes();
- for (int i = 0; i < parameterTypes.length; i++) {
- handle(new MethodArgument(i, parameterTypes[i], parameterAnnotations[i]), ruleSet);
+ for ( int i = 0; i < parameterTypes.length; i++ )
+ {
+ handle( new MethodArgument( i, parameterTypes[i], parameterAnnotations[i] ), ruleSet );
}
}
- ruleSet.addMappedClass(target);
- addRulesTo(target.getSuperclass(), ruleSet);
+ ruleSet.addMappedClass( target );
+ addRulesTo( target.getSuperclass(), ruleSet );
}
/**
* Executes an analysis for each annotation present in the element.
- *
+ *
* @param element the current element under analysis.
* @param ruleSet the ruleSet where add providers.
*/
- private void handle(AnnotatedElement element, FromAnnotationsRuleSet ruleSet) {
- for (Annotation annotation : element.getAnnotations()) {
- handle(annotation, element, ruleSet);
+ private void handle( AnnotatedElement element, FromAnnotationsRuleSet ruleSet )
+ {
+ for ( Annotation annotation : element.getAnnotations() )
+ {
+ handle( annotation, element, ruleSet );
}
}
/**
- * Handles the current visited element and related annotation, invoking the
- * right handler putting the rule provider in the rule set.
- *
+ * Handles the current visited element and related annotation, invoking the right handler putting the rule provider
+ * in the rule set.
+ *
* @param annotation the current visited annotation.
* @param element the current visited element.
*/
- @SuppressWarnings("unchecked")
- private <A extends Annotation, E extends AnnotatedElement, R extends Rule> void handle(A annotation,
- E element,
- FromAnnotationsRuleSet ruleSet) {
+ @SuppressWarnings( "unchecked" )
+ private <A extends Annotation, E extends AnnotatedElement, R extends Rule> void handle( A annotation,
+ E element,
+ FromAnnotationsRuleSet ruleSet )
+ {
Class<?> annotationType = annotation.annotationType();
// check if it is one of the @*.List annotation
- if (annotationType.isAnnotationPresent(DigesterRuleList.class)) {
- Annotation[] annotations = AnnotationUtils.getAnnotationsArrayValue(annotation);
- if (annotations != null && annotations.length > 0) {
+ if ( annotationType.isAnnotationPresent( DigesterRuleList.class ) )
+ {
+ Annotation[] annotations = AnnotationUtils.getAnnotationsArrayValue( annotation );
+ if ( annotations != null && annotations.length > 0 )
+ {
// if it is an annotations array, process them
- for (Annotation ptr : annotations) {
- handle(ptr, element, ruleSet);
+ for ( Annotation ptr : annotations )
+ {
+ handle( ptr, element, ruleSet );
}
}
- } else if (annotationType.isAnnotationPresent(DigesterRule.class)) {
- DigesterRule digesterRule = annotationType.getAnnotation(DigesterRule.class);
+ }
+ else if ( annotationType.isAnnotationPresent( DigesterRule.class ) )
+ {
+ DigesterRule digesterRule = annotationType.getAnnotation( DigesterRule.class );
- if (DefaultLoaderHandler.class == digesterRule.handledBy()) {
+ if ( DefaultLoaderHandler.class == digesterRule.handledBy() )
+ {
Class<? extends AnnotationRuleProvider<A, E, R>> providerType =
(Class<? extends AnnotationRuleProvider<A, E, R>>) digesterRule.providedBy();
- ruleSet.addRuleProvider(AnnotationUtils.getAnnotationPattern(annotation),
- providerType,
- annotation,
- element);
- } else {
+ ruleSet.addRuleProvider( AnnotationUtils.getAnnotationPattern( annotation ), providerType, annotation,
+ element );
+ }
+ else
+ {
Class<? extends DigesterLoaderHandler<Annotation, AnnotatedElement>> handlerType =
(Class<? extends DigesterLoaderHandler<Annotation, AnnotatedElement>>) digesterRule.handledBy();
DigesterLoaderHandler<Annotation, AnnotatedElement> handler =
- this.digesterLoaderHandlerFactory.newInstance(handlerType);
+ this.digesterLoaderHandlerFactory.newInstance( handlerType );
// run!
- handler.handle(annotation, element, ruleSet);
+ handler.handle( annotation, element, ruleSet );
}
}
}
/**
* Perform action with AccessController.doPrivileged() if possible.
- *
+ *
* @param action - the action to run
* @return result of running the action
*/
- private static <T> T run(PrivilegedAction<T> action) {
- if (System.getSecurityManager() != null) {
- return AccessController.doPrivileged(action);
+ private static <T> T run( PrivilegedAction<T> action )
+ {
+ if ( System.getSecurityManager() != null )
+ {
+ return AccessController.doPrivileged( action );
}
return action.run();
}
Modified: commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/annotations/DigesterLoaderBuilder.java
URL: http://svn.apache.org/viewvc/commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/annotations/DigesterLoaderBuilder.java?rev=1102402&r1=1102401&r2=1102402&view=diff
==============================================================================
--- commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/annotations/DigesterLoaderBuilder.java (original)
+++ commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/annotations/DigesterLoaderBuilder.java Thu May 12 18:03:26 2011
@@ -24,60 +24,60 @@ import org.apache.commons.digester3.anno
/**
* {@link DigesterLoader} builder implementation.
- *
+ *
* @since 2.1
*/
-public final class DigesterLoaderBuilder {
+public final class DigesterLoaderBuilder
+{
/**
- * Builds a new {@link DigesterLoader} using the default SPI
- * implementations.
- *
- * @return a new {@link DigesterLoader} using the default SPI
- * implementations.
+ * Builds a new {@link DigesterLoader} using the default SPI implementations.
+ *
+ * @return a new {@link DigesterLoader} using the default SPI implementations.
*/
- public static DigesterLoader byDefaultFactories() {
- return new DigesterLoaderBuilder()
- .useDefaultAnnotationRuleProviderFactory()
- .useDefaultDigesterLoaderHandlerFactory();
+ public static DigesterLoader byDefaultFactories()
+ {
+ return new DigesterLoaderBuilder().useDefaultAnnotationRuleProviderFactory().useDefaultDigesterLoaderHandlerFactory();
}
/**
- * Builds a new {@link DigesterLoader} using the default
- * {@link AnnotationRuleProviderFactory} implementation.
- *
+ * Builds a new {@link DigesterLoader} using the default {@link AnnotationRuleProviderFactory} implementation.
+ *
* @return the next chained builder.
* @see DefaultAnnotationRuleProviderFactory
*/
- public FromAnnotationRuleProviderFactory useDefaultAnnotationRuleProviderFactory() {
- return this.useAnnotationRuleProviderFactory(new DefaultAnnotationRuleProviderFactory());
+ public FromAnnotationRuleProviderFactory useDefaultAnnotationRuleProviderFactory()
+ {
+ return this.useAnnotationRuleProviderFactory( new DefaultAnnotationRuleProviderFactory() );
}
/**
- * Builds a new {@link DigesterLoader} using the user defined
- * {@link AnnotationRuleProviderFactory} implementation.
- *
- * @param annotationRuleProviderFactory the user defined
- * {@link AnnotationRuleProviderFactory} implementation.
+ * Builds a new {@link DigesterLoader} using the user defined {@link AnnotationRuleProviderFactory} implementation.
+ *
+ * @param annotationRuleProviderFactory the user defined {@link AnnotationRuleProviderFactory} implementation.
* @return the next chained builder.
*/
- public FromAnnotationRuleProviderFactory
- useAnnotationRuleProviderFactory(final AnnotationRuleProviderFactory annotationRuleProviderFactory) {
- if (annotationRuleProviderFactory == null) {
- throw new IllegalArgumentException("Parameter 'annotationRuleProviderFactory' must be not null");
+ public FromAnnotationRuleProviderFactory useAnnotationRuleProviderFactory( final AnnotationRuleProviderFactory annotationRuleProviderFactory )
+ {
+ if ( annotationRuleProviderFactory == null )
+ {
+ throw new IllegalArgumentException( "Parameter 'annotationRuleProviderFactory' must be not null" );
}
- return new FromAnnotationRuleProviderFactory() {
+ return new FromAnnotationRuleProviderFactory()
+ {
- public DigesterLoader useDefaultDigesterLoaderHandlerFactory() {
- return this.useDigesterLoaderHandlerFactory(new DefaultDigesterLoaderHandlerFactory());
+ public DigesterLoader useDefaultDigesterLoaderHandlerFactory()
+ {
+ return this.useDigesterLoaderHandlerFactory( new DefaultDigesterLoaderHandlerFactory() );
}
- public DigesterLoader useDigesterLoaderHandlerFactory(
- final DigesterLoaderHandlerFactory digesterLoaderHandlerFactory) {
- if (digesterLoaderHandlerFactory == null) {
- throw new IllegalArgumentException("Parameter 'digesterLoaderHandlerFactory' must be not null");
+ public DigesterLoader useDigesterLoaderHandlerFactory( final DigesterLoaderHandlerFactory digesterLoaderHandlerFactory )
+ {
+ if ( digesterLoaderHandlerFactory == null )
+ {
+ throw new IllegalArgumentException( "Parameter 'digesterLoaderHandlerFactory' must be not null" );
}
- return new DigesterLoader(annotationRuleProviderFactory, digesterLoaderHandlerFactory);
+ return new DigesterLoader( annotationRuleProviderFactory, digesterLoaderHandlerFactory );
}
};
}
Modified: commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/annotations/DigesterLoaderHandler.java
URL: http://svn.apache.org/viewvc/commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/annotations/DigesterLoaderHandler.java?rev=1102402&r1=1102401&r2=1102402&view=diff
==============================================================================
--- commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/annotations/DigesterLoaderHandler.java (original)
+++ commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/annotations/DigesterLoaderHandler.java Thu May 12 18:03:26 2011
@@ -21,23 +21,21 @@ import java.lang.annotation.Annotation;
import java.lang.reflect.AnnotatedElement;
/**
- * A {@code DigesterLoaderHandler} intercept a {@code Class} visit performed by
- * the {@link DigesterLoader} and performs the
- * {@link DigesterLoaderHandler#handle(Annotation, AnnotatedElement, FromAnnotationsRuleSet)}
- * method.
- *
+ * A {@code DigesterLoaderHandler} intercept a {@code Class} visit performed by the {@link DigesterLoader} and performs
+ * the {@link DigesterLoaderHandler#handle(Annotation, AnnotatedElement, FromAnnotationsRuleSet)} method.
+ *
* @since 2.1
*/
-public interface DigesterLoaderHandler<A extends Annotation, E extends AnnotatedElement> {
+public interface DigesterLoaderHandler<A extends Annotation, E extends AnnotatedElement>
+{
/**
* Handles the current visited element with the related current annotation.
- *
+ *
* @param annotation the current visited annotation.
* @param element the current visited element.
- * @param ruleSet the annotations {@code RuleSet} where providers have to be
- * added.
+ * @param ruleSet the annotations {@code RuleSet} where providers have to be added.
*/
- void handle(A annotation, E element, FromAnnotationsRuleSet ruleSet);
+ void handle( A annotation, E element, FromAnnotationsRuleSet ruleSet );
}
Modified: commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/annotations/DigesterLoadingException.java
URL: http://svn.apache.org/viewvc/commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/annotations/DigesterLoadingException.java?rev=1102402&r1=1102401&r2=1102402&view=diff
==============================================================================
--- commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/annotations/DigesterLoadingException.java (original)
+++ commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/annotations/DigesterLoadingException.java Thu May 12 18:03:26 2011
@@ -18,12 +18,13 @@
package org.apache.commons.digester3.annotations;
/**
- * The exception thrown when an error occurs while analyzing targets and
- * building rule sets.
- *
+ * The exception thrown when an error occurs while analyzing targets and building rule sets.
+ *
* @since 2.1
*/
-public final class DigesterLoadingException extends RuntimeException {
+public final class DigesterLoadingException
+ extends RuntimeException
+{
/**
* The default serial version UID.
@@ -32,31 +33,33 @@ public final class DigesterLoadingExcept
/**
* Constructs a new loading exception with the specified detail message.
- *
+ *
* @param message the detail message.
*/
- public DigesterLoadingException(String message) {
- super(message);
+ public DigesterLoadingException( String message )
+ {
+ super( message );
}
/**
* Constructs a new loading exception with the specified cause.
- *
+ *
* @param cause the specified cause.
*/
- public DigesterLoadingException(Throwable cause) {
- super(cause);
+ public DigesterLoadingException( Throwable cause )
+ {
+ super( cause );
}
/**
- * Constructs a new loading exception with the specified detail message
- * and cause.
- *
+ * Constructs a new loading exception with the specified detail message and cause.
+ *
* @param message the detail message.
* @param cause the specified cause.
*/
- public DigesterLoadingException(String message, Throwable cause) {
- super(message, cause);
+ public DigesterLoadingException( String message, Throwable cause )
+ {
+ super( message, cause );
}
}
Modified: commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/annotations/DigesterRule.java
URL: http://svn.apache.org/viewvc/commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/annotations/DigesterRule.java?rev=1102402&r1=1102401&r2=1102402&view=diff
==============================================================================
--- commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/annotations/DigesterRule.java (original)
+++ commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/annotations/DigesterRule.java Thu May 12 18:03:26 2011
@@ -30,37 +30,35 @@ import org.apache.commons.digester3.anno
/**
* Meta-annotation that marks an annotation as part of commons-digester.
- *
+ *
* @since 2.1
*/
@Documented
-@Target(ElementType.ANNOTATION_TYPE)
-@Retention(RetentionPolicy.RUNTIME)
-public @interface DigesterRule {
+@Target( ElementType.ANNOTATION_TYPE )
+@Retention( RetentionPolicy.RUNTIME )
+public @interface DigesterRule
+{
/**
* The reflected commons-digester rule.
- *
+ *
* @return the reflected commons-digester rule.
*/
Class<? extends Rule> reflectsRule();
/**
- * The handler that takes care on converting this annotation in the related
- * {@link AnnotationRuleProvider} and adds it o the {@link FromAnnotationsRuleSet}
- *
+ * The handler that takes care on converting this annotation in the related {@link AnnotationRuleProvider} and adds
+ * it o the {@link FromAnnotationsRuleSet}
+ *
* @return the {@link DigesterLoaderHandler}
*/
- Class<? extends DigesterLoaderHandler<? extends Annotation, ? extends AnnotatedElement>>
- handledBy() default DefaultLoaderHandler.class;
+ Class<? extends DigesterLoaderHandler<? extends Annotation, ? extends AnnotatedElement>> handledBy() default DefaultLoaderHandler.class;
/**
- * Define the {@link AnnotationRuleProvider} that builds the {@link Rule}
- * related to the digester rule.
- *
+ * Define the {@link AnnotationRuleProvider} that builds the {@link Rule} related to the digester rule.
+ *
* @return the {@link AnnotationRuleProvider}.
*/
- Class<? extends AnnotationRuleProvider<? extends Annotation, ? extends AnnotatedElement, ? extends Rule>>
- providedBy();
+ Class<? extends AnnotationRuleProvider<? extends Annotation, ? extends AnnotatedElement, ? extends Rule>> providedBy();
}
Modified: commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/annotations/DigesterRuleList.java
URL: http://svn.apache.org/viewvc/commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/annotations/DigesterRuleList.java?rev=1102402&r1=1102401&r2=1102402&view=diff
==============================================================================
--- commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/annotations/DigesterRuleList.java (original)
+++ commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/annotations/DigesterRuleList.java Thu May 12 18:03:26 2011
@@ -24,14 +24,14 @@ import java.lang.annotation.RetentionPol
import java.lang.annotation.Target;
/**
- * Meta-annotation that marks an annotation as a list of commons-digester
- * annotations.
- *
+ * Meta-annotation that marks an annotation as a list of commons-digester annotations.
+ *
* @since 2.1
*/
@Documented
-@Target(ElementType.ANNOTATION_TYPE)
-@Retention(RetentionPolicy.RUNTIME)
-public @interface DigesterRuleList {
+@Target( ElementType.ANNOTATION_TYPE )
+@Retention( RetentionPolicy.RUNTIME )
+public @interface DigesterRuleList
+{
}
Modified: commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/annotations/FromAnnotationRuleProviderFactory.java
URL: http://svn.apache.org/viewvc/commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/annotations/FromAnnotationRuleProviderFactory.java?rev=1102402&r1=1102401&r2=1102402&view=diff
==============================================================================
--- commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/annotations/FromAnnotationRuleProviderFactory.java (original)
+++ commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/annotations/FromAnnotationRuleProviderFactory.java Thu May 12 18:03:26 2011
@@ -21,26 +21,25 @@ import org.apache.commons.digester3.anno
/**
* {@link DigesterLoader} builder implementation.
- *
+ *
* @since 2.1
*/
-public interface FromAnnotationRuleProviderFactory {
+public interface FromAnnotationRuleProviderFactory
+{
/**
- * Builds a new {@link DigesterLoader} using the default
- * {@link DigesterLoaderHandlerFactory} implementation.
- *
+ * Builds a new {@link DigesterLoader} using the default {@link DigesterLoaderHandlerFactory} implementation.
+ *
* @return the {@link DigesterLoader}.
*/
DigesterLoader useDefaultDigesterLoaderHandlerFactory();
/**
- * Builds a new {@link DigesterLoader} using the user defined
- * {@link DigesterLoaderHandlerFactory} implementation.
- *
+ * Builds a new {@link DigesterLoader} using the user defined {@link DigesterLoaderHandlerFactory} implementation.
+ *
* @param digesterLoaderHandlerFactory
* @return the {@link DigesterLoader}.
*/
- DigesterLoader useDigesterLoaderHandlerFactory(DigesterLoaderHandlerFactory digesterLoaderHandlerFactory);
+ DigesterLoader useDigesterLoaderHandlerFactory( DigesterLoaderHandlerFactory digesterLoaderHandlerFactory );
}
Modified: commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/annotations/FromAnnotationsRuleSet.java
URL: http://svn.apache.org/viewvc/commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/annotations/FromAnnotationsRuleSet.java?rev=1102402&r1=1102401&r2=1102402&view=diff
==============================================================================
--- commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/annotations/FromAnnotationsRuleSet.java (original)
+++ commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/annotations/FromAnnotationsRuleSet.java Thu May 12 18:03:26 2011
@@ -32,16 +32,16 @@ import org.apache.commons.digester3.Rule
import org.apache.commons.digester3.RuleSet;
/**
- * A {@link RuleSet} implementation that's able to inject {@link Rule}s created
- * with the annotations analysis.
- *
+ * A {@link RuleSet} implementation that's able to inject {@link Rule}s created with the annotations analysis.
+ *
* @since 2.1
*/
-public final class FromAnnotationsRuleSet implements RuleSet {
+public final class FromAnnotationsRuleSet
+ implements RuleSet
+{
/**
- * The data structure that stores the patterns/{@link AnnotationRuleProvider}
- * pairs.
+ * The data structure that stores the patterns/{@link AnnotationRuleProvider} pairs.
*/
private final Map<String, List<AnnotationRuleProvider<Annotation, AnnotatedElement, Rule>>> rules =
new LinkedHashMap<String, List<AnnotationRuleProvider<Annotation, AnnotatedElement, Rule>>>();
@@ -60,105 +60,113 @@ public final class FromAnnotationsRuleSe
/**
* Created a new {@code FromAnnotationsRuleSet} instance.
- *
+ *
* @param digesterLoader the parent DigesterLoader.
*/
- protected FromAnnotationsRuleSet(DigesterLoader digesterLoader) {
+ protected FromAnnotationsRuleSet( DigesterLoader digesterLoader )
+ {
this.digesterLoader = digesterLoader;
}
/**
* {@inheritDoc}
*/
- public void addRuleInstances(Digester digester) {
+ public void addRuleInstances( Digester digester )
+ {
String pattern;
Rule rule;
- for (Entry<String, List<AnnotationRuleProvider<Annotation, AnnotatedElement, Rule>>> entry :
- this.rules.entrySet()) {
+ for ( Entry<String, List<AnnotationRuleProvider<Annotation, AnnotatedElement, Rule>>> entry : this.rules.entrySet() )
+ {
pattern = entry.getKey();
- for (AnnotationRuleProvider<Annotation, AnnotatedElement, Rule> provider : entry.getValue()) {
+ for ( AnnotationRuleProvider<Annotation, AnnotatedElement, Rule> provider : entry.getValue() )
+ {
rule = provider.get();
- if (this.namespaceURI != null) {
- rule.setNamespaceURI(this.namespaceURI);
+ if ( this.namespaceURI != null )
+ {
+ rule.setNamespaceURI( this.namespaceURI );
}
- digester.addRule(pattern, rule);
+ digester.addRule( pattern, rule );
}
}
}
/**
- * Analyzes the target class and adds the {@link AnnotationRuleProvider}s to
- * this {@link FromAnnotationsRuleSet}.
- *
+ * Analyzes the target class and adds the {@link AnnotationRuleProvider}s to this {@link FromAnnotationsRuleSet}.
+ *
* @param target the class has to be analyzed.
*/
- public void addRules(Class<?> target) {
- this.digesterLoader.addRulesTo(target, this);
+ public void addRules( Class<?> target )
+ {
+ this.digesterLoader.addRulesTo( target, this );
}
/**
- * Builds and register an {@link AnnotationRuleProvider} for a specific
- * pattern.
- *
+ * Builds and register an {@link AnnotationRuleProvider} for a specific pattern.
+ *
* @param <T> the {@link AnnotationRuleProvider} type.
* @param pattern the pattern has to be associated to the rule provider.
* @param klass the {@link AnnotationRuleProvider} type has to be instantiated.
* @param annotation the current visited annotation.
* @param element the current visited element.
*/
- 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) {
-
- T annotationRuleProvider =
- this.digesterLoader.getAnnotationRuleProviderFactory().newInstance(klass);
- annotationRuleProvider.init(annotation, element);
- this.addRuleProvider(pattern, annotationRuleProvider);
+ 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 )
+ {
+
+ T annotationRuleProvider = this.digesterLoader.getAnnotationRuleProviderFactory().newInstance( klass );
+ annotationRuleProvider.init( annotation, element );
+ this.addRuleProvider( pattern, annotationRuleProvider );
}
/**
* Register an {@link AnnotationRuleProvider} for a specific pattern.
- *
+ *
* @param pattern the pattern has to be associated to the rule provider.
* @param ruleProvider the provider that builds the digester rule.
*/
- @SuppressWarnings("unchecked")
- public void addRuleProvider(String pattern,
- AnnotationRuleProvider<? extends Annotation, ? extends AnnotatedElement, ? extends Rule> ruleProvider) {
+ @SuppressWarnings( "unchecked" )
+ public void addRuleProvider( String pattern,
+ AnnotationRuleProvider<? extends Annotation, ? extends AnnotatedElement, ? extends Rule> ruleProvider )
+ {
List<AnnotationRuleProvider<Annotation, AnnotatedElement, Rule>> rules;
- if (this.rules.containsKey(pattern)) {
- rules = this.rules.get(pattern);
- } else {
+ if ( this.rules.containsKey( pattern ) )
+ {
+ rules = this.rules.get( pattern );
+ }
+ else
+ {
rules = new ArrayList<AnnotationRuleProvider<Annotation, AnnotatedElement, Rule>>();
- this.rules.put(pattern, rules);
+ this.rules.put( pattern, rules );
}
- rules.add((AnnotationRuleProvider<Annotation, AnnotatedElement, Rule>) ruleProvider);
+ rules.add( (AnnotationRuleProvider<Annotation, AnnotatedElement, Rule>) ruleProvider );
}
/**
- * Retrieves a specific instance of the {@link AnnotationRuleProvider} for
- * the input pattern.
- *
+ * Retrieves a specific instance of the {@link AnnotationRuleProvider} for the input pattern.
+ *
* @param <T> the {@link AnnotationRuleProvider} type
* @param pattern the input pattern
* @param providerClass the {@link AnnotationRuleProvider} class
- * @return an {@link AnnotationRuleProvider} for the input pattern if found,
- * null otherwise.
+ * @return an {@link AnnotationRuleProvider} for the input pattern if found, null otherwise.
*/
- public <T extends AnnotationRuleProvider<? extends Annotation, ? extends AnnotatedElement, ? extends Rule>>
- T getProvider(String pattern, Class<T> providerClass) {
+ public <T extends AnnotationRuleProvider<? extends Annotation, ? extends AnnotatedElement, ? extends Rule>> T getProvider( String pattern,
+ Class<T> providerClass )
+ {
- if (!this.rules.containsKey(pattern)) {
+ if ( !this.rules.containsKey( pattern ) )
+ {
return null;
}
- for (AnnotationRuleProvider<Annotation, AnnotatedElement, Rule> rule : this.rules.get(pattern)) {
- if (providerClass.isInstance(rule)) {
- return providerClass.cast(rule);
+ for ( AnnotationRuleProvider<Annotation, AnnotatedElement, Rule> rule : this.rules.get( pattern ) )
+ {
+ if ( providerClass.isInstance( rule ) )
+ {
+ return providerClass.cast( rule );
}
}
@@ -166,62 +174,61 @@ public final class FromAnnotationsRuleSe
}
/**
- * Add created {@link AnnotationRuleProvider}s created in another analysis
- * session.
- *
+ * Add created {@link AnnotationRuleProvider}s created in another analysis session.
+ *
* @param ruleSet the {@code RuleSet} created in another analysis session.
*/
- public void addRulesProviderFrom(final FromAnnotationsRuleSet ruleSet) {
- this.rules.putAll(ruleSet.getRules());
+ public void addRulesProviderFrom( final FromAnnotationsRuleSet ruleSet )
+ {
+ this.rules.putAll( ruleSet.getRules() );
}
/**
* Checks if this RuleSet builds Digester mapping rules for the input type.
- *
+ *
* @param clazz the input type.
- * @return true, if this RuleSet builds Digester mapping rules for the input
- * type, false otherwise.
+ * @return true, if this RuleSet builds Digester mapping rules for the input type, false otherwise.
*/
- protected boolean mapsClass(Class<?> clazz) {
- return this.mappedClasses.contains(clazz);
+ protected boolean mapsClass( Class<?> clazz )
+ {
+ return this.mappedClasses.contains( clazz );
}
/**
- * Remember that this RuleSet is able to build Digester mapping rules for
- * the input type.
- *
+ * Remember that this RuleSet is able to build Digester mapping rules for the input type.
+ *
* @param clazz the input type.
*/
- protected void addMappedClass(Class<?> clazz) {
- this.mappedClasses.add(clazz);
+ protected void addMappedClass( Class<?> clazz )
+ {
+ this.mappedClasses.add( clazz );
}
/**
- * Returns the data structure the patterns/{@link AnnotationRuleProvider}
- * pairs.
- *
- * @return the data structure the patterns/{@link AnnotationRuleProvider}
- * pairs.
+ * Returns the data structure the patterns/{@link AnnotationRuleProvider} pairs.
+ *
+ * @return the data structure the patterns/{@link AnnotationRuleProvider} pairs.
*/
- private Map<String, List<AnnotationRuleProvider<Annotation, AnnotatedElement, Rule>>> getRules() {
+ private Map<String, List<AnnotationRuleProvider<Annotation, AnnotatedElement, Rule>>> getRules()
+ {
return this.rules;
}
/**
* {@inheritDoc}
*/
- public String getNamespaceURI() {
+ public String getNamespaceURI()
+ {
return this.namespaceURI;
}
/**
- * Sets the namespace URI that will be applied to all Rule instances
- * created from this RuleSet.
- *
- * @param namespaceURI the namespace URI that will be applied to all Rule
- * instances created from this RuleSet.
+ * Sets the namespace URI that will be applied to all Rule instances created from this RuleSet.
+ *
+ * @param namespaceURI the namespace URI that will be applied to all Rule instances created from this RuleSet.
*/
- public void setNamespaceURI(String namespaceURI) {
+ public void setNamespaceURI( String namespaceURI )
+ {
this.namespaceURI = namespaceURI;
}
@@ -229,14 +236,10 @@ public final class FromAnnotationsRuleSe
* {@inheritDoc}
*/
@Override
- public String toString() {
- return "{ mappedClasses="
- + this.mappedClasses
- + ", rules="
- + this.rules.toString()
- + ", namespaceURI="
- + this.namespaceURI
- + " }";
+ public String toString()
+ {
+ return "{ mappedClasses=" + this.mappedClasses + ", rules=" + this.rules.toString() + ", namespaceURI="
+ + this.namespaceURI + " }";
}
}
Modified: commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/annotations/handlers/DefaultLoaderHandler.java
URL: http://svn.apache.org/viewvc/commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/annotations/handlers/DefaultLoaderHandler.java?rev=1102402&r1=1102401&r2=1102402&view=diff
==============================================================================
--- commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/annotations/handlers/DefaultLoaderHandler.java (original)
+++ commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/annotations/handlers/DefaultLoaderHandler.java Thu May 12 18:03:26 2011
@@ -23,11 +23,12 @@ import java.lang.reflect.AnnotatedElemen
import org.apache.commons.digester3.annotations.DigesterLoaderHandler;
/**
- * The DefaultLoaderHandler marks rules that have to be processed by the built-in
- * Digester annotation rules engine.
- *
+ * The DefaultLoaderHandler marks rules that have to be processed by the built-in Digester annotation rules engine.
+ *
* @since 2.1
*/
-public interface DefaultLoaderHandler extends DigesterLoaderHandler<Annotation, AnnotatedElement> {
+public interface DefaultLoaderHandler
+ extends DigesterLoaderHandler<Annotation, AnnotatedElement>
+{
}
Modified: commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/annotations/handlers/MethodHandler.java
URL: http://svn.apache.org/viewvc/commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/annotations/handlers/MethodHandler.java?rev=1102402&r1=1102401&r2=1102402&view=diff
==============================================================================
--- commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/annotations/handlers/MethodHandler.java (original)
+++ commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/annotations/handlers/MethodHandler.java Thu May 12 18:03:26 2011
@@ -32,14 +32,14 @@ import org.apache.commons.digester3.anno
import org.apache.commons.digester3.annotations.utils.AnnotationUtils;
/**
- * Handler that takes care to create the
- * {@link org.apache.commons.digester3.annotations.providers.SetNextRuleProvider}
- * and
- * {@link org.apache.commons.digester3.annotations.providers.SetRootRuleProvider}.
- *
+ * Handler that takes care to create the {@link org.apache.commons.digester3.annotations.providers.SetNextRuleProvider}
+ * and {@link org.apache.commons.digester3.annotations.providers.SetRootRuleProvider}.
+ *
* @since 2.1
*/
-public final class MethodHandler implements DigesterLoaderHandler<Annotation, Method> {
+public final class MethodHandler
+ implements DigesterLoaderHandler<Annotation, Method>
+{
/**
* The default args size the method has to have in order to be analyzed.
@@ -49,86 +49,87 @@ public final class MethodHandler impleme
/**
* {@inheritDoc}
*/
- public void handle(Annotation annotation, Method element, FromAnnotationsRuleSet ruleSet) {
- if (SUPPORTED_ARGS != element.getParameterTypes().length) {
- DigesterRule rule = annotation.annotationType().getAnnotation(DigesterRule.class);
-
- throw new DigesterLoadingException("Methods annotated with digester annotation rule @"
- + rule.reflectsRule().getName()
- + " must have just one argument");
- }
-
- Object explicitTypesObject = AnnotationUtils.getAnnotationValue(annotation);
- if (explicitTypesObject == null
- || !explicitTypesObject.getClass().isArray()
- || Class.class != explicitTypesObject.getClass().getComponentType()) {
- throw new DigesterLoadingException("Impossible to apply this handler, @"
- + annotation.getClass().getName()
- + ".value() has to be of type 'Class<?>[]'");
+ public void handle( Annotation annotation, Method element, FromAnnotationsRuleSet ruleSet )
+ {
+ if ( SUPPORTED_ARGS != element.getParameterTypes().length )
+ {
+ DigesterRule rule = annotation.annotationType().getAnnotation( DigesterRule.class );
+
+ throw new DigesterLoadingException( "Methods annotated with digester annotation rule @"
+ + rule.reflectsRule().getName() + " must have just one argument" );
+ }
+
+ Object explicitTypesObject = AnnotationUtils.getAnnotationValue( annotation );
+ if ( explicitTypesObject == null || !explicitTypesObject.getClass().isArray()
+ || Class.class != explicitTypesObject.getClass().getComponentType() )
+ {
+ throw new DigesterLoadingException( "Impossible to apply this handler, @" + annotation.getClass().getName()
+ + ".value() has to be of type 'Class<?>[]'" );
}
Class<?>[] explicitTypes = (Class<?>[]) explicitTypesObject;
Class<?> paramType = element.getParameterTypes()[0];
- if (explicitTypes.length > 0) {
- for (Class<?> explicitType : explicitTypes) {
- if (!paramType.isAssignableFrom(explicitType)) {
- throw new DigesterLoadingException("Impossible to handle annotation "
- + annotation
- + " on method "
- + element.toGenericString()
- + ", "
- + explicitType.getName()
- + " has to be a "
- + paramType.getName());
+ if ( explicitTypes.length > 0 )
+ {
+ for ( Class<?> explicitType : explicitTypes )
+ {
+ if ( !paramType.isAssignableFrom( explicitType ) )
+ {
+ throw new DigesterLoadingException( "Impossible to handle annotation " + annotation + " on method "
+ + element.toGenericString() + ", " + explicitType.getName() + " has to be a "
+ + paramType.getName() );
}
- this.doHandle(annotation, element, explicitType, ruleSet);
+ this.doHandle( annotation, element, explicitType, ruleSet );
}
- } else {
- this.doHandle(annotation, element, paramType, ruleSet);
+ }
+ else
+ {
+ this.doHandle( annotation, element, paramType, ruleSet );
}
}
- private void doHandle(Annotation methodAnnotation, Method method, Class<?> type, FromAnnotationsRuleSet ruleSet) {
- if (type.isInterface()
- && Modifier.isAbstract(type.getModifiers())) {
- throw new DigesterLoadingException("Impossible to proceed analyzing "
- + methodAnnotation
- + ", specified type '"
- + type.getName()
- + "' is an interface/abstract");
+ private void doHandle( Annotation methodAnnotation, Method method, Class<?> type, FromAnnotationsRuleSet ruleSet )
+ {
+ if ( type.isInterface() && Modifier.isAbstract( type.getModifiers() ) )
+ {
+ throw new DigesterLoadingException( "Impossible to proceed analyzing " + methodAnnotation
+ + ", specified type '" + type.getName() + "' is an interface/abstract" );
}
- for (Annotation annotation : type.getAnnotations()) {
- this.doHandle(methodAnnotation, annotation, method, type, ruleSet);
+ for ( Annotation annotation : type.getAnnotations() )
+ {
+ this.doHandle( methodAnnotation, annotation, method, type, ruleSet );
}
}
- @SuppressWarnings("unchecked")
- private <A extends Annotation, R extends Rule> void doHandle(A methodAnnotation,
- Annotation annotation,
- Method method,
- Class<?> type,
- FromAnnotationsRuleSet ruleSet) {
- if (annotation.annotationType().isAnnotationPresent(DigesterRule.class)
- && annotation.annotationType().isAnnotationPresent(CreationRule.class)) {
- ruleSet.addRules(type);
+ @SuppressWarnings( "unchecked" )
+ private <A extends Annotation, R extends Rule> void doHandle( A methodAnnotation, Annotation annotation,
+ Method method, Class<?> type,
+ FromAnnotationsRuleSet ruleSet )
+ {
+ if ( annotation.annotationType().isAnnotationPresent( DigesterRule.class )
+ && annotation.annotationType().isAnnotationPresent( CreationRule.class ) )
+ {
+ ruleSet.addRules( type );
- DigesterRule digesterRule = methodAnnotation.annotationType().getAnnotation(DigesterRule.class);
+ DigesterRule digesterRule = methodAnnotation.annotationType().getAnnotation( DigesterRule.class );
Class<? extends AnnotationRuleProvider<A, Method, R>> providerType =
(Class<? extends AnnotationRuleProvider<A, Method, R>>) digesterRule.providedBy();
- ruleSet.addRuleProvider(AnnotationUtils.getAnnotationPattern(annotation),
- providerType,
- methodAnnotation,
- method);
- } else if (annotation.annotationType().isAnnotationPresent(DigesterRuleList.class)) {
+ ruleSet.addRuleProvider( AnnotationUtils.getAnnotationPattern( annotation ), providerType,
+ methodAnnotation, method );
+ }
+ else if ( annotation.annotationType().isAnnotationPresent( DigesterRuleList.class ) )
+ {
// check if it is one of the *.List annotation
- Annotation[] annotations = AnnotationUtils.getAnnotationsArrayValue(annotation);
- if (annotations != null) {
+ Annotation[] annotations = AnnotationUtils.getAnnotationsArrayValue( annotation );
+ if ( annotations != null )
+ {
// if it is an annotations array, process them
- for (Annotation ptr : annotations) {
- this.doHandle(methodAnnotation, ptr, method, type, ruleSet);
+ for ( Annotation ptr : annotations )
+ {
+ this.doHandle( methodAnnotation, ptr, method, type, ruleSet );
}
}
}
Modified: commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/annotations/handlers/SetPropertiesLoaderHandler.java
URL: http://svn.apache.org/viewvc/commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/annotations/handlers/SetPropertiesLoaderHandler.java?rev=1102402&r1=1102401&r2=1102402&view=diff
==============================================================================
--- commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/annotations/handlers/SetPropertiesLoaderHandler.java (original)
+++ commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/annotations/handlers/SetPropertiesLoaderHandler.java Thu May 12 18:03:26 2011
@@ -26,24 +26,28 @@ import org.apache.commons.digester3.anno
/**
* Handler that takes care to create the {@link SetPropertiesRuleProvider}.
- *
+ *
* @since 2.1
*/
-public final class SetPropertiesLoaderHandler implements DigesterLoaderHandler<SetProperty, Field> {
+public final class SetPropertiesLoaderHandler
+ implements DigesterLoaderHandler<SetProperty, Field>
+{
/**
* {@inheritDoc}
*/
- public void handle(SetProperty annotation, Field element, FromAnnotationsRuleSet ruleSet) {
+ public void handle( SetProperty annotation, Field element, FromAnnotationsRuleSet ruleSet )
+ {
SetPropertiesRuleProvider ruleProvider =
- ruleSet.getProvider(annotation.pattern(), SetPropertiesRuleProvider.class);
+ ruleSet.getProvider( annotation.pattern(), SetPropertiesRuleProvider.class );
- if (ruleProvider == null) {
+ if ( ruleProvider == null )
+ {
ruleProvider = new SetPropertiesRuleProvider();
- ruleSet.addRuleProvider(annotation.pattern(), ruleProvider);
+ ruleSet.addRuleProvider( annotation.pattern(), ruleProvider );
}
- ruleProvider.addAlias(annotation, element);
+ ruleProvider.addAlias( annotation, element );
}
}
Modified: commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/annotations/handlers/package-info.java
URL: http://svn.apache.org/viewvc/commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/annotations/handlers/package-info.java?rev=1102402&r1=1102401&r2=1102402&view=diff
==============================================================================
--- commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/annotations/handlers/package-info.java (original)
+++ commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/annotations/handlers/package-info.java Thu May 12 18:03:26 2011
@@ -22,3 +22,4 @@
* implementations.
*/
package org.apache.commons.digester3.annotations.handlers;
+
Modified: commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/annotations/internal/AbstractAnnotatedElementPrivilegedAction.java
URL: http://svn.apache.org/viewvc/commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/annotations/internal/AbstractAnnotatedElementPrivilegedAction.java?rev=1102402&r1=1102401&r2=1102402&view=diff
==============================================================================
--- commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/annotations/internal/AbstractAnnotatedElementPrivilegedAction.java (original)
+++ commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/annotations/internal/AbstractAnnotatedElementPrivilegedAction.java Thu May 12 18:03:26 2011
@@ -22,18 +22,22 @@ import java.security.PrivilegedAction;
/**
* Abstract {@link PrivilegedAction} to extract annotated elements from a type.
- *
+ *
* @since 2.2
*/
-abstract class AbstractAnnotatedElementPrivilegedAction<A extends AnnotatedElement> implements PrivilegedAction<A[]> {
+abstract class AbstractAnnotatedElementPrivilegedAction<A extends AnnotatedElement>
+ implements PrivilegedAction<A[]>
+{
private final Class<?> type;
- public AbstractAnnotatedElementPrivilegedAction(Class<?> type) {
+ public AbstractAnnotatedElementPrivilegedAction( Class<?> type )
+ {
this.type = type;
}
- protected final Class<?> getType() {
+ protected final Class<?> getType()
+ {
return this.type;
}
Modified: commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/annotations/internal/DefaultAnnotationRuleProviderFactory.java
URL: http://svn.apache.org/viewvc/commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/annotations/internal/DefaultAnnotationRuleProviderFactory.java?rev=1102402&r1=1102401&r2=1102402&view=diff
==============================================================================
--- commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/annotations/internal/DefaultAnnotationRuleProviderFactory.java (original)
+++ commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/annotations/internal/DefaultAnnotationRuleProviderFactory.java Thu May 12 18:03:26 2011
@@ -27,22 +27,26 @@ import org.apache.commons.digester3.anno
/**
* Default {@link AnnotationRuleProviderFactory} implementation.
- *
+ *
* @since 2.1
*/
-public final class DefaultAnnotationRuleProviderFactory implements AnnotationRuleProviderFactory {
+public final class DefaultAnnotationRuleProviderFactory
+ implements AnnotationRuleProviderFactory
+{
/**
* {@inheritDoc}
*/
- public <T extends AnnotationRuleProvider<? extends Annotation, ? extends AnnotatedElement, ? extends Rule>>
- T newInstance(Class<T> type) throws DigesterLoadingException {
- try {
+ public <T extends AnnotationRuleProvider<? extends Annotation, ? extends AnnotatedElement, ? extends Rule>> T newInstance( Class<T> type )
+ throws DigesterLoadingException
+ {
+ try
+ {
return type.newInstance();
- } catch (Exception e) {
- throw new DigesterLoadingException("An error occurred while creating '"
- + type
- + "' instance", e);
+ }
+ catch ( Exception e )
+ {
+ throw new DigesterLoadingException( "An error occurred while creating '" + type + "' instance", e );
}
}
Modified: commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/annotations/internal/DefaultDigesterLoaderHandlerFactory.java
URL: http://svn.apache.org/viewvc/commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/annotations/internal/DefaultDigesterLoaderHandlerFactory.java?rev=1102402&r1=1102401&r2=1102402&view=diff
==============================================================================
--- commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/annotations/internal/DefaultDigesterLoaderHandlerFactory.java (original)
+++ commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/annotations/internal/DefaultDigesterLoaderHandlerFactory.java Thu May 12 18:03:26 2011
@@ -26,22 +26,26 @@ import org.apache.commons.digester3.anno
/**
* Default {@link DigesterLoaderHandlerFactory} implementation.
- *
+ *
* @since 2.1
*/
-public final class DefaultDigesterLoaderHandlerFactory implements DigesterLoaderHandlerFactory {
+public final class DefaultDigesterLoaderHandlerFactory
+ implements DigesterLoaderHandlerFactory
+{
/**
* {@inheritDoc}
*/
- public <L extends DigesterLoaderHandler<? extends Annotation, ? extends AnnotatedElement>> L newInstance(
- Class<L> type) throws DigesterLoadingException {
- try {
+ public <L extends DigesterLoaderHandler<? extends Annotation, ? extends AnnotatedElement>> L newInstance( Class<L> type )
+ throws DigesterLoadingException
+ {
+ try
+ {
return type.newInstance();
- } catch (Exception e) {
- throw new DigesterLoadingException("An error occurred while creating '"
- + type
- + "' instance", e);
+ }
+ catch ( Exception e )
+ {
+ throw new DigesterLoadingException( "An error occurred while creating '" + type + "' instance", e );
}
}
Modified: commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/annotations/internal/GetDeclaredFieldsPrivilegedAction.java
URL: http://svn.apache.org/viewvc/commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/annotations/internal/GetDeclaredFieldsPrivilegedAction.java?rev=1102402&r1=1102401&r2=1102402&view=diff
==============================================================================
--- commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/annotations/internal/GetDeclaredFieldsPrivilegedAction.java (original)
+++ commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/annotations/internal/GetDeclaredFieldsPrivilegedAction.java Thu May 12 18:03:26 2011
@@ -21,20 +21,24 @@ import java.lang.reflect.Field;
/**
* Privileged action to extract declared fields of a class.
- *
+ *
* @version $Id$
*/
-public final class GetDeclaredFieldsPrivilegedAction extends AbstractAnnotatedElementPrivilegedAction<Field> {
+public final class GetDeclaredFieldsPrivilegedAction
+ extends AbstractAnnotatedElementPrivilegedAction<Field>
+{
- public GetDeclaredFieldsPrivilegedAction(Class<?> type) {
- super(type);
+ public GetDeclaredFieldsPrivilegedAction( Class<?> type )
+ {
+ super( type );
}
/**
* {@inheritDoc}
*/
@Override
- public Field[] run() {
+ public Field[] run()
+ {
return this.getType().getDeclaredFields();
}