diff --git a/docs/index.html b/docs/index.html index 7d6efbb15..71cfe2ff0 100644 --- a/docs/index.html +++ b/docs/index.html @@ -3229,7 +3229,7 @@ output. or any other type that has a constructor with a single String argument
  • If your task has enumerated attributes, you should consider using - a subclass of org.apache.tools.ant.EnumeratedAttribute as argument + a subclass of org.apache.tools.ant.types.EnumeratedAttribute as argument to your setter method. See org.apache.tools.ant.taskdefs.FixCRLF for an example.
  • If the task should support character data, write a public void diff --git a/src/main/org/apache/tools/ant/EnumeratedAttribute.java b/src/main/org/apache/tools/ant/EnumeratedAttribute.java index a38a436fa..a7b3826df 100644 --- a/src/main/org/apache/tools/ant/EnumeratedAttribute.java +++ b/src/main/org/apache/tools/ant/EnumeratedAttribute.java @@ -55,58 +55,8 @@ package org.apache.tools.ant; /** - * Helper class for attributes that can only take one of a fixed list - * of values. + * This class has been moved to org.apache.tools.ant.types. * - *

    See {@link org.apache.tools.ant.taskdefs.FixCRLF FixCRLF} for an - * example. - * - * @author Stefan Bodewig stefan.bodewig@megabit.net + * @deprecated This class has been moved to org.apache.tools.ant.types. */ -public abstract class EnumeratedAttribute { - - protected String value; - - /** - * This is the only method a subclass needs to implement. - * - * @return an array holding all possible values of the enumeration. - */ - public abstract String[] getValues(); - - public EnumeratedAttribute() {} - - /** - * Invoked by {@link IntrospectionHelper IntrospectionHelper}. - */ - public final void setValue(String value) throws BuildException { - if (!containsValue(value)) { - throw new BuildException(value+" is not a legal value for this attribute"); - } - this.value = value; - } - - /** - * Is this value included in the enumeration? - */ - public final boolean containsValue(String value) { - String[] values = getValues(); - if (values == null || value == null) { - return false; - } - - for (int i=0; istefan.bodewig@megabit.net + * @author Stefan Bodewig */ public class AntStructure extends Task { diff --git a/src/main/org/apache/tools/ant/taskdefs/FixCRLF.java b/src/main/org/apache/tools/ant/taskdefs/FixCRLF.java index 2f8466756..7092e9cad 100644 --- a/src/main/org/apache/tools/ant/taskdefs/FixCRLF.java +++ b/src/main/org/apache/tools/ant/taskdefs/FixCRLF.java @@ -54,7 +54,11 @@ package org.apache.tools.ant.taskdefs; -import org.apache.tools.ant.*; +import org.apache.tools.ant.BuildException; +import org.apache.tools.ant.DirectoryScanner; +import org.apache.tools.ant.Project; +import org.apache.tools.ant.types.EnumeratedAttribute; + import java.io.*; import java.util.*; import java.text.*; diff --git a/src/main/org/apache/tools/ant/types/EnumeratedAttribute.java b/src/main/org/apache/tools/ant/types/EnumeratedAttribute.java new file mode 100644 index 000000000..f44019452 --- /dev/null +++ b/src/main/org/apache/tools/ant/types/EnumeratedAttribute.java @@ -0,0 +1,114 @@ +/* + * The Apache Software License, Version 1.1 + * + * Copyright (c) 2000 The Apache Software Foundation. All rights + * reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. The end-user documentation included with the redistribution, if + * any, must include the following acknowlegement: + * "This product includes software developed by the + * Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowlegement may appear in the software itself, + * if and wherever such third-party acknowlegements normally appear. + * + * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software + * Foundation" must not be used to endorse or promote products derived + * from this software without prior written permission. For written + * permission, please contact apache@apache.org. + * + * 5. Products derived from this software may not be called "Apache" + * nor may "Apache" appear in their names without prior written + * permission of the Apache Group. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * ==================================================================== + * + * This software consists of voluntary contributions made by many + * individuals on behalf of the Apache Software Foundation. For more + * information on the Apache Software Foundation, please see + * . + */ + +package org.apache.tools.ant.types; + +import org.apache.tools.ant.BuildException; + +/** + * Helper class for attributes that can only take one of a fixed list + * of values. + * + *

    See {@link org.apache.tools.ant.taskdefs.FixCRLF FixCRLF} for an + * example. + * + * @author Stefan Bodewig stefan.bodewig@megabit.net + */ +public abstract class EnumeratedAttribute { + + protected String value; + + /** + * This is the only method a subclass needs to implement. + * + * @return an array holding all possible values of the enumeration. + */ + public abstract String[] getValues(); + + public EnumeratedAttribute() {} + + /** + * Invoked by {@link IntrospectionHelper IntrospectionHelper}. + */ + public final void setValue(String value) throws BuildException { + if (!containsValue(value)) { + throw new BuildException(value+" is not a legal value for this attribute"); + } + this.value = value; + } + + /** + * Is this value included in the enumeration? + */ + public final boolean containsValue(String value) { + String[] values = getValues(); + if (values == null || value == null) { + return false; + } + + for (int i=0; i. + */ + +package org.apache.tools.ant.types; + +import org.apache.tools.ant.Project; +import org.apache.tools.ant.PathTokenizer; + +import java.io.File; +import java.util.Vector; +import java.util.StringTokenizer; +import java.text.CharacterIterator; +import java.text.StringCharacterIterator; + +/** + * This object represents a path as used by CLASSPATH or PATH + * environment variable. + * + * + * <sometask>
    + *   <somepath> + *     <pathelement location="/path/to/file.jar" /> + *     <pathelement path="/path/to/file2.jar:/path/to/class2;/path/to/class3" /> + *     <pathelement location="/path/to/file3.jar" /> + *     <pathelement location="/path/to/file4.jar" /> + *   </somepath> + * </sometask>
    + *
    + * + * The object implemention sometask must provide a method called + * createSomepath which returns an instance of Path. + * Nested path definitions are handled by the Path object and must be labeled + * pathelement.

    + * + * The path element takes a parameter path which will be parsed + * and split into single elements. It will usually be used + * to define a path from an environment variable. + * + * @author Thomas.Haas@softwired-inc.com + * @author Stefan Bodewig + */ + +public class Path { + + private Vector definition; + private Project project; + + public static Path systemClasspath = + new Path(null, System.getProperty("java.class.path")); + + public Path(Project p, String path) { + this(p); + setPath(path); + } + + public Path(Project p) { + this.project = project; + definition = new Vector(); + } + + /** + * Adds a element definition to the path. + * @param location the location of the element to add (must not be + * null nor empty. + */ + public void setLocation(String location) { + if (location != null && location.length() > 0) { + String element = translateFile(resolveFile(project, location)); + if (definition.indexOf(element) == -1) { + definition.addElement(element); + } + } + } + + + /** + * Append the contents of the other Path instance to this. + */ + public void append(Path other) { + String[] l = other.list(); + for (int i=0; i