This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch 7.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git

commit 48cc552e31ebf34e87f59f38e1c0b5b94066c214
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Mon Sep 16 10:00:38 2019 +0100

    Polish. Spacing. Back-port clean-up from 8.5.x. Add Javadoc.
---
 .../org/apache/tomcat/util/IntrospectionUtils.java | 52 +++++++++++++++-------
 java/org/apache/tomcat/util/digester/Digester.java | 23 +++-------
 2 files changed, 42 insertions(+), 33 deletions(-)

diff --git a/java/org/apache/tomcat/util/IntrospectionUtils.java 
b/java/org/apache/tomcat/util/IntrospectionUtils.java
index 600d3da..bdce1e4 100644
--- a/java/org/apache/tomcat/util/IntrospectionUtils.java
+++ b/java/org/apache/tomcat/util/IntrospectionUtils.java
@@ -14,7 +14,6 @@
  *  See the License for the specific language governing permissions and
  *  limitations under the License.
  */
-
 package org.apache.tomcat.util;
 
 import java.io.File;
@@ -30,6 +29,8 @@ import java.util.Hashtable;
 import java.util.StringTokenizer;
 import java.util.Vector;
 
+import org.apache.juli.logging.Log;
+import org.apache.juli.logging.LogFactory;
 import org.apache.tomcat.util.security.PermissionCheck;
 
 /**
@@ -37,9 +38,7 @@ import org.apache.tomcat.util.security.PermissionCheck;
  */
 public final class IntrospectionUtils {
 
-
-    private static final org.apache.juli.logging.Log log=
-        org.apache.juli.logging.LogFactory.getLog( IntrospectionUtils.class );
+    private static final Log log = LogFactory.getLog(IntrospectionUtils.class);
 
     /**
      * Call execute() - any ant-like task should work
@@ -279,6 +278,10 @@ public final class IntrospectionUtils {
      * Find a method with the right name If found, call the method ( if param 
is
      * int or boolean we'll convert value to the right type before) - that 
means
      * you can have setDebug(1).
+     * @param o The object to set a property on
+     * @param name The property name
+     * @param value The property value
+     * @return <code>true</code> if operation was successful
      */
     public static boolean setProperty(Object o, String name, String value) {
         return setProperty(o,name,value,true);
@@ -568,7 +571,9 @@ public final class IntrospectionUtils {
     }
 
     /**
-     * Reverse of Introspector.decapitalize
+     * Reverse of Introspector.decapitalize.
+     * @param name The name
+     * @return the capitalized string
      */
     public static String capitalize(String name) {
         if (name == null || name.length() == 0) {
@@ -786,24 +791,19 @@ public final class IntrospectionUtils {
         return methods;
     }
 
-    @SuppressWarnings("null") // Neither params nor methodParams can be null
-                              // when comparing their lengths
+    @SuppressWarnings("null") // params cannot be null when comparing lengths
     public static Method findMethod(Class<?> c, String name,
             Class<?> params[]) {
         Method methods[] = findMethods(c);
-        if (methods == null)
-            return null;
         for (int i = 0; i < methods.length; i++) {
             if (methods[i].getName().equals(name)) {
                 Class<?> methodParams[] = methods[i].getParameterTypes();
-                if (methodParams == null)
-                    if (params == null || params.length == 0)
-                        return methods[i];
-                if (params == null)
-                    if (methodParams == null || methodParams.length == 0)
-                        return methods[i];
-                if (params.length != methodParams.length)
+                if (params == null && methodParams.length == 0) {
+                    return methods[i];
+                }
+                if (params.length != methodParams.length) {
                     continue;
+                }
                 boolean found = true;
                 for (int j = 0; j < params.length; j++) {
                     if (params[j] != methodParams[j]) {
@@ -811,8 +811,9 @@ public final class IntrospectionUtils {
                         break;
                     }
                 }
-                if (found)
+                if (found) {
                     return methods[i];
+                }
             }
         }
         return null;
@@ -995,6 +996,23 @@ public final class IntrospectionUtils {
     }
 
 
+    /**
+     * Checks to see if the specified class is an instance of or assignable 
from
+     * the specified type. The class <code>clazz</code>, all its superclasses,
+     * interfaces and those superinterfaces are tested for a match against
+     * the type name <code>type</code>.
+     *
+     * This is similar to <code>instanceof</code> or {@link 
Class#isAssignableFrom}
+     * except that the target type will not be resolved into a Class
+     * object, which provides some security and memory benefits.
+     *
+     * @param clazz The class to test for a match.
+     * @param type The name of the type that <code>clazz</code> must be.
+     *
+     * @return <code>true</code> if the <code>clazz</code> tested is an
+     *         instance of the specified <code>type</code>,
+     *         <code>false</code> otherwise.
+     */
     public static boolean isInstance(Class<?> clazz, String type) {
         if (type.equals(clazz.getName())) {
             return true;
diff --git a/java/org/apache/tomcat/util/digester/Digester.java 
b/java/org/apache/tomcat/util/digester/Digester.java
index 614b142..aee62dc 100644
--- a/java/org/apache/tomcat/util/digester/Digester.java
+++ b/java/org/apache/tomcat/util/digester/Digester.java
@@ -27,7 +27,6 @@ import java.net.URISyntaxException;
 import java.security.Permission;
 import java.util.EmptyStackException;
 import java.util.HashMap;
-import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 import java.util.PropertyPermission;
@@ -916,8 +915,7 @@ public class Digester extends DefaultHandler2 {
      * @exception SAXException if a parsing error is to be reported
      */
     @Override
-    public void characters(char buffer[], int start, int length)
-            throws SAXException {
+    public void characters(char buffer[], int start, int length) throws 
SAXException {
 
         if (saxLog.isDebugEnabled()) {
             saxLog.debug("characters(" + new String(buffer, start, length) + 
")");
@@ -949,9 +947,7 @@ public class Digester extends DefaultHandler2 {
         }
 
         // Fire "finish" events for all defined rules
-        Iterator<Rule> rules = getRules().rules().iterator();
-        while (rules.hasNext()) {
-            Rule rule = rules.next();
+        for (Rule rule : getRules().rules()) {
             try {
                 rule.finish();
             } catch (Exception e) {
@@ -2076,11 +2072,9 @@ public class Digester extends DefaultHandler2 {
      *  the default Java class name to be created
      * @see ObjectCreateRule
      */
-    public void addObjectCreate(String pattern, String className,
-                                String attributeName) {
+    public void addObjectCreate(String pattern, String className, String 
attributeName) {
 
-        addRule(pattern,
-                new ObjectCreateRule(className, attributeName));
+        addRule(pattern, new ObjectCreateRule(className, attributeName));
 
     }
 
@@ -2129,11 +2123,9 @@ public class Digester extends DefaultHandler2 {
      *  for a <code>boolean</code> parameter)
      * @see SetNextRule
      */
-    public void addSetNext(String pattern, String methodName,
-                           String paramType) {
+    public void addSetNext(String pattern, String methodName, String 
paramType) {
 
-        addRule(pattern,
-                new SetNextRule(methodName, paramType));
+        addRule(pattern, new SetNextRule(methodName, paramType));
 
     }
 
@@ -2177,8 +2169,7 @@ public class Digester extends DefaultHandler2 {
      */
     public void addSetProperties(String pattern) {
 
-        addRule(pattern,
-                new SetPropertiesRule());
+        addRule(pattern, new SetPropertiesRule());
 
     }
 


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to