From a643eaf19bd0fdb7640e07ae1c1e44e537ae2e66 Mon Sep 17 00:00:00 2001 From: Peter Reilly Date: Fri, 25 Jul 2003 08:31:45 +0000 Subject: [PATCH] checkstyle git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@274939 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/tools/ant/taskdefs/Copy.java | 47 +++++++++++-- .../org/apache/tools/ant/taskdefs/Move.java | 26 ++++++- .../tools/ant/taskdefs/condition/And.java | 6 +- .../ant/taskdefs/condition/Condition.java | 4 +- .../ant/taskdefs/condition/ConditionBase.java | 20 +++++- .../ant/taskdefs/condition/Contains.java | 26 +++---- .../tools/ant/taskdefs/condition/Equals.java | 25 +++++-- .../tools/ant/taskdefs/condition/Http.java | 17 ++++- .../tools/ant/taskdefs/condition/IsFalse.java | 7 +- .../ant/taskdefs/condition/IsReference.java | 17 ++++- .../tools/ant/taskdefs/condition/IsSet.java | 11 ++- .../tools/ant/taskdefs/condition/IsTrue.java | 7 +- .../tools/ant/taskdefs/condition/Or.java | 6 +- .../tools/ant/taskdefs/condition/Os.java | 67 ++++++++++++------- .../tools/ant/taskdefs/condition/Socket.java | 18 ++++- 15 files changed, 239 insertions(+), 65 deletions(-) diff --git a/src/main/org/apache/tools/ant/taskdefs/Copy.java b/src/main/org/apache/tools/ant/taskdefs/Copy.java index 5b0c53234..8ce34b6e2 100644 --- a/src/main/org/apache/tools/ant/taskdefs/Copy.java +++ b/src/main/org/apache/tools/ant/taskdefs/Copy.java @@ -129,12 +129,16 @@ public class Copy extends Task { fileUtils = FileUtils.newFileUtils(); } + /** + * @return the fileutils object + */ protected FileUtils getFileUtils() { return fileUtils; } /** * Sets a single source file to copy. + * @param file the file to copy */ public void setFile(File file) { this.file = file; @@ -142,6 +146,7 @@ public class Copy extends Task { /** * Sets the destination file. + * @param destFile the file to copy to */ public void setTofile(File destFile) { this.destFile = destFile; @@ -149,6 +154,7 @@ public class Copy extends Task { /** * Sets the destination directory. + * @param destDir the destination directory */ public void setTodir(File destDir) { this.destDir = destDir; @@ -156,6 +162,7 @@ public class Copy extends Task { /** * Adds a FilterChain. + * @return a filter chain object */ public FilterChain createFilterChain() { FilterChain filterChain = new FilterChain(); @@ -165,6 +172,7 @@ public class Copy extends Task { /** * Adds a filterset. + * @return a filter set object */ public FilterSet createFilterSet() { FilterSet filterSet = new FilterSet(); @@ -174,6 +182,7 @@ public class Copy extends Task { /** * Give the copied files the same last modified time as the original files. + * @param preserve a boolean string * @deprecated setPreserveLastModified(String) has been deprecated and * replaced with setPreserveLastModified(boolean) to * consistently let the Introspection mechanism work. @@ -184,6 +193,7 @@ public class Copy extends Task { /** * Give the copied files the same last modified time as the original files. + * @param preserve if true perserce the modified time, default is false */ public void setPreserveLastModified(boolean preserve) { preserveLastModified = preserve; @@ -192,7 +202,7 @@ public class Copy extends Task { /** * Whether to give the copied files the same last modified time as * the original files. - * + * @return the preserveLastModified attribute * @since 1.32, Ant 1.5 */ public boolean getPreserveLastModified() { @@ -219,6 +229,7 @@ public class Copy extends Task { /** * If true, enables filtering. + * @param filtering if true enable filtering, default is false */ public void setFiltering(boolean filtering) { this.filtering = filtering; @@ -226,6 +237,9 @@ public class Copy extends Task { /** * Overwrite any existing destination file(s). + * @param overwrite if true force overwriting of destination file(s) + * even if the destination file(s) are younger than + * the corresponding source file. Default is false. */ public void setOverwrite(boolean overwrite) { this.forceOverwrite = overwrite; @@ -237,6 +251,8 @@ public class Copy extends Task { * the same name in the source directory tree, only the first * file will be copied into the "flattened" directory, unless * the forceoverwrite attribute is true. + * @param flatten if true flatten the destination directory. Default + * is false. */ public void setFlatten(boolean flatten) { this.flatten = flatten; @@ -244,6 +260,7 @@ public class Copy extends Task { /** * Used to force listing of all names of copied files. + * @param verbose output the names of copied files. Default is false. */ public void setVerbose(boolean verbose) { if (verbose) { @@ -255,6 +272,7 @@ public class Copy extends Task { /** * Used to copy empty directories. + * @param includeEmpty if true copy empty directories. Default is true. */ public void setIncludeEmptyDirs(boolean includeEmpty) { this.includeEmpty = includeEmpty; @@ -281,7 +299,7 @@ public class Copy extends Task { public boolean isEnableMultipleMapping() { return enableMultipleMappings; } - + /** * If false, note errors to the output but keep going. * @param failonerror true or false @@ -292,6 +310,7 @@ public class Copy extends Task { /** * Adds a set of files to copy. + * @param set a set of files to copy */ public void addFileset(FileSet set) { filesets.addElement(set); @@ -299,6 +318,8 @@ public class Copy extends Task { /** * Defines the mapper to map source to destination files. + * @return a mapper to be configured + * @exception BuildException if more than one mapper is defined */ public Mapper createMapper() throws BuildException { if (mapperElement != null) { @@ -311,10 +332,10 @@ public class Copy extends Task { /** * Sets the character encoding - * + * @param encoding the character encoding * @since 1.32, Ant 1.5 */ - public void setEncoding (String encoding) { + public void setEncoding(String encoding) { this.inputEncoding = encoding; if (outputEncoding == null) { outputEncoding = encoding; @@ -332,7 +353,7 @@ public class Copy extends Task { /** * Sets the character encoding for output files. - * + * @param encoding the character encoding * @since Ant 1.6 */ public void setOutputEncoding(String encoding) { @@ -351,6 +372,7 @@ public class Copy extends Task { /** * Performs the copy operation. + * @exception BuildException if an error occurs */ public void execute() throws BuildException { File savedFile = file; // may be altered in validateAttributes @@ -456,6 +478,7 @@ public class Copy extends Task { * Ensure we have a consistent and legal set of attributes, and set * any internal flags necessary based on different combinations * of attributes. + * @exception BuildException if an error occurs */ protected void validateAttributes() throws BuildException { if (file == null && filesets.size() == 0) { @@ -512,6 +535,11 @@ public class Copy extends Task { /** * Compares source files to destination files to see if they should be * copied. + * + * @param fromDir The source directory + * @param toDir The destination dirctory + * @param files A list of files to copy + * @param dirs A list of directories to copy */ protected void scan(File fromDir, File toDir, String[] files, String[] dirs) { @@ -531,6 +559,15 @@ public class Copy extends Task { } } + /** + * Add to a map of files/directories to copy + * + * @param fromDir the source directory + * @param toDir the destination directory + * @param names a list of filenames + * @param mapper a FileNameMapper value + * @param map a map of source file to array of destination files + */ protected void buildMap(File fromDir, File toDir, String[] names, FileNameMapper mapper, Hashtable map) { diff --git a/src/main/org/apache/tools/ant/taskdefs/Move.java b/src/main/org/apache/tools/ant/taskdefs/Move.java index d9f83c2ac..f2a8a1b55 100644 --- a/src/main/org/apache/tools/ant/taskdefs/Move.java +++ b/src/main/org/apache/tools/ant/taskdefs/Move.java @@ -90,15 +90,25 @@ import org.apache.tools.ant.types.FilterSetCollection; */ public class Move extends Copy { + /** + * Constructor of object. + * This sets the forceOverwrite attribute of the Copy parent class + * to true. + * + */ public Move() { super(); - forceOverwrite = true; + setOverwrite(true); } //************************************************************************ // protected and private methods //************************************************************************ + /** + * Override copy's doFileOperations to move the + * files instead of copying them. + */ protected void doFileOperations() { //Attempt complete directory renames, if any, first. if (completeDirMap.size() > 0) { @@ -190,7 +200,7 @@ public class Move extends Copy { if (createCount > 0) { log("Moved " + dirCopyMap.size() + " empty director" - + (dirCopyMap.size()== 1 ? "y" : "ies") + + (dirCopyMap.size() == 1 ? "y" : "ies") + " to " + createCount + " empty director" + (createCount == 1 ? "y" : "ies") + " under " @@ -274,6 +284,7 @@ public class Move extends Copy { /** * Its only ok to delete a directory tree if there are * no files in it. + * @param d the directory to check * @return true if a deletion can go ahead */ protected boolean okToDelete(File d) { @@ -299,6 +310,7 @@ public class Move extends Copy { /** * Go and delete the directory tree. + * @param d the directory to delete */ protected void deleteDir(File d) { String[] list = d.list(); @@ -332,7 +344,15 @@ public class Move extends Copy { * Method then checks if token filtering is used. If it is, this method * returns false assuming it is the responsibility to the copyFile method. * - * @throws IOException + * @param sourceFile the file to rename + * @param destFile the destination file + * @param filtering if true, filtering is in operation, file will + * be copied/deleted instead of renamed + * @param overwrite if true force overwrite even if destination file + * is newer than source file + * @return true if the file was renamed + * @exception IOException if an error occurs + * @exception BuildException if an error occurs */ protected boolean renameFile(File sourceFile, File destFile, boolean filtering, boolean overwrite) diff --git a/src/main/org/apache/tools/ant/taskdefs/condition/And.java b/src/main/org/apache/tools/ant/taskdefs/condition/And.java index 26bddb1a7..21e345ae0 100644 --- a/src/main/org/apache/tools/ant/taskdefs/condition/And.java +++ b/src/main/org/apache/tools/ant/taskdefs/condition/And.java @@ -1,7 +1,7 @@ /* * The Apache Software License, Version 1.1 * - * Copyright (c) 2001-2002 The Apache Software Foundation. All rights + * Copyright (c) 2001-2003 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without @@ -69,6 +69,10 @@ import org.apache.tools.ant.BuildException; */ public class And extends ConditionBase implements Condition { + /** + * @return true if all the contained conditions evaluates to true + * @exception BuildException if an error occurs + */ public boolean eval() throws BuildException { Enumeration enum = getConditions(); while (enum.hasMoreElements()) { diff --git a/src/main/org/apache/tools/ant/taskdefs/condition/Condition.java b/src/main/org/apache/tools/ant/taskdefs/condition/Condition.java index 83daaf299..1a4961716 100644 --- a/src/main/org/apache/tools/ant/taskdefs/condition/Condition.java +++ b/src/main/org/apache/tools/ant/taskdefs/condition/Condition.java @@ -1,7 +1,7 @@ /* * The Apache Software License, Version 1.1 * - * Copyright (c) 2001 The Apache Software Foundation. All rights + * Copyright (c) 2001,2003 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without @@ -65,6 +65,8 @@ import org.apache.tools.ant.BuildException; public interface Condition { /** * Is this condition true? + * @return true if the condition is true + * @exception BuildException if an error occurs */ boolean eval() throws BuildException; } diff --git a/src/main/org/apache/tools/ant/taskdefs/condition/ConditionBase.java b/src/main/org/apache/tools/ant/taskdefs/condition/ConditionBase.java index 4998f39ae..44b1a88b3 100644 --- a/src/main/org/apache/tools/ant/taskdefs/condition/ConditionBase.java +++ b/src/main/org/apache/tools/ant/taskdefs/condition/ConditionBase.java @@ -76,6 +76,7 @@ public abstract class ConditionBase extends ProjectComponent { /** * Count the conditions. * + * @return the number of conditions in the container * @since 1.1 */ protected int countConditions() { @@ -85,6 +86,7 @@ public abstract class ConditionBase extends ProjectComponent { /** * Iterate through all conditions. * + * @return an enumeration to use for iteration * @since 1.1 */ protected final Enumeration getConditions() { @@ -93,7 +95,7 @@ public abstract class ConditionBase extends ProjectComponent { /** * Add an <available> condition. - * + * @param a an available condition * @since 1.1 */ public void addAvailable(Available a) { @@ -103,6 +105,7 @@ public abstract class ConditionBase extends ProjectComponent { /** * Add an <checksum> condition. * + * @param c a Checksum condition * @since 1.4, Ant 1.5 */ public void addChecksum(Checksum c) { @@ -112,6 +115,7 @@ public abstract class ConditionBase extends ProjectComponent { /** * Add an <uptodate> condition. * + * @param u an UpToDate condition * @since 1.1 */ public void addUptodate(UpToDate u) { @@ -121,6 +125,7 @@ public abstract class ConditionBase extends ProjectComponent { /** * Add an <not> condition "container". * + * @param n a Not condition * @since 1.1 */ public void addNot(Not n) { @@ -130,6 +135,7 @@ public abstract class ConditionBase extends ProjectComponent { /** * Add an <and> condition "container". * + * @param a an And condition * @since 1.1 */ public void addAnd(And a) { @@ -139,6 +145,7 @@ public abstract class ConditionBase extends ProjectComponent { /** * Add an <or> condition "container". * + * @param o an Or condition * @since 1.1 */ public void addOr(Or o) { @@ -148,6 +155,7 @@ public abstract class ConditionBase extends ProjectComponent { /** * Add an <equals> condition. * + * @param e an Equals condition * @since 1.1 */ public void addEquals(Equals e) { @@ -157,6 +165,7 @@ public abstract class ConditionBase extends ProjectComponent { /** * Add an <os> condition. * + * @param o an Os condition * @since 1.1 */ public void addOs(Os o) { @@ -166,6 +175,7 @@ public abstract class ConditionBase extends ProjectComponent { /** * Add an <isset> condition. * + * @param i an IsSet condition * @since Ant 1.5 */ public void addIsSet(IsSet i) { @@ -175,6 +185,7 @@ public abstract class ConditionBase extends ProjectComponent { /** * Add an <http> condition. * + * @param h an Http condition * @since Ant 1.5 */ public void addHttp(Http h) { @@ -184,6 +195,7 @@ public abstract class ConditionBase extends ProjectComponent { /** * Add a <socket> condition. * + * @param s a Socket condition * @since Ant 1.5 */ public void addSocket(Socket s) { @@ -193,6 +205,7 @@ public abstract class ConditionBase extends ProjectComponent { /** * Add a <filesmatch> condition. * + * @param test a FilesMatch condition * @since Ant 1.5 */ public void addFilesMatch(FilesMatch test) { @@ -202,6 +215,7 @@ public abstract class ConditionBase extends ProjectComponent { /** * Add a <contains> condition. * + * @param test a Contains condition * @since Ant 1.5 */ public void addContains(Contains test) { @@ -211,6 +225,7 @@ public abstract class ConditionBase extends ProjectComponent { /** * Add a <istrue> condition. * + * @param test an IsTrue condition * @since Ant 1.5 */ public void addIsTrue(IsTrue test) { @@ -220,6 +235,7 @@ public abstract class ConditionBase extends ProjectComponent { /** * Add a <isfalse> condition. * + * @param test an IsFalse condition * @since Ant 1.5 */ public void addIsFalse(IsFalse test) { @@ -229,6 +245,7 @@ public abstract class ConditionBase extends ProjectComponent { /** * Add an <isreference> condition. * + * @param i an IsReference condition * @since Ant 1.6 */ public void addIsReference(IsReference i) { @@ -237,6 +254,7 @@ public abstract class ConditionBase extends ProjectComponent { /** * Add an arbitary condition + * @param c a condition * @since Ant 1.6 */ public void add(Condition c) { diff --git a/src/main/org/apache/tools/ant/taskdefs/condition/Contains.java b/src/main/org/apache/tools/ant/taskdefs/condition/Contains.java index 4c8f5338b..875e0ba54 100644 --- a/src/main/org/apache/tools/ant/taskdefs/condition/Contains.java +++ b/src/main/org/apache/tools/ant/taskdefs/condition/Contains.java @@ -1,7 +1,7 @@ /* * The Apache Software License, Version 1.1 * - * Copyright (c) 2002 The Apache Software Foundation. All rights + * Copyright (c) 2002-2003 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without @@ -71,33 +71,35 @@ public class Contains implements Condition { /** * The string to search in. - * - * @since 1.1, Ant 1.5 + * @param string the string to search in + * @since Ant 1.5 */ - public void setString(String a1) { - string = a1; + public void setString(String string) { + this.string = string; } /** * The string to search for. - * - * @since 1.1, Ant 1.5 + * @param subString the string to search for + * @since Ant 1.5 */ - public void setSubstring(String a2) { - subString = a2; + public void setSubstring(String subString) { + this.subString = subString; } /** * Whether to search ignoring case or not. - * - * @since 1.1, Ant 1.5 + * @param b if true, ignore case + * @since Ant 1.5 */ public void setCasesensitive(boolean b) { caseSensitive = b; } /** - * @since 1.1, Ant 1.5 + * @since Ant 1.5 + * @return true if the substring is within the string + * @exception BuildException if the attributes are not set correctly */ public boolean eval() throws BuildException { if (string == null || subString == null) { diff --git a/src/main/org/apache/tools/ant/taskdefs/condition/Equals.java b/src/main/org/apache/tools/ant/taskdefs/condition/Equals.java index 5e9ad66f1..25001b560 100644 --- a/src/main/org/apache/tools/ant/taskdefs/condition/Equals.java +++ b/src/main/org/apache/tools/ant/taskdefs/condition/Equals.java @@ -1,7 +1,7 @@ /* * The Apache Software License, Version 1.1 * - * Copyright (c) 2001-2002 The Apache Software Foundation. All rights + * Copyright (c) 2001-2003 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without @@ -69,18 +69,28 @@ public class Equals implements Condition { private boolean trim = false; private boolean caseSensitive = true; + /** + * Set the first string + * + * @param a1 the first string + */ public void setArg1(String a1) { arg1 = a1; } + /** + * Set the second string + * + * @param a2 the second string + */ public void setArg2(String a2) { arg2 = a2; } /** * Should we want to trim the arguments before comparing them? - * - * @since Revision: 1.3, Ant 1.5 + * @param b if true trim the arguments + * @since Ant 1.5 */ public void setTrim(boolean b) { trim = b; @@ -88,13 +98,18 @@ public class Equals implements Condition { /** * Should the comparison be case sensitive? - * - * @since Revision: 1.3, Ant 1.5 + * @param b if true use a case sensitive comparision (this is the + * default) + * @since Ant 1.5 */ public void setCasesensitive(boolean b) { caseSensitive = b; } + /** + * @return true if the two strings are equal + * @exception BuildException if the attributes are not set correctly + */ public boolean eval() throws BuildException { if (arg1 == null || arg2 == null) { throw new BuildException("both arg1 and arg2 are required in " diff --git a/src/main/org/apache/tools/ant/taskdefs/condition/Http.java b/src/main/org/apache/tools/ant/taskdefs/condition/Http.java index 41f393880..932dc9b2b 100644 --- a/src/main/org/apache/tools/ant/taskdefs/condition/Http.java +++ b/src/main/org/apache/tools/ant/taskdefs/condition/Http.java @@ -1,7 +1,7 @@ /* * The Apache Software License, Version 1.1 * - * Copyright (c) 2001-2002 The Apache Software Foundation. All rights + * Copyright (c) 2001-2003 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without @@ -72,16 +72,31 @@ import org.apache.tools.ant.ProjectComponent; public class Http extends ProjectComponent implements Condition { private String spec = null; + /** + * Set the url attribute + * + * @param url the url of the request + */ public void setUrl(String url) { spec = url; } private int errorsBeginAt = 400; + /** + * Set the errorsBeginAt attribute + * + * @param errorsBeginAt number at which errors begin at, default is + * 400 + */ public void setErrorsBeginAt(int errorsBeginAt) { this.errorsBeginAt = errorsBeginAt; } + /** + * @return true if the HTTP request succeeds + * @exception BuildException if an error occurs + */ public boolean eval() throws BuildException { if (spec == null) { throw new BuildException("No url specified in http condition"); diff --git a/src/main/org/apache/tools/ant/taskdefs/condition/IsFalse.java b/src/main/org/apache/tools/ant/taskdefs/condition/IsFalse.java index a4b8294c1..fd31b0e06 100644 --- a/src/main/org/apache/tools/ant/taskdefs/condition/IsFalse.java +++ b/src/main/org/apache/tools/ant/taskdefs/condition/IsFalse.java @@ -1,7 +1,7 @@ /* * The Apache Software License, Version 1.1 * - * Copyright (c) 2002 The Apache Software Foundation. All rights + * Copyright (c) 2002-2003 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without @@ -71,13 +71,14 @@ public class IsFalse extends ProjectComponent implements Condition { /** * set the value to be tested; let ant eval it to true/false + * @param value the value to test */ public void setValue(boolean value) { - this.value = new Boolean(value); + this.value = value ? Boolean.TRUE : Boolean.FALSE; } /** - * return the inverted value; + * @return the inverted value; * @throws BuildException if someone forgot to spec a value */ public boolean eval() throws BuildException { diff --git a/src/main/org/apache/tools/ant/taskdefs/condition/IsReference.java b/src/main/org/apache/tools/ant/taskdefs/condition/IsReference.java index 664df1e3f..45538126d 100644 --- a/src/main/org/apache/tools/ant/taskdefs/condition/IsReference.java +++ b/src/main/org/apache/tools/ant/taskdefs/condition/IsReference.java @@ -1,7 +1,7 @@ /* * The Apache Software License, Version 1.1 * - * Copyright (c) 2002 The Apache Software Foundation. All rights + * Copyright (c) 2002-2003 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without @@ -71,14 +71,29 @@ public class IsReference extends ProjectComponent implements Condition { private Reference ref; private String type; + /** + * Set the refid attribute. + * + * @param r a Reference value + */ public void setRefid(Reference r) { ref = r; } + /** + * Set the type attribute. This is optional attribute. + * + * @param type an ant component type name + */ public void setType(String type) { this.type = type; } + /** + * @return true if the reference exists and if type is set, if + * the reference is the same type + * @exception BuildException if an error occurs + */ public boolean eval() throws BuildException { if (ref == null) { throw new BuildException("No reference specified for isreference " diff --git a/src/main/org/apache/tools/ant/taskdefs/condition/IsSet.java b/src/main/org/apache/tools/ant/taskdefs/condition/IsSet.java index 419d6c3c2..c3514199e 100644 --- a/src/main/org/apache/tools/ant/taskdefs/condition/IsSet.java +++ b/src/main/org/apache/tools/ant/taskdefs/condition/IsSet.java @@ -1,7 +1,7 @@ /* * The Apache Software License, Version 1.1 * - * Copyright (c) 2001-2002 The Apache Software Foundation. All rights + * Copyright (c) 2001-2003 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without @@ -67,10 +67,19 @@ import org.apache.tools.ant.ProjectComponent; public class IsSet extends ProjectComponent implements Condition { private String property; + /** + * Set the property attribute + * + * @param p the property name + */ public void setProperty(String p) { property = p; } + /** + * @return true if the property exists + * @exception BuildException if the property attribute is not set + */ public boolean eval() throws BuildException { if (property == null) { throw new BuildException("No property specified for isset " diff --git a/src/main/org/apache/tools/ant/taskdefs/condition/IsTrue.java b/src/main/org/apache/tools/ant/taskdefs/condition/IsTrue.java index 02a4c1127..cc095fdd4 100644 --- a/src/main/org/apache/tools/ant/taskdefs/condition/IsTrue.java +++ b/src/main/org/apache/tools/ant/taskdefs/condition/IsTrue.java @@ -1,7 +1,7 @@ /* * The Apache Software License, Version 1.1 * - * Copyright (c) 2002 The Apache Software Foundation. All rights + * Copyright (c) 2002-2003 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without @@ -71,13 +71,14 @@ public class IsTrue extends ProjectComponent implements Condition { /** * set the value to be tested; let ant eval it to true/false + * @param value the value to test */ public void setValue(boolean value) { - this.value = new Boolean(value); + this.value = value ? Boolean.TRUE : Boolean.FALSE; } /** - * return the value; + * @return the value * @throws BuildException if someone forgot to spec a value */ public boolean eval() throws BuildException { diff --git a/src/main/org/apache/tools/ant/taskdefs/condition/Or.java b/src/main/org/apache/tools/ant/taskdefs/condition/Or.java index 5e4f37e11..10b3496c1 100644 --- a/src/main/org/apache/tools/ant/taskdefs/condition/Or.java +++ b/src/main/org/apache/tools/ant/taskdefs/condition/Or.java @@ -1,7 +1,7 @@ /* * The Apache Software License, Version 1.1 * - * Copyright (c) 2001-2002 The Apache Software Foundation. All rights + * Copyright (c) 2001-2003 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without @@ -69,6 +69,10 @@ import org.apache.tools.ant.BuildException; */ public class Or extends ConditionBase implements Condition { + /** + * @return true if any of the contained conditions evaluate to true + * @exception BuildException if an error occurs + */ public boolean eval() throws BuildException { Enumeration enum = getConditions(); while (enum.hasMoreElements()) { diff --git a/src/main/org/apache/tools/ant/taskdefs/condition/Os.java b/src/main/org/apache/tools/ant/taskdefs/condition/Os.java index a839a8241..0b6ca7700 100644 --- a/src/main/org/apache/tools/ant/taskdefs/condition/Os.java +++ b/src/main/org/apache/tools/ant/taskdefs/condition/Os.java @@ -66,22 +66,32 @@ import org.apache.tools.ant.BuildException; * @version $Revision$ */ public class Os implements Condition { - private static final String osName = + private static final String OS_NAME = System.getProperty("os.name").toLowerCase(Locale.US); - private static final String osArch = + private static final String OS_ARCH = System.getProperty("os.arch").toLowerCase(Locale.US); - private static final String osVersion = + private static final String OS_VERSION = System.getProperty("os.version").toLowerCase(Locale.US); - private static final String pathSep = System.getProperty("path.separator"); + private static final String PATH_SEP = + System.getProperty("path.separator"); private String family; private String name; private String version; private String arch; + /** + * Default constructor + * + */ public Os() { } + /** + * Constructor that sets the family attribute + * + * @param family a String value + */ public Os(String family) { setFamily(family); } @@ -147,7 +157,8 @@ public class Os implements Condition { /** * Determines if the OS on which Ant is executing matches the * given OS family. - * + * @param family the family to check for + * @return true if the OS matches * @since 1.5 */ public static boolean isFamily(String family) { @@ -158,6 +169,8 @@ public class Os implements Condition { * Determines if the OS on which Ant is executing matches the * given OS name. * + * @param name the OS name to check for + * @return true if the OS matches * @since 1.7 */ public static boolean isName(String name) { @@ -168,6 +181,8 @@ public class Os implements Condition { * Determines if the OS on which Ant is executing matches the * given OS architecture. * + * @param arch the OS architecture to check for + * @return true if the OS matches * @since 1.7 */ public static boolean isArch(String arch) { @@ -178,6 +193,8 @@ public class Os implements Condition { * Determines if the OS on which Ant is executing matches the * given OS version. * + * @param version the OS version to check for + * @return true if the OS matches * @since 1.7 */ public static boolean isVersion(String version) { @@ -192,7 +209,7 @@ public class Os implements Condition { * @param name The OS name * @param arch The OS architecture * @param version The OS version - * + * @return true if the OS matches * @since 1.7 */ public static boolean isOs(String family, String name, String arch, @@ -209,34 +226,34 @@ public class Os implements Condition { if (family != null) { if (family.equals("windows")) { - isFamily = osName.indexOf("windows") > -1; + isFamily = OS_NAME.indexOf("windows") > -1; } else if (family.equals("os/2")) { - isFamily = osName.indexOf("os/2") > -1; + isFamily = OS_NAME.indexOf("os/2") > -1; } else if (family.equals("netware")) { - isFamily = osName.indexOf("netware") > -1; + isFamily = OS_NAME.indexOf("netware") > -1; } else if (family.equals("dos")) { - isFamily = pathSep.equals(";") && !isFamily("netware"); + isFamily = PATH_SEP.equals(";") && !isFamily("netware"); } else if (family.equals("mac")) { - isFamily = osName.indexOf("mac") > -1; + isFamily = OS_NAME.indexOf("mac") > -1; } else if (family.equals("tandem")) { - isFamily = osName.indexOf("nonstop_kernel") > -1; + isFamily = OS_NAME.indexOf("nonstop_kernel") > -1; } else if (family.equals("unix")) { - isFamily = pathSep.equals(":") + isFamily = PATH_SEP.equals(":") && !isFamily("openvms") - && (!isFamily("mac") || osName.endsWith("x")); + && (!isFamily("mac") || OS_NAME.endsWith("x")); } else if (family.equals("win9x")) { isFamily = isFamily("windows") - && (osName.indexOf("95") >= 0 - || osName.indexOf("98") >= 0 - || osName.indexOf("me") >= 0 - || osName.indexOf("ce") >= 0); + && (OS_NAME.indexOf("95") >= 0 + || OS_NAME.indexOf("98") >= 0 + || OS_NAME.indexOf("me") >= 0 + || OS_NAME.indexOf("ce") >= 0); } else if (family.equals("z/os")) { - isFamily = osName.indexOf("z/os") > -1 - || osName.indexOf("os/390") > -1; + isFamily = OS_NAME.indexOf("z/os") > -1 + || OS_NAME.indexOf("os/390") > -1; } else if (family.equals("os/400")) { - isFamily = osName.indexOf("os/400") > -1; + isFamily = OS_NAME.indexOf("os/400") > -1; } else if (family.equals("openvms")) { - isFamily = osName.indexOf("openvms") > -1; + isFamily = OS_NAME.indexOf("openvms") > -1; } else { throw new BuildException( "Don\'t know how to detect os family \"" @@ -244,13 +261,13 @@ public class Os implements Condition { } } if (name != null) { - isName = name.equals(osName); + isName = name.equals(OS_NAME); } if (arch != null) { - isArch = arch.equals(osArch); + isArch = arch.equals(OS_ARCH); } if (version != null) { - isVersion = version.equals(osVersion); + isVersion = version.equals(OS_VERSION); } retValue = isFamily && isName && isArch && isVersion; } diff --git a/src/main/org/apache/tools/ant/taskdefs/condition/Socket.java b/src/main/org/apache/tools/ant/taskdefs/condition/Socket.java index 9b063f8cd..432ebb71f 100644 --- a/src/main/org/apache/tools/ant/taskdefs/condition/Socket.java +++ b/src/main/org/apache/tools/ant/taskdefs/condition/Socket.java @@ -1,7 +1,7 @@ /* * The Apache Software License, Version 1.1 * - * Copyright (c) 2001-2002 The Apache Software Foundation. All rights + * Copyright (c) 2001-2003 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without @@ -60,7 +60,7 @@ import org.apache.tools.ant.Project; import org.apache.tools.ant.ProjectComponent; /** - * Condition to wait for a TCP/IP socket to have a listener. Its attribute(s) are: + * Condition to wait for a TCP/IP socket to have a listener. Its attributes are: * server - the name of the server. * port - the port number of the socket. * @@ -71,14 +71,28 @@ public class Socket extends ProjectComponent implements Condition { private String server = null; private int port = 0; + /** + * Set the server attribute + * + * @param server the server name + */ public void setServer(String server) { this.server = server; } + /** + * Set the port attribute + * + * @param port the port number of the socket + */ public void setPort(int port) { this.port = port; } + /** + * @return true if a socket can be created + * @exception BuildException if the attributes are not set + */ public boolean eval() throws BuildException { if (server == null) { throw new BuildException("No server specified in socket "