Browse Source

checkstyle

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@274939 13f79535-47bb-0310-9956-ffa450edef68
master
Peter Reilly 22 years ago
parent
commit
a643eaf19b
15 changed files with 239 additions and 65 deletions
  1. +42
    -5
      src/main/org/apache/tools/ant/taskdefs/Copy.java
  2. +23
    -3
      src/main/org/apache/tools/ant/taskdefs/Move.java
  3. +5
    -1
      src/main/org/apache/tools/ant/taskdefs/condition/And.java
  4. +3
    -1
      src/main/org/apache/tools/ant/taskdefs/condition/Condition.java
  5. +19
    -1
      src/main/org/apache/tools/ant/taskdefs/condition/ConditionBase.java
  6. +14
    -12
      src/main/org/apache/tools/ant/taskdefs/condition/Contains.java
  7. +20
    -5
      src/main/org/apache/tools/ant/taskdefs/condition/Equals.java
  8. +16
    -1
      src/main/org/apache/tools/ant/taskdefs/condition/Http.java
  9. +4
    -3
      src/main/org/apache/tools/ant/taskdefs/condition/IsFalse.java
  10. +16
    -1
      src/main/org/apache/tools/ant/taskdefs/condition/IsReference.java
  11. +10
    -1
      src/main/org/apache/tools/ant/taskdefs/condition/IsSet.java
  12. +4
    -3
      src/main/org/apache/tools/ant/taskdefs/condition/IsTrue.java
  13. +5
    -1
      src/main/org/apache/tools/ant/taskdefs/condition/Or.java
  14. +42
    -25
      src/main/org/apache/tools/ant/taskdefs/condition/Os.java
  15. +16
    -2
      src/main/org/apache/tools/ant/taskdefs/condition/Socket.java

+ 42
- 5
src/main/org/apache/tools/ant/taskdefs/Copy.java View File

@@ -129,12 +129,16 @@ public class Copy extends Task {
fileUtils = FileUtils.newFileUtils(); fileUtils = FileUtils.newFileUtils();
} }


/**
* @return the fileutils object
*/
protected FileUtils getFileUtils() { protected FileUtils getFileUtils() {
return fileUtils; return fileUtils;
} }


