Browse Source

Adding some @since tags.

cleanups.

Make sure <uptodate> honors property immutability rules.

Remove redundant Enumeration class from ConditionBase
(IntrospectionHelper will have taken care of it now).


git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@272364 13f79535-47bb-0310-9956-ffa450edef68
master
Stefan Bodewig 23 years ago
parent
commit
9fb2961443
22 changed files with 73 additions and 60 deletions
  1. +2
    -0
      src/main/org/apache/tools/ant/taskdefs/Ant.java
  2. +2
    -0
      src/main/org/apache/tools/ant/taskdefs/AntStructure.java
  3. +2
    -0
      src/main/org/apache/tools/ant/taskdefs/Available.java
  4. +2
    -0
      src/main/org/apache/tools/ant/taskdefs/CallTarget.java
  5. +2
    -0
      src/main/org/apache/tools/ant/taskdefs/Chmod.java
  6. +2
    -0
      src/main/org/apache/tools/ant/taskdefs/ConditionTask.java
  7. +3
    -1
      src/main/org/apache/tools/ant/taskdefs/ExecuteOn.java
  8. +2
    -0
      src/main/org/apache/tools/ant/taskdefs/GUnzip.java
  9. +2
    -0
      src/main/org/apache/tools/ant/taskdefs/GZip.java
  10. +0
    -2
      src/main/org/apache/tools/ant/taskdefs/Transform.java
  11. +15
    -8
      src/main/org/apache/tools/ant/taskdefs/UpToDate.java
  12. +2
    -1
      src/main/org/apache/tools/ant/taskdefs/condition/And.java
  13. +2
    -28
      src/main/org/apache/tools/ant/taskdefs/condition/ConditionBase.java
  14. +2
    -1
      src/main/org/apache/tools/ant/taskdefs/condition/Contains.java
  15. +3
    -1
      src/main/org/apache/tools/ant/taskdefs/condition/Equals.java
  16. +6
    -4
      src/main/org/apache/tools/ant/taskdefs/condition/FilesMatch.java
  17. +6
    -4
      src/main/org/apache/tools/ant/taskdefs/condition/Http.java
  18. +4
    -2
      src/main/org/apache/tools/ant/taskdefs/condition/IsSet.java
  19. +2
    -1
      src/main/org/apache/tools/ant/taskdefs/condition/Not.java
  20. +2
    -1
      src/main/org/apache/tools/ant/taskdefs/condition/Or.java
  21. +1
    -0
      src/main/org/apache/tools/ant/taskdefs/condition/Os.java
  22. +9
    -6
      src/main/org/apache/tools/ant/taskdefs/condition/Socket.java

+ 2
- 0
src/main/org/apache/tools/ant/taskdefs/Ant.java View File

