This is an automated email from the ASF dual-hosted git repository. markt pushed a commit to branch 11.0.x in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/11.0.x by this push: new 10b0e79c68 Code clean-up - formatting. No functional change. 10b0e79c68 is described below commit 10b0e79c68d36f39fb2918bedc7dac39b8b73170 Author: Mark Thomas <ma...@apache.org> AuthorDate: Thu May 22 17:11:10 2025 +0100 Code clean-up - formatting. No functional change. --- .../digester/AbstractObjectCreationFactory.java | 24 +- .../apache/tomcat/util/digester/ArrayStack.java | 70 +-- .../tomcat/util/digester/CallMethodRule.java | 198 ++++---- .../apache/tomcat/util/digester/CallParamRule.java | 66 +-- java/org/apache/tomcat/util/digester/Digester.java | 541 ++++++++++----------- .../tomcat/util/digester/DocumentProperties.java | 6 +- .../util/digester/EnvironmentPropertySource.java | 19 +- .../tomcat/util/digester/FactoryCreateRule.java | 50 +- .../tomcat/util/digester/ObjectCreateRule.java | 39 +- .../util/digester/ObjectCreationFactory.java | 25 +- java/org/apache/tomcat/util/digester/Rule.java | 64 ++- java/org/apache/tomcat/util/digester/RuleSet.java | 31 +- java/org/apache/tomcat/util/digester/Rules.java | 36 +- .../org/apache/tomcat/util/digester/RulesBase.java | 80 ++- .../digester/ServiceBindingPropertySource.java | 37 +- .../apache/tomcat/util/digester/SetNextRule.java | 88 ++-- .../tomcat/util/digester/SetPropertiesRule.java | 25 +- .../tomcat/util/digester/SystemPropertySource.java | 5 +- 18 files changed, 652 insertions(+), 752 deletions(-) diff --git a/java/org/apache/tomcat/util/digester/AbstractObjectCreationFactory.java b/java/org/apache/tomcat/util/digester/AbstractObjectCreationFactory.java index 01faa5347c..4c647fa766 100644 --- a/java/org/apache/tomcat/util/digester/AbstractObjectCreationFactory.java +++ b/java/org/apache/tomcat/util/digester/AbstractObjectCreationFactory.java @@ -21,19 +21,18 @@ import org.xml.sax.Attributes; /** - * <p>Abstract base class for <code>ObjectCreationFactory</code> - * implementations.</p> + * <p> + * Abstract base class for <code>ObjectCreationFactory</code> implementations. + * </p> */ -public abstract class AbstractObjectCreationFactory - implements ObjectCreationFactory { +public abstract class AbstractObjectCreationFactory implements ObjectCreationFactory { // ----------------------------------------------------- Instance Variables /** - * The associated <code>Digester</code> instance that was set up by - * {@link FactoryCreateRule} upon initialization. + * The associated <code>Digester</code> instance that was set up by {@link FactoryCreateRule} upon initialization. */ private Digester digester = null; @@ -42,8 +41,8 @@ public abstract class AbstractObjectCreationFactory /** - * <p>Factory method called by {@link FactoryCreateRule} to supply an - * object based on the element's attributes. + * <p> + * Factory method called by {@link FactoryCreateRule} to supply an object based on the element's attributes. * * @param attributes the element's attributes * @@ -54,8 +53,8 @@ public abstract class AbstractObjectCreationFactory /** - * <p>Returns the {@link Digester} that was set by the - * {@link FactoryCreateRule} upon initialization. + * <p> + * Returns the {@link Digester} that was set by the {@link FactoryCreateRule} upon initialization. */ @Override public Digester getDigester() { @@ -64,8 +63,9 @@ public abstract class AbstractObjectCreationFactory /** - * <p>Set the {@link Digester} to allow the implementation to do logging, - * classloading based on the digester's classloader, etc. + * <p> + * Set the {@link Digester} to allow the implementation to do logging, classloading based on the digester's + * classloader, etc. * * @param digester parent Digester object */ diff --git a/java/org/apache/tomcat/util/digester/ArrayStack.java b/java/org/apache/tomcat/util/digester/ArrayStack.java index 9911811d54..6f63b4f885 100644 --- a/java/org/apache/tomcat/util/digester/ArrayStack.java +++ b/java/org/apache/tomcat/util/digester/ArrayStack.java @@ -21,27 +21,28 @@ import java.util.ArrayList; import java.util.EmptyStackException; /** - * <p>Imported copy of the <code>ArrayStack</code> class from - * Commons Collections, which was the only direct dependency from Digester.</p> - * - * <p><strong>WARNING</strong> - This class is public solely to allow it to be - * used from subpackages of <code>org.apache.commons.digester</code>. - * It should not be considered part of the public API of Commons Digester. - * If you want to use such a class yourself, you should use the one from - * Commons Collections directly.</p> - * - * <p>An implementation of the {@link java.util.Stack} API that is based on an - * <code>ArrayList</code> instead of a <code>Vector</code>, so it is not - * synchronized to protect against multi-threaded access. The implementation - * is therefore operates faster in environments where you do not need to - * worry about multiple thread contention.</p> - * - * <p>Unlike <code>Stack</code>, <code>ArrayStack</code> accepts null entries. + * <p> + * Imported copy of the <code>ArrayStack</code> class from Commons Collections, which was the only direct dependency + * from Digester. + * </p> + * <p> + * <strong>WARNING</strong> - This class is public solely to allow it to be used from subpackages of + * <code>org.apache.commons.digester</code>. It should not be considered part of the public API of Commons Digester. If + * you want to use such a class yourself, you should use the one from Commons Collections directly. + * </p> + * <p> + * An implementation of the {@link java.util.Stack} API that is based on an <code>ArrayList</code> instead of a + * <code>Vector</code>, so it is not synchronized to protect against multi-threaded access. The implementation is + * therefore operates faster in environments where you do not need to worry about multiple thread contention. + * </p> + * <p> + * Unlike <code>Stack</code>, <code>ArrayStack</code> accepts null entries. * </p> * * @param <E> Type of object in this stack * * @see java.util.Stack + * * @since Digester 1.6 (from Commons Collections 1.0) */ public class ArrayStack<E> extends ArrayList<E> { @@ -51,8 +52,8 @@ public class ArrayStack<E> extends ArrayList<E> { private static final long serialVersionUID = 2130079159931574599L; /** - * Constructs a new empty <code>ArrayStack</code>. The initial size - * is controlled by <code>ArrayList</code> and is currently 10. + * Constructs a new empty <code>ArrayStack</code>. The initial size is controlled by <code>ArrayList</code> and is + * currently 10. */ public ArrayStack() { super(); @@ -61,9 +62,9 @@ public class ArrayStack<E> extends ArrayList<E> { /** * Constructs a new empty <code>ArrayStack</code> with an initial size. * - * @param initialSize the initial size to use - * @throws IllegalArgumentException if the specified initial size - * is negative + * @param initialSize the initial size to use + * + * @throws IllegalArgumentException if the specified initial size is negative */ public ArrayStack(int initialSize) { super(initialSize); @@ -72,8 +73,8 @@ public class ArrayStack<E> extends ArrayList<E> { /** * Return <code>true</code> if this stack is currently empty. * <p> - * This method exists for compatibility with <code>java.util.Stack</code>. - * New users of this class should use <code>isEmpty</code> instead. + * This method exists for compatibility with <code>java.util.Stack</code>. New users of this class should use + * <code>isEmpty</code> instead. * * @return true if the stack is currently empty */ @@ -85,7 +86,8 @@ public class ArrayStack<E> extends ArrayList<E> { * Returns the top item off of this stack without removing it. * * @return the top item on the stack - * @throws EmptyStackException if the stack is empty + * + * @throws EmptyStackException if the stack is empty */ public E peek() throws EmptyStackException { int n = size(); @@ -97,13 +99,13 @@ public class ArrayStack<E> extends ArrayList<E> { } /** - * Returns the n'th item down (zero-relative) from the top of this - * stack without removing it. + * Returns the n'th item down (zero-relative) from the top of this stack without removing it. + * + * @param n the number of items down to go * - * @param n the number of items down to go * @return the n'th item on the stack, zero relative - * @throws EmptyStackException if there are not enough items on the - * stack to satisfy this request + * + * @throws EmptyStackException if there are not enough items on the stack to satisfy this request */ public E peek(int n) throws EmptyStackException { int m = (size() - n) - 1; @@ -118,7 +120,8 @@ public class ArrayStack<E> extends ArrayList<E> { * Pops the top item off of this stack and return it. * * @return the top item on the stack - * @throws EmptyStackException if the stack is empty + * + * @throws EmptyStackException if the stack is empty */ public E pop() throws EmptyStackException { int n = size(); @@ -130,10 +133,11 @@ public class ArrayStack<E> extends ArrayList<E> { } /** - * Pushes a new item onto the top of this stack. The pushed item is also - * returned. This is equivalent to calling <code>add</code>. + * Pushes a new item onto the top of this stack. The pushed item is also returned. This is equivalent to calling + * <code>add</code>. + * + * @param item the item to be added * - * @param item the item to be added * @return the item just pushed */ public E push(E item) { diff --git a/java/org/apache/tomcat/util/digester/CallMethodRule.java b/java/org/apache/tomcat/util/digester/CallMethodRule.java index 6dc429f4d0..e2200350c3 100644 --- a/java/org/apache/tomcat/util/digester/CallMethodRule.java +++ b/java/org/apache/tomcat/util/digester/CallMethodRule.java @@ -22,56 +22,48 @@ import org.apache.tomcat.util.IntrospectionUtils; import org.xml.sax.Attributes; /** - * <p>Rule implementation that calls a method on an object on the stack - * (normally the top/parent object), passing arguments collected from - * subsequent <code>CallParamRule</code> rules or from the body of this - * element. </p> - * - * <p>By using {@link #CallMethodRule(String methodName)} - * a method call can be made to a method which accepts no - * arguments.</p> - * - * <p>Incompatible method parameter types are converted - * using <code>org.apache.commons.beanutils.ConvertUtils</code>. + * <p> + * Rule implementation that calls a method on an object on the stack (normally the top/parent object), passing arguments + * collected from subsequent <code>CallParamRule</code> rules or from the body of this element. * </p> - * - * <p>This rule now uses + * <p> + * By using {@link #CallMethodRule(String methodName)} a method call can be made to a method which accepts no arguments. + * </p> + * <p> + * Incompatible method parameter types are converted using <code>org.apache.commons.beanutils.ConvertUtils</code>. + * </p> + * <p> + * This rule now uses * <a href="https://commons.apache.org/beanutils/apidocs/org/apache/commons/beanutils/MethodUtils.html"> - * org.apache.commons.beanutils.MethodUtils#invokeMethod - * </a> by default. - * This increases the kinds of methods successfully and allows primitives - * to be matched by passing in wrapper classes. - * There are rare cases when org.apache.commons.beanutils.MethodUtils#invokeExactMethod - * (the old default) is required. - * This method is much stricter in its reflection. - * Setting the <code>UseExactMatch</code> to true reverts to the use of this - * method.</p> - * - * <p>Note that the target method is invoked when the <i>end</i> of - * the tag the CallMethodRule fired on is encountered, <i>not</i> when the - * last parameter becomes available. This implies that rules which fire on - * tags nested within the one associated with the CallMethodRule will - * fire before the CallMethodRule invokes the target method. This behaviour is - * not configurable. </p> - * - * <p>Note also that if a CallMethodRule is expecting exactly one parameter - * and that parameter is not available (e.g. CallParamRule is used with an - * attribute name but the attribute does not exist) then the method will - * not be invoked. If a CallMethodRule is expecting more than one parameter, - * then it is always invoked, regardless of whether the parameters were - * available or not (missing parameters are passed as null values).</p> + * org.apache.commons.beanutils.MethodUtils#invokeMethod </a> by default. This increases the kinds of methods + * successfully and allows primitives to be matched by passing in wrapper classes. There are rare cases when + * org.apache.commons.beanutils.MethodUtils#invokeExactMethod (the old default) is required. This method is much + * stricter in its reflection. Setting the <code>UseExactMatch</code> to true reverts to the use of this method. + * </p> + * <p> + * Note that the target method is invoked when the <i>end</i> of the tag the CallMethodRule fired on is encountered, + * <i>not</i> when the last parameter becomes available. This implies that rules which fire on tags nested within the + * one associated with the CallMethodRule will fire before the CallMethodRule invokes the target method. This behaviour + * is not configurable. + * </p> + * <p> + * Note also that if a CallMethodRule is expecting exactly one parameter and that parameter is not available (e.g. + * CallParamRule is used with an attribute name but the attribute does not exist) then the method will not be invoked. + * If a CallMethodRule is expecting more than one parameter, then it is always invoked, regardless of whether the + * parameters were available or not (missing parameters are passed as null values). + * </p> */ public class CallMethodRule extends Rule { // ----------------------------------------------------------- Constructors /** - * Construct a "call method" rule with the specified method name. The - * parameter types (if any) default to java.lang.String. + * Construct a "call method" rule with the specified method name. The parameter types (if any) default to + * java.lang.String. * * @param methodName Method name of the parent method to call - * @param paramCount The number of parameters to collect, or - * zero for a single argument from the body of this element. + * @param paramCount The number of parameters to collect, or zero for a single argument from the body of this + * element. */ public CallMethodRule(String methodName, int paramCount) { this(0, methodName, paramCount); @@ -79,16 +71,15 @@ public class CallMethodRule extends Rule { /** - * Construct a "call method" rule with the specified method name. The - * parameter types (if any) default to java.lang.String. + * Construct a "call method" rule with the specified method name. The parameter types (if any) default to + * java.lang.String. * - * @param targetOffset location of the target object. Positive numbers are - * relative to the top of the digester object stack. Negative numbers - * are relative to the bottom of the stack. Zero implies the top - * object on the stack. - * @param methodName Method name of the parent method to call - * @param paramCount The number of parameters to collect, or - * zero for a single argument from the body of this element. + * @param targetOffset location of the target object. Positive numbers are relative to the top of the digester + * object stack. Negative numbers are relative to the bottom of the stack. Zero implies the + * top object on the stack. + * @param methodName Method name of the parent method to call + * @param paramCount The number of parameters to collect, or zero for a single argument from the body of this + * element. */ public CallMethodRule(int targetOffset, String methodName, int paramCount) { this.targetOffset = targetOffset; @@ -104,8 +95,7 @@ public class CallMethodRule extends Rule { /** - * Construct a "call method" rule with the specified method name. - * The method should accept no parameters. + * Construct a "call method" rule with the specified method name. The method should accept no parameters. * * @param methodName Method name of the parent method to call */ @@ -115,27 +105,21 @@ public class CallMethodRule extends Rule { /** - * Construct a "call method" rule with the specified method name and - * parameter types. If <code>paramCount</code> is set to zero the rule - * will use the body of this element as the single argument of the - * method, unless <code>paramTypes</code> is null or empty, in this - * case the rule will call the specified method with no arguments. + * Construct a "call method" rule with the specified method name and parameter types. If <code>paramCount</code> is + * set to zero the rule will use the body of this element as the single argument of the method, unless + * <code>paramTypes</code> is null or empty, in this case the rule will call the specified method with no arguments. * - * @param targetOffset location of the target object. Positive numbers are - * relative to the top of the digester object stack. Negative numbers - * are relative to the bottom of the stack. Zero implies the top - * object on the stack. - * @param methodName Method name of the parent method to call - * @param paramCount The number of parameters to collect, or - * zero for a single argument from the body of this element - * @param paramTypes The Java classes that represent the - * parameter types of the method arguments - * (if you wish to use a primitive type, specify the corresponding - * Java wrapper class instead, such as <code>java.lang.Boolean.TYPE</code> - * for a <code>boolean</code> parameter) + * @param targetOffset location of the target object. Positive numbers are relative to the top of the digester + * object stack. Negative numbers are relative to the bottom of the stack. Zero implies the + * top object on the stack. + * @param methodName Method name of the parent method to call + * @param paramCount The number of parameters to collect, or zero for a single argument from the body of this + * element + * @param paramTypes The Java classes that represent the parameter types of the method arguments (if you wish to + * use a primitive type, specify the corresponding Java wrapper class instead, such as + * <code>java.lang.Boolean.TYPE</code> for a <code>boolean</code> parameter) */ - public CallMethodRule(int targetOffset, String methodName, int paramCount, - Class<?>[] paramTypes) { + public CallMethodRule(int targetOffset, String methodName, int paramCount, Class<?>[] paramTypes) { this.targetOffset = targetOffset; this.methodName = methodName; @@ -159,9 +143,8 @@ public class CallMethodRule extends Rule { /** - * location of the target object for the call, relative to the - * top of the digester object stack. The default value of zero - * means the target object is the one on top of the stack. + * location of the target object for the call, relative to the top of the digester object stack. The default value + * of zero means the target object is the one on top of the stack. */ protected final int targetOffset; @@ -173,9 +156,8 @@ public class CallMethodRule extends Rule { /** - * The number of parameters to collect from <code>MethodParam</code> rules. - * If this value is zero, a single parameter will be collected from the - * body of this element. + * The number of parameters to collect from <code>MethodParam</code> rules. If this value is zero, a single + * parameter will be collected from the body of this element. */ protected final int paramCount; @@ -195,8 +177,8 @@ public class CallMethodRule extends Rule { // --------------------------------------------------------- Public Methods /** - * Should <code>MethodUtils.invokeExactMethod</code> - * be used for the reflection. + * Should <code>MethodUtils.invokeExactMethod</code> be used for the reflection. + * * @return <code>true</code> if invokeExactMethod is used */ public boolean getUseExactMatch() { @@ -205,8 +187,8 @@ public class CallMethodRule extends Rule { /** - * Set whether <code>MethodUtils.invokeExactMethod</code> - * should be used for the reflection. + * Set whether <code>MethodUtils.invokeExactMethod</code> should be used for the reflection. + * * @param useExactMatch The flag value */ public void setUseExactMatch(boolean useExactMatch) { @@ -217,16 +199,13 @@ public class CallMethodRule extends Rule { /** * Process the start of this element. * - * @param namespace the namespace URI of the matching element, or an - * empty string if the parser is not namespace aware or the element has - * no namespace - * @param name the local name if the parser is namespace aware, or just - * the element name otherwise + * @param namespace the namespace URI of the matching element, or an empty string if the parser is not namespace + * aware or the element has no namespace + * @param name the local name if the parser is namespace aware, or just the element name otherwise * @param attributes The attribute list for this element */ @Override - public void begin(String namespace, String name, Attributes attributes) - throws Exception { + public void begin(String namespace, String name, Attributes attributes) throws Exception { // Push an array to capture the parameter values if necessary if (paramCount > 0) { @@ -240,16 +219,13 @@ public class CallMethodRule extends Rule { /** * Process the body text of this element. * - * @param namespace the namespace URI of the matching element, or an - * empty string if the parser is not namespace aware or the element has - * no namespace - * @param name the local name if the parser is namespace aware, or just - * the element name otherwise - * @param bodyText The body text of this element + * @param namespace the namespace URI of the matching element, or an empty string if the parser is not namespace + * aware or the element has no namespace + * @param name the local name if the parser is namespace aware, or just the element name otherwise + * @param bodyText The body text of this element */ @Override - public void body(String namespace, String name, String bodyText) - throws Exception { + public void body(String namespace, String name, String bodyText) throws Exception { if (paramCount == 0) { this.bodyText = bodyText.trim().intern(); @@ -261,11 +237,9 @@ public class CallMethodRule extends Rule { /** * Process the end of this element. * - * @param namespace the namespace URI of the matching element, or an - * empty string if the parser is not namespace aware or the element has - * no namespace - * @param name the local name if the parser is namespace aware, or just - * the element name otherwise + * @param namespace the namespace URI of the matching element, or an empty string if the parser is not namespace + * aware or the element has no namespace + * @param name the local name if the parser is namespace aware, or just the element name otherwise */ @SuppressWarnings("null") // parameters can't trigger NPE @Override @@ -278,8 +252,8 @@ public class CallMethodRule extends Rule { parameters = (Object[]) digester.popParams(); if (digester.log.isTraceEnabled()) { - for (int i=0,size=parameters.length;i<size;i++) { - digester.log.trace("[CallMethodRule](" + i + ")" + parameters[i]) ; + for (int i = 0, size = parameters.length; i < size; i++) { + digester.log.trace("[CallMethodRule](" + i + ")" + parameters[i]); } } @@ -314,13 +288,11 @@ public class CallMethodRule extends Rule { // for non-stringy param types Object param = parameters[i]; // Tolerate null non-primitive values - if(null == param && !paramTypes[i].isPrimitive()) { + if (null == param && !paramTypes[i].isPrimitive()) { paramValues[i] = null; - } else if(param instanceof String && - !String.class.isAssignableFrom(paramTypes[i])) { + } else if (param instanceof String && !String.class.isAssignableFrom(paramTypes[i])) { - paramValues[i] = - IntrospectionUtils.convert((String) parameters[i], paramTypes[i]); + paramValues[i] = IntrospectionUtils.convert((String) parameters[i], paramTypes[i]); } else { paramValues[i] = parameters[i]; } @@ -331,12 +303,12 @@ public class CallMethodRule extends Rule { if (targetOffset >= 0) { target = digester.peek(targetOffset); } else { - target = digester.peek( digester.getCount() + targetOffset ); + target = digester.peek(digester.getCount() + targetOffset); } if (target == null) { - String sb = "[CallMethodRule]{" + digester.match + "} Call target is null (" + - "targetOffset=" + targetOffset + ",stackdepth=" + digester.getCount() + ')'; + String sb = "[CallMethodRule]{" + digester.match + "} Call target is null (" + "targetOffset=" + + targetOffset + ",stackdepth=" + digester.getCount() + ')'; throw new org.xml.sax.SAXException(sb); } @@ -368,8 +340,7 @@ public class CallMethodRule extends Rule { sb.append(')'); digester.log.trace(sb.toString()); } - Object result = IntrospectionUtils.callMethodN(target, methodName, - paramValues, paramTypes); + Object result = IntrospectionUtils.callMethodN(target, methodName, paramValues, paramTypes); processMethodCallResult(result); StringBuilder code = digester.getGeneratedCode(); @@ -404,8 +375,7 @@ public class CallMethodRule extends Rule { /** - * Subclasses may override this method to perform additional processing of the - * invoked method's result. + * Subclasses may override this method to perform additional processing of the invoked method's result. * * @param result the Object returned by the method invoked, possibly null */ diff --git a/java/org/apache/tomcat/util/digester/CallParamRule.java b/java/org/apache/tomcat/util/digester/CallParamRule.java index 19bf7b290b..f996ef9be9 100644 --- a/java/org/apache/tomcat/util/digester/CallParamRule.java +++ b/java/org/apache/tomcat/util/digester/CallParamRule.java @@ -19,15 +19,15 @@ package org.apache.tomcat.util.digester; import org.xml.sax.Attributes; /** - * <p>Rule implementation that saves a parameter for use by a surrounding - * <code>CallMethodRule</code>.</p> - * - * <p>This parameter may be:</p> + * <p> + * Rule implementation that saves a parameter for use by a surrounding <code>CallMethodRule</code>. + * </p> + * <p> + * This parameter may be: + * </p> * <ul> - * <li>from an attribute of the current element - * See {@link #CallParamRule(int paramIndex, String attributeName)} - * <li>from current the element body - * See {@link #CallParamRule(int paramIndex)} + * <li>from an attribute of the current element See {@link #CallParamRule(int paramIndex, String attributeName)} + * <li>from current the element body See {@link #CallParamRule(int paramIndex)} * </ul> */ public class CallParamRule extends Rule { @@ -35,8 +35,7 @@ public class CallParamRule extends Rule { // ----------------------------------------------------------- Constructors /** - * Construct a "call parameter" rule that will save the body text of this - * element as the parameter value. + * Construct a "call parameter" rule that will save the body text of this element as the parameter value. * * @param paramIndex The zero-relative parameter number */ @@ -46,20 +45,17 @@ public class CallParamRule extends Rule { /** - * Construct a "call parameter" rule that will save the value of the - * specified attribute as the parameter value. + * Construct a "call parameter" rule that will save the value of the specified attribute as the parameter value. * - * @param paramIndex The zero-relative parameter number + * @param paramIndex The zero-relative parameter number * @param attributeName The name of the attribute to save */ - public CallParamRule(int paramIndex, - String attributeName) { + public CallParamRule(int paramIndex, String attributeName) { this(attributeName, paramIndex, 0, false); } - private CallParamRule(String attributeName, int paramIndex, int stackIndex, - boolean fromStack) { + private CallParamRule(String attributeName, int paramIndex, int stackIndex, boolean fromStack) { this.attributeName = attributeName; this.paramIndex = paramIndex; this.stackIndex = stackIndex; @@ -93,8 +89,7 @@ public class CallParamRule extends Rule { protected final int stackIndex; /** - * Stack is used to allow nested body text to be processed. - * Lazy creation. + * Stack is used to allow nested body text to be processed. Lazy creation. */ protected ArrayStack<String> bodyTextStack; @@ -104,16 +99,13 @@ public class CallParamRule extends Rule { /** * Process the start of this element. * - * @param namespace the namespace URI of the matching element, or an - * empty string if the parser is not namespace aware or the element has - * no namespace - * @param name the local name if the parser is namespace aware, or just - * the element name otherwise + * @param namespace the namespace URI of the matching element, or an empty string if the parser is not namespace + * aware or the element has no namespace + * @param name the local name if the parser is namespace aware, or just the element name otherwise * @param attributes The attribute list for this element */ @Override - public void begin(String namespace, String name, Attributes attributes) - throws Exception { + public void begin(String namespace, String name, Attributes attributes) throws Exception { Object param = null; @@ -126,8 +118,7 @@ public class CallParamRule extends Rule { param = digester.peek(stackIndex); if (digester.log.isTraceEnabled()) { - String sb = "[CallParamRule]{" + digester.match + - "} Save from stack; from stack? " + true + + String sb = "[CallParamRule]{" + digester.match + "} Save from stack; from stack? " + true + "; object=" + param; digester.log.trace(sb); } @@ -139,7 +130,7 @@ public class CallParamRule extends Rule { // the instance variables will be overwritten // if this CallParamRule is reused in subsequent nesting. - if(param != null) { + if (param != null) { Object[] parameters = (Object[]) digester.peekParams(); parameters[paramIndex] = param; } @@ -149,16 +140,13 @@ public class CallParamRule extends Rule { /** * Process the body text of this element. * - * @param namespace the namespace URI of the matching element, or an - * empty string if the parser is not namespace aware or the element has - * no namespace - * @param name the local name if the parser is namespace aware, or just - * the element name otherwise - * @param bodyText The body text of this element + * @param namespace the namespace URI of the matching element, or an empty string if the parser is not namespace + * aware or the element has no namespace + * @param name the local name if the parser is namespace aware, or just the element name otherwise + * @param bodyText The body text of this element */ @Override - public void body(String namespace, String name, String bodyText) - throws Exception { + public void body(String namespace, String name, String bodyText) throws Exception { if (attributeName == null && !fromStack) { // We must wait to set the parameter until end @@ -189,8 +177,8 @@ public class CallParamRule extends Rule { */ @Override public String toString() { - return "CallParamRule[" + "paramIndex=" + paramIndex + ", attributeName=" + attributeName + - ", from stack=" + fromStack + ']'; + return "CallParamRule[" + "paramIndex=" + paramIndex + ", attributeName=" + attributeName + ", from stack=" + + fromStack + ']'; } diff --git a/java/org/apache/tomcat/util/digester/Digester.java b/java/org/apache/tomcat/util/digester/Digester.java index da1c9905da..00e2c3e00b 100644 --- a/java/org/apache/tomcat/util/digester/Digester.java +++ b/java/org/apache/tomcat/util/digester/Digester.java @@ -63,23 +63,23 @@ import org.xml.sax.helpers.AttributesImpl; /** - * <p>A <strong>Digester</strong> processes an XML input stream by matching a - * series of element nesting patterns to execute Rules that have been added - * prior to the start of parsing. This package was inspired by the - * <code>XmlMapper</code> class that was part of Tomcat 3.0 and 3.1, - * but is organized somewhat differently.</p> - * - * <p>See the <a href="package-summary.html#package_description">Digester - * Developer Guide</a> for more information.</p> - * - * <p><strong>IMPLEMENTATION NOTE</strong> - A single Digester instance may - * only be used within the context of a single thread at a time, and a call - * to <code>parse()</code> must be completed before another can be initiated - * even from the same thread.</p> - * - * <p><strong>IMPLEMENTATION NOTE</strong> - A bug in Xerces 2.0.2 prevents - * the support of XML schema. You need Xerces 2.1/2.3 and up to make - * this class working with XML schema</p> + * <p> + * A <strong>Digester</strong> processes an XML input stream by matching a series of element nesting patterns to execute + * Rules that have been added prior to the start of parsing. This package was inspired by the <code>XmlMapper</code> + * class that was part of Tomcat 3.0 and 3.1, but is organized somewhat differently. + * </p> + * <p> + * See the <a href="package-summary.html#package_description">Digester Developer Guide</a> for more information. + * </p> + * <p> + * <strong>IMPLEMENTATION NOTE</strong> - A single Digester instance may only be used within the context of a single + * thread at a time, and a call to <code>parse()</code> must be completed before another can be initiated even from the + * same thread. + * </p> + * <p> + * <strong>IMPLEMENTATION NOTE</strong> - A bug in Xerces 2.0.2 prevents the support of XML schema. You need Xerces + * 2.1/2.3 and up to make this class working with XML schema + * </p> */ public class Digester extends DefaultHandler2 { @@ -106,7 +106,8 @@ public class Digester extends DefaultHandler2 { break; } catch (Throwable t) { ExceptionUtils.handleThrowable(t); - LogFactory.getLog(Digester.class).error(sm.getString("digester.propertySourceLoadError", className), t); + LogFactory.getLog(Digester.class) + .error(sm.getString("digester.propertySourceLoadError", className), t); } } } @@ -188,11 +189,9 @@ public class Digester extends DefaultHandler2 { /** - * Stack whose elements are List objects, each containing a list of - * Rule objects as returned from Rules.getMatch(). As each xml element - * in the input is entered, the matching rules are pushed onto this - * stack. After the end tag is reached, the matches are popped again. - * The depth of is stack is therefore exactly the same as the current + * Stack whose elements are List objects, each containing a list of Rule objects as returned from Rules.getMatch(). + * As each xml element in the input is entered, the matching rules are pushed onto this stack. After the end tag is + * reached, the matches are popped again. The depth of is stack is therefore exactly the same as the current * "nesting" level of the input xml. * * @since 1.6 @@ -200,10 +199,9 @@ public class Digester extends DefaultHandler2 { protected ArrayStack<List<Rule>> matches = new ArrayStack<>(10); /** - * The class loader to use for instantiating application objects. - * If not specified, the context class loader, or the class loader - * used to load Digester itself, is used, based on the value of the - * <code>useContextClassLoader</code> variable. + * The class loader to use for instantiating application objects. If not specified, the context class loader, or the + * class loader used to load Digester itself, is used, based on the value of the <code>useContextClassLoader</code> + * variable. */ protected ClassLoader classLoader = null; @@ -220,15 +218,13 @@ public class Digester extends DefaultHandler2 { protected EntityResolver entityResolver; /** - * The URLs of entityValidator that have been registered, keyed by the public - * identifier that corresponds. + * The URLs of entityValidator that have been registered, keyed by the public identifier that corresponds. */ - protected HashMap<String, String> entityValidator = new HashMap<>(); + protected HashMap<String,String> entityValidator = new HashMap<>(); /** - * The application-supplied error handler that is notified when parsing - * warnings, errors, or fatal errors occur. + * The application-supplied error handler that is notified when parsing warnings, errors, or fatal errors occur. */ protected ErrorHandler errorHandler = null; @@ -257,19 +253,16 @@ public class Digester extends DefaultHandler2 { /** - * Registered namespaces we are currently processing. The key is the - * namespace prefix that was declared in the document. The value is an - * ArrayStack of the namespace URIs this prefix has been mapped to -- - * the top Stack element is the most current one. (This architecture - * is required because documents can declare nested uses of the same - * prefix for different Namespace URIs). + * Registered namespaces we are currently processing. The key is the namespace prefix that was declared in the + * document. The value is an ArrayStack of the namespace URIs this prefix has been mapped to -- the top Stack + * element is the most current one. (This architecture is required because documents can declare nested uses of the + * same prefix for different Namespace URIs). */ - protected HashMap<String, ArrayStack<String>> namespaces = new HashMap<>(); + protected HashMap<String,ArrayStack<String>> namespaces = new HashMap<>(); /** - * The parameters stack being utilized by CallMethodRule and - * CallParamRule rules. + * The parameters stack being utilized by CallMethodRule and CallParamRule rules. */ protected ArrayStack<Object> params = new ArrayStack<>(); @@ -281,8 +274,7 @@ public class Digester extends DefaultHandler2 { /** - * The public identifier of the DTD we are currently parsing under - * (if any). + * The public identifier of the DTD we are currently parsing under (if any). */ protected String publicId = null; @@ -294,17 +286,14 @@ public class Digester extends DefaultHandler2 { /** - * The "root" element of the stack (in other words, the last object - * that was popped). + * The "root" element of the stack (in other words, the last object that was popped). */ protected Object root = null; /** - * The <code>Rules</code> implementation containing our collection of - * <code>Rule</code> instances and associated matching policy. If not - * established before the first rule is added, a default implementation - * will be provided. + * The <code>Rules</code> implementation containing our collection of <code>Rule</code> instances and associated + * matching policy. If not established before the first rule is added, a default implementation will be provided. */ protected Rules rules = null; @@ -315,8 +304,8 @@ public class Digester extends DefaultHandler2 { /** - * Do we want to use the Context ClassLoader when loading classes - * for instantiating new objects. Default is <code>false</code>. + * Do we want to use the Context ClassLoader when loading classes for instantiating new objects. Default is + * <code>false</code>. */ protected boolean useContextClassLoader = false; @@ -336,7 +325,7 @@ public class Digester extends DefaultHandler2 { /** * Fake attributes map (attributes are often used for object creation). */ - protected Map<Class<?>, List<String>> fakeAttributes = null; + protected Map<Class<?>,List<String>> fakeAttributes = null; /** @@ -409,9 +398,11 @@ public class Digester extends DefaultHandler2 { } protected ArrayList<Object> known = new ArrayList<>(); + public void setKnown(Object object) { known.add(object); } + public String toVariableName(Object object) { boolean found = false; int pos = 0; @@ -434,11 +425,11 @@ public class Digester extends DefaultHandler2 { // ------------------------------------------------------------- Properties /** - * Return the currently mapped namespace URI for the specified prefix, - * if any; otherwise return <code>null</code>. These mappings come and - * go dynamically as the document is parsed. + * Return the currently mapped namespace URI for the specified prefix, if any; otherwise return <code>null</code>. + * These mappings come and go dynamically as the document is parsed. * * @param prefix Prefix to look up + * * @return the namespace URI */ public String findNamespaceURI(String prefix) { @@ -455,14 +446,15 @@ public class Digester extends DefaultHandler2 { /** - * Return the class loader to be used for instantiating application objects - * when required. This is determined based upon the following rules: + * Return the class loader to be used for instantiating application objects when required. This is determined based + * upon the following rules: * <ul> * <li>The class loader set by <code>setClassLoader()</code>, if any</li> - * <li>The thread context class loader, if it exists and the - * <code>useContextClassLoader</code> property is set to true</li> + * <li>The thread context class loader, if it exists and the <code>useContextClassLoader</code> property is set to + * true</li> * <li>The class loader used to load the Digester class itself. * </ul> + * * @return the classloader */ public ClassLoader getClassLoader() { @@ -480,11 +472,9 @@ public class Digester extends DefaultHandler2 { /** - * Set the class loader to be used for instantiating application objects - * when required. + * Set the class loader to be used for instantiating application objects when required. * - * @param classLoader The new class loader to use, or <code>null</code> - * to revert to the standard rules + * @param classLoader The new class loader to use, or <code>null</code> to revert to the standard rules */ public void setClassLoader(ClassLoader classLoader) { this.classLoader = classLoader; @@ -532,13 +522,15 @@ public class Digester extends DefaultHandler2 { /** * SAX parser factory method. + * * @return the SAXParserFactory we will use, creating one if necessary. + * * @throws ParserConfigurationException Error creating parser - * @throws SAXNotSupportedException Error creating parser - * @throws SAXNotRecognizedException Error creating parser + * @throws SAXNotSupportedException Error creating parser + * @throws SAXNotRecognizedException Error creating parser */ - public SAXParserFactory getFactory() throws SAXNotRecognizedException, SAXNotSupportedException, - ParserConfigurationException { + public SAXParserFactory getFactory() + throws SAXNotRecognizedException, SAXNotSupportedException, ParserConfigurationException { if (factory == null) { factory = SAXParserFactory.newInstance(); @@ -562,27 +554,22 @@ public class Digester extends DefaultHandler2 { /** - * Sets a flag indicating whether the requested feature is supported - * by the underlying implementation of <code>org.xml.sax.XMLReader</code>. - * See <a href="http://www.saxproject.org/apidoc/xml/sax/package-summary.html#package-description"> - * http://www.saxproject.org/apidoc/xml/sax/package-summary.html#package-description</a> - * for information about the standard SAX2 feature flags. In order to be - * effective, this method must be called <strong>before</strong> the - * <code>getParser()</code> method is called for the first time, either - * directly or indirectly. + * Sets a flag indicating whether the requested feature is supported by the underlying implementation of + * <code>org.xml.sax.XMLReader</code>. See + * <a href="http://www.saxproject.org/apidoc/xml/sax/package-summary.html#package-description"> + * http://www.saxproject.org/apidoc/xml/sax/package-summary.html#package-description</a> for information about the + * standard SAX2 feature flags. In order to be effective, this method must be called <strong>before</strong> the + * <code>getParser()</code> method is called for the first time, either directly or indirectly. * * @param feature Name of the feature to set the status for - * @param value The new value for this feature + * @param value The new value for this feature * - * @exception ParserConfigurationException if a parser configuration error - * occurs - * @exception SAXNotRecognizedException if the property name is - * not recognized - * @exception SAXNotSupportedException if the property name is - * recognized but not supported + * @exception ParserConfigurationException if a parser configuration error occurs + * @exception SAXNotRecognizedException if the property name is not recognized + * @exception SAXNotSupportedException if the property name is recognized but not supported */ - public void setFeature(String feature, boolean value) throws ParserConfigurationException, - SAXNotRecognizedException, SAXNotSupportedException { + public void setFeature(String feature, boolean value) + throws ParserConfigurationException, SAXNotRecognizedException, SAXNotSupportedException { getFactory().setFeature(feature, value); @@ -601,6 +588,7 @@ public class Digester extends DefaultHandler2 { /** * Set the current logger for this Digester. + * * @param log The logger that will be used */ public void setLogger(Log log) { @@ -610,10 +598,10 @@ public class Digester extends DefaultHandler2 { } /** - * Gets the logger used for logging SAX-related information. - * <strong>Note</strong> the output is finely grained. + * Gets the logger used for logging SAX-related information. <strong>Note</strong> the output is finely grained. * * @since 1.6 + * * @return the SAX logger */ public Log getSAXLogger() { @@ -623,8 +611,8 @@ public class Digester extends DefaultHandler2 { /** - * Sets the logger used for logging SAX-related information. - * <strong>Note</strong> the output is finely grained. + * Sets the logger used for logging SAX-related information. <strong>Note</strong> the output is finely grained. + * * @param saxLog Log, not null * * @since 1.6 @@ -664,6 +652,7 @@ public class Digester extends DefaultHandler2 { /** * Set the public id of the current file being parsed. + * * @param publicId the DTD/Schema public's id. */ public void setPublicId(String publicId) { @@ -672,8 +661,7 @@ public class Digester extends DefaultHandler2 { /** - * @return the public identifier of the DTD we are currently - * parsing under, if any. + * @return the public identifier of the DTD we are currently parsing under, if any. */ public String getPublicId() { return this.publicId; @@ -681,8 +669,8 @@ public class Digester extends DefaultHandler2 { /** - * @return the SAXParser we will use to parse the input stream. If there - * is a problem creating the parser, return <code>null</code>. + * @return the SAXParser we will use to parse the input stream. If there is a problem creating the parser, return + * <code>null</code>. */ public SAXParser getParser() { @@ -704,30 +692,28 @@ public class Digester extends DefaultHandler2 { /** - * Return the current value of the specified property for the underlying - * <code>XMLReader</code> implementation. - * See <a href="http://www.saxproject.org/apidoc/xml/sax/package-summary.html#package-description"> - * http://www.saxproject.org/apidoc/xml/sax/package-summary.html#package-description</a> - * for information about the standard SAX2 properties. + * Return the current value of the specified property for the underlying <code>XMLReader</code> implementation. See + * <a href="http://www.saxproject.org/apidoc/xml/sax/package-summary.html#package-description"> + * http://www.saxproject.org/apidoc/xml/sax/package-summary.html#package-description</a> for information about the + * standard SAX2 properties. * * @param property Property name to be retrieved + * * @return the property value - * @exception SAXNotRecognizedException if the property name is - * not recognized - * @exception SAXNotSupportedException if the property name is - * recognized but not supported + * + * @exception SAXNotRecognizedException if the property name is not recognized + * @exception SAXNotSupportedException if the property name is recognized but not supported */ - public Object getProperty(String property) - throws SAXNotRecognizedException, SAXNotSupportedException { + public Object getProperty(String property) throws SAXNotRecognizedException, SAXNotSupportedException { return getParser().getProperty(property); } /** - * Return the <code>Rules</code> implementation object containing our - * rules collection and associated matching policy. If none has been - * established, a default implementation will be created and returned. + * Return the <code>Rules</code> implementation object containing our rules collection and associated matching + * policy. If none has been established, a default implementation will be created and returned. + * * @return the rules */ public Rules getRules() { @@ -740,8 +726,7 @@ public class Digester extends DefaultHandler2 { /** - * Set the <code>Rules</code> implementation object containing our - * rules collection and associated matching policy. + * Set the <code>Rules</code> implementation object containing our rules collection and associated matching policy. * * @param rules New Rules implementation */ @@ -760,11 +745,9 @@ public class Digester extends DefaultHandler2 { /** - * Determine whether to use the Context ClassLoader (the one found by - * calling <code>Thread.currentThread().getContextClassLoader()</code>) - * to resolve/load classes that are defined in various rules. If not - * using Context ClassLoader, then the class-loading defaults to - * using the calling class' ClassLoader. + * Determine whether to use the Context ClassLoader (the one found by calling + * <code>Thread.currentThread().getContextClassLoader()</code>) to resolve/load classes that are defined in various + * rules. If not using Context ClassLoader, then the class-loading defaults to using the calling class' ClassLoader. * * @param use determines whether to use Context ClassLoader. */ @@ -784,8 +767,7 @@ public class Digester extends DefaultHandler2 { /** - * Set the validating parser flag. This must be called before - * <code>parse()</code> is called the first time. + * Set the validating parser flag. This must be called before <code>parse()</code> is called the first time. * * @param validating The new validating parser flag. */ @@ -803,8 +785,7 @@ public class Digester extends DefaultHandler2 { /** - * Set the rules validation flag. This must be called before - * <code>parse()</code> is called the first time. + * Set the rules validation flag. This must be called before <code>parse()</code> is called the first time. * * @param rulesValidation The new rules validation flag. */ @@ -816,15 +797,17 @@ public class Digester extends DefaultHandler2 { /** * @return the fake attributes list. */ - public Map<Class<?>, List<String>> getFakeAttributes() { + public Map<Class<?>,List<String>> getFakeAttributes() { return this.fakeAttributes; } /** * Determine if an attribute is a fake attribute. + * * @param object The object - * @param name The attribute name + * @param name The attribute name + * * @return <code>true</code> if this is a fake attribute */ public boolean isFakeAttribute(Object object, String name) { @@ -848,7 +831,7 @@ public class Digester extends DefaultHandler2 { * * @param fakeAttributes The new fake attributes. */ - public void setFakeAttributes(Map<Class<?>, List<String>> fakeAttributes) { + public void setFakeAttributes(Map<Class<?>,List<String>> fakeAttributes) { this.fakeAttributes = fakeAttributes; @@ -856,10 +839,11 @@ public class Digester extends DefaultHandler2 { /** - * Return the XMLReader to be used for parsing the input document. - * FIX ME: there is a bug in JAXP/XERCES that prevent the use of a - * parser that contains a schema with a DTD. + * Return the XMLReader to be used for parsing the input document. FIX ME: there is a bug in JAXP/XERCES that + * prevent the use of a parser that contains a schema with a DTD. + * * @return the XML reader + * * @exception SAXException if no XMLReader can be instantiated */ public XMLReader getXMLReader() throws SAXException { @@ -894,11 +878,10 @@ public class Digester extends DefaultHandler2 { /** - * Process notification of character data received from the body of - * an XML element. + * Process notification of character data received from the body of an XML element. * * @param buffer The characters from the XML document - * @param start Starting offset into the buffer + * @param start Starting offset into the buffer * @param length Number of characters from the buffer * * @exception SAXException if a parsing error is to be reported @@ -957,18 +940,17 @@ public class Digester extends DefaultHandler2 { /** * Process notification of the end of an XML element being reached. * - * @param namespaceURI - The Namespace URI, or the empty string if the - * element has no Namespace URI or if Namespace processing is not - * being performed. - * @param localName - The local name (without prefix), or the empty - * string if Namespace processing is not being performed. - * @param qName - The qualified XML 1.0 name (with prefix), or the - * empty string if qualified names are not available. + * @param namespaceURI - The Namespace URI, or the empty string if the element has no Namespace URI or if Namespace + * processing is not being performed. + * @param localName - The local name (without prefix), or the empty string if Namespace processing is not being + * performed. + * @param qName - The qualified XML 1.0 name (with prefix), or the empty string if qualified names are not + * available. + * * @exception SAXException if a parsing error is to be reported */ @Override - public void endElement(String namespaceURI, String localName, String qName) - throws SAXException { + public void endElement(String namespaceURI, String localName, String qName) throws SAXException { boolean debug = log.isTraceEnabled(); @@ -1083,12 +1065,11 @@ public class Digester extends DefaultHandler2 { /** - * Process notification of ignorable whitespace received from the body of - * an XML element. + * Process notification of ignorable whitespace received from the body of an XML element. * * @param buffer The characters from the XML document - * @param start Starting offset into the buffer - * @param len Number of characters from the buffer + * @param start Starting offset into the buffer + * @param len Number of characters from the buffer * * @exception SAXException if a parsing error is to be reported */ @@ -1108,7 +1089,7 @@ public class Digester extends DefaultHandler2 { * Process notification of a processing instruction that was encountered. * * @param target The processing instruction target - * @param data The processing instruction data (if any) + * @param data The processing instruction data (if any) * * @exception SAXException if a parsing error is to be reported */ @@ -1206,19 +1187,18 @@ public class Digester extends DefaultHandler2 { /** * Process notification of the start of an XML element being reached. * - * @param namespaceURI The Namespace URI, or the empty string if the element - * has no Namespace URI or if Namespace processing is not being performed. - * @param localName The local name (without prefix), or the empty - * string if Namespace processing is not being performed. - * @param qName The qualified name (with prefix), or the empty - * string if qualified names are not available.\ - * @param list The attributes attached to the element. If there are - * no attributes, it shall be an empty Attributes object. + * @param namespaceURI The Namespace URI, or the empty string if the element has no Namespace URI or if Namespace + * processing is not being performed. + * @param localName The local name (without prefix), or the empty string if Namespace processing is not being + * performed. + * @param qName The qualified name (with prefix), or the empty string if qualified names are not available.\ + * @param list The attributes attached to the element. If there are no attributes, it shall be an empty + * Attributes object. + * * @exception SAXException if a parsing error is to be reported */ @Override - public void startElement(String namespaceURI, String localName, String qName, Attributes list) - throws SAXException { + public void startElement(String namespaceURI, String localName, String qName, Attributes list) throws SAXException { boolean debug = log.isTraceEnabled(); if (saxLog.isTraceEnabled()) { @@ -1286,7 +1266,7 @@ public class Digester extends DefaultHandler2 { /** * Process notification that a namespace prefix is coming in to scope. * - * @param prefix Prefix that is being declared + * @param prefix Prefix that is being declared * @param namespaceURI Corresponding namespace URI being mapped to * * @exception SAXException if a parsing error is to be reported @@ -1315,7 +1295,7 @@ public class Digester extends DefaultHandler2 { /** * Receive notification of a notation declaration event. * - * @param name The notation name + * @param name The notation name * @param publicId The public identifier (if any) * @param systemId The system identifier (if any) */ @@ -1332,7 +1312,7 @@ public class Digester extends DefaultHandler2 { /** * Receive notification of an unparsed entity declaration event. * - * @param name The unparsed entity name + * @param name The unparsed entity name * @param publicId The public identifier (if any) * @param systemId The system identifier (if any) * @param notation The name of the associated notation @@ -1341,8 +1321,7 @@ public class Digester extends DefaultHandler2 { public void unparsedEntityDecl(String name, String publicId, String systemId, String notation) { if (saxLog.isTraceEnabled()) { - saxLog.trace("unparsedEntityDecl(" + name + "," + publicId + "," + systemId + "," - + notation + ")"); + saxLog.trace("unparsedEntityDecl(" + name + "," + publicId + "," + systemId + "," + notation + ")"); } } @@ -1351,9 +1330,9 @@ public class Digester extends DefaultHandler2 { // ----------------------------------------------- EntityResolver Methods /** - * Set the <code>EntityResolver</code> used by SAX when resolving - * public id and system id. - * This must be called before the first call to <code>parse()</code>. + * Set the <code>EntityResolver</code> used by SAX when resolving public id and system id. This must be called + * before the first call to <code>parse()</code>. + * * @param entityResolver a class that implement the <code>EntityResolver</code> interface. */ public void setEntityResolver(EntityResolver entityResolver) { @@ -1363,6 +1342,7 @@ public class Digester extends DefaultHandler2 { /** * Return the Entity Resolver used by the SAX parser. + * * @return Return the Entity Resolver used by the SAX parser. */ public EntityResolver getEntityResolver() { @@ -1374,8 +1354,7 @@ public class Digester extends DefaultHandler2 { throws SAXException, IOException { if (saxLog.isTraceEnabled()) { - saxLog.trace( - "resolveEntity('" + publicId + "', '" + systemId + "', '" + baseURI + "')"); + saxLog.trace("resolveEntity('" + publicId + "', '" + systemId + "', '" + baseURI + "')"); } // Has this system identifier been registered? @@ -1438,8 +1417,7 @@ public class Digester extends DefaultHandler2 { // ------------------------------------------------- ErrorHandler Methods /** - * Forward notification of a parsing error to the application supplied - * error handler (if any). + * Forward notification of a parsing error to the application supplied error handler (if any). * * @param exception The error information * @@ -1456,8 +1434,7 @@ public class Digester extends DefaultHandler2 { /** - * Forward notification of a fatal parsing error to the application - * supplied error handler (if any). + * Forward notification of a fatal parsing error to the application supplied error handler (if any). * * @param exception The fatal error information * @@ -1474,8 +1451,7 @@ public class Digester extends DefaultHandler2 { /** - * Forward notification of a parse warning to the application supplied - * error handler (if any). + * Forward notification of a parse warning to the application supplied error handler (if any). * * @param exception The warning information * @@ -1495,12 +1471,14 @@ public class Digester extends DefaultHandler2 { // ------------------------------------------------------- Public Methods /** - * Parse the content of the specified file using this Digester. Returns - * the root element from the object stack (if any). + * Parse the content of the specified file using this Digester. Returns the root element from the object stack (if + * any). * * @param file File containing the XML data to be parsed + * * @return the root object - * @exception IOException if an input/output error occurs + * + * @exception IOException if an input/output error occurs * @exception SAXException if a parsing exception occurs */ public Object parse(File file) throws IOException, SAXException { @@ -1513,12 +1491,14 @@ public class Digester extends DefaultHandler2 { /** - * Parse the content of the specified input source using this Digester. - * Returns the root element from the object stack (if any). + * Parse the content of the specified input source using this Digester. Returns the root element from the object + * stack (if any). * * @param input Input source containing the XML data to be parsed + * * @return the root object - * @exception IOException if an input/output error occurs + * + * @exception IOException if an input/output error occurs * @exception SAXException if a parsing exception occurs */ public Object parse(InputSource input) throws IOException, SAXException { @@ -1529,12 +1509,14 @@ public class Digester extends DefaultHandler2 { /** - * Parse the content of the specified input stream using this Digester. - * Returns the root element from the object stack (if any). + * Parse the content of the specified input stream using this Digester. Returns the root element from the object + * stack (if any). * * @param input Input stream containing the XML data to be parsed + * * @return the root object - * @exception IOException if an input/output error occurs + * + * @exception IOException if an input/output error occurs * @exception SAXException if a parsing exception occurs */ public Object parse(InputStream input) throws IOException, SAXException { @@ -1546,24 +1528,24 @@ public class Digester extends DefaultHandler2 { /** - * <p>Register the specified DTD URL for the specified public identifier. - * This must be called before the first call to <code>parse()</code>. - * </p><p> - * <code>Digester</code> contains an internal <code>EntityResolver</code> - * implementation. This maps <code>PUBLICID</code>'s to URLs - * (from which the resource will be loaded). A common use case for this - * method is to register local URLs (possibly computed at runtime by a - * classloader) for DTDs. This allows the performance advantage of using - * a local version without having to ensure every <code>SYSTEM</code> - * URI on every processed xml document is local. This implementation provides - * only basic functionality. If more sophisticated features are required, - * using {@link #setEntityResolver} to set a custom resolver is recommended. - * </p><p> - * <strong>Note:</strong> This method will have no effect when a custom - * <code>EntityResolver</code> has been set. (Setting a custom - * <code>EntityResolver</code> overrides the internal implementation.) + * <p> + * Register the specified DTD URL for the specified public identifier. This must be called before the first call to + * <code>parse()</code>. * </p> - * @param publicId Public identifier of the DTD to be resolved + * <p> + * <code>Digester</code> contains an internal <code>EntityResolver</code> implementation. This maps + * <code>PUBLICID</code>'s to URLs (from which the resource will be loaded). A common use case for this method is to + * register local URLs (possibly computed at runtime by a classloader) for DTDs. This allows the performance + * advantage of using a local version without having to ensure every <code>SYSTEM</code> URI on every processed xml + * document is local. This implementation provides only basic functionality. If more sophisticated features are + * required, using {@link #setEntityResolver} to set a custom resolver is recommended. + * </p> + * <p> + * <strong>Note:</strong> This method will have no effect when a custom <code>EntityResolver</code> has been set. + * (Setting a custom <code>EntityResolver</code> overrides the internal implementation.) + * </p> + * + * @param publicId Public identifier of the DTD to be resolved * @param entityURL The URL to use for reading this DTD */ public void register(String publicId, String entityURL) { @@ -1580,11 +1562,13 @@ public class Digester extends DefaultHandler2 { /** - * <p>Register a new Rule matching the specified pattern. - * This method sets the <code>Digester</code> property on the rule.</p> + * <p> + * Register a new Rule matching the specified pattern. This method sets the <code>Digester</code> property on the + * rule. + * </p> * * @param pattern Element matching pattern - * @param rule Rule to be registered + * @param rule Rule to be registered */ public void addRule(String pattern, Rule rule) { @@ -1607,8 +1591,9 @@ public class Digester extends DefaultHandler2 { /** * Add a "call method" rule for a method which accepts no arguments. * - * @param pattern Element matching pattern + * @param pattern Element matching pattern * @param methodName Method name to be called + * * @see CallMethodRule */ public void addCallMethod(String pattern, String methodName) { @@ -1620,10 +1605,10 @@ public class Digester extends DefaultHandler2 { /** * Add a "call method" rule for the specified parameters. * - * @param pattern Element matching pattern + * @param pattern Element matching pattern * @param methodName Method name to be called - * @param paramCount Number of expected parameters (or zero - * for a single parameter from the body of this element) + * @param paramCount Number of expected parameters (or zero for a single parameter from the body of this element) + * * @see CallMethodRule */ public void addCallMethod(String pattern, String methodName, int paramCount) { @@ -1636,9 +1621,9 @@ public class Digester extends DefaultHandler2 { /** * Add a "call parameter" rule for the specified parameters. * - * @param pattern Element matching pattern - * @param paramIndex Zero-relative parameter index to set - * (from the body of this element) + * @param pattern Element matching pattern + * @param paramIndex Zero-relative parameter index to set (from the body of this element) + * * @see CallParamRule */ public void addCallParam(String pattern, int paramIndex) { @@ -1651,11 +1636,11 @@ public class Digester extends DefaultHandler2 { /** * Add a "factory create" rule for the specified parameters. * - * @param pattern Element matching pattern - * @param creationFactory Previously instantiated ObjectCreationFactory - * to be utilized - * @param ignoreCreateExceptions when <code>true</code> any exceptions thrown during - * object creation will be ignored. + * @param pattern Element matching pattern + * @param creationFactory Previously instantiated ObjectCreationFactory to be utilized + * @param ignoreCreateExceptions when <code>true</code> any exceptions thrown during object creation will be + * ignored. + * * @see FactoryCreateRule */ public void addFactoryCreate(String pattern, ObjectCreationFactory creationFactory, @@ -1669,8 +1654,9 @@ public class Digester extends DefaultHandler2 { /** * Add an "object create" rule for the specified parameters. * - * @param pattern Element matching pattern + * @param pattern Element matching pattern * @param className Java class name to be created + * * @see ObjectCreateRule */ public void addObjectCreate(String pattern, String className) { @@ -1683,10 +1669,10 @@ public class Digester extends DefaultHandler2 { /** * Add an "object create" rule for the specified parameters. * - * @param pattern Element matching pattern - * @param className Default Java class name to be created - * @param attributeName Attribute name that optionally overrides - * the default Java class name to be created + * @param pattern Element matching pattern + * @param className Default Java class name to be created + * @param attributeName Attribute name that optionally overrides the default Java class name to be created + * * @see ObjectCreateRule */ public void addObjectCreate(String pattern, String className, String attributeName) { @@ -1699,12 +1685,12 @@ public class Digester extends DefaultHandler2 { /** * Add a "set next" rule for the specified parameters. * - * @param pattern Element matching pattern + * @param pattern Element matching pattern * @param methodName Method name to call on the parent element - * @param paramType Java class name of the expected parameter type - * (if you wish to use a primitive type, specify the corresponding - * Java wrapper class instead, such as <code>java.lang.Boolean</code> - * for a <code>boolean</code> parameter) + * @param paramType Java class name of the expected parameter type (if you wish to use a primitive type, specify + * the corresponding Java wrapper class instead, such as <code>java.lang.Boolean</code> for a + * <code>boolean</code> parameter) + * * @see SetNextRule */ public void addSetNext(String pattern, String methodName, String paramType) { @@ -1718,6 +1704,7 @@ public class Digester extends DefaultHandler2 { * Add a "set properties" rule for the specified parameters. * * @param pattern Element matching pattern + * * @see SetPropertiesRule */ public void addSetProperties(String pattern) { @@ -1740,10 +1727,9 @@ public class Digester extends DefaultHandler2 { /** * Clear the current contents of the object stack. * <p> - * Calling this method <i>might</i> allow another document of the same type - * to be correctly parsed. However, this method was not intended for this - * purpose. In general, a separate Digester object should be created for - * each document to be parsed. + * Calling this method <i>might</i> allow another document of the same type to be correctly parsed. However, this + * method was not intended for this purpose. In general, a separate Digester object should be created for each + * document to be parsed. */ public void clear() { @@ -1767,8 +1753,9 @@ public class Digester extends DefaultHandler2 { /** - * Return the top object on the stack without removing it. If there are - * no objects on the stack, return <code>null</code>. + * Return the top object on the stack without removing it. If there are no objects on the stack, return + * <code>null</code>. + * * @return the top object */ public Object peek() { @@ -1782,12 +1769,11 @@ public class Digester extends DefaultHandler2 { /** - * Return the n'th object down the stack, where 0 is the top element - * and [getCount()-1] is the bottom element. If the specified index - * is out of range, return <code>null</code>. + * Return the n'th object down the stack, where 0 is the top element and [getCount()-1] is the bottom element. If + * the specified index is out of range, return <code>null</code>. + * + * @param n Index of the desired element, where 0 is the top of the stack, 1 is the next element down, and so on. * - * @param n Index of the desired element, where 0 is the top of the stack, - * 1 is the next element down, and so on. * @return the specified object */ public Object peek(int n) { @@ -1801,8 +1787,9 @@ public class Digester extends DefaultHandler2 { /** - * Pop the top object off of the stack, and return it. If there are - * no objects on the stack, return <code>null</code>. + * Pop the top object off of the stack, and return it. If there are no objects on the stack, return + * <code>null</code>. + * * @return the top object */ public Object pop() { @@ -1830,12 +1817,10 @@ public class Digester extends DefaultHandler2 { } /** - * When the Digester is being used as a SAXContentHandler, - * this method allows you to access the root object that has been - * created after parsing. + * When the Digester is being used as a SAXContentHandler, this method allows you to access the root object that has + * been created after parsing. * - * @return the root object that has been created after parsing - * or null if the digester has not parsed any XML yet. + * @return the root object that has been created after parsing or null if the digester has not parsed any XML yet. */ public Object getRoot() { return root; @@ -1850,11 +1835,9 @@ public class Digester extends DefaultHandler2 { /** * <p> - * Provide a hook for lazy configuration of this <code>Digester</code> - * instance. The default implementation does nothing, but subclasses - * can override as needed. + * Provide a hook for lazy configuration of this <code>Digester</code> instance. The default implementation does + * nothing, but subclasses can override as needed. * </p> - * * <p> * <strong>Note</strong> This method may be called more than once. * </p> @@ -1875,11 +1858,14 @@ public class Digester extends DefaultHandler2 { /** - * <p>Return the top object on the parameters stack without removing it. If there are - * no objects on the stack, return <code>null</code>.</p> + * <p> + * Return the top object on the parameters stack without removing it. If there are no objects on the stack, return + * <code>null</code>. + * </p> + * <p> + * The parameters stack is used to store <code>CallMethodRule</code> parameters. See {@link #params}. + * </p> * - * <p>The parameters stack is used to store <code>CallMethodRule</code> parameters. - * See {@link #params}.</p> * @return the top object on the parameters stack */ public Object peekParams() { @@ -1893,11 +1879,14 @@ public class Digester extends DefaultHandler2 { /** - * <p>Pop the top object off of the parameters stack, and return it. If there are - * no objects on the stack, return <code>null</code>.</p> + * <p> + * Pop the top object off of the parameters stack, and return it. If there are no objects on the stack, return + * <code>null</code>. + * </p> + * <p> + * The parameters stack is used to store <code>CallMethodRule</code> parameters. See {@link #params}. + * </p> * - * <p>The parameters stack is used to store <code>CallMethodRule</code> parameters. - * See {@link #params}.</p> * @return the top object on the parameters stack */ public Object popParams() { @@ -1914,10 +1903,12 @@ public class Digester extends DefaultHandler2 { /** - * <p>Push a new object onto the top of the parameters stack.</p> - * - * <p>The parameters stack is used to store <code>CallMethodRule</code> parameters. - * See {@link #params}.</p> + * <p> + * Push a new object onto the top of the parameters stack. + * </p> + * <p> + * The parameters stack is used to store <code>CallMethodRule</code> parameters. See {@link #params}. + * </p> * * @param object The new object */ @@ -1930,10 +1921,11 @@ public class Digester extends DefaultHandler2 { } /** - * Create a SAX exception which also understands about the location in - * the digester file where the exception occurs + * Create a SAX exception which also understands about the location in the digester file where the exception occurs + * * @param message The error message - * @param e The root cause + * @param e The root cause + * * @return the new exception */ public SAXException createSAXException(String message, Exception e) { @@ -1947,8 +1939,7 @@ public class Digester extends DefaultHandler2 { } } if (locator != null) { - String error = sm.getString("digester.errorLocation", - Integer.valueOf(locator.getLineNumber()), + String error = sm.getString("digester.errorLocation", Integer.valueOf(locator.getLineNumber()), Integer.valueOf(locator.getColumnNumber()), message); if (e != null) { return new SAXParseException(error, locator, e); @@ -1965,9 +1956,10 @@ public class Digester extends DefaultHandler2 { } /** - * Create a SAX exception which also understands about the location in - * the digester file where the exception occurs + * Create a SAX exception which also understands about the location in the digester file where the exception occurs + * * @param e The root cause + * * @return the new exception */ public SAXException createSAXException(Exception e) { @@ -1984,9 +1976,10 @@ public class Digester extends DefaultHandler2 { } /** - * Create a SAX exception which also understands about the location in - * the digester file where the exception occurs + * Create a SAX exception which also understands about the location in the digester file where the exception occurs + * * @param message The error message + * * @return the new exception */ public SAXException createSAXException(String message) { @@ -1997,10 +1990,9 @@ public class Digester extends DefaultHandler2 { // ------------------------------------------------------- Private Methods - /** - * Returns an attributes list which contains all the attributes - * passed in, with any text of form "${xxx}" in an attribute value - * replaced by the appropriate value from the system property. + /** + * Returns an attributes list which contains all the attributes passed in, with any text of form "${xxx}" in an + * attribute value replaced by the appropriate value from the system property. */ private Attributes updateAttributes(Attributes list) { @@ -2013,7 +2005,8 @@ public class Digester extends DefaultHandler2 { for (int i = 0; i < nAttributes; ++i) { String value = newAttrs.getValue(i); try { - newAttrs.setValue(i, IntrospectionUtils.replaceProperties(value, null, source, getClassLoader()).intern()); + newAttrs.setValue(i, + IntrospectionUtils.replaceProperties(value, null, source, getClassLoader()).intern()); } catch (Exception e) { log.warn(sm.getString("digester.failedToUpdateAttributes", newAttrs.getLocalName(i), value), e); } @@ -2024,9 +2017,8 @@ public class Digester extends DefaultHandler2 { /** - * Return a new StringBuilder containing the same contents as the - * input buffer, except that data of form ${varname} have been - * replaced by the value of that var as defined in the system property. + * Return a new StringBuilder containing the same contents as the input buffer, except that data of form ${varname} + * have been replaced by the value of that var as defined in the system property. */ private StringBuilder updateBodyText(StringBuilder bodyText) { String in = bodyText.toString(); @@ -2060,8 +2052,7 @@ public class Digester extends DefaultHandler2 { } @Override - public InputSource resolveEntity(String publicId, String systemId) - throws SAXException, IOException { + public InputSource resolveEntity(String publicId, String systemId) throws SAXException, IOException { publicId = replace(publicId); systemId = replace(systemId); return entityResolver.resolveEntity(publicId, systemId); @@ -2081,23 +2072,21 @@ public class Digester extends DefaultHandler2 { private final EntityResolver2 entityResolver2; - EntityResolver2Wrapper(EntityResolver2 entityResolver, PropertySource[] source, - ClassLoader classLoader) { + EntityResolver2Wrapper(EntityResolver2 entityResolver, PropertySource[] source, ClassLoader classLoader) { super(entityResolver, source, classLoader); this.entityResolver2 = entityResolver; } @Override - public InputSource getExternalSubset(String name, String baseURI) - throws SAXException, IOException { + public InputSource getExternalSubset(String name, String baseURI) throws SAXException, IOException { name = replace(name); baseURI = replace(baseURI); return entityResolver2.getExternalSubset(name, baseURI); } @Override - public InputSource resolveEntity(String name, String publicId, String baseURI, - String systemId) throws SAXException, IOException { + public InputSource resolveEntity(String name, String publicId, String baseURI, String systemId) + throws SAXException, IOException { name = replace(name); publicId = replace(publicId); baseURI = replace(baseURI); diff --git a/java/org/apache/tomcat/util/digester/DocumentProperties.java b/java/org/apache/tomcat/util/digester/DocumentProperties.java index c688ee6f97..5729fed779 100644 --- a/java/org/apache/tomcat/util/digester/DocumentProperties.java +++ b/java/org/apache/tomcat/util/digester/DocumentProperties.java @@ -17,10 +17,8 @@ package org.apache.tomcat.util.digester; /** - * A collection of interfaces, one per property, that enables the object being - * populated by the digester to signal to the digester that it supports the - * given property and that the digester should populate that property if - * available. + * A collection of interfaces, one per property, that enables the object being populated by the digester to signal to + * the digester that it supports the given property and that the digester should populate that property if available. */ public interface DocumentProperties { diff --git a/java/org/apache/tomcat/util/digester/EnvironmentPropertySource.java b/java/org/apache/tomcat/util/digester/EnvironmentPropertySource.java index f7de712685..9f6bc13e97 100644 --- a/java/org/apache/tomcat/util/digester/EnvironmentPropertySource.java +++ b/java/org/apache/tomcat/util/digester/EnvironmentPropertySource.java @@ -19,11 +19,11 @@ package org.apache.tomcat.util.digester; import org.apache.tomcat.util.IntrospectionUtils; /** - * A {@link org.apache.tomcat.util.IntrospectionUtils.PropertySource} - * that uses environment variables to resolve expressions. - * - * <p><strong>Usage example:</strong></p> - * + * A {@link org.apache.tomcat.util.IntrospectionUtils.PropertySource} that uses environment variables to resolve + * expressions. + * <p> + * <strong>Usage example:</strong> + * </p> * Configure the certificate with environment variables. * * <pre> @@ -37,10 +37,12 @@ import org.apache.tomcat.util.IntrospectionUtils; * </pre> * * How to configure: + * * <pre> * {@code * echo "org.apache.tomcat.util.digester.PROPERTY_SOURCE=org.apache.tomcat.util.digester.EnvironmentPropertySource" >> conf/catalina.properties} * </pre> + * * or add this to {@code CATALINA_OPTS} * * <pre> @@ -48,12 +50,11 @@ import org.apache.tomcat.util.IntrospectionUtils; * -Dorg.apache.tomcat.util.digester.PROPERTY_SOURCE=org.apache.tomcat.util.digester.EnvironmentPropertySource} * </pre> * - * <b>NOTE</b>: When configured the PropertySource for resolving expressions - * from system properties is still active. + * <b>NOTE</b>: When configured the PropertySource for resolving expressions from system properties is still active. * * @see Digester - * - * @see <a href="https://tomcat.apache.org/tomcat-9.0-doc/config/systemprops.html#Property_replacements">Tomcat Configuration Reference System Properties</a> + * @see <a href="https://tomcat.apache.org/tomcat-9.0-doc/config/systemprops.html#Property_replacements">Tomcat + * Configuration Reference System Properties</a> */ public class EnvironmentPropertySource implements IntrospectionUtils.PropertySource { diff --git a/java/org/apache/tomcat/util/digester/FactoryCreateRule.java b/java/org/apache/tomcat/util/digester/FactoryCreateRule.java index dbeebb78dc..aa362c3977 100644 --- a/java/org/apache/tomcat/util/digester/FactoryCreateRule.java +++ b/java/org/apache/tomcat/util/digester/FactoryCreateRule.java @@ -20,14 +20,14 @@ import org.xml.sax.Attributes; /** - * <p>Rule implementation that uses an {@link ObjectCreationFactory} to create - * a new object which it pushes onto the object stack. When the element is - * complete, the object will be popped.</p> - * - * <p>This rule is intended in situations where the element's attributes are - * needed before the object can be created. A common scenario is for the - * ObjectCreationFactory implementation to use the attributes as parameters - * in a call to either a factory method or to a non-empty constructor. + * <p> + * Rule implementation that uses an {@link ObjectCreationFactory} to create a new object which it pushes onto the object + * stack. When the element is complete, the object will be popped. + * </p> + * <p> + * This rule is intended in situations where the element's attributes are needed before the object can be created. A + * common scenario is for the ObjectCreationFactory implementation to use the attributes as parameters in a call to + * either a factory method or to a non-empty constructor. */ public class FactoryCreateRule extends Rule { @@ -43,16 +43,12 @@ public class FactoryCreateRule extends Rule { // ----------------------------------------------------------- Constructors /** - * Construct a factory create rule using the given, already instantiated, - * {@link ObjectCreationFactory}. + * Construct a factory create rule using the given, already instantiated, {@link ObjectCreationFactory}. * - * @param creationFactory called on to create the object. - * @param ignoreCreateExceptions if true, exceptions thrown by the object - * creation factory will be ignored. + * @param creationFactory called on to create the object. + * @param ignoreCreateExceptions if true, exceptions thrown by the object creation factory will be ignored. */ - public FactoryCreateRule( - ObjectCreationFactory creationFactory, - boolean ignoreCreateExceptions) { + public FactoryCreateRule(ObjectCreationFactory creationFactory, boolean ignoreCreateExceptions) { this.creationFactory = creationFactory; this.ignoreCreateExceptions = ignoreCreateExceptions; @@ -62,9 +58,8 @@ public class FactoryCreateRule extends Rule { // ----------------------------------------------------- Instance Variables /** - * The object creation factory we will use to instantiate objects - * as required based on the attributes specified in the matched XML - * element. + * The object creation factory we will use to instantiate objects as required based on the attributes specified in + * the matched XML element. */ protected ObjectCreationFactory creationFactory; @@ -90,8 +85,8 @@ public class FactoryCreateRule extends Rule { Object instance = creationFactory.createObject(attributes); if (digester.log.isTraceEnabled()) { - digester.log.trace("[FactoryCreateRule]{" + digester.match + - "} New " + instance.getClass().getName()); + digester.log + .trace("[FactoryCreateRule]{" + digester.match + "} New " + instance.getClass().getName()); } digester.push(instance); exceptionIgnoredStack.push(Boolean.FALSE); @@ -103,7 +98,7 @@ public class FactoryCreateRule extends Rule { ((e.getMessage() == null) ? e.getClass().getName() : e.getMessage())), e); } else if (digester.log.isInfoEnabled()) { digester.log.info(sm.getString("rule.createError", - ((e.getMessage() == null) ? e.getClass().getName() : e.getMessage()))); + ((e.getMessage() == null) ? e.getClass().getName() : e.getMessage()))); } exceptionIgnoredStack.push(Boolean.TRUE); } @@ -112,8 +107,7 @@ public class FactoryCreateRule extends Rule { Object instance = creationFactory.createObject(attributes); if (digester.log.isTraceEnabled()) { - digester.log.trace("[FactoryCreateRule]{" + digester.match + - "} New " + instance.getClass().getName()); + digester.log.trace("[FactoryCreateRule]{" + digester.match + "} New " + instance.getClass().getName()); } digester.push(instance); } @@ -128,10 +122,7 @@ public class FactoryCreateRule extends Rule { // check if object was created // this only happens if an exception was thrown, and we're ignoring them - if ( - ignoreCreateExceptions && - exceptionIgnoredStack != null && - !(exceptionIgnoredStack.empty())) { + if (ignoreCreateExceptions && exceptionIgnoredStack != null && !(exceptionIgnoredStack.empty())) { if ((exceptionIgnoredStack.pop()).booleanValue()) { // creation exception was ignored @@ -145,8 +136,7 @@ public class FactoryCreateRule extends Rule { Object top = digester.pop(); if (digester.log.isTraceEnabled()) { - digester.log.trace("[FactoryCreateRule]{" + digester.match + - "} Pop " + top.getClass().getName()); + digester.log.trace("[FactoryCreateRule]{" + digester.match + "} Pop " + top.getClass().getName()); } } diff --git a/java/org/apache/tomcat/util/digester/ObjectCreateRule.java b/java/org/apache/tomcat/util/digester/ObjectCreateRule.java index 37f0697dc8..0dbac181c1 100644 --- a/java/org/apache/tomcat/util/digester/ObjectCreateRule.java +++ b/java/org/apache/tomcat/util/digester/ObjectCreateRule.java @@ -21,8 +21,7 @@ import org.xml.sax.Attributes; /** - * Rule implementation that creates a new object and pushes it - * onto the object stack. When the element is complete, the + * Rule implementation that creates a new object and pushes it onto the object stack. When the element is complete, the * object will be popped */ @@ -45,15 +44,13 @@ public class ObjectCreateRule extends Rule { /** - * Construct an object create rule with the specified class name and an - * optional attribute name containing an override. + * Construct an object create rule with the specified class name and an optional attribute name containing an + * override. * - * @param className Java class name of the object to be created - * @param attributeName Attribute name which, if present, contains an - * override of the class name to create + * @param className Java class name of the object to be created + * @param attributeName Attribute name which, if present, contains an override of the class name to create */ - public ObjectCreateRule(String className, - String attributeName) { + public ObjectCreateRule(String className, String attributeName) { this.className = className; this.attributeName = attributeName; @@ -81,16 +78,13 @@ public class ObjectCreateRule extends Rule { /** * Process the beginning of this element. * - * @param namespace the namespace URI of the matching element, or an - * empty string if the parser is not namespace aware or the element has - * no namespace - * @param name the local name if the parser is namespace aware, or just - * the element name otherwise + * @param namespace the namespace URI of the matching element, or an empty string if the parser is not namespace + * aware or the element has no namespace + * @param name the local name if the parser is namespace aware, or just the element name otherwise * @param attributes The attribute list for this element */ @Override - public void begin(String namespace, String name, Attributes attributes) - throws Exception { + public void begin(String namespace, String name, Attributes attributes) throws Exception { String realClassName = getRealClassName(attributes); @@ -115,7 +109,9 @@ public class ObjectCreateRule extends Rule { /** * Return the actual class name of the class to be instantiated. + * * @param attributes The attribute list for this element + * * @return the class name */ protected String getRealClassName(Attributes attributes) { @@ -134,19 +130,16 @@ public class ObjectCreateRule extends Rule { /** * Process the end of this element. * - * @param namespace the namespace URI of the matching element, or an - * empty string if the parser is not namespace aware or the element has - * no namespace - * @param name the local name if the parser is namespace aware, or just - * the element name otherwise + * @param namespace the namespace URI of the matching element, or an empty string if the parser is not namespace + * aware or the element has no namespace + * @param name the local name if the parser is namespace aware, or just the element name otherwise */ @Override public void end(String namespace, String name) throws Exception { Object top = digester.pop(); if (digester.log.isTraceEnabled()) { - digester.log.trace("[ObjectCreateRule]{" + digester.match + - "} Pop " + top.getClass().getName()); + digester.log.trace("[ObjectCreateRule]{" + digester.match + "} Pop " + top.getClass().getName()); } } diff --git a/java/org/apache/tomcat/util/digester/ObjectCreationFactory.java b/java/org/apache/tomcat/util/digester/ObjectCreationFactory.java index 39cbda25da..9dd99f3496 100644 --- a/java/org/apache/tomcat/util/digester/ObjectCreationFactory.java +++ b/java/org/apache/tomcat/util/digester/ObjectCreationFactory.java @@ -20,36 +20,35 @@ package org.apache.tomcat.util.digester; import org.xml.sax.Attributes; /** - * <p> Interface for use with {@link FactoryCreateRule}. - * The rule calls {@link #createObject} to create an object - * to be pushed onto the <code>Digester</code> stack - * whenever it is matched.</p> - * - * <p> {@link AbstractObjectCreationFactory} is an abstract - * implementation suitable for creating anonymous + * <p> + * Interface for use with {@link FactoryCreateRule}. The rule calls {@link #createObject} to create an object to be + * pushed onto the <code>Digester</code> stack whenever it is matched. + * </p> + * <p> + * {@link AbstractObjectCreationFactory} is an abstract implementation suitable for creating anonymous * <code>ObjectCreationFactory</code> implementations. */ public interface ObjectCreationFactory { /** - * Factory method called by {@link FactoryCreateRule} to supply an - * object based on the element's attributes. + * Factory method called by {@link FactoryCreateRule} to supply an object based on the element's attributes. * * @param attributes the element's attributes + * * @return the created object + * * @throws Exception any exception thrown will be propagated upwards */ Object createObject(Attributes attributes) throws Exception; /** - * @return the {@link Digester} that was set by the - * {@link FactoryCreateRule} upon initialization. + * @return the {@link Digester} that was set by the {@link FactoryCreateRule} upon initialization. */ Digester getDigester(); /** - * Set the {@link Digester} to allow the implementation to do logging, - * classloading based on the digester's classloader, etc. + * Set the {@link Digester} to allow the implementation to do logging, classloading based on the digester's + * classloader, etc. * * @param digester parent Digester object */ diff --git a/java/org/apache/tomcat/util/digester/Rule.java b/java/org/apache/tomcat/util/digester/Rule.java index 5c77de4f9c..41ba78c530 100644 --- a/java/org/apache/tomcat/util/digester/Rule.java +++ b/java/org/apache/tomcat/util/digester/Rule.java @@ -20,8 +20,8 @@ import org.apache.tomcat.util.res.StringManager; import org.xml.sax.Attributes; /** - * Concrete implementations of this class implement actions to be taken when - * a corresponding nested pattern of XML elements has been matched. + * Concrete implementations of this class implement actions to be taken when a corresponding nested pattern of XML + * elements has been matched. */ public abstract class Rule { @@ -30,10 +30,12 @@ public abstract class Rule { // ----------------------------------------------------------- Constructors /** - * <p>Base constructor. - * Now the digester will be set when the rule is added.</p> + * <p> + * Base constructor. Now the digester will be set when the rule is added. + * </p> */ - public Rule() {} + public Rule() { + } // ----------------------------------------------------- Instance Variables @@ -64,8 +66,7 @@ public abstract class Rule { /** - * Set the <code>Digester</code> with which this <code>Rule</code> is - * associated. + * Set the <code>Digester</code> with which this <code>Rule</code> is associated. * * @param digester The digester with which to associate this rule */ @@ -77,8 +78,7 @@ public abstract class Rule { /** * Return the namespace URI for which this Rule is relevant, if any. * - * @return The namespace URI for which this rule is relevant or - * <code>null</code> if none. + * @return The namespace URI for which this rule is relevant or <code>null</code> if none. */ public String getNamespaceURI() { return namespaceURI; @@ -88,8 +88,8 @@ public abstract class Rule { /** * Set the namespace URI for which this Rule is relevant, if any. * - * @param namespaceURI Namespace URI for which this Rule is relevant, - * or <code>null</code> to match independent of namespace. + * @param namespaceURI Namespace URI for which this Rule is relevant, or <code>null</code> to match independent of + * namespace. */ public void setNamespaceURI(String namespaceURI) { this.namespaceURI = namespaceURI; @@ -99,14 +99,12 @@ public abstract class Rule { // --------------------------------------------------------- Public Methods /** - * This method is called when the beginning of a matching XML element - * is encountered. The default implementation is a NO-OP. + * This method is called when the beginning of a matching XML element is encountered. The default implementation is + * a NO-OP. * - * @param namespace the namespace URI of the matching element, or an - * empty string if the parser is not namespace aware or the - * element has no namespace - * @param name the local name if the parser is namespace aware, or just - * the element name otherwise + * @param namespace the namespace URI of the matching element, or an empty string if the parser is not namespace + * aware or the element has no namespace + * @param name the local name if the parser is namespace aware, or just the element name otherwise * @param attributes The attribute list of this element * * @throws Exception if an error occurs while processing the event @@ -117,16 +115,13 @@ public abstract class Rule { /** - * This method is called when the body of a matching XML element is - * encountered. If the element has no body, this method is not called at - * all. The default implementation is a NO-OP. + * This method is called when the body of a matching XML element is encountered. If the element has no body, this + * method is not called at all. The default implementation is a NO-OP. * - * @param namespace the namespace URI of the matching element, or an empty - * string if the parser is not namespace aware or the - * element has no namespace - * @param name the local name if the parser is namespace aware, or just the - * element name otherwise - * @param text The text of the body of this element + * @param namespace the namespace URI of the matching element, or an empty string if the parser is not namespace + * aware or the element has no namespace + * @param name the local name if the parser is namespace aware, or just the element name otherwise + * @param text The text of the body of this element * * @throws Exception if an error occurs while processing the event */ @@ -136,14 +131,12 @@ public abstract class Rule { /** - * This method is called when the end of a matching XML element - * is encountered. The default implementation is a NO-OP. + * This method is called when the end of a matching XML element is encountered. The default implementation is a + * NO-OP. * - * @param namespace the namespace URI of the matching element, or an empty - * string if the parser is not namespace aware or the - * element has no namespace - * @param name the local name if the parser is namespace aware, or just the - * element name otherwise + * @param namespace the namespace URI of the matching element, or an empty string if the parser is not namespace + * aware or the element has no namespace + * @param name the local name if the parser is namespace aware, or just the element name otherwise * * @throws Exception if an error occurs while processing the event */ @@ -153,8 +146,7 @@ public abstract class Rule { /** - * This method is called after all parsing methods have been - * called, to allow Rules to remove temporary data. + * This method is called after all parsing methods have been called, to allow Rules to remove temporary data. * * @throws Exception if an error occurs while processing the event */ diff --git a/java/org/apache/tomcat/util/digester/RuleSet.java b/java/org/apache/tomcat/util/digester/RuleSet.java index 990dee3602..5527fda803 100644 --- a/java/org/apache/tomcat/util/digester/RuleSet.java +++ b/java/org/apache/tomcat/util/digester/RuleSet.java @@ -17,31 +17,28 @@ package org.apache.tomcat.util.digester; /** - * <p>Public interface defining a shorthand means of configuring a complete - * set of related <code>Rule</code> definitions, possibly associated with - * a particular namespace URI, in one operation. To use an instance of a - * class that implements this interface:</p> + * <p> + * Public interface defining a shorthand means of configuring a complete set of related <code>Rule</code> definitions, + * possibly associated with a particular namespace URI, in one operation. To use an instance of a class that implements + * this interface: + * </p> * <ul> * <li>Create a concrete implementation of this interface.</li> - * <li>Optionally, you can configure a <code>RuleSet</code> to be relevant - * only for a particular namespace URI by configuring the value to be - * returned by <code>getNamespaceURI()</code>.</li> - * <li>As you are configuring your Digester instance, call - * <code>digester.addRuleSet()</code> and pass the RuleSet instance.</li> - * <li>Digester will call the <code>addRuleInstances()</code> method of - * your RuleSet to configure the necessary rules.</li> + * <li>Optionally, you can configure a <code>RuleSet</code> to be relevant only for a particular namespace URI by + * configuring the value to be returned by <code>getNamespaceURI()</code>.</li> + * <li>As you are configuring your Digester instance, call <code>digester.addRuleSet()</code> and pass the RuleSet + * instance.</li> + * <li>Digester will call the <code>addRuleInstances()</code> method of your RuleSet to configure the necessary + * rules.</li> * </ul> */ public interface RuleSet { /** - * Add the set of Rule instances defined in this RuleSet to the - * specified <code>Digester</code> instance, associating them with - * our namespace URI (if any). This method should only be called - * by a Digester instance. + * Add the set of Rule instances defined in this RuleSet to the specified <code>Digester</code> instance, + * associating them with our namespace URI (if any). This method should only be called by a Digester instance. * - * @param digester Digester instance to which the new Rule instances - * should be added. + * @param digester Digester instance to which the new Rule instances should be added. */ void addRuleInstances(Digester digester); } diff --git a/java/org/apache/tomcat/util/digester/Rules.java b/java/org/apache/tomcat/util/digester/Rules.java index d22a3658cc..f600979336 100644 --- a/java/org/apache/tomcat/util/digester/Rules.java +++ b/java/org/apache/tomcat/util/digester/Rules.java @@ -19,18 +19,16 @@ package org.apache.tomcat.util.digester; import java.util.List; /** - * Public interface defining a collection of Rule instances (and corresponding - * matching patterns) plus an implementation of a matching policy that selects - * the rules that match a particular pattern of nested elements discovered - * during parsing. + * Public interface defining a collection of Rule instances (and corresponding matching patterns) plus an implementation + * of a matching policy that selects the rules that match a particular pattern of nested elements discovered during + * parsing. */ public interface Rules { // ------------------------------------------------------------- Properties /** - * @return the Digester instance with which this Rules instance is - * associated. + * @return the Digester instance with which this Rules instance is associated. */ Digester getDigester(); @@ -49,7 +47,7 @@ public interface Rules { * Register a new Rule instance matching the specified pattern. * * @param pattern Nesting pattern to be matched for this Rule - * @param rule Rule instance to be registered + * @param rule Rule instance to be registered */ void add(String pattern, Rule rule); @@ -61,26 +59,24 @@ public interface Rules { /** - * Return a List of all registered Rule instances that match the specified - * nesting pattern, or a zero-length List if there are no matches. If more - * than one Rule instance matches, they <strong>must</strong> be returned - * in the order originally registered through the <code>add()</code> - * method. + * Return a List of all registered Rule instances that match the specified nesting pattern, or a zero-length List if + * there are no matches. If more than one Rule instance matches, they <strong>must</strong> be returned in the order + * originally registered through the <code>add()</code> method. + * + * @param namespaceURI Namespace URI for which to select matching rules, or <code>null</code> to match regardless of + * namespace URI + * @param pattern Nesting pattern to be matched * - * @param namespaceURI Namespace URI for which to select matching rules, - * or <code>null</code> to match regardless of namespace URI - * @param pattern Nesting pattern to be matched * @return a rules list */ List<Rule> match(String namespaceURI, String pattern); /** - * Return a List of all registered Rule instances, or a zero-length List - * if there are no registered Rule instances. If more than one Rule - * instance has been registered, they <strong>must</strong> be returned - * in the order originally registered through the <code>add()</code> - * method. + * Return a List of all registered Rule instances, or a zero-length List if there are no registered Rule instances. + * If more than one Rule instance has been registered, they <strong>must</strong> be returned in the order + * originally registered through the <code>add()</code> method. + * * @return a rules list */ List<Rule> rules(); diff --git a/java/org/apache/tomcat/util/digester/RulesBase.java b/java/org/apache/tomcat/util/digester/RulesBase.java index 7e113331d4..cc4a7912c5 100644 --- a/java/org/apache/tomcat/util/digester/RulesBase.java +++ b/java/org/apache/tomcat/util/digester/RulesBase.java @@ -21,19 +21,18 @@ import java.util.HashMap; import java.util.List; /** - * <p>Default implementation of the <code>Rules</code> interface that supports - * the standard rule matching behavior. This class can also be used as a - * base class for specialized <code>Rules</code> implementations.</p> - * - * <p>The matching policies implemented by this class support two different - * types of pattern matching rules:</p> + * <p> + * Default implementation of the <code>Rules</code> interface that supports the standard rule matching behavior. This + * class can also be used as a base class for specialized <code>Rules</code> implementations. + * </p> + * <p> + * The matching policies implemented by this class support two different types of pattern matching rules: + * </p> * <ul> - * <li><em>Exact Match</em> - A pattern "a/b/c" exactly matches a - * <code><c></code> element, nested inside a <code><b></code> - * element, which is nested inside an <code><a></code> element.</li> - * <li><em>Tail Match</em> - A pattern "*/a/b" matches a - * <code><b></code> element, nested inside an <code><a></code> - * element, no matter how deeply the pair is nested.</li> + * <li><em>Exact Match</em> - A pattern "a/b/c" exactly matches a <code><c></code> element, nested inside a + * <code><b></code> element, which is nested inside an <code><a></code> element.</li> + * <li><em>Tail Match</em> - A pattern "*/a/b" matches a <code><b></code> element, nested inside an + * <code><a></code> element, no matter how deeply the pair is nested.</li> * </ul> */ public class RulesBase implements Rules { @@ -41,9 +40,8 @@ public class RulesBase implements Rules { // ----------------------------------------------------- Instance Variables /** - * The set of registered Rule instances, keyed by the matching pattern. - * Each value is a List containing the Rules for that pattern, in the - * order that they were originally registered. + * The set of registered Rule instances, keyed by the matching pattern. Each value is a List containing the Rules + * for that pattern, in the order that they were originally registered. */ protected HashMap<String,List<Rule>> cache = new HashMap<>(); @@ -55,8 +53,7 @@ public class RulesBase implements Rules { /** - * The set of registered Rule instances, in the order that they were - * originally registered. + * The set of registered Rule instances, in the order that they were originally registered. */ protected ArrayList<Rule> rules = new ArrayList<>(); @@ -64,8 +61,7 @@ public class RulesBase implements Rules { // ------------------------------------------------------------- Properties /** - * Return the Digester instance with which this Rules instance is - * associated. + * Return the Digester instance with which this Rules instance is associated. */ @Override public Digester getDigester() { @@ -93,14 +89,14 @@ public class RulesBase implements Rules { * Register a new Rule instance matching the specified pattern. * * @param pattern Nesting pattern to be matched for this Rule - * @param rule Rule instance to be registered + * @param rule Rule instance to be registered */ @Override public void add(String pattern, Rule rule) { // to help users who accidentally add '/' to the end of their patterns int patternLength = pattern.length(); - if (patternLength>1 && pattern.endsWith("/")) { - pattern = pattern.substring(0, patternLength-1); + if (patternLength > 1 && pattern.endsWith("/")) { + pattern = pattern.substring(0, patternLength - 1); } cache.computeIfAbsent(pattern, k -> new ArrayList<>()).add(rule); @@ -122,15 +118,13 @@ public class RulesBase implements Rules { /** - * Return a List of all registered Rule instances that match the specified - * nesting pattern, or a zero-length List if there are no matches. If more - * than one Rule instance matches, they <strong>must</strong> be returned - * in the order originally registered through the <code>add()</code> - * method. + * Return a List of all registered Rule instances that match the specified nesting pattern, or a zero-length List if + * there are no matches. If more than one Rule instance matches, they <strong>must</strong> be returned in the order + * originally registered through the <code>add()</code> method. * - * @param namespaceURI Namespace URI for which to select matching rules, - * or <code>null</code> to match regardless of namespace URI - * @param pattern Nesting pattern to be matched + * @param namespaceURI Namespace URI for which to select matching rules, or <code>null</code> to match regardless of + * namespace URI + * @param pattern Nesting pattern to be matched */ @Override public List<Rule> match(String namespaceURI, String pattern) { @@ -142,8 +136,7 @@ public class RulesBase implements Rules { String longKey = ""; for (String key : this.cache.keySet()) { if (key.startsWith("*/")) { - if (pattern.equals(key.substring(2)) || - pattern.endsWith(key.substring(1))) { + if (pattern.equals(key.substring(2)) || pattern.endsWith(key.substring(1))) { if (key.length() > longKey.length()) { // rulesList = (List) this.cache.get(key); rulesList = lookup(namespaceURI, key); @@ -161,11 +154,9 @@ public class RulesBase implements Rules { /** - * Return a List of all registered Rule instances, or a zero-length List - * if there are no registered Rule instances. If more than one Rule - * instance has been registered, they <strong>must</strong> be returned - * in the order originally registered through the <code>add()</code> - * method. + * Return a List of all registered Rule instances, or a zero-length List if there are no registered Rule instances. + * If more than one Rule instance has been registered, they <strong>must</strong> be returned in the order + * originally registered through the <code>add()</code> method. */ @Override public List<Rule> rules() { @@ -176,13 +167,13 @@ public class RulesBase implements Rules { // ------------------------------------------------------ Protected Methods /** - * Return a List of Rule instances for the specified pattern that also - * match the specified namespace URI (if any). If there are no such - * rules, return <code>null</code>. + * Return a List of Rule instances for the specified pattern that also match the specified namespace URI (if any). + * If there are no such rules, return <code>null</code>. + * + * @param namespaceURI Namespace URI to match, or <code>null</code> to select matching rules regardless of namespace + * URI + * @param pattern Pattern to be matched * - * @param namespaceURI Namespace URI to match, or <code>null</code> to - * select matching rules regardless of namespace URI - * @param pattern Pattern to be matched * @return a rules list */ protected List<Rule> lookup(String namespaceURI, String pattern) { @@ -198,8 +189,7 @@ public class RulesBase implements Rules { // Select only Rules that match on the specified namespace URI List<Rule> results = new ArrayList<>(); for (Rule item : list) { - if ((namespaceURI.equals(item.getNamespaceURI())) || - (item.getNamespaceURI() == null)) { + if ((namespaceURI.equals(item.getNamespaceURI())) || (item.getNamespaceURI() == null)) { results.add(item); } } diff --git a/java/org/apache/tomcat/util/digester/ServiceBindingPropertySource.java b/java/org/apache/tomcat/util/digester/ServiceBindingPropertySource.java index c4b162c228..d675ff2604 100644 --- a/java/org/apache/tomcat/util/digester/ServiceBindingPropertySource.java +++ b/java/org/apache/tomcat/util/digester/ServiceBindingPropertySource.java @@ -24,16 +24,15 @@ import java.nio.file.Paths; import org.apache.tomcat.util.IntrospectionUtils; /** - * A {@link org.apache.tomcat.util.IntrospectionUtils.PropertySource} - * that uses Kubernetes service bindings to resolve expressions. - * + * A {@link org.apache.tomcat.util.IntrospectionUtils.PropertySource} that uses Kubernetes service bindings to resolve + * expressions. * <p> - * The Kubernetes service binding specification can be found at - * <a href="https://servicebinding.io/">https://servicebinding.io/</a>. + * The Kubernetes service binding specification can be found at + * <a href="https://servicebinding.io/">https://servicebinding.io/</a>. + * </p> + * <p> + * <strong>Usage example:</strong> * </p> - * - * <p><strong>Usage example:</strong></p> - * * Configure the certificate with a service binding. * <p> * When the service binding is constructed as follows: @@ -46,6 +45,7 @@ import org.apache.tomcat.util.IntrospectionUtils; * /chainFile * /keyPassword * </pre> + * * <pre> * {@code * <SSLHostConfig> @@ -56,20 +56,19 @@ import org.apache.tomcat.util.IntrospectionUtils; * type="RSA" /> * </SSLHostConfig> } * </pre> - * * <p> - * The optional <code>chomp:</code> prefix will cause the ServiceBindingPropertySource - * to trim a single newline (<code>\r\n</code>, <code>\r</code>, or <code>\n</code>) - * from the end of the file, if it exists. This is a convenience for hand-edited - * files/values where removing a trailing newline is difficult, and trailing - * whitespace changes the meaning of the value. + * The optional <code>chomp:</code> prefix will cause the ServiceBindingPropertySource to trim a single newline + * (<code>\r\n</code>, <code>\r</code>, or <code>\n</code>) from the end of the file, if it exists. This is a + * convenience for hand-edited files/values where removing a trailing newline is difficult, and trailing whitespace + * changes the meaning of the value. * </p> - * * How to configure: + * * <pre> * {@code * echo "org.apache.tomcat.util.digester.PROPERTY_SOURCE=org.apache.tomcat.util.digester.ServiceBindingPropertySource" >> conf/catalina.properties} * </pre> + * * or add this to {@code CATALINA_OPTS} * * <pre> @@ -77,13 +76,11 @@ import org.apache.tomcat.util.IntrospectionUtils; * -Dorg.apache.tomcat.util.digester.PROPERTY_SOURCE=org.apache.tomcat.util.digester.ServiceBindingPropertySource} * </pre> * - * <b>NOTE</b>: When configured the PropertySource for resolving expressions - * from system properties is still active. + * <b>NOTE</b>: When configured the PropertySource for resolving expressions from system properties is still active. * * @see Digester - * * @see <a href="https://tomcat.apache.org/tomcat-9.0-doc/config/systemprops.html#Property_replacements">Tomcat - * Configuration Reference System Properties</a> + * Configuration Reference System Properties</a> */ public class ServiceBindingPropertySource implements IntrospectionUtils.PropertySource { @@ -121,7 +118,7 @@ public class ServiceBindingPropertySource implements IntrospectionUtils.Property int length = bytes.length; if (chomp) { - if(length > 1 && bytes[length - 2] == '\r' && bytes[length - 1] == '\n') { + if (length > 1 && bytes[length - 2] == '\r' && bytes[length - 1] == '\n') { length -= 2; } else if (length > 0) { byte c = bytes[length - 1]; diff --git a/java/org/apache/tomcat/util/digester/SetNextRule.java b/java/org/apache/tomcat/util/digester/SetNextRule.java index 4709205a58..2bfd5292db 100644 --- a/java/org/apache/tomcat/util/digester/SetNextRule.java +++ b/java/org/apache/tomcat/util/digester/SetNextRule.java @@ -20,14 +20,14 @@ import org.apache.tomcat.util.IntrospectionUtils; /** - * <p>Rule implementation that calls a method on the (top-1) (parent) - * object, passing the top object (child) as an argument. It is - * commonly used to establish parent-child relationships.</p> - * - * <p>This rule now supports more flexible method matching by default. - * It is possible that this may break (some) code - * written against release 1.1.1 or earlier. - * See {@link #isExactMatch()} for more details.</p> + * <p> + * Rule implementation that calls a method on the (top-1) (parent) object, passing the top object (child) as an + * argument. It is commonly used to establish parent-child relationships. + * </p> + * <p> + * This rule now supports more flexible method matching by default. It is possible that this may break (some) code + * written against release 1.1.1 or earlier. See {@link #isExactMatch()} for more details. + * </p> */ public class SetNextRule extends Rule { @@ -38,13 +38,11 @@ public class SetNextRule extends Rule { * Construct a "set next" rule with the specified method name. * * @param methodName Method name of the parent method to call - * @param paramType Java class of the parent method's argument - * (if you wish to use a primitive type, specify the corresponding - * Java wrapper class instead, such as <code>java.lang.Boolean</code> - * for a <code>boolean</code> parameter) + * @param paramType Java class of the parent method's argument (if you wish to use a primitive type, specify the + * corresponding Java wrapper class instead, such as <code>java.lang.Boolean</code> for a + * <code>boolean</code> parameter) */ - public SetNextRule(String methodName, - String paramType) { + public SetNextRule(String methodName, String paramType) { this.methodName = methodName; this.paramType = paramType; @@ -75,23 +73,26 @@ public class SetNextRule extends Rule { /** - * <p>Is exact matching being used.</p> - * - * <p>This rule uses <code>org.apache.commons.beanutils.MethodUtils</code> - * to introspect the relevant objects so that the right method can be called. - * Originally, <code>MethodUtils.invokeExactMethod</code> was used. - * This matches methods very strictly - * and so may not find a matching method when one exists. - * This is still the behaviour when exact matching is enabled.</p> - * - * <p>When exact matching is disabled, <code>MethodUtils.invokeMethod</code> is used. - * This method finds more methods but is less precise when there are several methods - * with correct signatures. - * So, if you want to choose an exact signature you might need to enable this property.</p> - * - * <p>The default setting is to disable exact matches.</p> + * <p> + * Is exact matching being used. + * </p> + * <p> + * This rule uses <code>org.apache.commons.beanutils.MethodUtils</code> to introspect the relevant objects so that + * the right method can be called. Originally, <code>MethodUtils.invokeExactMethod</code> was used. This matches + * methods very strictly and so may not find a matching method when one exists. This is still the behaviour when + * exact matching is enabled. + * </p> + * <p> + * When exact matching is disabled, <code>MethodUtils.invokeMethod</code> is used. This method finds more methods + * but is less precise when there are several methods with correct signatures. So, if you want to choose an exact + * signature you might need to enable this property. + * </p> + * <p> + * The default setting is to disable exact matches. + * </p> * * @return true iff exact matching is enabled + * * @since Digester Release 1.1.1 */ public boolean isExactMatch() { @@ -100,11 +101,15 @@ public class SetNextRule extends Rule { } /** - * <p>Set whether exact matching is enabled.</p> - * - * <p>See {@link #isExactMatch()}.</p> + * <p> + * Set whether exact matching is enabled. + * </p> + * <p> + * See {@link #isExactMatch()}. + * </p> * * @param useExactMatch should this rule use exact method matching + * * @since Digester Release 1.1.1 */ public void setExactMatch(boolean useExactMatch) { @@ -115,11 +120,9 @@ public class SetNextRule extends Rule { /** * Process the end of this element. * - * @param namespace the namespace URI of the matching element, or an - * empty string if the parser is not namespace aware or the element has - * no namespace - * @param name the local name if the parser is namespace aware, or just - * the element name otherwise + * @param namespace the namespace URI of the matching element, or an empty string if the parser is not namespace + * aware or the element has no namespace + * @param name the local name if the parser is namespace aware, or just the element name otherwise */ @Override public void end(String namespace, String name) throws Exception { @@ -129,19 +132,16 @@ public class SetNextRule extends Rule { Object parent = digester.peek(1); if (digester.log.isTraceEnabled()) { if (parent == null) { - digester.log.trace("[SetNextRule]{" + digester.match + - "} Call [NULL PARENT]." + - methodName + "(" + child + ")"); + digester.log.trace( + "[SetNextRule]{" + digester.match + "} Call [NULL PARENT]." + methodName + "(" + child + ")"); } else { - digester.log.trace("[SetNextRule]{" + digester.match + - "} Call " + parent.getClass().getName() + "." + + digester.log.trace("[SetNextRule]{" + digester.match + "} Call " + parent.getClass().getName() + "." + methodName + "(" + child + ")"); } } // Call the specified method - IntrospectionUtils.callMethod1(parent, methodName, - child, paramType, digester.getClassLoader()); + IntrospectionUtils.callMethod1(parent, methodName, child, paramType, digester.getClassLoader()); StringBuilder code = digester.getGeneratedCode(); if (code != null) { diff --git a/java/org/apache/tomcat/util/digester/SetPropertiesRule.java b/java/org/apache/tomcat/util/digester/SetPropertiesRule.java index 5c2c6e6d68..bf11213eb4 100644 --- a/java/org/apache/tomcat/util/digester/SetPropertiesRule.java +++ b/java/org/apache/tomcat/util/digester/SetPropertiesRule.java @@ -24,8 +24,10 @@ import org.xml.sax.Attributes; /** - * <p>Rule implementation that sets properties on the object at the top of the - * stack, based on attributes with corresponding names.</p> + * <p> + * Rule implementation that sets properties on the object at the top of the stack, based on attributes with + * corresponding names. + * </p> */ public class SetPropertiesRule extends Rule { @@ -52,23 +54,19 @@ public class SetPropertiesRule extends Rule { /** * Process the beginning of this element. * - * @param namespace the namespace URI of the matching element, or an - * empty string if the parser is not namespace aware or the element has - * no namespace - * @param theName the local name if the parser is namespace aware, or just - * the element name otherwise + * @param namespace the namespace URI of the matching element, or an empty string if the parser is not namespace + * aware or the element has no namespace + * @param theName the local name if the parser is namespace aware, or just the element name otherwise * @param attributes The attribute list for this element */ @Override - public void begin(String namespace, String theName, Attributes attributes) - throws Exception { + public void begin(String namespace, String theName, Attributes attributes) throws Exception { // Populate the corresponding properties of the top object Object top = digester.peek(); if (digester.log.isTraceEnabled()) { - digester.log.trace("[SetPropertiesRule]{" + digester.match + - "} Set " + top.getClass().getName() + - " properties"); + digester.log.trace( + "[SetPropertiesRule]{" + digester.match + "} Set " + top.getClass().getName() + " properties"); } StringBuilder code = digester.getGeneratedCode(); String variableName = null; @@ -84,8 +82,7 @@ public class SetPropertiesRule extends Rule { String value = attributes.getValue(i); if (digester.log.isTraceEnabled()) { - digester.log.trace("[SetPropertiesRule]{" + digester.match + - "} Setting property '" + name + "' to '" + + digester.log.trace("[SetPropertiesRule]{" + digester.match + "} Setting property '" + name + "' to '" + value + "'"); } if (!digester.isFakeAttribute(top, name) && (excludes == null || !excludes.containsKey(name))) { diff --git a/java/org/apache/tomcat/util/digester/SystemPropertySource.java b/java/org/apache/tomcat/util/digester/SystemPropertySource.java index fa42a097e5..40d3271ee7 100644 --- a/java/org/apache/tomcat/util/digester/SystemPropertySource.java +++ b/java/org/apache/tomcat/util/digester/SystemPropertySource.java @@ -19,9 +19,8 @@ package org.apache.tomcat.util.digester; import org.apache.tomcat.util.IntrospectionUtils; /** - * A {@link org.apache.tomcat.util.IntrospectionUtils.PropertySource} - * that uses system properties to resolve expressions. - * This property source is always active by default. + * A {@link org.apache.tomcat.util.IntrospectionUtils.PropertySource} that uses system properties to resolve + * expressions. This property source is always active by default. * * @see Digester */ --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org