/** /**
* Sets a single source file to copy. * Sets a single source file to copy.
* @param file the file to copy
*/ */
public void setFile(File file) { public void setFile(File file) {
this.file = file; this.file = file;
@@ -142,6 +146,7 @@ public class Copy extends Task {


/** /**
* Sets the destination file. * Sets the destination file.
* @param destFile the file to copy to
*/ */
public void setTofile(File destFile) { public void setTofile(File destFile) {
this.destFile = destFile; this.destFile = destFile;
@@ -149,6 +154,7 @@ public class Copy extends Task {


/** /**
* Sets the destination directory. * Sets the destination directory.
* @param destDir the destination directory
*/ */
public void setTodir(File destDir) { public void setTodir(File destDir) {
this.destDir = destDir; this.destDir = destDir;
@@ -156,6 +162,7 @@ public class Copy extends Task {


/** /**
* Adds a FilterChain. * Adds a FilterChain.
* @return a filter chain object
*/ */
public FilterChain createFilterChain() { public FilterChain createFilterChain() {
FilterChain filterChain = new FilterChain(); FilterChain filterChain = new FilterChain();
@@ -165,6 +172,7 @@ public class Copy extends Task {


/** /**
* Adds a filterset. * Adds a filterset.
* @return a filter set object
*/ */
public FilterSet createFilterSet() { public FilterSet createFilterSet() {
FilterSet filterSet = new FilterSet(); 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. * 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 * @deprecated setPreserveLastModified(String) has been deprecated and
* replaced with setPreserveLastModified(boolean) to * replaced with setPreserveLastModified(boolean) to
* consistently let the Introspection mechanism work. * 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. * 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) { public void setPreserveLastModified(boolean preserve) {
preserveLastModified = preserve; preserveLastModified = preserve;
@@ -192,7 +202,7 @@ public class Copy extends Task {
/** /**
* Whether to give the copied files the same last modified time as * Whether to give the copied files the same last modified time as
* the original files. * the original files.
*
* @return the preserveLastModified attribute
* @since 1.32, Ant 1.5 * @since 1.32, Ant 1.5
*/ */
public boolean getPreserveLastModified() { public boolean getPreserveLastModified() {
@@ -219,6 +229,7 @@ public class Copy extends Task {


/** /**
* If true, enables filtering. * If true, enables filtering.
* @param filtering if true enable filtering, default is false
*/ */
public void setFiltering(boolean filtering) { public void setFiltering(boolean filtering) {
this.filtering = filtering; this.filtering = filtering;
@@ -226,6 +237,9 @@ public class Copy extends Task {


/** /**
* Overwrite any existing destination file(s). * 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) { public void setOverwrite(boolean overwrite) {
this.forceOverwrite = overwrite; this.forceOverwrite = overwrite;
@@ -237,6 +251,8 @@ public class Copy extends Task {
* the same name in the source directory tree, only the first * the same name in the source directory tree, only the first
* file will be copied into the "flattened" directory, unless * file will be copied into the "flattened" directory, unless
* the forceoverwrite attribute is true. * the forceoverwrite attribute is true.
* @param flatten if true flatten the destination directory. Default
* is false.
*/ */
public void setFlatten(boolean flatten) { public void setFlatten(boolean flatten) {
this.flatten = flatten; this.flatten = flatten;
@@ -244,6 +260,7 @@ public class Copy extends Task {


/** /**
* Used to force listing of all names of copied files. * 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) { public void setVerbose(boolean verbose) {
if (verbose) { if (verbose) {
@@ -255,6 +272,7 @@ public class Copy extends Task {


/** /**
* Used to copy empty directories. * Used to copy empty directories.
* @param includeEmpty if true copy empty directories. Default is true.
*/ */
public void setIncludeEmptyDirs(boolean includeEmpty) { public void setIncludeEmptyDirs(boolean includeEmpty) {
this.includeEmpty = includeEmpty; this.includeEmpty = includeEmpty;
@@ -281,7 +299,7 @@ public class Copy extends Task {
public boolean isEnableMultipleMapping() { public boolean isEnableMultipleMapping() {
return enableMultipleMappings; return enableMultipleMappings;
} }
/** /**
* If false, note errors to the output but keep going. * If false, note errors to the output but keep going.
* @param failonerror true or false * @param failonerror true or false
@@ -292,6 +310,7 @@ public class Copy extends Task {


/** /**
* Adds a set of files to copy. * Adds a set of files to copy.
* @param set a set of files to copy
*/ */
public void addFileset(FileSet set) { public void addFileset(FileSet set) {
filesets.addElement(set); filesets.addElement(set);
@@ -299,6 +318,8 @@ public class Copy extends Task {


/** /**
* Defines the mapper to map source to destination files. * 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 { public Mapper createMapper() throws BuildException {
if (mapperElement != null) { if (mapperElement != null) {
@@ -311,10 +332,10 @@ public class Copy extends Task {


/** /**
* Sets the character encoding * Sets the character encoding
*
* @param encoding the character encoding
* @since 1.32, Ant 1.5 * @since 1.32, Ant 1.5
*/ */
public void setEncoding (String encoding) {
public void setEncoding(String encoding) {
this.inputEncoding = encoding; this.inputEncoding = encoding;
if (outputEncoding == null) { if (outputEncoding == null) {
outputEncoding = encoding; outputEncoding = encoding;
@@ -332,7 +353,7 @@ public class Copy extends Task {


/** /**
* Sets the character encoding for output files. * Sets the character encoding for output files.
*
* @param encoding the character encoding
* @since Ant 1.6 * @since Ant 1.6
*/ */
public void setOutputEncoding(String encoding) { public void setOutputEncoding(String encoding) {
@@ -351,6 +372,7 @@ public class Copy extends Task {


/** /**
* Performs the copy operation. * Performs the copy operation.
* @exception BuildException if an error occurs
*/ */
public void execute() throws BuildException { public void execute() throws BuildException {
File savedFile = file; // may be altered in validateAttributes 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 * Ensure we have a consistent and legal set of attributes, and set
* any internal flags necessary based on different combinations * any internal flags necessary based on different combinations
* of attributes. * of attributes.
* @exception BuildException if an error occurs
*/ */
protected void validateAttributes() throws BuildException { protected void validateAttributes() throws BuildException {
if (file == null && filesets.size() == 0) { 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 * Compares source files to destination files to see if they should be
* copied. * 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, protected void scan(File fromDir, File toDir, String[] files,
String[] dirs) { 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 <code>FileNameMapper</code> value
* @param map a map of source file to array of destination files
*/
protected void buildMap(File fromDir, File toDir, String[] names, protected void buildMap(File fromDir, File toDir, String[] names,
FileNameMapper mapper, Hashtable map) { FileNameMapper mapper, Hashtable map) {




+ 23
- 3
src/main/org/apache/tools/ant/taskdefs/Move.java View File

@@ -90,15 +90,25 @@ import org.apache.tools.ant.types.FilterSetCollection;
*/ */
public class Move extends Copy { public class Move extends Copy {


/**
* Constructor of object.
* This sets the forceOverwrite attribute of the Copy parent class
* to true.
*
*/
public Move() { public Move() {
super(); super();
forceOverwrite = true;
setOverwrite(true);
} }


//************************************************************************ //************************************************************************
// protected and private methods // protected and private methods
//************************************************************************ //************************************************************************


/**
* Override copy's doFileOperations to move the
* files instead of copying them.
*/
protected void doFileOperations() { protected void doFileOperations() {
//Attempt complete directory renames, if any, first. //Attempt complete directory renames, if any, first.
if (completeDirMap.size() > 0) { if (completeDirMap.size() > 0) {
@@ -190,7 +200,7 @@ public class Move extends Copy {
if (createCount > 0) { if (createCount > 0) {
log("Moved " + dirCopyMap.size() log("Moved " + dirCopyMap.size()
+ " empty director" + " empty director"
+ (dirCopyMap.size()== 1 ? "y" : "ies")
+ (dirCopyMap.size() == 1 ? "y" : "ies")
+ " to " + createCount + " to " + createCount
+ " empty director" + " empty director"
+ (createCount == 1 ? "y" : "ies") + " under " + (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 * Its only ok to delete a directory tree if there are
* no files in it. * no files in it.
* @param d the directory to check
* @return true if a deletion can go ahead * @return true if a deletion can go ahead
*/ */
protected boolean okToDelete(File d) { protected boolean okToDelete(File d) {
@@ -299,6 +310,7 @@ public class Move extends Copy {


/** /**
* Go and delete the directory tree. * Go and delete the directory tree.
* @param d the directory to delete
*/ */
protected void deleteDir(File d) { protected void deleteDir(File d) {
String[] list = d.list(); 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 * Method then checks if token filtering is used. If it is, this method
* returns false assuming it is the responsibility to the copyFile 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, protected boolean renameFile(File sourceFile, File destFile,
boolean filtering, boolean overwrite) boolean filtering, boolean overwrite)


+ 5
- 1
src/main/org/apache/tools/ant/taskdefs/condition/And.java View File

@@ -1,7 +1,7 @@
/* /*
* The Apache Software License, Version 1.1 * 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. * reserved.
* *
* Redistribution and use in source and binary forms, with or without * 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 { 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 { public boolean eval() throws BuildException {
Enumeration enum = getConditions(); Enumeration enum = getConditions();
while (enum.hasMoreElements()) { while (enum.hasMoreElements()) {


+ 3
- 1
src/main/org/apache/tools/ant/taskdefs/condition/Condition.java View File

@@ -1,7 +1,7 @@
/* /*
* The Apache Software License, Version 1.1 * 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. * reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@@ -65,6 +65,8 @@ import org.apache.tools.ant.BuildException;
public interface Condition { public interface Condition {
/** /**
* Is this condition true? * Is this condition true?
* @return true if the condition is true
* @exception BuildException if an error occurs
*/ */
boolean eval() throws BuildException; boolean eval() throws BuildException;
} }


+ 19
- 1
src/main/org/apache/tools/ant/taskdefs/condition/ConditionBase.java View File

@@ -76,6 +76,7 @@ public abstract class ConditionBase extends ProjectComponent {
/** /**
* Count the conditions. * Count the conditions.
* *
* @return the number of conditions in the container
* @since 1.1 * @since 1.1
*/ */
protected int countConditions() { protected int countConditions() {
@@ -85,6 +86,7 @@ public abstract class ConditionBase extends ProjectComponent {
/** /**
* Iterate through all conditions. * Iterate through all conditions.
* *
* @return an enumeration to use for iteration
* @since 1.1 * @since 1.1
*/ */
protected final Enumeration getConditions() { protected final Enumeration getConditions() {
@@ -93,7 +95,7 @@ public abstract class ConditionBase extends ProjectComponent {


/** /**
* Add an &lt;available&gt; condition. * Add an &lt;available&gt; condition.
*
* @param a an available condition
* @since 1.1 * @since 1.1
*/ */
public void addAvailable(Available a) { public void addAvailable(Available a) {
@@ -103,6 +105,7 @@ public abstract class ConditionBase extends ProjectComponent {
/** /**
* Add an &lt;checksum&gt; condition. * Add an &lt;checksum&gt; condition.
* *
* @param c a Checksum condition
* @since 1.4, Ant 1.5 * @since 1.4, Ant 1.5
*/ */
public void addChecksum(Checksum c) { public void addChecksum(Checksum c) {
@@ -112,6 +115,7 @@ public abstract class ConditionBase extends ProjectComponent {
/** /**
* Add an &lt;uptodate&gt; condition. * Add an &lt;uptodate&gt; condition.
* *
* @param u an UpToDate condition
* @since 1.1 * @since 1.1
*/ */
public void addUptodate(UpToDate u) { public void addUptodate(UpToDate u) {
@@ -121,6 +125,7 @@ public abstract class ConditionBase extends ProjectComponent {
/** /**
* Add an &lt;not&gt; condition "container". * Add an &lt;not&gt; condition "container".
* *
* @param n a Not condition
* @since 1.1 * @since 1.1
*/ */
public void addNot(Not n) { public void addNot(Not n) {
@@ -130,6 +135,7 @@ public abstract class ConditionBase extends ProjectComponent {
/** /**
* Add an &lt;and&gt; condition "container". * Add an &lt;and&gt; condition "container".
* *
* @param a an And condition
* @since 1.1 * @since 1.1
*/ */
public void addAnd(And a) { public void addAnd(And a) {
@@ -139,6 +145,7 @@ public abstract class ConditionBase extends ProjectComponent {
/** /**
* Add an &lt;or&gt; condition "container". * Add an &lt;or&gt; condition "container".
* *
* @param o an Or condition
* @since 1.1 * @since 1.1
*/ */
public void addOr(Or o) { public void addOr(Or o) {
@@ -148,6 +155,7 @@ public abstract class ConditionBase extends ProjectComponent {
/** /**
* Add an &lt;equals&gt; condition. * Add an &lt;equals&gt; condition.
* *
* @param e an Equals condition
* @since 1.1 * @since 1.1
*/ */
public void addEquals(Equals e) { public void addEquals(Equals e) {
@@ -157,6 +165,7 @@ public abstract class ConditionBase extends ProjectComponent {
/** /**
* Add an &lt;os&gt; condition. * Add an &lt;os&gt; condition.
* *
* @param o an Os condition
* @since 1.1 * @since 1.1
*/ */
public void addOs(Os o) { public void addOs(Os o) {
@@ -166,6 +175,7 @@ public abstract class ConditionBase extends ProjectComponent {
/** /**
* Add an &lt;isset&gt; condition. * Add an &lt;isset&gt; condition.
* *
* @param i an IsSet condition
* @since Ant 1.5 * @since Ant 1.5
*/ */
public void addIsSet(IsSet i) { public void addIsSet(IsSet i) {
@@ -175,6 +185,7 @@ public abstract class ConditionBase extends ProjectComponent {
/** /**
* Add an &lt;http&gt; condition. * Add an &lt;http&gt; condition.
* *
* @param h an Http condition
* @since Ant 1.5 * @since Ant 1.5
*/ */
public void addHttp(Http h) { public void addHttp(Http h) {
@@ -184,6 +195,7 @@ public abstract class ConditionBase extends ProjectComponent {
/** /**
* Add a &lt;socket&gt; condition. * Add a &lt;socket&gt; condition.
* *
* @param s a Socket condition
* @since Ant 1.5 * @since Ant 1.5
*/ */
public void addSocket(Socket s) { public void addSocket(Socket s) {
@@ -193,6 +205,7 @@ public abstract class ConditionBase extends ProjectComponent {
/** /**
* Add a &lt;filesmatch&gt; condition. * Add a &lt;filesmatch&gt; condition.
* *
* @param test a FilesMatch condition
* @since Ant 1.5 * @since Ant 1.5
*/ */
public void addFilesMatch(FilesMatch test) { public void addFilesMatch(FilesMatch test) {
@@ -202,6 +215,7 @@ public abstract class ConditionBase extends ProjectComponent {
/** /**
* Add a &lt;contains&gt; condition. * Add a &lt;contains&gt; condition.
* *
* @param test a Contains condition
* @since Ant 1.5 * @since Ant 1.5
*/ */
public void addContains(Contains test) { public void addContains(Contains test) {
@@ -211,6 +225,7 @@ public abstract class ConditionBase extends ProjectComponent {
/** /**
* Add a &lt;istrue&gt; condition. * Add a &lt;istrue&gt; condition.
* *
* @param test an IsTrue condition
* @since Ant 1.5 * @since Ant 1.5
*/ */
public void addIsTrue(IsTrue test) { public void addIsTrue(IsTrue test) {
@@ -220,6 +235,7 @@ public abstract class ConditionBase extends ProjectComponent {
/** /**
* Add a &lt;isfalse&gt; condition. * Add a &lt;isfalse&gt; condition.
* *
* @param test an IsFalse condition
* @since Ant 1.5 * @since Ant 1.5
*/ */
public void addIsFalse(IsFalse test) { public void addIsFalse(IsFalse test) {
@@ -229,6 +245,7 @@ public abstract class ConditionBase extends ProjectComponent {
/** /**
* Add an &lt;isreference&gt; condition. * Add an &lt;isreference&gt; condition.
* *
* @param i an IsReference condition
* @since Ant 1.6 * @since Ant 1.6
*/ */
public void addIsReference(IsReference i) { public void addIsReference(IsReference i) {
@@ -237,6 +254,7 @@ public abstract class ConditionBase extends ProjectComponent {


/** /**
* Add an arbitary condition * Add an arbitary condition
* @param c a condition
* @since Ant 1.6 * @since Ant 1.6
*/ */
public void add(Condition c) { public void add(Condition c) {


+ 14
- 12
src/main/org/apache/tools/ant/taskdefs/condition/Contains.java View File

@@ -1,7 +1,7 @@
/* /*
* The Apache Software License, Version 1.1 * 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. * reserved.
* *
* Redistribution and use in source and binary forms, with or without * 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. * 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. * 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. * 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) { public void setCasesensitive(boolean b) {
caseSensitive = 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 { public boolean eval() throws BuildException {
if (string == null || subString == null) { if (string == null || subString == null) {


+ 20
- 5
src/main/org/apache/tools/ant/taskdefs/condition/Equals.java View File

@@ -1,7 +1,7 @@
/* /*
* The Apache Software License, Version 1.1 * 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. * reserved.
* *
* Redistribution and use in source and binary forms, with or without * 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 trim = false;
private boolean caseSensitive = true; private boolean caseSensitive = true;


/**
* Set the first string
*
* @param a1 the first string
*/
public void setArg1(String a1) { public void setArg1(String a1) {
arg1 = a1; arg1 = a1;
} }


/**
* Set the second string
*
* @param a2 the second string
*/
public void setArg2(String a2) { public void setArg2(String a2) {
arg2 = a2; arg2 = a2;
} }


/** /**
* Should we want to trim the arguments before comparing them? * 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) { public void setTrim(boolean b) {
trim = b; trim = b;
@@ -88,13 +98,18 @@ public class Equals implements Condition {


/** /**
* Should the comparison be case sensitive? * 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) { public void setCasesensitive(boolean b) {
caseSensitive = 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 { public boolean eval() throws BuildException {
if (arg1 == null || arg2 == null) { if (arg1 == null || arg2 == null) {
throw new BuildException("both arg1 and arg2 are required in " throw new BuildException("both arg1 and arg2 are required in "


+ 16
- 1
src/main/org/apache/tools/ant/taskdefs/condition/Http.java View File

@@ -1,7 +1,7 @@
/* /*
* The Apache Software License, Version 1.1 * 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. * reserved.
* *
* Redistribution and use in source and binary forms, with or without * 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 { public class Http extends ProjectComponent implements Condition {
private String spec = null; private String spec = null;


/**
* Set the url attribute
*
* @param url the url of the request
*/
public void setUrl(String url) { public void setUrl(String url) {
spec = url; spec = url;
} }


private int errorsBeginAt = 400; private int errorsBeginAt = 400;


/**
* Set the errorsBeginAt attribute
*
* @param errorsBeginAt number at which errors begin at, default is
* 400
*/
public void setErrorsBeginAt(int errorsBeginAt) { public void setErrorsBeginAt(int errorsBeginAt) {
this.errorsBeginAt = errorsBeginAt; this.errorsBeginAt = errorsBeginAt;
} }


/**
* @return true if the HTTP request succeeds
* @exception BuildException if an error occurs
*/
public boolean eval() throws BuildException { public boolean eval() throws BuildException {
if (spec == null) { if (spec == null) {
throw new BuildException("No url specified in http condition"); throw new BuildException("No url specified in http condition");


+ 4
- 3
src/main/org/apache/tools/ant/taskdefs/condition/IsFalse.java View File

@@ -1,7 +1,7 @@
/* /*
* The Apache Software License, Version 1.1 * 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. * reserved.
* *
* Redistribution and use in source and binary forms, with or without * 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 * set the value to be tested; let ant eval it to true/false
* @param value the value to test
*/ */
public void setValue(boolean value) { 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 * @throws BuildException if someone forgot to spec a value
*/ */
public boolean eval() throws BuildException { public boolean eval() throws BuildException {


+ 16
- 1
src/main/org/apache/tools/ant/taskdefs/condition/IsReference.java View File

@@ -1,7 +1,7 @@
/* /*
* The Apache Software License, Version 1.1 * 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. * reserved.
* *
* Redistribution and use in source and binary forms, with or without * 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 Reference ref;
private String type; private String type;


/**
* Set the refid attribute.
*
* @param r a Reference value
*/
public void setRefid(Reference r) { public void setRefid(Reference r) {
ref = r; ref = r;
} }


/**
* Set the type attribute. This is optional attribute.
*
* @param type an ant component type name
*/
public void setType(String type) { public void setType(String type) {
this.type = 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 { public boolean eval() throws BuildException {
if (ref == null) { if (ref == null) {
throw new BuildException("No reference specified for isreference " throw new BuildException("No reference specified for isreference "


+ 10
- 1
src/main/org/apache/tools/ant/taskdefs/condition/IsSet.java View File

@@ -1,7 +1,7 @@
/* /*
* The Apache Software License, Version 1.1 * 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. * reserved.
* *
* Redistribution and use in source and binary forms, with or without * 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 { public class IsSet extends ProjectComponent implements Condition {
private String property; private String property;


/**
* Set the property attribute
*
* @param p the property name
*/
public void setProperty(String p) { public void setProperty(String p) {
property = p; property = p;
} }


/**
* @return true if the property exists
* @exception BuildException if the property attribute is not set
*/
public boolean eval() throws BuildException { public boolean eval() throws BuildException {
if (property == null) { if (property == null) {
throw new BuildException("No property specified for isset " throw new BuildException("No property specified for isset "


+ 4
- 3
src/main/org/apache/tools/ant/taskdefs/condition/IsTrue.java View File

@@ -1,7 +1,7 @@
/* /*
* The Apache Software License, Version 1.1 * 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. * reserved.
* *
* Redistribution and use in source and binary forms, with or without * 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 * set the value to be tested; let ant eval it to true/false
* @param value the value to test
*/ */
public void setValue(boolean value) { 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 * @throws BuildException if someone forgot to spec a value
*/ */
public boolean eval() throws BuildException { public boolean eval() throws BuildException {


+ 5
- 1
src/main/org/apache/tools/ant/taskdefs/condition/Or.java View File

@@ -1,7 +1,7 @@
/* /*
* The Apache Software License, Version 1.1 * 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. * reserved.
* *
* Redistribution and use in source and binary forms, with or without * 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 { 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 { public boolean eval() throws BuildException {
Enumeration enum = getConditions(); Enumeration enum = getConditions();
while (enum.hasMoreElements()) { while (enum.hasMoreElements()) {


+ 42
- 25
src/main/org/apache/tools/ant/taskdefs/condition/Os.java View File

@@ -66,22 +66,32 @@ import org.apache.tools.ant.BuildException;
* @version $Revision$ * @version $Revision$
*/ */
public class Os implements Condition { public class Os implements Condition {
private static final String osName =
private static final String OS_NAME =
System.getProperty("os.name").toLowerCase(Locale.US); 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); 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); 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 family;
private String name; private String name;
private String version; private String version;
private String arch; private String arch;


/**
* Default constructor
*
*/
public Os() { public Os() {
} }


/**
* Constructor that sets the family attribute
*
* @param family a String value
*/
public Os(String family) { public Os(String family) {
setFamily(family); setFamily(family);
} }
@@ -147,7 +157,8 @@ public class Os implements Condition {
/** /**
* Determines if the OS on which Ant is executing matches the * Determines if the OS on which Ant is executing matches the
* given OS family. * given OS family.
*
* @param family the family to check for
* @return true if the OS matches
* @since 1.5 * @since 1.5
*/ */
public static boolean isFamily(String family) { 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 * Determines if the OS on which Ant is executing matches the
* given OS name. * given OS name.
* *
* @param name the OS name to check for
* @return true if the OS matches
* @since 1.7 * @since 1.7
*/ */
public static boolean isName(String name) { 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 * Determines if the OS on which Ant is executing matches the
* given OS architecture. * given OS architecture.
* *
* @param arch the OS architecture to check for
* @return true if the OS matches
* @since 1.7 * @since 1.7
*/ */
public static boolean isArch(String arch) { 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 * Determines if the OS on which Ant is executing matches the
* given OS version. * given OS version.
* *
* @param version the OS version to check for
* @return true if the OS matches
* @since 1.7 * @since 1.7
*/ */
public static boolean isVersion(String version) { public static boolean isVersion(String version) {
@@ -192,7 +209,7 @@ public class Os implements Condition {
* @param name The OS name * @param name The OS name
* @param arch The OS architecture * @param arch The OS architecture
* @param version The OS version * @param version The OS version
*
* @return true if the OS matches
* @since 1.7 * @since 1.7
*/ */
public static boolean isOs(String family, String name, String arch, public static boolean isOs(String family, String name, String arch,
@@ -209,34 +226,34 @@ public class Os implements Condition {


if (family != null) { if (family != null) {
if (family.equals("windows")) { if (family.equals("windows")) {
isFamily = osName.indexOf("windows") > -1;
isFamily = OS_NAME.indexOf("windows") > -1;
} else if (family.equals("os/2")) { } else if (family.equals("os/2")) {
isFamily = osName.indexOf("os/2") > -1;
isFamily = OS_NAME.indexOf("os/2") > -1;
} else if (family.equals("netware")) { } else if (family.equals("netware")) {
isFamily = osName.indexOf("netware") > -1;
isFamily = OS_NAME.indexOf("netware") > -1;
} else if (family.equals("dos")) { } else if (family.equals("dos")) {
isFamily = pathSep.equals(";") && !isFamily("netware");
isFamily = PATH_SEP.equals(";") && !isFamily("netware");
} else if (family.equals("mac")) { } else if (family.equals("mac")) {
isFamily = osName.indexOf("mac") > -1;
isFamily = OS_NAME.indexOf("mac") > -1;
} else if (family.equals("tandem")) { } else if (family.equals("tandem")) {
isFamily = osName.indexOf("nonstop_kernel") > -1;
isFamily = OS_NAME.indexOf("nonstop_kernel") > -1;
} else if (family.equals("unix")) { } else if (family.equals("unix")) {
isFamily = pathSep.equals(":")
isFamily = PATH_SEP.equals(":")
&& !isFamily("openvms") && !isFamily("openvms")
&& (!isFamily("mac") || osName.endsWith("x"));
&& (!isFamily("mac") || OS_NAME.endsWith("x"));
} else if (family.equals("win9x")) { } else if (family.equals("win9x")) {
isFamily = isFamily("windows") 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")) { } 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")) { } else if (family.equals("os/400")) {
isFamily = osName.indexOf("os/400") > -1;
isFamily = OS_NAME.indexOf("os/400") > -1;
} else if (family.equals("openvms")) { } else if (family.equals("openvms")) {
isFamily = osName.indexOf("openvms") > -1;
isFamily = OS_NAME.indexOf("openvms") > -1;
} else { } else {
throw new BuildException( throw new BuildException(
"Don\'t know how to detect os family \"" "Don\'t know how to detect os family \""
@@ -244,13 +261,13 @@ public class Os implements Condition {
} }
} }
if (name != null) { if (name != null) {
isName = name.equals(osName);
isName = name.equals(OS_NAME);
} }
if (arch != null) { if (arch != null) {
isArch = arch.equals(osArch);
isArch = arch.equals(OS_ARCH);
} }
if (version != null) { if (version != null) {
isVersion = version.equals(osVersion);
isVersion = version.equals(OS_VERSION);
} }
retValue = isFamily && isName && isArch && isVersion; retValue = isFamily && isName && isArch && isVersion;
} }


+ 16
- 2
src/main/org/apache/tools/ant/taskdefs/condition/Socket.java View File

@@ -1,7 +1,7 @@
/* /*
* The Apache Software License, Version 1.1 * 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. * reserved.
* *
* Redistribution and use in source and binary forms, with or without * 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; 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. * server - the name of the server.
* port - the port number of the socket. * port - the port number of the socket.
* *
@@ -71,14 +71,28 @@ public class Socket extends ProjectComponent implements Condition {
private String server = null; private String server = null;
private int port = 0; private int port = 0;


/**
* Set the server attribute
*
* @param server the server name
*/
public void setServer(String server) { public void setServer(String server) {
this.server = server; this.server = server;
} }


/**
* Set the port attribute
*
* @param port the port number of the socket
*/
public void setPort(int port) { public void setPort(int port) {
this.port = 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 { public boolean eval() throws BuildException {
if (server == null) { if (server == null) {
throw new BuildException("No server specified in socket " throw new BuildException("No server specified in socket "


Loading…
Cancel
Save