ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From peterrei...@apache.org
Subject svn commit: r471552 - in /ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/condition: AntVersion.java ConditionBase.java HasMethod.java Http.java IsReachable.java IsSigned.java Matches.java Os.java ParserSupports.java TypeFound.java
Date Sun, 05 Nov 2006 22:47:43 GMT
Author: peterreilly
Date: Sun Nov  5 14:47:42 2006
New Revision: 471552

URL: http://svn.apache.org/viewvc?view=rev&rev=471552
Log:
checkstyle

Modified:
    ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/condition/AntVersion.java
    ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/condition/ConditionBase.java
    ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/condition/HasMethod.java
    ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/condition/Http.java
    ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/condition/IsReachable.java
    ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/condition/IsSigned.java
    ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/condition/Matches.java
    ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/condition/Os.java
    ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/condition/ParserSupports.java
    ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/condition/TypeFound.java

Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/condition/AntVersion.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/condition/AntVersion.java?view=diff&rev=471552&r1=471551&r2=471552
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/condition/AntVersion.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/condition/AntVersion.java Sun Nov
 5 14:47:42 2006
@@ -27,31 +27,28 @@
  * @since Ant 1.7
  */
 public class AntVersion implements Condition {
-    
+
     private String atLeast = null;
     private String exactly = null;
-    
+
+    /**
+     * Evalute the condition.
+     * @return true if the condition is true.
+     * @throws BuildException if an error occurs.
+     */
     public boolean eval() throws BuildException {
         validate();
         DeweyDecimal actual = getVersion();
         if (null != atLeast) {
-            if (actual.isGreaterThanOrEqual(new DeweyDecimal(atLeast))) {
-                return true;
-            } else {
-                return false;
-            }
+            return actual.isGreaterThanOrEqual(new DeweyDecimal(atLeast));
         }
         if (null != exactly) {
-            if (actual.isEqual(new DeweyDecimal(exactly))) {
-                return true;
-            } else {
-                return false;
-            }
+            return actual.isEqual(new DeweyDecimal(exactly));
         }
         //default
         return false;
     }
-    
+
     private void validate() throws BuildException {
         if (atLeast != null && exactly != null) {
             throw new BuildException("Only one of atleast or exactly may be set.");
@@ -69,19 +66,19 @@
             throw new BuildException("The argument is not a Dewey Decimal eg 1.1.0");
         }
     }
-        
+
     private DeweyDecimal getVersion() {
         Project p = new Project();
         p.init();
         char[] versionString = p.getProperty("ant.version").toCharArray();
         StringBuffer sb = new StringBuffer();
         boolean foundFirstDigit = false;
-        for (int i=0; i<versionString.length; i++) {
+        for (int i = 0; i < versionString.length; i++) {
             if (Character.isDigit(versionString[i])) {
                 sb.append(versionString[i]);
                 foundFirstDigit = true;
             }
-            if  (versionString[i]=='.' && foundFirstDigit) {
+            if (versionString[i] == '.' && foundFirstDigit) {
                 sb.append(versionString[i]);
             }
             if (Character.isLetter(versionString[i]) && foundFirstDigit) {
@@ -90,20 +87,40 @@
         }
         return new DeweyDecimal(sb.toString());
     }
-    
+
+    /**
+     * Get the atleast attribute.
+     * @return the atleast attribute.
+     */
     public String getAtLeast() {
         return atLeast;
     }
-    
+
+    /**
+     * Set the atleast attribute.
+     * This is of the form major.minor.point.
+     * For example 1.7.0.
+     * @param atLeast the version to check against.
+     */
     public void setAtLeast(String atLeast) {
         this.atLeast = atLeast;
     }
-    
+
+    /**
+     * Get the exactly attribute.
+     * @return the exactly attribute.
+     */
     public String getExactly() {
         return exactly;
     }
-    
+
+    /**
+     * Set the exactly attribute.
+     * This is of the form major.minor.point.
+     * For example 1.7.0.
+     * @param exactly the version to check against.
+     */
     public void setExactly(String exactly) {
         this.exactly = exactly;
-    }   
+    }
 }

Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/condition/ConditionBase.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/condition/ConditionBase.java?view=diff&rev=471552&r1=471551&r2=471552
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/condition/ConditionBase.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/condition/ConditionBase.java Sun
Nov  5 14:47:42 2006
@@ -44,7 +44,7 @@
     /**
      * name of the component
      */
-    private String taskName="condition";
+    private String taskName = "condition";
 
     /**
      *
@@ -60,7 +60,7 @@
 
     /**
      * Constructor that takes the name of the task in the task name.
-     * @param taskName
+     * @param taskName the name of the task.
      * @since Ant 1.7
      */
     protected ConditionBase(String taskName) {
@@ -289,6 +289,7 @@
      * be discovered from the org.apache.tools.ant.taskdefs.condition
      * antlib.
      * @param name the condition to create.
+     * @return the dynamic condition if found, null otherwise.
      */
     public Object createDynamicElement(String name) {
         Object cond = ComponentHelper.getComponentHelper(getProject())

Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/condition/HasMethod.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/condition/HasMethod.java?view=diff&rev=471552&r1=471551&r2=471552
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/condition/HasMethod.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/condition/HasMethod.java Sun Nov
 5 14:47:42 2006
@@ -69,18 +69,34 @@
         createClasspath().setRefid(r);
     }
 
+    /**
+     * Set the classname attribute.
+     * @param classname the name of the class to check.
+     */
     public void setClassname(String classname) {
         this.classname = classname;
     }
 
+    /**
+     * Set the name of the method.
+     * @param method the name of the method to check.
+     */
     public void setMethod(String method) {
         this.method = method;
     }
 
+    /**
+     * Set the name of the field.
+     * @param field the name of the field to check.
+     */
     public void setField(String field) {
         this.field = field;
     }
 
+    /**
+     * Set whether to ignore system classes when looking for the class.
+     * @param ignoreSystemClasses a <code>boolean</code> value.
+     */
     public void setIgnoreSystemClasses(boolean ignoreSystemClasses) {
         this.ignoreSystemClasses = ignoreSystemClasses;
     }
@@ -127,15 +143,16 @@
     }
 
 
+    /** {@inheritDoc}. */
     public boolean eval() throws BuildException {
-        if(classname==null) {
+        if (classname == null) {
             throw new BuildException("No classname defined");
         }
-        Class clazz=loadClass(classname);
-        if (method!=null) {
+        Class clazz = loadClass(classname);
+        if (method != null) {
             return isMethodFound(clazz);
         }
-        if(field!=null) {
+        if (field != null) {
             return isFieldFound(clazz);
         }
         throw new BuildException("Neither method nor field defined");
@@ -143,9 +160,9 @@
 
     private boolean isFieldFound(Class clazz) {
         Field[] fields = clazz.getDeclaredFields();
-        for(int i=0;i<fields.length;i++) {
-            Field fieldEntry=fields[i];
-            if(fieldEntry.getName().equals(field)) {
+        for (int i = 0; i < fields.length; i++) {
+            Field fieldEntry = fields[i];
+            if (fieldEntry.getName().equals(field)) {
                 return true;
             }
         }
@@ -154,9 +171,9 @@
 
     private boolean isMethodFound(Class clazz) {
         Method[] methods = clazz.getDeclaredMethods();
-        for(int i=0;i<methods.length;i++) {
-            Method methodEntry =methods[i];
-            if(methodEntry.getName().equals(method)) {
+        for (int i = 0; i < methods.length; i++) {
+            Method methodEntry = methods[i];
+            if (methodEntry.getName().equals(method)) {
                 return true;
             }
         }

Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/condition/Http.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/condition/Http.java?view=diff&rev=471552&r1=471551&r2=471552
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/condition/Http.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/condition/Http.java Sun Nov  5 14:47:42
2006
@@ -33,6 +33,7 @@
  * @since Ant 1.5
  */
 public class Http extends ProjectComponent implements Condition {
+    private static final int ERROR_BEGINS = 400;
     private String spec = null;
 
     /**
@@ -43,7 +44,7 @@
         spec = url;
     }
 
-    private int errorsBeginAt = 400;
+    private int errorsBeginAt = ERROR_BEGINS;
 
     /**
      * Set the errorsBeginAt attribute
@@ -74,7 +75,7 @@
                         Project.MSG_VERBOSE);
                     if (code > 0 && code < errorsBeginAt) {
                         return true;
-                    } 
+                    }
                     return false;
                 }
             } catch (java.io.IOException e) {
@@ -85,4 +86,4 @@
         }
         return true;
     }
-}
\ No newline at end of file
+}

Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/condition/IsReachable.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/condition/IsReachable.java?view=diff&rev=471552&r1=471551&r2=471552
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/condition/IsReachable.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/condition/IsReachable.java Sun Nov
 5 14:47:42 2006
@@ -53,6 +53,7 @@
  */
 public class IsReachable extends ProjectComponent implements Condition {
 
+    private static final int SECOND = 1000; // millis per second
     private String host;
     private String url;
 
@@ -64,24 +65,25 @@
     /**
      * Error when no hostname is defined
      */
-    public static final String ERROR_NO_HOSTNAME = "No hostname defined";
+    private static final String ERROR_NO_HOSTNAME = "No hostname defined";
     /**
      * Error when invalid timeout value is defined
      */
-    public static final String ERROR_BAD_TIMEOUT = "Invalid timeout value";
+    private static final String ERROR_BAD_TIMEOUT = "Invalid timeout value";
     /**
      * Unknown host message is seen.
      */
-    public static final String WARN_UNKNOWN_HOST = "Unknown host: ";
+    private static final String WARN_UNKNOWN_HOST = "Unknown host: ";
     /**
      * Network error message is seen.
      */
-    public static final String ERROR_ON_NETWORK = "network error to ";
-    public static final String ERROR_BOTH_TARGETS = "Both url and host have been specified";
-    public static final String MSG_NO_REACHABLE_TEST
+    private static final String ERROR_ON_NETWORK = "network error to ";
+    private static final String ERROR_BOTH_TARGETS
+        = "Both url and host have been specified";
+    private static final String MSG_NO_REACHABLE_TEST
         = "cannot do a proper reachability test on this Java version";
-    public static final String ERROR_BAD_URL = "Bad URL ";
-    public static final String ERROR_NO_HOST_IN_URL = "No hostname in URL ";
+    private static final String ERROR_BAD_URL = "Bad URL ";
+    private static final String ERROR_NO_HOST_IN_URL = "No hostname in URL ";
     private static final String METHOD_NAME = "isReachable";
 
     /**
@@ -172,7 +174,7 @@
             reachableMethod = InetAddress.class.getMethod(METHOD_NAME,
                     parameterTypes);
             Object[] params = new Object[1];
-            params[0] = new Integer(timeout * 1000);
+            params[0] = new Integer(timeout * SECOND);
             try {
                 reachable = ((Boolean) reachableMethod.invoke(address, params))
                         .booleanValue();

Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/condition/IsSigned.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/condition/IsSigned.java?view=diff&rev=471552&r1=471551&r2=471552
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/condition/IsSigned.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/condition/IsSigned.java Sun Nov
 5 14:47:42 2006
@@ -37,11 +37,12 @@
 
     private static final String SIG_START = "META-INF/";
     private static final String SIG_END = ".SF";
+    private static final int    SHORT_SIG_LIMIT = 8;
 
     private String name;
     private File file;
-    
-   /**
+
+    /**
      * The jarfile that is to be tested for the presence
      * of a signature.
      * @param file jarfile to be tested.
@@ -82,18 +83,18 @@
                     }
                 }
                 return false;
-            } 
+            }
             boolean shortSig = jarFile.getEntry(SIG_START
                         + name.toUpperCase()
                         + SIG_END) != null;
             boolean longSig = false;
-            if (name.length() > 8) {
-                longSig =
-                        jarFile.getEntry(SIG_START
-                                        + name.substring(0, 8).toUpperCase()
-                                        + SIG_END) != null;
+            if (name.length() > SHORT_SIG_LIMIT) {
+                longSig = jarFile.getEntry(
+                    SIG_START
+                    + name.substring(0, SHORT_SIG_LIMIT).toUpperCase()
+                    + SIG_END) != null;
             }
-            
+
             return shortSig || longSig;
         } finally {
             ZipFile.closeQuietly(jarFile);

Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/condition/Matches.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/condition/Matches.java?view=diff&rev=471552&r1=471551&r2=471552
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/condition/Matches.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/condition/Matches.java Sun Nov 
5 14:47:42 2006
@@ -19,7 +19,6 @@
 
 import org.apache.tools.ant.BuildException;
 import org.apache.tools.ant.ProjectComponent;
-import org.apache.tools.ant.filters.TokenFilter;
 import org.apache.tools.ant.util.regexp.Regexp;
 import org.apache.tools.ant.types.RegularExpression;
 import org.apache.tools.ant.util.regexp.RegexpMatcher;

Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/condition/Os.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/condition/Os.java?view=diff&rev=471552&r1=471551&r2=471552
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/condition/Os.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/condition/Os.java Sun Nov  5 14:47:42
2006
@@ -168,6 +168,8 @@
     /**
      * Determines if the OS on which Ant is executing matches the type of
      * that set in setFamily.
+     * @return true if the os matches.
+     * @throws BuildException if there is an error.
      * @see Os#setFamily(String)
      */
     public boolean eval() throws BuildException {

Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/condition/ParserSupports.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/condition/ParserSupports.java?view=diff&rev=471552&r1=471551&r2=471552
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/condition/ParserSupports.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/condition/ParserSupports.java Sun
Nov  5 14:47:42 2006
@@ -35,23 +35,23 @@
     private String feature;
     private String property;
     private String value;
-    public static final String ERROR_BOTH_ATTRIBUTES =
+    private static final String ERROR_BOTH_ATTRIBUTES =
             "Property and feature attributes are exclusive";
-    public static final String FEATURE="feature";
-    public static final String PROPERTY = "property";
+    private static final String FEATURE = "feature";
+    private static final String PROPERTY = "property";
 
-    public static final String NOT_RECOGNIZED =
+    private static final String NOT_RECOGNIZED =
             " not recognized: ";
     private static final String NOT_SUPPORTED =
             " not supported: ";
-    public static final String ERROR_NO_ATTRIBUTES = 
+    private static final String ERROR_NO_ATTRIBUTES =
         "Neither feature or property are set";
-    public static final String ERROR_NO_VALUE = 
+    private static final String ERROR_NO_VALUE =
         "A value is needed when testing for property support";
 
     /**
      * Feature to probe for.
-     * @param feature
+     * @param feature the feature to probe for.
      */
     public void setFeature(String feature) {
         this.feature = feature;
@@ -59,7 +59,7 @@
 
     /**
      * Property to probe for
-     * @param property
+     * @param property the property to probe for.
      */
     public void setProperty(String property) {
         this.property = property;
@@ -68,12 +68,13 @@
     /**
      * Optional value to set.
      * Converted to a boolean value when setting a property
-     * @param value
+     * @param value the value to set.
      */
     public void setValue(String value) {
         this.value = value;
     }
 
+    /** {@inheritDoc}. */
     public boolean eval() throws BuildException {
         if (feature != null && property != null) {
             throw new BuildException(ERROR_BOTH_ATTRIBUTES);
@@ -109,14 +110,14 @@
         if (value == null) {
             value = "true";
         }
-        boolean v= Project.toBoolean(value);
+        boolean v = Project.toBoolean(value);
         try {
             reader.setFeature(feature, v);
         } catch (SAXNotRecognizedException e) {
-            log(FEATURE+NOT_RECOGNIZED+feature,Project.MSG_VERBOSE);
+            log(FEATURE + NOT_RECOGNIZED + feature, Project.MSG_VERBOSE);
             return false;
         } catch (SAXNotSupportedException e) {
-            log(FEATURE+NOT_SUPPORTED + feature, Project.MSG_VERBOSE);
+            log(FEATURE + NOT_SUPPORTED + feature, Project.MSG_VERBOSE);
             return false;
         }
         return true;
@@ -139,4 +140,4 @@
         }
         return true;
     }
-}
\ No newline at end of file
+}

Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/condition/TypeFound.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/condition/TypeFound.java?view=diff&rev=471552&r1=471551&r2=471552
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/condition/TypeFound.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/condition/TypeFound.java Sun Nov
 5 14:47:42 2006
@@ -68,8 +68,8 @@
         }
         //now verify that the class has an implementation
         boolean found = def.getExposedClass(getProject()) != null;
-        if(!found) {
-            String text= helper.diagnoseCreationFailure(componentName,"type");
+        if (!found) {
+            String text = helper.diagnoseCreationFailure(componentName, "type");
             log(text, Project.MSG_VERBOSE);
         }
         return found;



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org


Mime
View raw message