@@ -90,6 +90,8 @@ import java.util.Enumeration;
*
* @author costin@dnt.ro
*
* @since Ant 1.1
*
* @ant.task category="control"
*/
public class Ant extends Task {


+ 2
- 0
src/main/org/apache/tools/ant/taskdefs/AntStructure.java View File

@@ -79,6 +79,8 @@ import java.io.IOException;
*
* @version $Revision$
*
* @since Ant 1.1
*
* @ant.task category="xml"
*/



+ 2
- 0
src/main/org/apache/tools/ant/taskdefs/Available.java View File

@@ -73,6 +73,8 @@ import org.apache.tools.ant.util.StringUtils;
* @author Stefano Mazzocchi <a href="mailto:stefano@apache.org">stefano@apache.org</a>
* @author <a href="mailto:umagesh@apache.org">Magesh Umasankar</a>
*
* @since Ant 1.1
*
* @ant.task category="control"
*/
public class Available extends Task implements Condition {


+ 2
- 0
src/main/org/apache/tools/ant/taskdefs/CallTarget.java View File

@@ -79,6 +79,8 @@ import org.apache.tools.ant.BuildException;
*
* @author <a href="mailto:stefan.bodewig@epost.de">Stefan Bodewig</a>
*
* @since Ant 1.2
*
* @ant.task name="antcall" category="control"
*/
public class CallTarget extends Task {


+ 2
- 0
src/main/org/apache/tools/ant/taskdefs/Chmod.java View File

@@ -71,6 +71,8 @@ import org.apache.tools.ant.types.PatternSet;
* @author Mariusz Nowostawski (Marni) <a href="mailto:mnowostawski@infoscience.otago.ac.nz">mnowostawski@infoscience.otago.ac.nz</a>
* @author <a href="mailto:stefan.bodewig@epost.de">Stefan Bodewig</a>
*
* @since Ant 1.1
*
* @ant.task category="filesystem"
*/
public class Chmod extends ExecuteOn {


+ 2
- 0
src/main/org/apache/tools/ant/taskdefs/ConditionTask.java View File

@@ -71,6 +71,8 @@ import org.apache.tools.ant.taskdefs.condition.ConditionBase;
* @author <a href="mailto:stefan.bodewig@epost.de">Stefan Bodewig</a>
* @version $Revision$
*
* @since Ant 1.4
*
* @ant.task category="control"
*/
public class ConditionTask extends ConditionBase {


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

@@ -75,7 +75,9 @@ import java.io.IOException;
* @author <a href="mailto:stefan.bodewig@epost.de">Stefan Bodewig</a>
* @author <a href="mailto:mariusz@rakiura.org">Mariusz Nowostawski</a>
*
* @ant.task name="execon"
* @since Ant 1.2
*
* @ant.task name="apply" category="control"
*/
public class ExecuteOn extends ExecTask {



+ 2
- 0
src/main/org/apache/tools/ant/taskdefs/GUnzip.java View File

@@ -69,6 +69,8 @@ import java.util.zip.GZIPInputStream;
* @author <a href="mailto:stefan.bodewig@epost.de">Stefan Bodewig</a>
* @author <a href="mailto:umagesh@rediffmail.com">Magesh Umasankar</a>
*
* @since Ant 1.1
*
* @ant.task category="packaging"
*/



+ 2
- 0
src/main/org/apache/tools/ant/taskdefs/GZip.java View File

@@ -68,6 +68,8 @@ import java.util.zip.GZIPOutputStream;
* @author Jon S. Stevens <a href="mailto:jon@clearink.com">jon@clearink.com</a>
* @author <a href="mailto:umagesh@rediffmail.com">Magesh Umasankar</a>
*
* @since Ant 1.1
*
* @ant.task category="packaging"
*/



+ 0
- 2
src/main/org/apache/tools/ant/taskdefs/Transform.java View File

@@ -58,7 +58,5 @@ package org.apache.tools.ant.taskdefs;
* Has been merged into ExecuteOn, empty class for backwards compatibility.
*
* @author <a href="mailto:stefan.bodewig@epost.de">Stefan Bodewig</a>
*
* @ant.task name="apply" category="control"
*/
public class Transform extends ExecuteOn {}

+ 15
- 8
src/main/org/apache/tools/ant/taskdefs/UpToDate.java View File

@@ -77,6 +77,8 @@ import java.util.Vector;
* @author Hiroaki Nakamura <a href="mailto:hnakamur@mc.neweb.ne.jp">hnakamur@mc.neweb.ne.jp</a>
* @author <a href="mailto:stefan.bodewig@epost.de">Stefan Bodewig</a>
*
* @since Ant 1.2
*
* @ant.task category="control"
*/

@@ -162,15 +164,19 @@ public class UpToDate extends Task implements Condition {
*/
public boolean eval() {
if (sourceFileSets.size() == 0 && _sourceFile == null) {
throw new BuildException("At least one srcfile or a nested <srcfiles> element must be set.");
throw new BuildException("At least one srcfile or a nested "
+ "<srcfiles> element must be set.");
}

if (sourceFileSets.size() > 0 && _sourceFile != null) {
throw new BuildException("Cannot specify both the srcfile attribute and a nested <srcfiles> element.");
throw new BuildException("Cannot specify both the srcfile "
+ "attribute and a nested <srcfiles> "
+ "element.");
}

if (_targetFile == null && mapperElement == null) {
throw new BuildException("The targetfile attribute or a nested mapper element must be set.");
throw new BuildException("The targetfile attribute or a nested "
+ "mapper element must be set.");
}

// if the target file is not there, then it can't be up-to-date
@@ -180,8 +186,9 @@ public class UpToDate extends Task implements Condition {

// if the source file isn't there, throw an exception
if (_sourceFile != null && !_sourceFile.exists()) {
throw new BuildException(_sourceFile.getAbsolutePath() + " not found.");
}
throw new BuildException(_sourceFile.getAbsolutePath()
+ " not found.");
}

Enumeration enum = sourceFileSets.elements();
boolean upToDate = true;
@@ -216,10 +223,10 @@ public class UpToDate extends Task implements Condition {
public void execute() throws BuildException {
boolean upToDate = eval();
if (upToDate) {
this.project.setProperty(_property, this.getValue());
this.project.setNewProperty(_property, getValue());
if (mapperElement == null) {
log("File \"" + _targetFile.getAbsolutePath() + "\" is up-to-date.",
Project.MSG_VERBOSE);
log("File \"" + _targetFile.getAbsolutePath()
+ "\" is up-to-date.", Project.MSG_VERBOSE);
} else {
log("All target files are up-to-date.",
Project.MSG_VERBOSE);


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

@@ -1,7 +1,7 @@
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 2001 The Apache Software Foundation. All rights
* Copyright (c) 2001-2002 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -65,6 +65,7 @@ import org.apache.tools.ant.BuildException;
* evaluates to false.</p>
*
* @author <a href="mailto:stefan.bodewig@epost.de">Stefan Bodewig</a>
* @since Ant 1.4
* @version $Revision$
*/
public class And extends ConditionBase implements Condition {


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

@@ -70,6 +70,7 @@ import org.apache.tools.ant.taskdefs.UpToDate;
* and the "container" conditions are in sync.
*
* @author <a href="mailto:stefan.bodewig@epost.de">Stefan Bodewig</a>
* @since Ant 1.4
* @version $Revision$
*/
public abstract class ConditionBase extends ProjectComponent {
@@ -88,7 +89,7 @@ public abstract class ConditionBase extends ProjectComponent {
* @since 1.1
*/
protected final Enumeration getConditions() {
return new ConditionEnumeration();
return conditions.elements();
}

/**
@@ -182,31 +183,4 @@ public abstract class ConditionBase extends ProjectComponent {
*/
public void addContains(Contains test) {conditions.addElement(test);}
/**
* Inner class that configures those conditions with a project
* instance that need it.
*
* @since 1.1
*/
private class ConditionEnumeration implements Enumeration {
private int currentElement = 0;

public boolean hasMoreElements() {
return countConditions() > currentElement;
}

public Object nextElement() throws NoSuchElementException {
Object o = null;
try {
o = conditions.elementAt(currentElement++);
} catch (ArrayIndexOutOfBoundsException e) {
throw new NoSuchElementException();
}
if (o instanceof ProjectComponent) {
((ProjectComponent) o).setProject(getProject());
}
return o;
}
}
}

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

@@ -101,7 +101,8 @@ public class Contains implements Condition {
*/
public boolean eval() throws BuildException {
if (string == null || subString == null) {
throw new BuildException("both string and substring are required in contains");
throw new BuildException("both string and substring are required "
+ "in contains");
}

return caseSensitive


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

@@ -60,6 +60,7 @@ import org.apache.tools.ant.BuildException;
* Simple String comparison condition.
*
* @author <a href="mailto:stefan.bodewig@epost.de">Stefan Bodewig</a>
* @since Ant 1.4
* @version $Revision$
*/
public class Equals implements Condition {
@@ -96,7 +97,8 @@ public class Equals implements Condition {

public boolean eval() throws BuildException {
if (arg1 == null || arg2 == null) {
throw new BuildException("both arg1 and arg2 are required in equals");
throw new BuildException("both arg1 and arg2 are required in "
+ "equals");
}

if (trim) {


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

@@ -59,8 +59,8 @@ import java.io.File;
import java.io.IOException;

/**
* Compares two files for bitwise equality based on size and content. Timestamps
* are not looked at at all.
* Compares two files for bitwise equality based on size and
* content. Timestamps are not looked at at all.
*
* @author Steve Loughran
* @version $Revision$
@@ -109,7 +109,8 @@ public class FilesMatch implements Condition {

//validate
if (file1 == null || file2 == null) {
throw new BuildException("both file1 and file2 are required in filesmatch");
throw new BuildException("both file1 and file2 are required in "
+ "filesmatch");
}

//#now match the files
@@ -117,7 +118,8 @@ public class FilesMatch implements Condition {
try {
matches=fu.contentEquals(file1, file2);
} catch(IOException ioe) {
throw new BuildException("when comparing files", ioe);
throw new BuildException("when comparing files: "+ioe.getMessage(),
ioe);
}
return matches;
}


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

@@ -1,7 +1,7 @@
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 2001 The Apache Software Foundation. All rights
* Copyright (c) 2001-2002 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -69,9 +69,10 @@ import java.net.URL;
* url - the URL of the request.
*
* @author <a href="mailto:denis@network365.com">Denis Hennessy</a>
* @since Ant 1.5
*/
public class Http extends ProjectComponent implements Condition {
String spec = null;
private String spec = null;

public void setUrl(String url) {
spec = url;
@@ -79,7 +80,7 @@ public class Http extends ProjectComponent implements Condition {

public boolean eval() throws BuildException {
if (spec == null) {
throw new BuildException("No url specified in HTTP task");
throw new BuildException("No url specified in http condition");
}
log("Checking for " + spec, Project.MSG_VERBOSE);
try {
@@ -89,7 +90,8 @@ public class Http extends ProjectComponent implements Condition {
if (conn instanceof HttpURLConnection) {
HttpURLConnection http = (HttpURLConnection) conn;
int code = http.getResponseCode();
log("Result code for " + spec + " was " + code, Project.MSG_VERBOSE);
log("Result code for " + spec + " was " + code,
Project.MSG_VERBOSE);
if (code > 0 && code < 500) {
return true;
} else {


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

@@ -1,7 +1,7 @@
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 2001 The Apache Software Foundation. All rights
* Copyright (c) 2001-2002 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -61,6 +61,7 @@ import org.apache.tools.ant.ProjectComponent;
* Condition that tests whether a given property has been set.
*
* @author <a href="mailto:stefan.bodewig@epost.de">Stefan Bodewig</a>
* @since Ant 1.5
* @version $Revision$
*/
public class IsSet extends ProjectComponent implements Condition {
@@ -70,7 +71,8 @@ public class IsSet extends ProjectComponent implements Condition {

public boolean eval() throws BuildException {
if (property == null) {
throw new BuildException("No property specified for isset condition");
throw new BuildException("No property specified for isset "
+ "condition");
}
return getProject().getProperty(property) != null;


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

@@ -1,7 +1,7 @@
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 2001 The Apache Software Foundation. All rights
* Copyright (c) 2001-2002 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -63,6 +63,7 @@ import org.apache.tools.ant.BuildException;
* and vice versa.
*
* @author <a href="mailto:stefan.bodewig@epost.de">Stefan Bodewig</a>
* @since Ant 1.4
* @version $Revision$
*/
public class Not extends ConditionBase implements Condition {


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

@@ -1,7 +1,7 @@
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 2001 The Apache Software Foundation. All rights
* Copyright (c) 2001-2002 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -65,6 +65,7 @@ import org.apache.tools.ant.BuildException;
* evaluates to true.</p>
*
* @author <a href="mailto:stefan.bodewig@epost.de">Stefan Bodewig</a>
* @since Ant 1.4
* @version $Revision$
*/
public class Or extends ConditionBase implements Condition {


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

@@ -63,6 +63,7 @@ import java.util.Locale;
*
* @author <a href="mailto:stefan.bodewig@epost.de">Stefan Bodewig</a>
* @author <a href="mailto:umagesh@apache.org">Magesh Umasankar</a>
* @since Ant 1.4
* @version $Revision$
*/
public class Os implements Condition {


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

@@ -1,7 +1,7 @@
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 2001 The Apache Software Foundation. All rights
* Copyright (c) 2001-2002 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -66,10 +66,11 @@ import java.io.IOException;
* port - the port number of the socket.
*
* @author <a href="mailto:denis@network365.com">Denis Hennessy</a>
* @since Ant 1.5
*/
public class Socket extends ProjectComponent implements Condition {
String server = null;
int port = 0;
private String server = null;
private int port = 0;

public void setServer(String server) {
this.server = server;
@@ -81,12 +82,14 @@ public class Socket extends ProjectComponent implements Condition {

public boolean eval() throws BuildException {
if (server == null) {
throw new BuildException("No server specified in Socket task");
throw new BuildException("No server specified in socket "
+ "condition");
}
if (port == 0) {
throw new BuildException("No port specified in Socket task");
throw new BuildException("No port specified in socket condition");
}
log("Checking for listener at " + server + ":" + port, Project.MSG_VERBOSE);
log("Checking for listener at " + server + ":" + port,
Project.MSG_VERBOSE);
try {
java.net.Socket socket = new java.net.Socket(server, port);
} catch (IOException e) {


Loading…
Cancel
Save