diff --git a/proposal/sandbox/filterreaders/README b/proposal/sandbox/filterreaders/README
index 90c268b0c..5c1a5bfa4 100644
--- a/proposal/sandbox/filterreaders/README
+++ b/proposal/sandbox/filterreaders/README
@@ -1,3 +1,7 @@
+
+***** Filter Readers is now available in Ant's main development tree *****
+
+
Ant Filter Readers
==================
diff --git a/proposal/sandbox/filterreaders/docs/manual/CoreTasks/loadfile.html b/proposal/sandbox/filterreaders/docs/manual/CoreTasks/loadfile.html
deleted file mode 100644
index 7603b6e17..000000000
--- a/proposal/sandbox/filterreaders/docs/manual/CoreTasks/loadfile.html
+++ /dev/null
@@ -1,97 +0,0 @@
-
-
-LoadFile Task
-
-
-
-
-
-
-Description
-
- Load a text file into a single property. Unless an encoding is specified,
- the encoding of the current locale is used.
-
-
-
-Parameters
-
-
- Attribute |
- Description |
- Required |
-
-
- srcFile |
- source file |
- Yes |
-
-
- property |
- property to save to |
- Yes |
-
-
- encoding |
- encoding to use when loading the file |
- No |
-
-
- failonerror |
- Whether to halt the build on failure |
- No, default "true" |
-
-
-
-The LoadFile task supports nested
-FilterChains.
-
-
Examples
- <loadfile property="message"
- srcFile="message.txt" />
-
-Load file message.txt into property "message"; an <echo>
-can print this.
-
- <loadfile property="encoded-file"
- srcFile="loadfile.xml"
- encoding="ISO-8859-1" />
-
-Load a file using the latin-1 encoding
-
- <loadfile
- property="optional.value"
- srcFile="optional.txt"
- failonerror="false" />
-
-Load a file, don't fail if it is missing (a message is printed, though)
-
- <loadfile
- property="mail.recipients"
- srcFile="recipientlist.txt">
- <filterchain>
- <striplinebreaks/>
- </filterchaint>
- </loadfile>
-
-Load a property which can be used as a parameter for another task (in this case mail),
-merging lines to ensure this happens.
-
- <loadfile
- property="system.configuration.xml"
- srcFile="configuration.xml">
- <expandproperties/>
- </loadfile>
-
-Load an XML file into a property, expanding all properties declared
-in the file in the process.
-
-
-
-
-Copyright © 2001-2002 Apache Software Foundation. All rights
-Reserved.
-
-
-
-
diff --git a/proposal/sandbox/filterreaders/docs/manual/CoreTasks/loadproperties.html b/proposal/sandbox/filterreaders/docs/manual/CoreTasks/loadproperties.html
deleted file mode 100644
index 91d94ad26..000000000
--- a/proposal/sandbox/filterreaders/docs/manual/CoreTasks/loadproperties.html
+++ /dev/null
@@ -1,59 +0,0 @@
-
-
-LoadProperties Task
-
-
-
-
-
-
-Description
-
-Load a file's contents as Ant properties. This is equivalent
-to <property file="..."/> except that it
-supports nested <filterchain> elements and it cannot be
-specified outside a target.
-
-
-
-Parameters
-
-
- Attribute |
- Description |
- Required |
-
-
- srcFile |
- source file |
- Yes |
-
-
-
-The LoadProperties task supports nested
-FilterChains.
-
-
Examples
- <loadproperties srcFile="file.properties" />
-
-Load contents of file.properties as Ant properties.
-
- <loadproperties srcFile="file.properties">
- <filterchain>
- <linecontains>
- <contains value="import."/>
- <linecontains/>
- </filterchaint>
- </loadproperties>
-
-Read the lines that contain the string "import."
-from the file "file.properties" and load them as
-Ant properties.
-
-
-Copyright © 2002 Apache Software Foundation. All rights
-Reserved.
-
-
-
-
diff --git a/proposal/sandbox/filterreaders/docs/manual/CoreTypes/filterchain.html b/proposal/sandbox/filterreaders/docs/manual/CoreTypes/filterchain.html
deleted file mode 100644
index 6bf995fcc..000000000
--- a/proposal/sandbox/filterreaders/docs/manual/CoreTypes/filterchain.html
+++ /dev/null
@@ -1,488 +0,0 @@
-
-
-
-
- FilterChains and FilterReaders
-
-
-
-
-FilterChains and FilterReaders
-Look at Unix pipes - they offer you so much flexibility -
-say you wanted to copy just those lines that contained the
-string blee from the first 10 lines of a file 'foo'
-to a file 'bar' - you would do something like
-
-cat foo|head -n10|grep blee > bar
-
-Ant was not flexible enough. There was no way for the
-<copy> task to do something similar. If you wanted
-the <copy> task to get the first 10 lines, you would have
-had to create special attributes:
-
-<copy file="foo" tofile="bar" head="10" contains="blee"/>
-
-The obvious problem thus surfaced: Ant tasks would not be able
-to accomodate such data transformation attributes as they would
-be endless. The task would also not know in which order these
-attributes were to be interpreted. That is, must the task execute the
-contains attribute first and then the head attribute or vice-versa?
-What Ant tasks needed was a mechanism to allow pluggable filter (data
-tranformer) chains. Ant would provide a few filters for which there
-have been repeated requests. Users with special filtering needs
-would be able to easily write their own and plug them in.
-
-The solution was to refactor data transformation oriented
-tasks to support FilterChains. A FilterChain is a group of
-ordered FilterReaders. Users can define their own FilterReaders
-by just extending the java.io.FilterReader class. Such custom
-FilterReaders can be easily plugged in as nested elements of
-<filterchain> by using <filterreader> elements.
-
-Example:
-
-<copy file="${src.file}" tofile="${dest.file}">
- <filterchain>
- <filterreader classname="your.extension.of.java.io.FilterReader">
- <param name="foo" value="bar"/>
- </filterreader>
- <filterreader classname="another.extension.of.java.io.FilterReader">
- <classpath>
- <pathelement path="${classpath}"/>
- </classpath>
- <param name="blah" value="blee"/>
- <param type="abra" value="cadabra"/>
- </filterreader>
- </filterchain>
-</copy>
-
-
-Ant provides some built-in filter readers. These filter readers
-can also be declared using a syntax similar to the above syntax.
-However, they can be declared using some simpler syntax also.
-Example:
-
-<loadfile srcfile="${src.file}" property="${src.file.head}">
- <filterchain>
- <headfilter lines="15"/>
- </filterchain>
-</loadfile>
-
-is equivalent to:
-
-<loadfile srcfile="${src.file}" property="${src.file.head}">
- <filterchain>
- <filterreader classname="org.apache.tools.ant.filters.HeadFilter">
- <param name="lines" value="15"/>
- </filterreader>
- </filterchain>
-</loadfile>
-
-
-The following built-in tasks support nested <filterchain> elements.
-Copy,
-LoadFile,
-LoadProperties,
-Move
-
-A FilterChain is formed by defining zero or more of the following
-nested elements.
-FilterReader
-ClassConstants
-ExpandProperties
-HeadFilter
-LineContains
-LineContainsRegExp
-PrefixLines
-ReplaceTokens
-StripJavaComments
-StripLineBreaks
-StripLineComments
-TabsToSpaces
-TailFilter
-
-
-
-The filterreader element is the generic way to
-define a filter. User defined filter elements are
-defined in the build file using this. Please note that
-built in filter readers can also be defined using this
-syntax.
-
-A FilterReader element must be supplied with a class name as
-an attribute value. The class resolved by this name must
-extend java.io.FilterReader. If the custom filter reader
-needs to be parameterized, it must implement
-org.apache.tools.type.Parameterizable.
-
-
-
- Attribute |
- Description |
- Required |
-
-
- classname |
- The class name of the filter reader. |
- Yes |
-
-
-
-
-
Nested Elements:
-<filterreader> supports <classpath> and <param>
-as nested elements. Each <param> element may take in the following
-attributes - name, type and value.
-
-The following FilterReaders are supplied with the default
-distribution.
-
-
-
-This filters basic constants defined in a Java Class,
-and outputs them in lines composed of the format name=value
-
-
Example:
-
-This loads the basic constants defined in a Java class as Ant properties.
-
-<loadproperties srcfile="foo.class">
- <filterchain>
- <filterreader classname="org.apache.tools.ant.filters.ClassConstants"/>
- </filterchain>
-</loadproperties>
-
-
-Convenience method:
-
-<loadproperties srcfile="foo.class">
- <filterchain>
- <classconstants/>
- </filterchain>
-</loadproperties>
-
-
-
-
-If the data contains data that represents Ant
-properties (of the form ${...}), that is substituted
-with the property's actual value.
-
-
Example:
-
-This results in the property modifiedmessage holding the value
-"All these moments will be lost in time, like teardrops in the rain"
-
-<echo
- message="All these moments will be lost in time, like teardrops in the ${weather}"
- file="loadfile1.tmp"
- />
-<property name="weather" value="rain" />
-<loadfile property="modifiedmessage" srcFile="loadfile1.tmp">
- <filterchain>
- <filterreader classname="org.apache.tools.ant.filters.ExpandProperties"/>
- </filterchain>
-</loadfile>
-
-
-Convenience method:
-
-<echo
- message="All these moments will be lost in time, like teardrops in the ${weather}"
- file="loadfile1.tmp"
- />
-<property name="weather" value="rain" />
-<loadfile property="modifiedmessage" srcFile="loadfile1.tmp">
- <filterchain>
- <expandproperties/>
- </filterchain>
-</loadfile>
-
-
-
-
-This filter reads the first few lines from the data supplied to it.
-
-
-
- Parameter Name |
- Parameter Value |
- Required |
-
-
- lines |
- Number of lines to be read.
- Defaults to "10" |
- No |
-
-
-
-
Example:
-
-This stores the first 15 lines of the supplied data in the property ${src.file.head}
-
-<loadfile srcfile="${src.file}" property="${src.file.head}">
- <filterchain>
- <filterreader classname="org.apache.tools.ant.filters.HeadFilter">
- <param name="lines" value="15"/>
- </filterreader>
- </filterchain>
-</loadfile>
-
-
-Convenience method:
-
-<loadfile srcfile="${src.file}" property="${src.file.head}">
- <filterchain>
- <headfilter lines="15"/>
- </filterchain>
-</loadfile>
-
-
-
-
-This filter reader replaces all strings that are
-sandwiched between begintoken and endtoken with
-user defined values.
-
-
-
- Parameter Type |
- Parameter Name |
- Parameter Value |
- Required |
-
-
- tokenchar |
- begintoken |
- Character marking the
- beginning of a token. Defaults to @ |
- No |
-
-
- tokenchar |
- endtoken |
- Character marking the
- end of a token. Defaults to @ |
- No |
-
-
- token |
- User defined String. |
- User defined search String |
- Yes |
-
-
-
-
-
Example:
-
-This replaces occurences of the string @DATE@ in the data
-with today's date and stores it in the property ${src.file.replaced}
-
-<tstamp/>
-<loadfile srcfile="${src.file}" property="${src.file.replaced}">
- <filterchain>
- <filterreader classname="org.apache.tools.ant.filters.ReplaceTokens">
- <param type="token" name="DATE" value="${TODAY}"/>
- </filterreader>
- </filterchain>
-</loadfile>
-
-
-Convenience method:
-
-<tstamp/>
-<loadfile srcfile="${src.file}" property="${src.file.replaced}">
- <filterchain>
- <replacetokens>
- <token key="DATE" value="${TODAY}"/>
- </replacetokens>
- </filterchain>
-</loadfile>
-
-
-
-
-This filter reader strips away comments from the data,
-using Java syntax guidelines. This filter does not
-take in any parameters.
-
-
Example:
-
-
-<loadfile srcfile="${java.src.file}" property="${java.src.file.nocomments}">
- <filterchain>
- <filterreader classname="org.apache.tools.ant.filters.StripJavaComments"/>
- </filterchain>
-</loadfile>
-
-
-Convenience method:
-
-<loadfile srcfile="${java.src.file}" property="${java.src.file.nocomments}">
- <filterchain>
- <stripjavacomments/>
- </filterchain>
-</loadfile>
-
-
-
-
-This filter reader strips away specific characters
-from the data supplied to it.
-
-
-
- Parameter Name |
- Parameter Value |
- Required |
-
-
- linebreaks |
- Characters that are to
- be stripped out. Defaults to "\r\n" |
- No |
-
-
-
-
Examples:
-
-This strips the '\r' and '\n' characters.
-
-<loadfile srcfile="${src.file}" property="${src.file.contents}">
- <filterchain>
- <filterreader classname="org.apache.tools.ant.filters.StripLineBreaks"/>
- </filterchain>
-</loadfile>
-
-
-Convenience method:
-
-<loadfile srcfile="${src.file}" property="${src.file.contents}">
- <filterchain>
- <striplinebreaks/>
- </filterchain>
-</loadfile>
-
-
-This treats the '(' and ')' characters as line break characters and
-strips them.
-
-<loadfile srcfile="${src.file}" property="${src.file.contents}">
- <filterchain>
- <filterreader classname="org.apache.tools.ant.filters.StripLineBreaks">
- <param name="linebreaks" value="()"/>
- </filterreader>
- </filterchain>
-</loadfile>
-
-
-
-
-This filter replaces tabs with spaces
-
-
-
- Parameter Name |
- Parameter Value |
- Required |
-
-
- lines |
- tablength
- Defaults to "8" |
- No |
-
-
-
-
Examples:
-
-This replaces tabs in ${src.file} with spaces.
-
-<loadfile srcfile="${src.file}" property="${src.file.notab}">
- <filterchain>
- <filterreader classname="org.apache.tools.ant.filters.TabsToSpaces"/>
- </filterchain>
-</loadfile>
-
-
-Convenience method:
-
-<loadfile srcfile="${src.file}" property="${src.file.notab}">
- <filterchain>
- <tabstospaces/>
- </filterchain>
-</loadfile>
-
-
-
-
-This filter reads the last few lines from the data supplied to it.
-
-
-
- Parameter Name |
- Parameter Value |
- Required |
-
-
- lines |
- Number of lines to be read.
- Defaults to "10" |
- No |
-
-
-
-
Examples:
-
-This stores the last 15 lines of the supplied data in the property ${src.file.tail}
-
-<loadfile srcfile="${src.file}" property="${src.file.tail}">
- <filterchain>
- <filterreader classname="org.apache.tools.ant.filters.TailFilter">
- <param name="lines" value="15"/>
- </filterreader>
- </filterchain>
-</loadfile>
-
-
-Convenience method:
-
-<loadfile srcfile="${src.file}" property="${src.file.tail}">
- <filterchain>
- <tailfilter lines="15"/>
- </filterchain>
-</loadfile>
-
-
-
-This stores the last 5 lines of the first 15 lines of the supplied
-data in the property ${src.file.mid}
-
-<loadfile srcfile="${src.file}" property="${src.file.mid}">
- <filterchain>
- <filterreader classname="org.apache.tools.ant.filters.HeadFilter">
- <param name="lines" value="15"/>
- </filterreader>
- <filterreader classname="org.apache.tools.ant.filters.TailFilter">
- <param name="lines" value="5"/>
- </filterreader>
- </filterchain>
-</loadfile>
-
-
-Convenience method:
-
-<loadfile srcfile="${src.file}" property="${src.file.mid}">
- <filterchain>
- <HeadFilter lines="15"/>
- <TailFilter lines="5"/>
- </filterchain>
-</loadfile>
-
-
-
-
-Copyright © 2002 Apache Software Foundation. All rights
-Reserved.
diff --git a/proposal/sandbox/filterreaders/src/etc/testcases/taskdefs/copy.filterset b/proposal/sandbox/filterreaders/src/etc/testcases/taskdefs/copy.filterset
deleted file mode 100644
index 367acbb26..000000000
--- a/proposal/sandbox/filterreaders/src/etc/testcases/taskdefs/copy.filterset
+++ /dev/null
@@ -1 +0,0 @@
-This is the @TITLE@.
\ No newline at end of file
diff --git a/proposal/sandbox/filterreaders/src/etc/testcases/taskdefs/copy.xml b/proposal/sandbox/filterreaders/src/etc/testcases/taskdefs/copy.xml
deleted file mode 100644
index 73014a75a..000000000
--- a/proposal/sandbox/filterreaders/src/etc/testcases/taskdefs/copy.xml
+++ /dev/null
@@ -1,78 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/proposal/sandbox/filterreaders/src/etc/testcases/taskdefs/expected/copy.filterset.filtered b/proposal/sandbox/filterreaders/src/etc/testcases/taskdefs/expected/copy.filterset.filtered
deleted file mode 100644
index ddbcf5d83..000000000
--- a/proposal/sandbox/filterreaders/src/etc/testcases/taskdefs/expected/copy.filterset.filtered
+++ /dev/null
@@ -1 +0,0 @@
-This is the Apache Ant Project.
diff --git a/proposal/sandbox/filterreaders/src/etc/testcases/taskdefs/loadfile.xml b/proposal/sandbox/filterreaders/src/etc/testcases/taskdefs/loadfile.xml
deleted file mode 100644
index b90fad278..000000000
--- a/proposal/sandbox/filterreaders/src/etc/testcases/taskdefs/loadfile.xml
+++ /dev/null
@@ -1,110 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- ${testLoadAFile}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- ${testEvalProps}
-
-
-
- #Line 1
-REM Line 2
---Line 3
-Line 4
-Hello World!
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- ${testOneLine}
-
-
-
-
-
-
-
-
diff --git a/proposal/sandbox/filterreaders/src/etc/testcases/taskdefs/move.xml b/proposal/sandbox/filterreaders/src/etc/testcases/taskdefs/move.xml
deleted file mode 100644
index e40e78516..000000000
--- a/proposal/sandbox/filterreaders/src/etc/testcases/taskdefs/move.xml
+++ /dev/null
@@ -1,30 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/proposal/sandbox/filterreaders/src/main/org/apache/tools/ant/filters/BaseFilterReader.java b/proposal/sandbox/filterreaders/src/main/org/apache/tools/ant/filters/BaseFilterReader.java
deleted file mode 100644
index 5ce041edb..000000000
--- a/proposal/sandbox/filterreaders/src/main/org/apache/tools/ant/filters/BaseFilterReader.java
+++ /dev/null
@@ -1,207 +0,0 @@
-/*
- * The Apache Software License, Version 1.1
- *
- * Copyright (c) 2002 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", "Ant", 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.filters;
-
-import java.io.FilterReader;
-import java.io.IOException;
-import java.io.Reader;
-import java.io.StringReader;
-
-import org.apache.tools.ant.Project;
-import org.apache.tools.ant.util.FileUtils;
-
-/**
- * Base class for core filter readers.
- *
- * @author Magesh Umasankar
- */
-public abstract class BaseFilterReader
- extends FilterReader
-{
- /** Have the parameters passed been interpreted? */
- private boolean initialized = false;
-
- /** The Ant project */
- private Project project = null;
-
- /**
- * This constructor is a dummy constructor and is
- * not meant to be used by any class other than Ant's
- * introspection mechanism. This will close the filter
- * that is created making it useless for further operations.
- */
- public BaseFilterReader() {
- // Dummy constructor to be invoked by Ant's Introspector
- super(new StringReader(new String()));
- try {
- close();
- } catch (IOException ioe) {
- // Ignore
- }
- }
-
- /**
- * Create a new filtered reader.
- *
- * @param in a Reader object providing the underlying stream.
- */
- public BaseFilterReader(final Reader in) {
- super(in);
- }
-
- /**
- * Read characters into a portion of an array. This method will block
- * until some input is available, an I/O error occurs, or the end of the
- * stream is reached.
- *
- * @param cbuf Destination buffer
- * @param off Offset at which to start storing characters
- * @param len Maximum number of characters to read
- *
- * @return The number of characters read, or -1 if the end of the
- * stream has been reached
- *
- * @exception IOException If an I/O error occurs
- */
- public final int read(final char cbuf[], final int off,
- final int len) throws IOException {
- for (int i = 0; i < len; i++) {
- final int ch = read();
- if (ch == -1) {
- if (i == 0) {
- return -1;
- } else {
- return i;
- }
- }
- cbuf[off + i] = (char) ch;
- }
- return len;
- }
-
- /**
- * Skip characters. This method will block until some characters are
- * available, an I/O error occurs, or the end of the stream is reached.
- *
- * @param n The number of characters to skip
- *
- * @return The number of characters actually skipped
- *
- * @exception IllegalArgumentException If n
is negative.
- * @exception IOException If an I/O error occurs
- */
- public final long skip(final long n) throws IOException {
- if (n < 0L) {
- throw new IllegalArgumentException("skip value is negative");
- }
-
- for (long i = 0; i < n; i++) {
- if (read() == -1) {
- return i;
- }
- }
- return n;
- }
-
- /**
- * Set the initialized status.
- */
- protected final void setInitialized(final boolean initialized) {
- this.initialized = initialized;
- }
-
- /**
- * Get the initialized status.
- */
- protected final boolean getInitialized() {
- return initialized;
- }
-
- /**
- * Set the project to work with
- */
- public final void setProject(final Project project) {
- this.project = project;
- }
-
- /**
- * Get the project
- */
- protected final Project getProject() {
- return project;
- }
-
- /**
- * Read till EOL
- */
- protected final String readLine() throws IOException {
- int ch = in.read();
- String line = (ch == -1) ? null : "";
- while (ch != -1) {
- line += (char) ch;
- if (ch == '\n') {
- break;
- }
- ch = in.read();
- }
- return line;
- }
-
- /**
- * Read till EOF
- */
- protected final String readFully() throws IOException {
- return FileUtils.readFully(in, 8192);
- }
-}
diff --git a/proposal/sandbox/filterreaders/src/main/org/apache/tools/ant/filters/BaseParamFilterReader.java b/proposal/sandbox/filterreaders/src/main/org/apache/tools/ant/filters/BaseParamFilterReader.java
deleted file mode 100644
index ff9109c48..000000000
--- a/proposal/sandbox/filterreaders/src/main/org/apache/tools/ant/filters/BaseParamFilterReader.java
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- * The Apache Software License, Version 1.1
- *
- * Copyright (c) 2002 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", "Ant", 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.filters;
-
-import java.io.FilterReader;
-import java.io.IOException;
-import java.io.Reader;
-import java.io.StringReader;
-
-import org.apache.tools.ant.types.Parameter;
-import org.apache.tools.ant.types.Parameterizable;
-
-/**
- * Parameterized Base class for core filter readers.
- *
- * @author Magesh Umasankar
- */
-public abstract class BaseParamFilterReader
- extends BaseFilterReader
- implements Parameterizable
-{
- /** The passed in parameter array. */
- private Parameter[] parameters;
-
- /**
- * This constructor is a dummy constructor and is
- * not meant to be used by any class other than Ant's
- * introspection mechanism. This will close the filter
- * that is created making it useless for further operations.
- */
- public BaseParamFilterReader() {
- super();
- }
-
- /**
- * Create a new filtered reader.
- *
- * @param in a Reader object providing the underlying stream.
- */
- public BaseParamFilterReader(final Reader in) {
- super(in);
- }
-
- /**
- * Set Parameters
- */
- public final void setParameters(final Parameter[] parameters) {
- this.parameters = parameters;
- setInitialized(false);
- }
-
- protected final Parameter[] getParameters() {
- return parameters;
- }
-}
diff --git a/proposal/sandbox/filterreaders/src/main/org/apache/tools/ant/filters/ChainableReader.java b/proposal/sandbox/filterreaders/src/main/org/apache/tools/ant/filters/ChainableReader.java
deleted file mode 100644
index 548d0aaeb..000000000
--- a/proposal/sandbox/filterreaders/src/main/org/apache/tools/ant/filters/ChainableReader.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * The Apache Software License, Version 1.1
- *
- * Copyright (c) 2002 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", "Ant", 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.filters;
-
-import java.io.Reader;
-
-/**
- * Chains readers.
- *
- * @author Magesh Umasankar
- */
-public interface ChainableReader {
- public Reader chain(Reader rdr);
-}
diff --git a/proposal/sandbox/filterreaders/src/main/org/apache/tools/ant/filters/ClassConstants.java b/proposal/sandbox/filterreaders/src/main/org/apache/tools/ant/filters/ClassConstants.java
deleted file mode 100644
index f59c88130..000000000
--- a/proposal/sandbox/filterreaders/src/main/org/apache/tools/ant/filters/ClassConstants.java
+++ /dev/null
@@ -1,187 +0,0 @@
-/*
- * The Apache Software License, Version 1.1
- *
- * Copyright (c) 2002 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", "Ant", 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.filters;
-
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.io.Reader;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-
-import org.apache.tools.ant.Project;
-
-/**
- * Assemble the constants declared in a Java class in
- * key1=value1(line separator)key2=value2
- * format
- *
- * Notes:
- * =====
- * 1. This filter uses the BCEL external toolkit.
- * 2. This assembles only those constants that are not created
- * using the syntax new whatever().
- * 3. This assembles constants declared using the basic datatypes
- * and String only.
- * 4. The access modifiers of the declared constants do not matter.
- *
- * Example:
- * =======
- *
- * <classconstants/>
- *
- * Or:
- *
- * <filterreader classname="org.apache.tools.ant.filters.ClassConstants"/>
- *
- * @author Magesh Umasankar
- */
-public final class ClassConstants
- extends BaseFilterReader
- implements ChainableReader
-{
- /** Data that must be read from, if not null. */
- private String queuedData = null;
-
- /** Helper Class to be invoked via reflection. */
- private String JAVA_CLASS_HELPER =
- "org.apache.tools.ant.filters.util.JavaClassHelper";
-
- /**
- * This constructor is a dummy constructor and is
- * not meant to be used by any class other than Ant's
- * introspection mechanism. This will close the filter
- * that is created making it useless for further operations.
- */
- public ClassConstants() {
- super();
- }
-
- /**
- * Create a new filtered reader.
- *
- * @param in a Reader object providing the underlying stream.
- */
- public ClassConstants(final Reader in) {
- super(in);
- }
-
- /**
- * Read and assemble the constants declared in a class file.
- */
- public final int read() throws IOException {
-
- int ch = -1;
-
- if (queuedData != null && queuedData.length() == 0) {
- queuedData = null;
- }
-
- if (queuedData != null) {
- ch = queuedData.charAt(0);
- queuedData = queuedData.substring(1);
- if (queuedData.length() == 0) {
- queuedData = null;
- }
- } else {
- final String clazz = readFully();
- if (clazz == null) {
- ch = -1;
- } else {
- final byte[] bytes = clazz.getBytes();
- try {
- final Class javaClassHelper =
- Class.forName(JAVA_CLASS_HELPER);
- if (javaClassHelper != null) {
- final Class params[] = {
- byte[].class
- };
- final Method getConstants =
- javaClassHelper.getMethod("getConstants", params);
- final Object[] args = {
- bytes
- };
- // getConstants is a staic method, no need to
- // pass in the object
- final StringBuffer sb = (StringBuffer)
- getConstants.invoke(null, args);
- if (sb.length() > 0) {
- queuedData = sb.toString();
- return read();
- }
- }
- } catch (ClassNotFoundException cnfe) {
- throw new IOException(cnfe.getMessage());
- } catch (NoSuchMethodException nsme) {
- throw new IOException(nsme.getMessage());
- } catch (IllegalAccessException iae) {
- throw new IOException(iae.getMessage());
- } catch (IllegalArgumentException iarge) {
- throw new IOException(iarge.getMessage());
- } catch (InvocationTargetException ite) {
- throw new IOException(ite.getMessage());
- }
- }
- }
- return ch;
- }
-
- /**
- * Create a new ClassConstants using the passed in
- * Reader for instantiation.
- */
- public final Reader chain(final Reader rdr) {
- ClassConstants newFilter = new ClassConstants(rdr);
- return newFilter;
- }
-}
diff --git a/proposal/sandbox/filterreaders/src/main/org/apache/tools/ant/filters/ExpandProperties.java b/proposal/sandbox/filterreaders/src/main/org/apache/tools/ant/filters/ExpandProperties.java
deleted file mode 100644
index 3cf146031..000000000
--- a/proposal/sandbox/filterreaders/src/main/org/apache/tools/ant/filters/ExpandProperties.java
+++ /dev/null
@@ -1,140 +0,0 @@
-/*
- * The Apache Software License, Version 1.1
- *
- * Copyright (c) 2002 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", "Ant", 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.filters;
-
-import java.io.IOException;
-import java.io.Reader;
-
-import org.apache.tools.ant.Project;
-
-/**
- * Expand Ant properties, if any, in the data.
- *
- * Example:
- * =======
- *
- * <expandproperties/>
- *
- * Or:
- *
- * <filterreader classname="org.apache.tools.ant.filters.ExpandProperties"/>
- *
- * @author Magesh Umasankar
- */
-public final class ExpandProperties
- extends BaseFilterReader
- implements ChainableReader
-{
- /** Data that must be read from, if not null. */
- private String queuedData = null;
-
- /**
- * This constructor is a dummy constructor and is
- * not meant to be used by any class other than Ant's
- * introspection mechanism. This will close the filter
- * that is created making it useless for further operations.
- */
- public ExpandProperties() {
- super();
- }
-
- /**
- * Create a new filtered reader.
- *
- * @param in a Reader object providing the underlying stream.
- */
- public ExpandProperties(final Reader in) {
- super(in);
- }
-
- /**
- * Prefix lines with user defined prefix.
- */
- public final int read() throws IOException {
-
- int ch = -1;
-
- if (queuedData != null && queuedData.length() == 0) {
- queuedData = null;
- }
-
- if (queuedData != null) {
- ch = queuedData.charAt(0);
- queuedData = queuedData.substring(1);
- if (queuedData.length() == 0) {
- queuedData = null;
- }
- } else {
- queuedData = readFully();
- if (queuedData == null) {
- ch = -1;
- } else {
- Project project = getProject();
- queuedData = project.replaceProperties(queuedData);
- return read();
- }
- }
- return ch;
- }
-
- /**
- * Create a new PrefixLines using the passed in
- * Reader for instantiation.
- */
- public final Reader chain(final Reader rdr) {
- ExpandProperties newFilter = new ExpandProperties(rdr);
- newFilter.setProject(getProject());
- return newFilter;
- }
-}
diff --git a/proposal/sandbox/filterreaders/src/main/org/apache/tools/ant/filters/HeadFilter.java b/proposal/sandbox/filterreaders/src/main/org/apache/tools/ant/filters/HeadFilter.java
deleted file mode 100644
index f0eb99847..000000000
--- a/proposal/sandbox/filterreaders/src/main/org/apache/tools/ant/filters/HeadFilter.java
+++ /dev/null
@@ -1,171 +0,0 @@
-/*
- * The Apache Software License, Version 1.1
- *
- * Copyright (c) 2002 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", "Ant", 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.filters;
-
-import java.io.IOException;
-import java.io.Reader;
-
-import org.apache.tools.ant.types.Parameter;
-
-/**
- * Read the first n lines (Default is first 10 lines)
- *
- * Example:
- * =======
- *
- * <headfilter lines="3"/>
- *
- * Or:
- *
- * <filterreader classname="org.apache.tools.ant.filters.HeadFilter">
- * <param name="lines" value="3"/>
- * </filterreader>
- *
- * @author Magesh Umasankar
- */
-public final class HeadFilter
- extends BaseParamFilterReader
- implements ChainableReader
-{
- /** Lines key to represent the number of lines to be returned. */
- private static final String LINES_KEY = "lines";
-
- /** Number of lines currently read in. */
- private long linesRead = 0;
-
- /** Default number of lines returned. */
- private long lines = 10;
-
- /**
- * This constructor is a dummy constructor and is
- * not meant to be used by any class other than Ant's
- * introspection mechanism. This will close the filter
- * that is created making it useless for further operations.
- */
- public HeadFilter() {
- super();
- }
-
- /**
- * Create a new filtered reader.
- *
- * @param in a Reader object providing the underlying stream.
- */
- public HeadFilter(final Reader in) {
- super(in);
- }
-
- /**
- * Read the first n lines.
- */
- public final int read() throws IOException {
- if (!getInitialized()) {
- initialize();
- setInitialized(true);
- }
-
- int ch = -1;
-
- if (linesRead < lines) {
-
- ch = in.read();
-
- if (ch == '\n') {
- linesRead++;
- }
- }
-
- return ch;
- }
-
- /**
- * Set number of lines to be returned.
- */
- public final void setLines(final long lines) {
- this.lines = lines;
- }
-
- /**
- * Get number of lines to be returned.
- */
- private final long getLines() {
- return lines;
- }
-
- /**
- * Create a new HeadFilter using the passed in
- * Reader for instantiation.
- */
- public final Reader chain(final Reader rdr) {
- HeadFilter newFilter = new HeadFilter(rdr);
- newFilter.setLines(getLines());
- newFilter.setInitialized(true);
- return newFilter;
- }
-
- /**
- * Scan for the lines parameter.
- */
- private final void initialize() {
- Parameter[] params = getParameters();
- if (params != null) {
- for (int i = 0; i < params.length; i++) {
- if (LINES_KEY.equals(params[i].getName())) {
- lines = new Long(params[i].getValue()).longValue();
- break;
- }
- }
- }
- }
-}
diff --git a/proposal/sandbox/filterreaders/src/main/org/apache/tools/ant/filters/LineContains.java b/proposal/sandbox/filterreaders/src/main/org/apache/tools/ant/filters/LineContains.java
deleted file mode 100644
index 8e9fd6b0d..000000000
--- a/proposal/sandbox/filterreaders/src/main/org/apache/tools/ant/filters/LineContains.java
+++ /dev/null
@@ -1,225 +0,0 @@
-/*
- * The Apache Software License, Version 1.1
- *
- * Copyright (c) 2002 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", "Ant", 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.filters;
-
-import java.io.IOException;
-import java.io.Reader;
-import java.util.Vector;
-
-import org.apache.tools.ant.types.Parameter;
-
-/**
- * Filter Reader to fetch only those lines that contain user specified
- * strings.
- *
- * Example:
- * =======
- *
- * <linecontains>
- * <contains value="foo">
- * <contains value="bar">
- * </linecontains>
- *
- * Or:
- *
- * <filterreader classname="org.apache.tools.ant.filters.LineContains">
- * <param type="contains" value="foo"/>
- * <param type="contains" value="bar"/>
- * </filterreader>
- *
- * This will fetch all those lines that contain foo and bar
- *
- * @author Magesh Umasankar
- */
-public final class LineContains
- extends BaseParamFilterReader
- implements ChainableReader
-{
- /** contains key */
- private static final String CONTAINS_KEY = "contains";
-
- /** Vector that holds the strings that input lines must contain. */
- private Vector contains = new Vector();
-
- /** Currently read in line. */
- private String line = null;
-
- /**
- * This constructor is a dummy constructor and is
- * not meant to be used by any class other than Ant's
- * introspection mechanism. This will close the filter
- * that is created making it useless for further operations.
- */
- public LineContains() {
- super();
- }
-
- /**
- * Create a new filtered reader.
- *
- * @param in a Reader object providing the underlying stream.
- */
- public LineContains(final Reader in) {
- super(in);
- }
-
- /**
- * Choose only those lines that contains
- * user defined values.
- */
- public final int read() throws IOException {
- if (!getInitialized()) {
- initialize();
- setInitialized(true);
- }
-
- int ch = -1;
-
- if (line != null) {
- ch = line.charAt(0);
- if (line.length() == 1) {
- line = null;
- } else {
- line = line.substring(1);
- }
- } else {
- line = readLine();
- if (line == null) {
- ch = -1;
- } else {
- int containsSize = contains.size();
- for (int i = 0; i < containsSize; i++) {
- String containsStr = (String) contains.elementAt(i);
- if (line.indexOf(containsStr) == -1) {
- line = null;
- break;
- }
- }
-
- return read();
- }
- }
-
- return ch;
- }
-
- /**
- * Add a contains element.
- */
- public final void addConfiguredContains(final Contains contains) {
- this.contains.addElement(contains.getValue());
- }
-
- /**
- * Set contains vector.
- */
- private void setContains(final Vector contains) {
- this.contains = contains;
- }
-
- /**
- * Get contains vector.
- */
- private final Vector getContains() {
- return contains;
- }
-
- /**
- * Create a new LineContains using the passed in
- * Reader for instantiation.
- */
- public final Reader chain(final Reader rdr) {
- LineContains newFilter = new LineContains(rdr);
- newFilter.setContains(getContains());
- newFilter.setInitialized(true);
- return newFilter;
- }
-
- /**
- * Parse params to add user defined contains strings.
- */
- private final void initialize() {
- Parameter[] params = getParameters();
- if (params != null) {
- for (int i = 0; i < params.length; i++) {
- if (CONTAINS_KEY.equals(params[i].getType())) {
- contains.addElement(params[i].getValue());
- }
- }
- }
- }
-
- /**
- * Holds a contains element
- */
- public static class Contains {
-
- /** User defined contains string */
- private String value;
-
- /**
- * Set the contains string
- */
- public final void setValue(String contains) {
- value = contains;
- }
-
- /**
- * Get the contains string
- */
- public final String getValue() {
- return value;
- }
- }
-}
diff --git a/proposal/sandbox/filterreaders/src/main/org/apache/tools/ant/filters/LineContainsRegExp.java b/proposal/sandbox/filterreaders/src/main/org/apache/tools/ant/filters/LineContainsRegExp.java
deleted file mode 100644
index 8e2e2e999..000000000
--- a/proposal/sandbox/filterreaders/src/main/org/apache/tools/ant/filters/LineContainsRegExp.java
+++ /dev/null
@@ -1,208 +0,0 @@
-/*
- * The Apache Software License, Version 1.1
- *
- * Copyright (c) 2002 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", "Ant", 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.filters;
-
-import java.io.IOException;
-import java.io.Reader;
-import java.util.Vector;
-
-import org.apache.tools.ant.types.Parameter;
-import org.apache.tools.ant.types.RegularExpression;
-import org.apache.tools.ant.util.regexp.Regexp;
-
-/**
- * Filter Reader to fetch only those lines that contain user specified
- * regular expression matching strings.
- *
- * Example:
- * =======
- *
- * <linecontainsregexp>
- * <regexp pattern="foo*">
- * </linecontainsregexp>
- *
- * Or:
- *
- * <filterreader classname="org.apache.tools.ant.filters.LineContainsRegExp">
- * <param type="regexp" value="foo*"/>
- * </filterreader>
- *
- * This will fetch all those lines that contain the pattern foo
- *
- * @author Magesh Umasankar
- */
-public final class LineContainsRegExp
- extends BaseParamFilterReader
- implements ChainableReader
-{
- /** contains key */
- private static final String REGEXP_KEY = "regexp";
-
- /** Vector that holds the strings that input lines must contain. */
- private Vector regexps = new Vector();
-
- /** Currently read in line. */
- private String line = null;
-
- /**
- * This constructor is a dummy constructor and is
- * not meant to be used by any class other than Ant's
- * introspection mechanism. This will close the filter
- * that is created making it useless for further operations.
- */
- public LineContainsRegExp() {
- super();
- }
-
- /**
- * Create a new filtered reader.
- *
- * @param in a Reader object providing the underlying stream.
- */
- public LineContainsRegExp(final Reader in) {
- super(in);
- }
-
- /**
- * Choose only those lines that contains
- * user defined values.
- */
- public final int read() throws IOException {
- if (!getInitialized()) {
- initialize();
- setInitialized(true);
- }
-
- int ch = -1;
-
- if (line != null) {
- ch = line.charAt(0);
- if (line.length() == 1) {
- line = null;
- } else {
- line = line.substring(1);
- }
- } else {
- line = readLine();
- if (line == null) {
- ch = -1;
- } else {
- final int regexpsSize = regexps.size();
- for (int i = 0; i < regexpsSize; i++) {
- RegularExpression regexp = (RegularExpression)
- regexps.elementAt(i);
- Regexp re = regexp.getRegexp(getProject());
- boolean matches = re.matches(line);
- if (!matches) {
- line = null;
- break;
- }
- }
-
- return read();
- }
- }
-
- return ch;
- }
-
- /**
- * Add a contains element.
- */
- public final void addConfiguredRegexp(final RegularExpression regExp) {
- this.regexps.addElement(regExp);
- }
-
- /**
- * Set regexps vector.
- */
- private void setRegexps(final Vector regexps) {
- this.regexps = regexps;
- }
-
- /**
- * Get regexps vector.
- */
- private final Vector getRegexps() {
- return regexps;
- }
-
- /**
- * Create a new LineContainsRegExp using the passed in
- * Reader for instantiation.
- */
- public final Reader chain(final Reader rdr) {
- LineContainsRegExp newFilter = new LineContainsRegExp(rdr);
- newFilter.setRegexps(getRegexps());
- newFilter.setInitialized(true);
- return newFilter;
- }
-
- /**
- * Parse params to add user defined contains strings.
- */
- private final void initialize() {
- Parameter[] params = getParameters();
- if (params != null) {
- for (int i = 0; i < params.length; i++) {
- if (REGEXP_KEY.equals(params[i].getType())) {
- String pattern = params[i].getValue();
- RegularExpression regexp = new RegularExpression();
- regexp.setPattern(pattern);
- regexps.addElement(regexp);
- }
- }
- }
- }
-}
diff --git a/proposal/sandbox/filterreaders/src/main/org/apache/tools/ant/filters/PrefixLines.java b/proposal/sandbox/filterreaders/src/main/org/apache/tools/ant/filters/PrefixLines.java
deleted file mode 100644
index 6ba85a936..000000000
--- a/proposal/sandbox/filterreaders/src/main/org/apache/tools/ant/filters/PrefixLines.java
+++ /dev/null
@@ -1,183 +0,0 @@
-/*
- * The Apache Software License, Version 1.1
- *
- * Copyright (c) 2002 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", "Ant", 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.filters;
-
-import java.io.IOException;
-import java.io.Reader;
-
-import org.apache.tools.ant.types.Parameter;
-
-/**
- * Attach a prefix to every line
- *
- * Example:
- * =======
- *
- * <prefixlines prefix="Foo"/>
- *
- * Or:
- *
- * <filterreader classname="org.apache.tools.ant.filters.PrefixLines">
- * <param name="prefix" value="Foo"/>
- * </filterreader>
- *
- * @author Magesh Umasankar
- */
-public final class PrefixLines
- extends BaseParamFilterReader
- implements ChainableReader
-{
- /** prefix key */
- private static final String PREFIX_KEY = "prefix";
-
- /** The prefix to be used. */
- private String prefix = null;
-
- /** Data that must be read from, if not null. */
- private String queuedData = null;
-
- /**
- * This constructor is a dummy constructor and is
- * not meant to be used by any class other than Ant's
- * introspection mechanism. This will close the filter
- * that is created making it useless for further operations.
- */
- public PrefixLines() {
- super();
- }
-
- /**
- * Create a new filtered reader.
- *
- * @param in a Reader object providing the underlying stream.
- */
- public PrefixLines(final Reader in) {
- super(in);
- }
-
- /**
- * Prefix lines with user defined prefix.
- */
- public final int read() throws IOException {
- if (!getInitialized()) {
- initialize();
- setInitialized(true);
- }
-
- int ch = -1;
-
- if (queuedData != null && queuedData.length() == 0) {
- queuedData = null;
- }
-
- if (queuedData != null) {
- ch = queuedData.charAt(0);
- queuedData = queuedData.substring(1);
- if (queuedData.length() == 0) {
- queuedData = null;
- }
- } else {
- queuedData = readLine();
- if (queuedData == null) {
- ch = -1;
- } else {
- if (prefix != null) {
- queuedData = prefix + queuedData;
- }
- return read();
- }
- }
- return ch;
- }
-
- /**
- * Set the prefix
- */
- public final void setPrefix(final String prefix) {
- this.prefix = prefix;
- }
-
- /**
- * Get the prefix
- */
- private final String getPrefix() {
- return prefix;
- }
-
- /**
- * Create a new PrefixLines using the passed in
- * Reader for instantiation.
- */
- public final Reader chain(final Reader rdr) {
- PrefixLines newFilter = new PrefixLines(rdr);
- newFilter.setPrefix(getPrefix());
- newFilter.setInitialized(true);
- return newFilter;
- }
-
- /**
- * Initialize prefix if available from the param element.
- */
- private final void initialize() {
- Parameter[] params = getParameters();
- if (params != null) {
- for (int i = 0; i < params.length; i++) {
- if (PREFIX_KEY.equals(params[i].getName())) {
- prefix = params[i].getValue();
- break;
- }
- }
- }
- }
-}
diff --git a/proposal/sandbox/filterreaders/src/main/org/apache/tools/ant/filters/ReplaceTokens.java b/proposal/sandbox/filterreaders/src/main/org/apache/tools/ant/filters/ReplaceTokens.java
deleted file mode 100644
index fd7ab0a50..000000000
--- a/proposal/sandbox/filterreaders/src/main/org/apache/tools/ant/filters/ReplaceTokens.java
+++ /dev/null
@@ -1,299 +0,0 @@
-/*
- * The Apache Software License, Version 1.1
- *
- * Copyright (c) 2002 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", "Ant", 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.filters;
-
-import java.io.IOException;
-import java.io.Reader;
-import java.util.Hashtable;
-
-import org.apache.tools.ant.types.Parameter;
-
-/**
- * Replace tokens with user supplied values
- *
- * Example Usage:
- * =============
- *
- * <replacetokens begintoken="#" endtoken="#">
- * <token key="DATE" value="${TODAY}"/>
- * </replacetokens>
- *
- * Or:
- *
- * <filterreader classname="org.apache.tools.ant.filters.ReplaceTokens">
- * <param type="tokenchar" name="begintoken" value="#"/>
- * <param type="tokenchar" name="endtoken" value="#"/>
- * <param type="token" name="DATE" value="${TODAY}"/>
- * </filterreader>
- *
- * @author Magesh Umasankar
- */
-public final class ReplaceTokens
- extends BaseParamFilterReader
- implements ChainableReader
-{
- /** Default begin token character. */
- private static final char DEFAULT_BEGIN_TOKEN = '@';
-
- /** Default end token character. */
- private static final char DEFAULT_END_TOKEN = '@';
-
- /** Data that must be read from, if not null. */
- private String queuedData = null;
-
- /** Hashtable to hold the replacee-replacer pairs. */
- private Hashtable hash = new Hashtable();
-
- /** Begin token. */
- private char beginToken = DEFAULT_BEGIN_TOKEN;
-
- /** End token. */
- private char endToken = DEFAULT_END_TOKEN;
-
- /**
- * This constructor is a dummy constructor and is
- * not meant to be used by any class other than Ant's
- * introspection mechanism. This will close the filter
- * that is created making it useless for further operations.
- */
- public ReplaceTokens() {
- super();
- }
-
- /**
- * Create a new filtered reader.
- *
- * @param in a Reader object providing the underlying stream.
- */
- public ReplaceTokens(final Reader in) {
- super(in);
- }
-
- /**
- * Replace tokens with values.
- */
- public final int read() throws IOException {
- if (!getInitialized()) {
- initialize();
- setInitialized(true);
- }
-
- if (queuedData != null && queuedData.length() > 0) {
- final int ch = queuedData.charAt(0);
- if (queuedData.length() > 1) {
- queuedData = queuedData.substring(1);
- } else {
- queuedData = null;
- }
- return ch;
- }
-
- int ch = in.read();
- if (ch == beginToken) {
- final StringBuffer key = new StringBuffer("");
- do {
- ch = in.read();
- if (ch != -1) {
- key.append((char) ch);
- } else {
- break;
- }
- } while (ch != endToken);
-
- if (ch == -1) {
- queuedData = beginToken + key.toString();
- return read();
- } else {
- key.setLength(key.length() - 1);
- final String replaceWith = (String) hash.get(key.toString());
- if (replaceWith != null) {
- queuedData = replaceWith;
- return read();
- } else {
- queuedData = beginToken + key.toString() + endToken;
- return read();
- }
- }
- }
- return ch;
- }
-
- /**
- * Set begin token.
- */
- public final void setBeginToken(final char beginToken) {
- this.beginToken = beginToken;
- }
-
- /**
- * Get begin token.
- */
- private final char getBeginToken() {
- return beginToken;
- }
-
- /**
- * Set end token.
- */
- public final void setEndToken(final char endToken) {
- this.endToken = endToken;
- }
-
- /**
- * Get begin token.
- */
- private final char getEndToken() {
- return endToken;
- }
-
- /**
- * Add a token element.
- */
- public final void addConfiguredToken(final Token token) {
- hash.put(token.getKey(), token.getValue());
- }
-
- /**
- * Set the tokens.
- */
- private void setTokens(final Hashtable hash) {
- this.hash = hash;
- }
-
- /**
- * Get the tokens.
- */
- private final Hashtable getTokens() {
- return hash;
- }
-
- /**
- * Create a new ReplaceTokens using the passed in
- * Reader for instantiation.
- */
- public final Reader chain(final Reader rdr) {
- ReplaceTokens newFilter = new ReplaceTokens(rdr);
- newFilter.setBeginToken(getBeginToken());
- newFilter.setEndToken(getEndToken());
- newFilter.setTokens(getTokens());
- newFilter.setInitialized(true);
- return newFilter;
- }
-
- /**
- * Initialize tokens and load the replacee-replacer hashtable.
- */
- private final void initialize() {
- Parameter[] params = getParameters();
- if (params != null) {
- for (int i = 0; i < params.length; i++) {
- if (params[i] != null) {
- final String type = params[i].getType();
- if ("tokenchar".equals(type)) {
- final String name = params[i].getName();
- if ("begintoken".equals(name)) {
- beginToken = params[i].getValue().charAt(0);
- } else if ("endtoken".equals(name)) {
- endToken = params[i].getValue().charAt(0);
- }
- } else if ("token".equals(type)) {
- final String name = params[i].getName();
- final String value = params[i].getValue();
- hash.put(name, value);
- }
- }
- }
- }
- }
-
- /**
- * Holds a token
- */
- public static class Token {
-
- /** token key */
- private String key;
-
- /** token value */
- private String value;
-
- /**
- * Set the token key
- */
- public final void setKey(String key) {
- this.key = key;
- }
-
- /**
- * Set the token value
- */
- public final void setValue(String value) {
- this.value = value;
- }
-
- /**
- * Get the token key
- */
- public final String getKey() {
- return key;
- }
-
- /**
- * Get the token value
- */
- public final String getValue() {
- return value;
- }
- }
-}
diff --git a/proposal/sandbox/filterreaders/src/main/org/apache/tools/ant/filters/StringInputStream.java b/proposal/sandbox/filterreaders/src/main/org/apache/tools/ant/filters/StringInputStream.java
deleted file mode 100644
index abfc50491..000000000
--- a/proposal/sandbox/filterreaders/src/main/org/apache/tools/ant/filters/StringInputStream.java
+++ /dev/null
@@ -1,115 +0,0 @@
-/*
- * The Apache Software License, Version 1.1
- *
- * Copyright (c) 2002 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", "Ant", 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.filters;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.StringReader;
-
-/**
- * Wrap a String as an InputStream
- *
- * @author Magesh Umasankar
- * @created 20 February 2002
- */
-public class StringInputStream
- extends InputStream
-{
- /** Source string is stored as a StringReader */
- private StringReader in;
-
- /**
- * Compose a stream from a String
- */
- public StringInputStream(String source) {
- in = new StringReader(source);
- }
-
- /**
- * Read from the Stringreader
- */
- public int read() throws IOException {
- return in.read();
- }
-
- /**
- * Close the Stringreader
- */
- public void close() throws IOException {
- in.close();
- }
-
- /**
- * Mark the read limit of the StringReader
- */
- public synchronized void mark(final int limit) {
- try {
- in.mark(limit);
- } catch (IOException ioe) {
- throw new RuntimeException(ioe.getMessage());
- }
- }
-
- /**
- * Resetthe StringReader
- */
- public synchronized void reset() throws IOException {
- in.reset();
- }
-
- public boolean markSupported() {
- return true;
- }
-}
-
diff --git a/proposal/sandbox/filterreaders/src/main/org/apache/tools/ant/filters/StripJavaComments.java b/proposal/sandbox/filterreaders/src/main/org/apache/tools/ant/filters/StripJavaComments.java
deleted file mode 100644
index fb01559b1..000000000
--- a/proposal/sandbox/filterreaders/src/main/org/apache/tools/ant/filters/StripJavaComments.java
+++ /dev/null
@@ -1,150 +0,0 @@
-/*
- * The Apache Software License, Version 1.1
- *
- * Copyright (c) 2002 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", "Ant", 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.filters;
-
-import java.io.IOException;
-import java.io.Reader;
-
-/**
- * This is a java comment and string stripper reader that filters
- * these lexical tokens out for purposes of simple Java parsing.
- * (if you have more complex Java parsing needs, use a real lexer).
- * Since this class heavily relies on the single char read function,
- * you are reccomended to make it work on top of a buffered reader.
- */
-public final class StripJavaComments
- extends BaseFilterReader
- implements ChainableReader
-{
- /**
- * This constructor is a dummy constructor and is
- * not meant to be used by any class other than Ant's
- * introspection mechanism. This will close the filter
- * that is created making it useless for further operations.
- */
- public StripJavaComments() {
- super();
- }
-
- /**
- * Create a new filtered reader.
- *
- * @param in a Reader object providing the underlying stream.
- */
- public StripJavaComments(final Reader in) {
- super(in);
- }
-
- /**
- * Filter out Java Style comments
- */
- public final int read() throws IOException {
- int ch = in.read();
- if (ch == '/') {
- ch = in.read();
- if (ch == '/') {
- while (ch != '\n' && ch != -1) {
- ch = in.read();
- }
- } else if (ch == '*') {
- while (ch != -1) {
- ch = in.read();
- if (ch == '*') {
- ch = in.read();
- while (ch == '*' && ch != -1) {
- ch = in.read();
- }
-
- if (ch == '/') {
- ch = read();
- break;
- }
- }
- }
- }
- }
-
- if (ch == '"') {
- while (ch != -1) {
- ch = in.read();
- if (ch == '\\') {
- ch = in.read();
- } else if (ch == '"') {
- ch = read();
- break;
- }
- }
- }
-
- if (ch == '\'') {
- ch = in.read();
- if (ch == '\\') {
- ch = in.read();
- }
- ch = in.read();
- ch = read();
- }
-
- return ch;
- }
-
- /**
- * Create a new StripJavaComments object using the passed in
- * Reader for instantiation.
- */
- public final Reader chain(final Reader rdr) {
- StripJavaComments newFilter = new StripJavaComments(rdr);
- return newFilter;
- }
-}
diff --git a/proposal/sandbox/filterreaders/src/main/org/apache/tools/ant/filters/StripLineBreaks.java b/proposal/sandbox/filterreaders/src/main/org/apache/tools/ant/filters/StripLineBreaks.java
deleted file mode 100644
index e448bcd31..000000000
--- a/proposal/sandbox/filterreaders/src/main/org/apache/tools/ant/filters/StripLineBreaks.java
+++ /dev/null
@@ -1,176 +0,0 @@
-/*
- * The Apache Software License, Version 1.1
- *
- * Copyright (c) 2002 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", "Ant", 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.filters;
-
-import java.io.IOException;
-import java.io.Reader;
-
-import org.apache.tools.ant.types.Parameter;
-
-/**
- * Filter to flatten the stream to a single line.
- *
- * <striplinebreaks/>
- *
- * Or:
- *
- * <filterreader classname="org.apache.tools.ant.filters.StripLineBreaks"/>
- *
- * @author Steve Loughran
- * @author Magesh Umasankar
- */
-public final class StripLineBreaks
- extends BaseParamFilterReader
- implements ChainableReader
-{
- /**
- * Linebreaks. What do to on funny IBM mainframes with odd line endings?
- */
- private static final String DEFAULT_LINE_BREAKS = "\r\n";
-
- /**
- * Linebreaks key that can be set via param element of
- * AntFilterReader
- */
- private static final String LINE_BREAKS_KEY = "linebreaks";
-
-
- /** Holds the characters that are recognized as line breaks. */
- private String lineBreaks = DEFAULT_LINE_BREAKS;
-
- /**
- * This constructor is a dummy constructor and is
- * not meant to be used by any class other than Ant's
- * introspection mechanism. This will close the filter
- * that is created making it useless for further operations.
- */
- public StripLineBreaks() {
- super();
- }
-
- /**
- * Create a new filtered reader.
- *
- * @param in a Reader object providing the underlying stream.
- */
- public StripLineBreaks(final Reader in) {
- super(in);
- }
-
- /**
- * If the character that is being read in is a
- * line break character, ignore it and move on to the
- * next one.
- */
- public final int read() throws IOException {
- if (!getInitialized()) {
- initialize();
- setInitialized(true);
- }
-
- int ch = in.read();
- while (ch != -1) {
- if (lineBreaks.indexOf(ch) == -1) {
- break;
- } else {
- ch = in.read();
- }
- }
- return ch;
- }
-
- /**
- * Set the line break characters.
- */
- public final void setLineBreaks(final String lineBreaks) {
- this.lineBreaks = lineBreaks;
- }
-
- /**
- * Get the line breaks characters
- */
- private final String getLineBreaks() {
- return lineBreaks;
- }
-
- /**
- * Create a new StripLineBreaks object using the passed in
- * Reader for instantiation.
- */
- public final Reader chain(final Reader rdr) {
- StripLineBreaks newFilter = new StripLineBreaks(rdr);
- newFilter.setLineBreaks(getLineBreaks());
- newFilter.setInitialized(true);
- return newFilter;
- }
-
- /**
- * Line break characters set using the param element.
- */
- private final void initialize() {
- String userDefinedLineBreaks = null;
- Parameter[] params = getParameters();
- if (params != null) {
- for (int i = 0; i < params.length; i++) {
- if (LINE_BREAKS_KEY.equals(params[i].getName())) {
- userDefinedLineBreaks = params[i].getValue();
- break;
- }
- }
- }
- if (userDefinedLineBreaks != null) {
- lineBreaks = userDefinedLineBreaks;
- }
- }
-}
diff --git a/proposal/sandbox/filterreaders/src/main/org/apache/tools/ant/filters/StripLineComments.java b/proposal/sandbox/filterreaders/src/main/org/apache/tools/ant/filters/StripLineComments.java
deleted file mode 100644
index f9521c65b..000000000
--- a/proposal/sandbox/filterreaders/src/main/org/apache/tools/ant/filters/StripLineComments.java
+++ /dev/null
@@ -1,227 +0,0 @@
-/*
- * The Apache Software License, Version 1.1
- *
- * Copyright (c) 2002 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", "Ant", 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.filters;
-
-import java.io.IOException;
-import java.io.Reader;
-import java.util.Vector;
-
-import org.apache.tools.ant.types.Parameter;
-
-/**
- * This is a line comment stripper reader
- *
- * Example:
- * =======
- *
- * <striplinecomments>
- * <comment value="#"/>
- * <comment value="--"/>
- * <comment value="REM "/>
- * <comment value="rem "/>
- * <comment value="//"/>
- * </striplinecomments>
- *
- * Or:
- *
- * <filterreader classname="org.apache.tools.ant.filters.StripLineComments">
- * <param type="comment" value="#"/>
- * <param type="comment" value="--"/>
- * <param type="comment" value="REM "/>
- * <param type="comment" value="rem "/>
- * <param type="comment" value="//"/>
- * </filterreader>
- *
- * @author Magesh Umasankar
- */
-public final class StripLineComments
- extends BaseParamFilterReader
- implements ChainableReader
-{
- /** The type that param recognizes to set the comments. */
- private static final String COMMENTS_KEY = "comment";
-
- /** Vector that holds comments. */
- private Vector comments = new Vector();
-
- /** The line that has been read ahead. */
- private String line = null;
-
- /**
- * This constructor is a dummy constructor and is
- * not meant to be used by any class other than Ant's
- * introspection mechanism. This will close the filter
- * that is created making it useless for further operations.
- */
- public StripLineComments() {
- super();
- }
-
- /**
- * Create a new filtered reader.
- *
- * @param in a Reader object providing the underlying stream.
- */
- public StripLineComments(final Reader in) {
- super(in);
- }
-
- /**
- * Read in line by line; Ignore line if it
- * begins with a comment string.
- */
- public final int read() throws IOException {
- if (!getInitialized()) {
- initialize();
- setInitialized(true);
- }
-
- int ch = -1;
-
- if (line != null) {
- ch = line.charAt(0);
- if (line.length() == 1) {
- line = null;
- } else {
- line = line.substring(1);
- }
- } else {
- line = readLine();
- if (line == null) {
- ch = -1;
- } else {
- int commentsSize = comments.size();
- for (int i = 0; i < commentsSize; i++) {
- String comment = (String) comments.elementAt(i);
- if (line.startsWith(comment)) {
- line = null;
- break;
- }
- }
- return read();
- }
- }
-
- return ch;
- }
-
- /**
- * Add the Comment element.
- */
- public final void addConfiguredComment(final Comment comment) {
- comments.addElement(comment.getValue());
- }
-
- /**
- * Set the comments vector.
- */
- private void setComments(final Vector comments) {
- this.comments = comments;
- }
-
- /**
- * Get the comments vector.
- */
- private final Vector getComments() {
- return comments;
- }
-
- /**
- * Create a new StripLineComments object using the passed in
- * Reader for instantiation.
- */
- public final Reader chain(final Reader rdr) {
- StripLineComments newFilter = new StripLineComments(rdr);
- newFilter.setComments(getComments());
- newFilter.setInitialized(true);
- return newFilter;
- }
-
- /**
- * Comments set using the param element.
- */
- private final void initialize() {
- Parameter[] params = getParameters();
- if (params != null) {
- for (int i = 0; i < params.length; i++) {
- if (COMMENTS_KEY.equals(params[i].getType())) {
- comments.addElement(params[i].getValue());
- }
- }
- }
- }
-
- /**
- * The class that holds a comment.
- */
- public static class Comment {
-
- /** The comment*/
- private String value;
-
- /**
- * Set the comment.
- */
- public final void setValue(String comment) {
- value = comment;
- }
-
- /**
- * Get the comment.
- */
- public final String getValue() {
- return value;
- }
- }
-}
diff --git a/proposal/sandbox/filterreaders/src/main/org/apache/tools/ant/filters/TabsToSpaces.java b/proposal/sandbox/filterreaders/src/main/org/apache/tools/ant/filters/TabsToSpaces.java
deleted file mode 100644
index 8c91aa286..000000000
--- a/proposal/sandbox/filterreaders/src/main/org/apache/tools/ant/filters/TabsToSpaces.java
+++ /dev/null
@@ -1,178 +0,0 @@
-/*
- * The Apache Software License, Version 1.1
- *
- * Copyright (c) 2002 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", "Ant", 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.filters;
-
-import java.io.IOException;
-import java.io.Reader;
-
-import org.apache.tools.ant.types.Parameter;
-
-/**
- * Converts tabs to spaces.
- *
- * Example Usage:
- * =============
- *
- * <tabtospaces tablength="8"/>
- *
- * Or:
- *
- *
- *
- *
- *
- * @author Magesh Umasankar
- */
-public final class TabsToSpaces
- extends BaseParamFilterReader
- implements ChainableReader
-{
- /** The default tab length is 8 */
- private static final int DEFAULT_TAB_LENGTH = 8;
-
- /** The name that param recognizes to set the tablength. */
- private static final String TAB_LENGTH_KEY = "tablength";
-
- /** Default tab length. */
- private int tabLength = DEFAULT_TAB_LENGTH;
-
- /** How many more spaces must be returned to replace a tab? */
- private int spacesRemaining = 0;
-
- /**
- * This constructor is a dummy constructor and is
- * not meant to be used by any class other than Ant's
- * introspection mechanism. This will close the filter
- * that is created making it useless for further operations.
- */
- public TabsToSpaces() {
- super();
- }
-
- /**
- * Create a new filtered reader.
- *
- * @param in a Reader object providing the underlying stream.
- */
- public TabsToSpaces(final Reader in) {
- super(in);
- }
-
- /**
- * Convert tabs with spaces
- */
- public final int read() throws IOException {
- if (!getInitialized()) {
- initialize();
- setInitialized(true);
- }
-
- int ch = -1;
-
- if (spacesRemaining > 0) {
- spacesRemaining--;
- ch = ' ';
- } else {
- ch = in.read();
- if (ch == '\t') {
- spacesRemaining = tabLength - 1;
- ch = ' ';
- }
- }
- return ch;
- }
-
- /**
- * Set the tab length.
- */
- public final void setTablength(final int tabLength) {
- this.tabLength = tabLength;
- }
-
- /**
- * Get the tab length
- */
- private final int getTablength() {
- return tabLength;
- }
-
- /**
- * Create a new TabsToSpaces object using the passed in
- * Reader for instantiation.
- */
- public final Reader chain(final Reader rdr) {
- TabsToSpaces newFilter = new TabsToSpaces(rdr);
- newFilter.setTablength(getTablength());
- newFilter.setInitialized(true);
- return newFilter;
- }
-
- /**
- * Initialize tokens
- */
- private final void initialize() {
- Parameter[] params = getParameters();
- if (params != null) {
- for (int i = 0; i < params.length; i++) {
- if (params[i] != null) {
- if (TAB_LENGTH_KEY.equals(params[i].getName())) {
- tabLength =
- new Integer(params[i].getValue()).intValue();
- break;
- }
- }
- }
- }
- }
-}
diff --git a/proposal/sandbox/filterreaders/src/main/org/apache/tools/ant/filters/TailFilter.java b/proposal/sandbox/filterreaders/src/main/org/apache/tools/ant/filters/TailFilter.java
deleted file mode 100644
index 0f9ccd953..000000000
--- a/proposal/sandbox/filterreaders/src/main/org/apache/tools/ant/filters/TailFilter.java
+++ /dev/null
@@ -1,218 +0,0 @@
-/*
- * The Apache Software License, Version 1.1
- *
- * Copyright (c) 2002 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", "Ant", 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.filters;
-
-import java.io.IOException;
-import java.io.Reader;
-
-import org.apache.tools.ant.types.Parameter;
-
-/**
- * Read the last n lines. Default is last 10 lines.
- *
- * Example:
- * =======
- *
- * <tailfilter lines="3"/>
- *
- * Or:
- *
- * <filterreader classname="org.apache.tools.ant.filters.TailFilter">
- * <param name="lines" value="3"/>
- * </filterreader>
- *
- * @author Magesh Umasankar
- */
-public final class TailFilter
- extends BaseParamFilterReader
- implements ChainableReader
-{
- /** The name that param recognizes to set the number of lines. */
- private static final String LINES_KEY = "lines";
-
- /** Number of lines currently read in. */
- private long linesRead = 0;
-
- /** Default number of lines returned. */
- private long lines = 10;
-
- /** Buffer to hold in characters read ahead. */
- private char[] buffer = new char[4096];
-
- /** The character position that has been returned from the buffer. */
- private int returnedCharPos = -1;
-
- /** Has read ahead been completed? */
- private boolean completedReadAhead = false;
-
- /** Current index position on the buffer. */
- private int bufferPos = 0;
-
- /**
- * This constructor is a dummy constructor and is
- * not meant to be used by any class other than Ant's
- * introspection mechanism. This will close the filter
- * that is created making it useless for further operations.
- */
- public TailFilter() {
- super();
- }
-
- /**
- * Create a new filtered reader.
- *
- * @param in a Reader object providing the underlying stream.
- */
- public TailFilter(final Reader in) {
- super(in);
- }
-
- /**
- * Read ahead and keep in buffer last n lines only at any given
- * point. Grow buffer as needed.
- */
- public final int read() throws IOException {
- if (!getInitialized()) {
- initialize();
- setInitialized(true);
- }
-
- if (!completedReadAhead) {
- int ch = -1;
- while ((ch = in.read()) != -1) {
- if (buffer.length == bufferPos) {
- if (returnedCharPos != -1) {
- final char[] tmpBuffer = new char[buffer.length];
- System.arraycopy(buffer, returnedCharPos + 1, tmpBuffer,
- 0, buffer.length - (returnedCharPos + 1));
- buffer = tmpBuffer;
- bufferPos = bufferPos - (returnedCharPos + 1);
- returnedCharPos = -1;
- } else {
- final char[] tmpBuffer = new char[buffer.length * 2];
- System.arraycopy(buffer, 0, tmpBuffer, 0, bufferPos);
- buffer = tmpBuffer;
- }
- }
-
- if (ch == '\n' || ch == -1) {
- ++linesRead;
-
- if (linesRead == lines) {
- int i = 0;
- for (i = returnedCharPos + 1;
- buffer[i] != 0 && buffer[i] != '\n'; i++) {
- }
- returnedCharPos = i;
- --linesRead;
- }
- }
- if (ch == -1) {
- break;
- }
-
- buffer[bufferPos] = (char) ch;
- bufferPos++;
- }
- completedReadAhead = true;
- }
-
- ++returnedCharPos;
- if (returnedCharPos >= bufferPos) {
- return -1;
- } else {
- return buffer[returnedCharPos];
- }
- }
-
- /**
- * Set number of lines to be returned.
- */
- public final void setLines(final long lines) {
- this.lines = lines;
- }
-
- /**
- * Get number of lines to be returned.
- */
- private final long getLines() {
- return lines;
- }
-
- /**
- * Create a new TailFilter using the passed in
- * Reader for instantiation.
- */
- public final Reader chain(final Reader rdr) {
- TailFilter newFilter = new TailFilter(rdr);
- newFilter.setLines(getLines());
- newFilter.setInitialized(true);
- return newFilter;
- }
-
- /**
- * Scan for the lines parameter.
- */
- private final void initialize() {
- Parameter[] params = getParameters();
- if (params != null) {
- for (int i = 0; i < params.length; i++) {
- if (LINES_KEY.equals(params[i].getName())) {
- setLines(new Long(params[i].getValue()).longValue());
- break;
- }
- }
- }
- }
-}
diff --git a/proposal/sandbox/filterreaders/src/main/org/apache/tools/ant/filters/util/ChainReaderHelper.java b/proposal/sandbox/filterreaders/src/main/org/apache/tools/ant/filters/util/ChainReaderHelper.java
deleted file mode 100644
index 384ba17b6..000000000
--- a/proposal/sandbox/filterreaders/src/main/org/apache/tools/ant/filters/util/ChainReaderHelper.java
+++ /dev/null
@@ -1,234 +0,0 @@
-/*
- * The Apache Software License, Version 1.1
- *
- * Copyright (c) 2002 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", "Ant", 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.filters.util;
-
-import org.apache.tools.ant.AntClassLoader;
-import org.apache.tools.ant.BuildException;
-import org.apache.tools.ant.Project;
-import org.apache.tools.ant.filters.BaseFilterReader;
-import org.apache.tools.ant.filters.ChainableReader;
-import org.apache.tools.ant.types.AntFilterReader;
-import org.apache.tools.ant.types.FilterChain;
-import org.apache.tools.ant.types.Path;
-import org.apache.tools.ant.types.Parameter;
-import org.apache.tools.ant.types.Parameterizable;
-import org.apache.tools.ant.util.FileUtils;
-
-import java.io.*;
-import java.lang.reflect.Constructor;
-import java.lang.reflect.InvocationTargetException;
-import java.util.Vector;
-
-/**
- * Process a FilterReader chain.
- *
- * @author Magesh Umasankar
- * @created 23 February 2002
- */
-public final class ChainReaderHelper {
-
- /**
- * The primary reader to which the reader chain is to be attached.
- */
- public Reader primaryReader;
-
- /**
- * The size of the buffer to be used.
- */
- public int bufferSize = 8192;
-
- /**
- * Chain of filters
- */
- public Vector filterChains = new Vector();
-
- /** The Ant project */
- private Project project = null;
-
- /**
- * Sets the primary reader
- */
- public final void setPrimaryReader(Reader rdr) {
- primaryReader = rdr;
- }
-
- /**
- * Set the project to work with
- */
- public final void setProject(final Project project) {
- this.project = project;
- }
-
- /**
- * Get the project
- */
- public final Project getProject() {
- return project;
- }
-
- /**
- * Sets the buffer size to be used. Defaults to 4096,
- * if this method is not invoked.
- */
- public final void setBufferSize(int size) {
- bufferSize = size;
- }
-
- /**
- * Sets the collection of filter reader sets
- */
- public final void setFilterChains(Vector fchain) {
- filterChains = fchain;
- }
-
- /**
- * Assemble the reader
- */
- public final Reader getAssembledReader() throws BuildException {
- if (primaryReader == null) {
- throw new BuildException("primaryReader must not be null.");
- }
-
- Reader instream = primaryReader;
- final int filterReadersCount = filterChains.size();
- final Vector finalFilters = new Vector();
-
- for (int i = 0; i < filterReadersCount; i++) {
- final FilterChain filterchain =
- (FilterChain) filterChains.elementAt(i);
- final Vector filterReaders = filterchain.getFilterReaders();
- final int readerCount = filterReaders.size();
- for (int j = 0; j < readerCount; j++) {
- finalFilters.addElement(filterReaders.elementAt(j));
- }
- }
-
- final int filtersCount = finalFilters.size();
-
- if (filtersCount > 0) {
- for (int i = 0; i < filtersCount; i++) {
- Object o = finalFilters.elementAt(i);
-
- if (o instanceof AntFilterReader) {
- final AntFilterReader filter = (AntFilterReader) finalFilters.elementAt(i);
- final String className = filter.getClassName();
- final Path classpath = filter.getClasspath();
- final Project project = filter.getProject();
- if (className != null) {
- try {
- Class clazz = null;
- if (classpath == null) {
- clazz = Class.forName(className);
- } else {
- AntClassLoader al = new AntClassLoader(project,
- classpath);
- clazz = al.loadClass(className);
- AntClassLoader.initializeClass(clazz);
- }
- if (clazz != null) {
- if (!FilterReader.class.isAssignableFrom(clazz)) {
- throw new BuildException(className +
- " does not extend java.io.FilterReader");
- }
- final Constructor[] constructors =
- clazz.getConstructors();
- int j = 0;
- for (; j < constructors.length; j++) {
- Class[] types = constructors[j]
- .getParameterTypes();
- if (types.length == 1 &&
- types[0].isAssignableFrom(Reader.class)) {
- break;
- }
- }
- final Reader[] rdr = {instream};
- instream =
- (Reader) constructors[j].newInstance(rdr);
- if (Parameterizable.class.isAssignableFrom(clazz)) {
- final Parameter[] params = filter.getParams();
- ((Parameterizable)
- instream).setParameters(params);
- }
- }
- } catch (final ClassNotFoundException cnfe) {
- throw new BuildException(cnfe);
- } catch (final InstantiationException ie) {
- throw new BuildException(ie);
- } catch (final IllegalAccessException iae) {
- throw new BuildException(iae);
- } catch (final InvocationTargetException ite) {
- throw new BuildException(ite);
- }
- }
- } else if (o instanceof ChainableReader &&
- o instanceof Reader) {
- if (project != null && o instanceof BaseFilterReader) {
- ((BaseFilterReader) o).setProject(project);
- }
- instream = ((ChainableReader) o).chain(instream);
- }
- }
- }
- return instream;
- }
-
- /**
- * Read data from the reader and return the
- * contents as a string.
- */
- public final String readFully(Reader rdr)
- throws IOException {
- return FileUtils.readFully(rdr, bufferSize);
- }
-}
diff --git a/proposal/sandbox/filterreaders/src/main/org/apache/tools/ant/filters/util/JavaClassHelper.java b/proposal/sandbox/filterreaders/src/main/org/apache/tools/ant/filters/util/JavaClassHelper.java
deleted file mode 100644
index 809a407a0..000000000
--- a/proposal/sandbox/filterreaders/src/main/org/apache/tools/ant/filters/util/JavaClassHelper.java
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
- * The Apache Software License, Version 1.1
- *
- * Copyright (c) 2002 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", "Ant", 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.filters.util;
-
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-
-import org.apache.bcel.classfile.ClassParser;
-import org.apache.bcel.classfile.ConstantValue;
-import org.apache.bcel.classfile.Field;
-import org.apache.bcel.classfile.JavaClass;
-
-/**
- * Helper class that filters constants from a Java Class
- *
- * @author Magesh Umasankar
- */
-public final class JavaClassHelper {
-
- /** System specific line separator. */
- private static final String LS = System.getProperty("line.separator");
-
- /**
- * Get the constants declared in a file as name=value
- */
- public static final StringBuffer getConstants(byte[] bytes)
- throws IOException {
- final StringBuffer sb = new StringBuffer();
- final ByteArrayInputStream bis = new ByteArrayInputStream(bytes);
- final ClassParser parser = new ClassParser(bis, "");
- final JavaClass javaClass = parser.parse();
- final Field[] fields = javaClass.getFields();
- for (int i = 0; i < fields.length; i++) {
- final Field field = fields[i];
- if (field != null) {
- final ConstantValue cv = field.getConstantValue();
- if (cv != null) {
- String cvs = cv.toString();
- //Remove start and end quotes if field is a String
- if (cvs.startsWith("\"") && cvs.endsWith("\"")) {
- cvs = cvs.substring(1, cvs.length() - 1);
- }
- sb.append(field.getName());
- sb.append('=');
- sb.append(cvs);
- sb.append(LS);
- }
- }
- }
- return sb;
- }
-}
diff --git a/proposal/sandbox/filterreaders/src/main/org/apache/tools/ant/taskdefs/Copy.java b/proposal/sandbox/filterreaders/src/main/org/apache/tools/ant/taskdefs/Copy.java
deleted file mode 100644
index 0a3baf5f6..000000000
--- a/proposal/sandbox/filterreaders/src/main/org/apache/tools/ant/taskdefs/Copy.java
+++ /dev/null
@@ -1,514 +0,0 @@
-/*
- * The Apache Software License, Version 1.1
- *
- * Copyright (c) 2000-2002 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", "Ant", 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.taskdefs;
-
-import org.apache.tools.ant.Task;
-import org.apache.tools.ant.BuildException;
-import org.apache.tools.ant.Project;
-import org.apache.tools.ant.DirectoryScanner;
-import org.apache.tools.ant.types.FileSet;
-import org.apache.tools.ant.types.Mapper;
-import org.apache.tools.ant.types.FilterChain;
-import org.apache.tools.ant.types.FilterSet;
-import org.apache.tools.ant.types.FilterSetCollection;
-import org.apache.tools.ant.util.FileUtils;
-import org.apache.tools.ant.util.FileNameMapper;
-import org.apache.tools.ant.util.FlatFileNameMapper;
-import org.apache.tools.ant.util.IdentityMapper;
-import org.apache.tools.ant.util.SourceFileScanner;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.Vector;
-import java.util.Hashtable;
-import java.util.Enumeration;
-
-/**
- * A consolidated copy task. Copies a file or directory to a new file
- * or directory. Files are only copied if the source file is newer
- * than the destination file, or when the destination file does not
- * exist. It is possible to explicitly overwrite existing files.
- *
- * This implementation is based on Arnout Kuiper's initial design
- * document, the following mailing list discussions, and the
- * copyfile/copydir tasks.
- *
- * @author Glenn McAllister glennm@ca.ibm.com
- * @author Stefan Bodewig
- * @author Michael McCallum
- * @author Magesh Umasankar
- *
- * @version $Revision$
- *
- * @ant:task category="filesystem"
- */
-public class Copy extends Task {
- protected File file = null; // the source file
- protected File destFile = null; // the destination file
- protected File destDir = null; // the destination directory
- protected Vector filesets = new Vector();
-
- protected boolean filtering = false;
- protected boolean preserveLastModified = false;
- protected boolean forceOverwrite = false;
- protected boolean flatten = false;
- protected int verbosity = Project.MSG_VERBOSE;
- protected boolean includeEmpty = true;
-
- protected Hashtable fileCopyMap = new Hashtable();
- protected Hashtable dirCopyMap = new Hashtable();
- protected Hashtable completeDirMap = new Hashtable();
-
- protected Mapper mapperElement = null;
- private Vector filterChains = new Vector();
- private Vector filterSets = new Vector();
- private FileUtils fileUtils;
- private String encoding = null;
-
- public Copy() {
- fileUtils = FileUtils.newFileUtils();
- }
-
- protected FileUtils getFileUtils() {return fileUtils;}
-
- /**
- * Sets a single source file to copy.
- */
- public void setFile(File file) {
- this.file = file;
- }
-
- /**
- * Sets the destination file.
- */
- public void setTofile(File destFile) {
- this.destFile = destFile;
- }
-
- /**
- * Sets the destination directory.
- */
- public void setTodir(File destDir) {
- this.destDir = destDir;
- }
-
- /**
- * Create a nested filterchain
- */
- public FilterChain createFilterChain() {
- FilterChain filterChain = new FilterChain();
- filterChains.addElement(filterChain);
- return filterChain;
- }
-
- /**
- * Create a nested filterset
- */
- public FilterSet createFilterSet() {
- FilterSet filterSet = new FilterSet();
- filterSets.addElement(filterSet);
- return filterSet;
- }
-
- /**
- * Give the copied files the same last modified time as the original files.
- * @deprecated setPreserveLastModified(String) has been deprecated and
- * replaced with setPreserveLastModified(boolean) to
- * consistently let the Introspection mechanism work.
- */
- public void setPreserveLastModified(String preserve) {
- setPreserveLastModified(Project.toBoolean(preserve));
- }
-
- /**
- * Give the copied files the same last modified time as the original files.
- */
- public void setPreserveLastModified(boolean preserve) {
- preserveLastModified = preserve;
- }
-
- /**
- * Whether to give the copied files the same last modified time as
- * the original files.
- *
- * @since 1.32, Ant 1.5
- */
- public boolean getPreserveLastModified() {
- return preserveLastModified;
- }
-
- /**
- * Get the filtersets being applied to this operation.
- *
- * @return a vector of FilterSet objects
- */
- protected Vector getFilterSets() {
- return filterSets;
- }
-
- /**
- * Get the filterchains being applied to this operation.
- *
- * @return a vector of FilterChain objects
- */
- protected Vector getFilterChains() {
- return filterChains;
- }
-
- /**
- * Sets filtering.
- */
- public void setFiltering(boolean filtering) {
- this.filtering = filtering;
- }
-
- /**
- * Overwrite any existing destination file(s).
- */
- public void setOverwrite(boolean overwrite) {
- this.forceOverwrite = overwrite;
- }
-
- /**
- * When copying directory trees, the files can be "flattened"
- * into a single directory. If there are multiple files with
- * 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.
- */
- public void setFlatten(boolean flatten) {
- this.flatten = flatten;
- }
-
- /**
- * Used to force listing of all names of copied files.
- */
- public void setVerbose(boolean verbose) {
- if (verbose) {
- this.verbosity = Project.MSG_INFO;
- } else {
- this.verbosity = Project.MSG_VERBOSE;
- }
- }
-
- /**
- * Used to copy empty directories.
- */
- public void setIncludeEmptyDirs(boolean includeEmpty) {
- this.includeEmpty = includeEmpty;
- }
-
- /**
- * Adds a set of files (nested fileset attribute).
- */
- public void addFileset(FileSet set) {
- filesets.addElement(set);
- }
-
- /**
- * Defines the FileNameMapper to use (nested mapper element).
- */
- public Mapper createMapper() throws BuildException {
- if (mapperElement != null) {
- throw new BuildException("Cannot define more than one mapper",
- location);
- }
- mapperElement = new Mapper(project);
- return mapperElement;
- }
-
- /**
- * Sets the character encoding
- *
- * @since 1.32, Ant 1.5
- */
- public void setEncoding (String encoding) {
- this.encoding = encoding;
- }
-
- /**
- * @return the character encoding, null
if not set.
- *
- * @since 1.32, Ant 1.5
- */
- public String getEncoding() {
- return encoding;
- }
-
- /**
- * Performs the copy operation.
- */
- public void execute() throws BuildException {
- // make sure we don't have an illegal set of options
- validateAttributes();
-
- // deal with the single file
- if (file != null) {
- if (file.exists()) {
- if (destFile == null) {
- destFile = new File(destDir, file.getName());
- }
-
- if (forceOverwrite ||
- (file.lastModified() > destFile.lastModified())) {
- fileCopyMap.put(file.getAbsolutePath(), destFile.getAbsolutePath());
- } else {
- log(file + " omitted as " + destFile + " is up to date.",
- Project.MSG_VERBOSE);
- }
- } else {
- String message = "Could not find file "
- + file.getAbsolutePath() + " to copy.";
- log(message);
- throw new BuildException(message);
- }
- }
-
- // deal with the filesets
- for (int i=0; i 0) {
- if (filesets.size() > 1) {
- throw new BuildException(
- "Cannot concatenate multiple files into a single file.");
- } else {
- FileSet fs = (FileSet) filesets.elementAt(0);
- DirectoryScanner ds = fs.getDirectoryScanner(project);
- String[] srcFiles = ds.getIncludedFiles();
-
- if (srcFiles.length > 0) {
- if (file == null) {
- file = new File(ds.getBasedir(), srcFiles[0]);
- filesets.removeElementAt(0);
- } else {
- throw new BuildException(
- "Cannot concatenate multiple files into a single file.");
- }
- } else {
- throw new BuildException(
- "Cannot perform operation from directory to file.");
- }
- }
- }
-
- if (destFile != null) {
- destDir = new File(destFile.getParent()); // be 1.1 friendly
- }
-
- }
-
- /**
- * Compares source files to destination files to see if they should be
- * copied.
- */
- protected void scan(File fromDir, File toDir, String[] files, String[] dirs) {
- FileNameMapper mapper = null;
- if (mapperElement != null) {
- mapper = mapperElement.getImplementation();
- } else if (flatten) {
- mapper = new FlatFileNameMapper();
- } else {
- mapper = new IdentityMapper();
- }
-
- buildMap(fromDir, toDir, files, mapper, fileCopyMap);
-
- if (includeEmpty) {
- buildMap(fromDir, toDir, dirs, mapper, dirCopyMap);
- }
- }
-
- protected void buildMap(File fromDir, File toDir, String[] names,
- FileNameMapper mapper, Hashtable map) {
-
- String[] toCopy = null;
- if (forceOverwrite) {
- Vector v = new Vector();
- for (int i=0; i 0) {
- log("Copying " + fileCopyMap.size() +
- " file" + (fileCopyMap.size() == 1 ? "" : "s") +
- " to " + destDir.getAbsolutePath() );
-
- Enumeration e = fileCopyMap.keys();
- while (e.hasMoreElements()) {
- String fromFile = (String) e.nextElement();
- String toFile = (String) fileCopyMap.get(fromFile);
-
- if( fromFile.equals( toFile ) ) {
- log("Skipping self-copy of " + fromFile, verbosity);
- continue;
- }
-
- try {
- log("Copying " + fromFile + " to " + toFile, verbosity);
-
- FilterSetCollection executionFilters = new FilterSetCollection();
- if (filtering) {
- executionFilters.addFilterSet(project.getGlobalFilterSet());
- }
- for (Enumeration filterEnum = filterSets.elements(); filterEnum.hasMoreElements();) {
- executionFilters.addFilterSet((FilterSet)filterEnum.nextElement());
- }
- fileUtils.copyFile(fromFile, toFile, executionFilters, filterChains,
- forceOverwrite, preserveLastModified,
- encoding, project);
- } catch (IOException ioe) {
- String msg = "Failed to copy " + fromFile + " to " + toFile
- + " due to " + ioe.getMessage();
- throw new BuildException(msg, ioe, location);
- }
- }
- }
-
- if (includeEmpty) {
- Enumeration e = dirCopyMap.elements();
- int count = 0;
- while (e.hasMoreElements()) {
- File d = new File((String)e.nextElement());
- if (!d.exists()) {
- if (!d.mkdirs()) {
- log("Unable to create directory " + d.getAbsolutePath(), Project.MSG_ERR);
- } else {
- count++;
- }
- }
- }
-
- if (count > 0) {
- log("Copied " + count +
- " empty director" +
- (count==1?"y":"ies") +
- " to " + destDir.getAbsolutePath());
- }
- }
- }
-
-}
diff --git a/proposal/sandbox/filterreaders/src/main/org/apache/tools/ant/taskdefs/LoadFile.java b/proposal/sandbox/filterreaders/src/main/org/apache/tools/ant/taskdefs/LoadFile.java
deleted file mode 100644
index 60215517d..000000000
--- a/proposal/sandbox/filterreaders/src/main/org/apache/tools/ant/taskdefs/LoadFile.java
+++ /dev/null
@@ -1,228 +0,0 @@
-/*
- * The Apache Software License, Version 1.1
- *
- * Copyright (c) 2001-2002 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", "Ant", 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.taskdefs;
-
-import org.apache.tools.ant.Task;
-import org.apache.tools.ant.Project;
-import org.apache.tools.ant.BuildException;
-import org.apache.tools.ant.types.FilterChain;
-import org.apache.tools.ant.filters.util.ChainReaderHelper;
-
-import java.io.*;
-import java.util.Vector;
-
-/**
- * Load a file into a property
- *
- * @author Steve Loughran
- * @author Magesh Umasankar
- * @created 10 December 2001
- */
-public final class LoadFile extends Task {
-
- /**
- * source file, usually null
- */
- private File srcFile = null;
-
- /**
- * what to do when it goes pear-shaped
- */
- private boolean failOnError = true;
-
- /**
- * Encoding to use for filenames, defaults to the platform's default
- * encoding.
- */
- private String encoding = null;
-
- /**
- * name of property
- */
- private String property = null;
-
- /**
- * Holds FilterChains
- */
- private final Vector filterChains = new Vector();
-
- /**
- * Encoding to use for filenames, defaults to the platform's default
- * encoding.
- *
- * For a list of possible values see
- * http://java.sun.com/products/jdk/1.2/docs/guide/internat/encoding.doc.html
- * .
- *
- * @param encoding The new Encoding value
- */
-
- public final void setEncoding(final String encoding) {
- this.encoding = encoding;
- }
-
-
- /**
- * Sets the Property attribute of the LoadFile object
- *
- * @param property The new Property value
- */
- public final void setProperty(final String property) {
- this.property = property;
- }
-
-
- /**
- * Sets the srcfile attribute.
- *
- * @param srcFile The new SrcFile value
- */
- public final void setSrcFile(final File srcFile) {
- this.srcFile = srcFile;
- }
-
-
- /**
- * Sets the Failonerror attribute of the LoadFile object
- *
- * @param fail The new Failonerror value
- */
- public final void setFailonerror(final boolean fail) {
- failOnError = fail;
- }
-
-
- /**
- * read in a source file to a property
- *
- * @exception BuildException if something goes wrong with the build
- */
- public final void execute()
- throws BuildException {
- //validation
- if (srcFile == null) {
- throw new BuildException("source file not defined");
- }
- if (property == null) {
- throw new BuildException("output property not defined");
- }
- FileInputStream fis = null;
- BufferedInputStream bis = null;
- Reader instream = null;
- log("loading "+srcFile+" into property "+property,Project.MSG_VERBOSE);
- try {
- final long len = srcFile.length();
- log("file size = "+len,Project.MSG_DEBUG);
- //discard most of really big files
- final int size=(int) len;
- //open up the file
- fis = new FileInputStream(srcFile);
- bis = new BufferedInputStream(fis);
- if (encoding == null) {
- instream = new InputStreamReader(bis);
- }
- else {
- instream = new InputStreamReader(bis, encoding);
- }
-
- ChainReaderHelper crh = new ChainReaderHelper();
- crh.setBufferSize(size);
- crh.setPrimaryReader(instream);
- crh.setFilterChains(filterChains);
- crh.setProject(project);
- instream = crh.getAssembledReader();
-
- String text = crh.readFully(instream);
-
- if (text != null) {
- project.setNewProperty(property, text);
- log("loaded " + text.length() + " characters",Project.MSG_VERBOSE);
- log(property+" := "+text,Project.MSG_DEBUG);
- }
-
- } catch (final IOException ioe) {
- final String message = "Unable to load file: " + ioe.toString();
- if (failOnError) {
- throw new BuildException(message, ioe, location);
- }
- else {
- log(message, Project.MSG_ERR);
- }
- } catch (final BuildException be) {
- if (failOnError) {
- throw be;
- }
- else {
- log(be.getMessage(), Project.MSG_ERR);
- }
- } finally {
- try {
- if (fis != null) {
- fis.close();
- }
- } catch (IOException ioex) {
- //ignore
- }
- }
- }
-
- /**
- * Add the FilterChain element.
- */
- public final void addFilterChain(FilterChain filter) {
- filterChains.addElement(filter);
- }
-
-//end class
-}
diff --git a/proposal/sandbox/filterreaders/src/main/org/apache/tools/ant/taskdefs/LoadProperties.java b/proposal/sandbox/filterreaders/src/main/org/apache/tools/ant/taskdefs/LoadProperties.java
deleted file mode 100644
index 9e6982f38..000000000
--- a/proposal/sandbox/filterreaders/src/main/org/apache/tools/ant/taskdefs/LoadProperties.java
+++ /dev/null
@@ -1,180 +0,0 @@
-/*
- * The Apache Software License, Version 1.1
- *
- * Copyright (c) 2002 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", "Ant", 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.taskdefs;
-
-import org.apache.tools.ant.Task;
-import org.apache.tools.ant.Project;
-import org.apache.tools.ant.BuildException;
-import org.apache.tools.ant.types.FilterChain;
-import org.apache.tools.ant.filters.StringInputStream;
-import org.apache.tools.ant.filters.util.ChainReaderHelper;
-
-import java.io.*;
-import java.util.Enumeration;
-import java.util.Properties;
-import java.util.Vector;
-
-/**
- * Load a file's contents as Ant Properties.
- *
- * @author Magesh Umasankar
- * @created 20 February 2002
- */
-public final class LoadProperties extends Task {
-
- /**
- * Source file
- */
- private File srcFile = null;
-
- /**
- * Holds filterchains
- */
- private final Vector filterChains = new Vector();
-
- /**
- * Sets the srcfile attribute.
- *
- * @param srcFile The new SrcFile value
- */
- public final void setSrcFile(final File srcFile) {
- this.srcFile = srcFile;
- }
-
- /**
- * read in a source file's contents and load them up as Ant properties
- *
- * @exception BuildException if something goes wrong with the build
- */
- public final void execute() throws BuildException {
- //validation
- if (srcFile == null) {
- throw new BuildException("Source file not defined.");
- }
-
- if (!srcFile.exists()) {
- throw new BuildException("Source file does not exist.");
- }
-
- if (!srcFile.isFile()) {
- throw new BuildException("Source file is not a file.");
- }
-
- FileInputStream fis = null;
- BufferedInputStream bis = null;
- Reader instream = null;
-
- try {
- final long len = srcFile.length();
- final int size=(int) len;
-
- //open up the file
- fis = new FileInputStream(srcFile);
- bis = new BufferedInputStream(fis);
- instream = new InputStreamReader(bis);
-
- ChainReaderHelper crh = new ChainReaderHelper();
- crh.setBufferSize(size);
- crh.setPrimaryReader(instream);
- crh.setFilterChains(filterChains);
- crh.setProject(project);
- instream = crh.getAssembledReader();
-
- String text = crh.readFully(instream);
-
- if (text != null) {
- if (!text.endsWith("\n")) {
- text = text + "\n";
- }
-
- final StringInputStream sis = new StringInputStream(text);
- final Properties props = new Properties();
- props.load(sis);
- final Enumeration e = props.keys();
- while (e.hasMoreElements()) {
- final String key = (String) e.nextElement();
- final String value = props.getProperty(key);
- if (key != null && value != null
- && value.trim().length() > 0) {
- project.setNewProperty(key, value);
- }
- }
- sis.close();
- }
-
- } catch (final IOException ioe) {
- final String message = "Unable to load file: " + ioe.toString();
- throw new BuildException(message, ioe, location);
- } catch (final BuildException be) {
- throw be;
- } finally {
- try {
- if (fis != null) {
- fis.close();
- }
- } catch (IOException ioex) {
- //ignore
- }
- }
- }
-
- /**
- * Add the FilterChain element.
- */
- public final void addFilterChain(FilterChain filter) {
- filterChains.addElement(filter);
- }
-
-//end class
-}
diff --git a/proposal/sandbox/filterreaders/src/main/org/apache/tools/ant/taskdefs/Move.java b/proposal/sandbox/filterreaders/src/main/org/apache/tools/ant/taskdefs/Move.java
deleted file mode 100644
index 269e4b64b..000000000
--- a/proposal/sandbox/filterreaders/src/main/org/apache/tools/ant/taskdefs/Move.java
+++ /dev/null
@@ -1,312 +0,0 @@
-/*
- * The Apache Software License, Version 1.1
- *
- * Copyright (c) 2000-2002 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", "Ant", 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.taskdefs;
-
-import org.apache.tools.ant.BuildException;
-import org.apache.tools.ant.Project;
-import org.apache.tools.ant.types.FilterSetCollection;
-import org.apache.tools.ant.types.FilterSet;
-import org.apache.tools.ant.types.FileSet;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.Enumeration;
-import java.util.Vector;
-
-/**
- * Moves a file or directory to a new file or directory. By default,
- * the destination is overwriten when existing. When overwrite is
- * turned off, then files are only moved if the source file is
- * newer than the destination file, or when the destination file does
- * not exist.
- *
- * Source files and directories are only deleted when the file or
- * directory has been copied to the destination successfully. Filtering
- * also works.
- *
- * This implementation is based on Arnout Kuiper's initial design
- * document, the following mailing list discussions, and the
- * copyfile/copydir tasks.
- *
- * @author Glenn McAllister glennm@ca.ibm.com
- * @author Magesh Umasankar
- * @version $Revision$
- *
- * @ant:task category="filesystem"
- */
-public class Move extends Copy {
-
- private Vector filterSets = null;
- private Vector filterChains = null;
-
- public Move() {
- super();
- forceOverwrite = true;
- }
-
-//************************************************************************
-// protected and private methods
-//************************************************************************
-
- protected void doFileOperations() {
- filterSets = getFilterSets();
- filterChains = getFilterChains();
-
- //Attempt complete directory renames, if any, first.
- if (completeDirMap.size() > 0) {
- Enumeration e = completeDirMap.keys();
- while (e.hasMoreElements()) {
- File fromDir = (File) e.nextElement();
- File toDir = (File) completeDirMap.get(fromDir);
- try {
- log("Attempting to rename dir: " + fromDir +
- " to " + toDir, verbosity);
- renameFile(fromDir, toDir, filtering, forceOverwrite);
- } catch (IOException ioe) {
- String msg = "Failed to rename dir " + fromDir
- + " to " + toDir
- + " due to " + ioe.getMessage();
- throw new BuildException(msg, ioe, location);
- }
- }
- }
- if (fileCopyMap.size() > 0) { // files to move
- log("Moving " + fileCopyMap.size() + " files to " +
- destDir.getAbsolutePath() );
-
- Enumeration e = fileCopyMap.keys();
- while (e.hasMoreElements()) {
- String fromFile = (String) e.nextElement();
- String toFile = (String) fileCopyMap.get(fromFile);
-
- if( fromFile.equals( toFile ) ) {
- log("Skipping self-move of " + fromFile, verbosity);
- continue;
- }
-
- boolean moved = false;
- File f = new File(fromFile);
-
- if (f.exists()) { //Is this file still available to be moved?
- File d = new File(toFile);
-
- try {
- log("Attempting to rename: " + fromFile +
- " to " + toFile, verbosity);
- moved = renameFile(f, d, filtering, forceOverwrite);
- } catch (IOException ioe) {
- String msg = "Failed to rename " + fromFile
- + " to " + toFile
- + " due to " + ioe.getMessage();
- throw new BuildException(msg, ioe, location);
- }
-
- if (!moved) {
- try {
- log("Moving " + fromFile + " to " + toFile, verbosity);
-
- FilterSetCollection executionFilters = new FilterSetCollection();
- if (filtering) {
- executionFilters.addFilterSet(project.getGlobalFilterSet());
- }
- for (Enumeration filterEnum = getFilterSets().elements(); filterEnum.hasMoreElements();) {
- executionFilters.addFilterSet((FilterSet)filterEnum.nextElement());
- }
- getFileUtils().copyFile(f, d, executionFilters, filterChains,
- forceOverwrite,
- getPreserveLastModified(),
- getEncoding(), project);
-
- f = new File(fromFile);
- if (!f.delete()) {
- throw new BuildException("Unable to delete file "
- + f.getAbsolutePath());
- }
- } catch (IOException ioe) {
- String msg = "Failed to copy " + fromFile + " to "
- + toFile
- + " due to " + ioe.getMessage();
- throw new BuildException(msg, ioe, location);
- }
- }
- }
- }
- }
-
- if (includeEmpty) {
- Enumeration e = dirCopyMap.elements();
- int count = 0;
- while (e.hasMoreElements()) {
- File d = new File((String)e.nextElement());
- if (!d.exists()) {
- if (!d.mkdirs()) {
- log("Unable to create directory " + d.getAbsolutePath(), Project.MSG_ERR);
- } else {
- count++;
- }
- }
- }
-
- if (count > 0) {
- log("Moved " + count + " empty directories to " + destDir.getAbsolutePath());
- }
- }
-
- if (filesets.size() > 0) {
- Enumeration e = filesets.elements();
- while (e.hasMoreElements()) {
- FileSet fs = (FileSet)e.nextElement();
- File dir = fs.getDir(project);
-
- if (okToDelete(dir)) {
- deleteDir(dir);
- }
- }
- }
- }
-
- /**
- * Its only ok to delete a directory tree if there are
- * no files in it.
- */
- protected boolean okToDelete(File d) {
- String[] list = d.list();
- if (list == null) {
- return false;
- } // maybe io error?
-
- for (int i = 0; i < list.length; i++) {
- String s = list[i];
- File f = new File(d, s);
- if (f.isDirectory()) {
- if (!okToDelete(f)) {
- return false;
- }
- } else {
- return false; // found a file
- }
- }
-
- return true;
- }
-
- /**
- * Go and delete the directory tree.
- */
- protected void deleteDir(File d) {
- String[] list = d.list();
- if (list == null) {
- return;
- } // on an io error list() can return null
-
- for (int i = 0; i < list.length; i++) {
- String s = list[i];
- File f = new File(d, s);
- if (f.isDirectory()) {
- deleteDir(f);
- } else {
- throw new BuildException("UNEXPECTED ERROR - The file " + f.getAbsolutePath() + " should not exist!");
- }
- }
- log("Deleting directory " + d.getAbsolutePath(), verbosity);
- if (!d.delete()) {
- throw new BuildException("Unable to delete directory " + d.getAbsolutePath());
- }
- }
-
- /**
- * Attempts to rename a file from a source to a destination.
- * If overwrite is set to true, this method overwrites existing file
- * even if the destination file is newer. Otherwise, the source file is
- * renamed only if the destination file is older than it.
- * 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
- */
- protected boolean renameFile(File sourceFile, File destFile,
- boolean filtering, boolean overwrite)
- throws IOException, BuildException {
-
- boolean renamed = true;
- if ((filterSets != null && filterSets.size() > 0) ||
- (filterChains != null && filterChains.size() > 0)) {
- renamed = false;
- } else {
- if (!filtering) {
- // ensure that parent dir of dest file exists!
- // not using getParentFile method to stay 1.1 compat
- String parentPath = destFile.getParent();
- if (parentPath != null) {
- File parent = new File(parentPath);
- if (!parent.exists()) {
- parent.mkdirs();
- }
- }
-
- if (destFile.exists()) {
- if (!destFile.delete()) {
- throw new BuildException("Unable to remove existing file "
- + destFile);
- }
- }
- renamed = sourceFile.renameTo(destFile);
- } else {
- renamed = false;
- }
- }
- return renamed;
- }
-}
diff --git a/proposal/sandbox/filterreaders/src/main/org/apache/tools/ant/types/AntFilterReader.java b/proposal/sandbox/filterreaders/src/main/org/apache/tools/ant/types/AntFilterReader.java
deleted file mode 100644
index 80f20b648..000000000
--- a/proposal/sandbox/filterreaders/src/main/org/apache/tools/ant/types/AntFilterReader.java
+++ /dev/null
@@ -1,141 +0,0 @@
-/*
- * The Apache Software License, Version 1.1
- *
- * Copyright (c) 2002 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", "Ant", 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 java.io.FilterReader;
-import java.util.Hashtable;
-import java.util.Vector;
-
-import org.apache.tools.ant.BuildException;
-import org.apache.tools.ant.Project;
-
-/**
- * An AntFileReader is a wrapper class that encloses the classname
- * and configuration of a Configurable FilterReader.
- *
- * @author Magesh Umasankar
- */
-public final class AntFilterReader
- extends DataType
- implements Cloneable {
-
- private String className;
-
- private final Vector parameters = new Vector();
-
- private Path classpath;
-
- public final void setClassName(final String className) {
- this.className = className;
- }
-
- public final String getClassName() {
- return className;
- }
-
- public final void addParam(final Parameter param) {
- parameters.addElement(param);
- }
-
- /**
- * Set the classpath to load the FilterReader through (attribute).
- */
- public final void setClasspath(Path classpath) {
- if (isReference()) {
- throw tooManyAttributes();
- }
- if (this.classpath == null) {
- this.classpath = classpath;
- } else {
- this.classpath.append(classpath);
- }
- }
-
- /**
- * Set the classpath to load the FilterReader through (nested element).
- */
- public final Path createClasspath() {
- if (isReference()) {
- throw noChildrenAllowed();
- }
- if (this.classpath == null) {
- this.classpath = new Path(getProject());
- }
- return this.classpath.createPath();
- }
-
- /**
- * Get the classpath
- */
- public final Path getClasspath() {
- return classpath;
- }
-
- /**
- * Set the classpath to load the FilterReader through via
- * reference (attribute).
- */
- public void setClasspathRef(Reference r) {
- if (isReference()) {
- throw tooManyAttributes();
- }
- createClasspath().setRefid(r);
- }
-
- public final Parameter[] getParams() {
- Parameter[] params = new Parameter[parameters.size()];
- parameters.copyInto(params);
- return params;
- }
-}
diff --git a/proposal/sandbox/filterreaders/src/main/org/apache/tools/ant/types/FilterChain.java b/proposal/sandbox/filterreaders/src/main/org/apache/tools/ant/types/FilterChain.java
deleted file mode 100644
index d5a8c6b04..000000000
--- a/proposal/sandbox/filterreaders/src/main/org/apache/tools/ant/types/FilterChain.java
+++ /dev/null
@@ -1,139 +0,0 @@
-/*
- * The Apache Software License, Version 1.1
- *
- * Copyright (c) 2002 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", "Ant", 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 java.util.Vector;
-
-import org.apache.tools.ant.filters.ClassConstants;
-import org.apache.tools.ant.filters.ExpandProperties;
-import org.apache.tools.ant.filters.HeadFilter;
-import org.apache.tools.ant.filters.LineContains;
-import org.apache.tools.ant.filters.LineContainsRegExp;
-import org.apache.tools.ant.filters.PrefixLines;
-import org.apache.tools.ant.filters.ReplaceTokens;
-import org.apache.tools.ant.filters.StripJavaComments;
-import org.apache.tools.ant.filters.StripLineBreaks;
-import org.apache.tools.ant.filters.StripLineComments;
-import org.apache.tools.ant.filters.TabsToSpaces;
-import org.apache.tools.ant.filters.TailFilter;
-
-/**
- * FilterChain may contain a chained set of filter readers.
- *
- * @author Magesh Umasankar
- */
-public final class FilterChain {
-
- private final Vector filterReaders = new Vector();
-
- public final void addFilterReader(final AntFilterReader filterReader) {
- filterReaders.addElement(filterReader);
- }
-
- public final Vector getFilterReaders() {
- return filterReaders;
- }
-
- public final void addClassConstants(final ClassConstants classConstants) {
- filterReaders.addElement(classConstants);
- }
-
- public final void addExpandProperties(final ExpandProperties expandProperties) {
- filterReaders.addElement(expandProperties);
- }
-
- public final void addHeadFilter(final HeadFilter headFilter) {
- filterReaders.addElement(headFilter);
- }
-
- public final void addLineContains(final LineContains lineContains) {
- filterReaders.addElement(lineContains);
- }
-
- public final void addLineContainsRegExp(final LineContainsRegExp
- lineContainsRegExp) {
- filterReaders.addElement(lineContainsRegExp);
- }
-
- public final void addPrefixLines(final PrefixLines prefixLines) {
- filterReaders.addElement(prefixLines);
- }
-
- public final void addReplaceTokens(final ReplaceTokens replaceTokens) {
- filterReaders.addElement(replaceTokens);
- }
-
- public final void addStripJavaComments(final StripJavaComments
- stripJavaComments) {
- filterReaders.addElement(stripJavaComments);
- }
-
- public final void addStripLineBreaks(final StripLineBreaks
- stripLineBreaks) {
- filterReaders.addElement(stripLineBreaks);
- }
-
- public final void addStripLineComments(final StripLineComments
- stripLineComments) {
- filterReaders.addElement(stripLineComments);
- }
-
- public final void addTabsToSpaces(final TabsToSpaces tabsToSpaces) {
- filterReaders.addElement(tabsToSpaces);
- }
-
- public final void addTailFilter(final TailFilter tailFilter) {
- filterReaders.addElement(tailFilter);
- }
-}
diff --git a/proposal/sandbox/filterreaders/src/main/org/apache/tools/ant/types/Parameter.java b/proposal/sandbox/filterreaders/src/main/org/apache/tools/ant/types/Parameter.java
deleted file mode 100644
index 224de23b5..000000000
--- a/proposal/sandbox/filterreaders/src/main/org/apache/tools/ant/types/Parameter.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * The Apache Software License, Version 1.1
- *
- * Copyright (c) 2002 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", "Ant", 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;
-
-/**
- * A parameter is composed of a name, type and value.
- *
- * @author Magesh Umasankar
- */
-public final class Parameter {
- private String name = null;
- private String type = null;
- private String value = null;
-
- public final void setName(final String name) {
- this.name = name;
- }
-
- public final void setType(final String type) {
- this.type = type;
- }
-
- public final void setValue(final String value) {
- this.value = value;
- }
-
- public final String getName() {
- return name;
- }
-
- public final String getType() {
- return type;
- }
-
- public final String getValue() {
- return value;
- }
-}
diff --git a/proposal/sandbox/filterreaders/src/main/org/apache/tools/ant/types/Parameterizable.java b/proposal/sandbox/filterreaders/src/main/org/apache/tools/ant/types/Parameterizable.java
deleted file mode 100644
index 7c4b5e0b5..000000000
--- a/proposal/sandbox/filterreaders/src/main/org/apache/tools/ant/types/Parameterizable.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * The Apache Software License, Version 1.1
- *
- * Copyright (c) 2002 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", "Ant", 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 java.util.Vector;
-
-/**
- * Parameterizable objects take genric key value pairs.
- *
- * @author Magesh Umasankar
- */
-public interface Parameterizable {
- void setParameters(Parameter[] parameters);
-}
diff --git a/proposal/sandbox/filterreaders/src/main/org/apache/tools/ant/util/FileUtils.java b/proposal/sandbox/filterreaders/src/main/org/apache/tools/ant/util/FileUtils.java
deleted file mode 100644
index 9febac2b4..000000000
--- a/proposal/sandbox/filterreaders/src/main/org/apache/tools/ant/util/FileUtils.java
+++ /dev/null
@@ -1,744 +0,0 @@
-/*
- * The Apache Software License, Version 1.1
- *
- * Copyright (c) 2001-2002 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", "Ant", 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.util;
-
-import java.io.BufferedInputStream;
-import java.io.BufferedReader;
-import java.io.BufferedWriter;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.FileReader;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.OutputStreamWriter;
-import java.io.Reader;
-
-import java.lang.reflect.Method;
-import java.text.DecimalFormat;
-import java.util.Random;
-import java.util.Stack;
-import java.util.StringTokenizer;
-import java.util.Vector;
-
-import org.apache.tools.ant.BuildException;
-import org.apache.tools.ant.Project;
-import org.apache.tools.ant.filters.util.ChainReaderHelper;
-import org.apache.tools.ant.types.FilterSetCollection;
-
-/**
- * This class also encapsulates methods which allow Files to be
- * refered to using abstract path names which are translated to native
- * system file paths at runtime as well as copying files or setting
- * there last modification time.
- *
- * @author duncan@x180.com
- * @author Conor MacNeill
- * @author Stefan Bodewig
- * @author Magesh Umasankar
- *
- * @version $Revision$
- */
-
-public class FileUtils {
- private static Random rand = new Random(System.currentTimeMillis());
- private static Object lockReflection = new Object();
- private static java.lang.reflect.Method setLastModified = null;
-
- /**
- * Factory method.
- */
- public static FileUtils newFileUtils() {
- return new FileUtils();
- }
-
- /**
- * Empty constructor.
- */
- protected FileUtils() {}
-
- /**
- * Convienence method to copy a file from a source to a destination.
- * No filtering is performed.
- *
- * @throws IOException
- */
- public void copyFile(String sourceFile, String destFile) throws IOException {
- copyFile(new File(sourceFile), new File(destFile), null, false, false);
- }
-
- /**
- * Convienence method to copy a file from a source to a destination
- * specifying if token filtering must be used.
- *
- * @throws IOException
- */
- public void copyFile(String sourceFile, String destFile, FilterSetCollection filters)
- throws IOException
- {
- copyFile(new File(sourceFile), new File(destFile), filters, false, false);
- }
-
- /**
- * Convienence method to copy a file from a source to a
- * destination specifying if token filtering must be used and if
- * source files may overwrite newer destination files.
- *
- * @throws IOException
- */
- public void copyFile(String sourceFile, String destFile, FilterSetCollection filters,
- boolean overwrite) throws IOException {
- copyFile(new File(sourceFile), new File(destFile), filters,
- overwrite, false);
- }
-
- /**
- * Convienence method to copy a file from a source to a
- * destination specifying if token filtering must be used, if
- * source files may overwrite newer destination files and the
- * last modified time of destFile
file should be made equal
- * to the last modified time of sourceFile
.
- *
- * @throws IOException
- */
- public void copyFile(String sourceFile, String destFile, FilterSetCollection filters,
- boolean overwrite, boolean preserveLastModified)
- throws IOException {
- copyFile(new File(sourceFile), new File(destFile), filters,
- overwrite, preserveLastModified);
- }
-
- /**
- * Convienence method to copy a file from a source to a
- * destination specifying if token filtering must be used, if
- * source files may overwrite newer destination files and the
- * last modified time of destFile
file should be made equal
- * to the last modified time of sourceFile
.
- *
- * @throws IOException
- *
- * @since 1.14, Ant 1.5
- */
- public void copyFile(String sourceFile, String destFile,
- FilterSetCollection filters, boolean overwrite,
- boolean preserveLastModified, String encoding)
- throws IOException {
- copyFile(new File(sourceFile), new File(destFile), filters,
- overwrite, preserveLastModified, encoding);
- }
-
- /**
- * Convienence method to copy a file from a source to a
- * destination specifying if token filtering must be used, if
- * filter chains must be used, if source files may overwrite
- * newer destination files and the last modified time of
- * destFile
file should be made equal
- * to the last modified time of sourceFile
.
- *
- * @throws IOException
- *
- * @since 1.15, Ant 1.5
- */
- public void copyFile(String sourceFile, String destFile,
- FilterSetCollection filters, Vector filterChains,
- boolean overwrite, boolean preserveLastModified,
- String encoding, Project project)
- throws IOException {
- copyFile(new File(sourceFile), new File(destFile), filters,
- filterChains, overwrite, preserveLastModified,
- encoding, project);
- }
-
- /**
- * Convienence method to copy a file from a source to a destination.
- * No filtering is performed.
- *
- * @throws IOException
- */
- public void copyFile(File sourceFile, File destFile) throws IOException {
- copyFile(sourceFile, destFile, null, false, false);
- }
-
- /**
- * Convienence method to copy a file from a source to a destination
- * specifying if token filtering must be used.
- *
- * @throws IOException
- */
- public void copyFile(File sourceFile, File destFile, FilterSetCollection filters)
- throws IOException {
- copyFile(sourceFile, destFile, filters, false, false);
- }
-
- /**
- * Convienence method to copy a file from a source to a
- * destination specifying if token filtering must be used and if
- * source files may overwrite newer destination files.
- *
- * @throws IOException
- */
- public void copyFile(File sourceFile, File destFile, FilterSetCollection filters,
- boolean overwrite) throws IOException {
- copyFile(sourceFile, destFile, filters, overwrite, false);
- }
-
- /**
- * Convienence method to copy a file from a source to a
- * destination specifying if token filtering must be used, if
- * source files may overwrite newer destination files and the
- * last modified time of destFile
file should be made equal
- * to the last modified time of sourceFile
.
- *
- * @throws IOException
- */
- public void copyFile(File sourceFile, File destFile, FilterSetCollection filters,
- boolean overwrite, boolean preserveLastModified)
- throws IOException {
- copyFile(sourceFile, destFile, filters, overwrite,
- preserveLastModified, null);
- }
-
- /**
- * Convienence method to copy a file from a source to a
- * destination specifying if token filtering must be used, if
- * source files may overwrite newer destination files, the last
- * modified time of destFile
file should be made
- * equal to the last modified time of sourceFile
and
- * which character encoding to assume.
- *
- * @throws IOException
- *
- * @since 1.14, Ant 1.5
- */
- public void copyFile(File sourceFile, File destFile,
- FilterSetCollection filters, boolean overwrite,
- boolean preserveLastModified, String encoding)
- throws IOException {
- copyFile(sourceFile, destFile, filters, null, overwrite,
- preserveLastModified, encoding, null);
- }
-
- /**
- * Convienence method to copy a file from a source to a
- * destination specifying if token filtering must be used, if
- * filter chains must be used, if source files may overwrite
- * newer destination files and the last modified time of
- * destFile
file should be made equal
- * to the last modified time of sourceFile
.
- *
- * @throws IOException
- *
- * @since 1.15, Ant 1.5
- */
- public void copyFile(File sourceFile, File destFile,
- FilterSetCollection filters, Vector filterChains,
- boolean overwrite, boolean preserveLastModified,
- String encoding, Project project)
- throws IOException {
-
- if (overwrite || !destFile.exists() ||
- destFile.lastModified() < sourceFile.lastModified()) {
-
- if (destFile.exists() && destFile.isFile()) {
- destFile.delete();
- }
-
- // ensure that parent dir of dest file exists!
- // not using getParentFile method to stay 1.1 compat
- File parent = getParentFile(destFile);
- if (!parent.exists()) {
- parent.mkdirs();
- }
-
- final boolean filterSetsAvailable = (filters != null
- && filters.hasFilters());
- final boolean filterChainsAvailable = (filterChains != null
- && filterChains.size() > 0);
-
- if (filterSetsAvailable || filterChainsAvailable) {
- BufferedReader in = null;
- BufferedWriter out = null;
-
- if (encoding == null) {
- in = new BufferedReader(new FileReader(sourceFile));
- out = new BufferedWriter(new FileWriter(destFile));
- } else {
- in = new BufferedReader(new InputStreamReader(
- new FileInputStream(sourceFile), encoding));
- out = new BufferedWriter(new OutputStreamWriter(
- new FileOutputStream(destFile), encoding));
- }
-
- if (filterChainsAvailable) {
- ChainReaderHelper crh = new ChainReaderHelper();
- crh.setBufferSize(8192);
- crh.setPrimaryReader(in);
- crh.setFilterChains(filterChains);
- crh.setProject(project);
- Reader rdr = crh.getAssembledReader();
- in = new BufferedReader(rdr);
- }
-
- int length;
- String newline = null;
- String line = in.readLine();
- while (line != null) {
- if (line.length() == 0) {
- out.newLine();
- } else {
- if (filterSetsAvailable) {
- newline = filters.replaceTokens(line);
- } else {
- newline = line;
- }
- out.write(newline);
- out.newLine();
- }
- line = in.readLine();
- }
-
- out.close();
- in.close();
- } else {
- FileInputStream in = new FileInputStream(sourceFile);
- FileOutputStream out = new FileOutputStream(destFile);
-
- byte[] buffer = new byte[8 * 1024];
- int count = 0;
- do {
- out.write(buffer, 0, count);
- count = in.read(buffer, 0, buffer.length);
- } while (count != -1);
-
- in.close();
- out.close();
- }
-
- if (preserveLastModified) {
- setFileLastModified(destFile, sourceFile.lastModified());
- }
- }
- }
-
- /**
- * see whether we have a setLastModified method in File and return it.
- */
- protected final Method getSetLastModified() {
- if (Project.getJavaVersion() == Project.JAVA_1_1) {
- return null;
- }
- if (setLastModified == null) {
- synchronized (lockReflection) {
- if (setLastModified == null) {
- try {
- setLastModified =
- java.io.File.class.getMethod("setLastModified",
- new Class[] {Long.TYPE});
- } catch (NoSuchMethodException nse) {
- throw new BuildException("File.setlastModified not in JDK > 1.1?",
- nse);
- }
- }
- }
- }
- return setLastModified;
- }
-
- /**
- * Calls File.setLastModified(long time) in a Java 1.1 compatible way.
- */
- public void setFileLastModified(File file, long time) throws BuildException {
- if (Project.getJavaVersion() == Project.JAVA_1_1) {
- return;
- }
- Long[] times = new Long[1];
- if (time < 0) {
- times[0] = new Long(System.currentTimeMillis());
- } else {
- times[0] = new Long(time);
- }
-
- try {
- getSetLastModified().invoke(file, times);
- } catch (java.lang.reflect.InvocationTargetException ite) {
- Throwable nested = ite.getTargetException();
- throw new BuildException("Exception setting the modification time "
- + "of " + file, nested);
- } catch (Throwable other) {
- throw new BuildException("Exception setting the modification time "
- + "of " + file, other);
- }
- }
-
- /**
- * Interpret the filename as a file relative to the given file -
- * unless the filename already represents an absolute filename.
- *
- * @param file the "reference" file for relative paths. This
- * instance must be an absolute file and must not contain
- * "./" or "../" sequences (same for \ instead
- * of /). If it is null, this call is equivalent to
- * new java.io.File(filename)
.
- *
- * @param filename a file name
- *
- * @return an absolute file that doesn't contain "./" or
- * "../" sequences and uses the correct separator for
- * the current platform.
- */
- public File resolveFile(File file, String filename) {
- filename = filename.replace('/', File.separatorChar)
- .replace('\\', File.separatorChar);
-
- // deal with absolute files
- if (filename.startsWith(File.separator) ||
-
- (filename.length() >= 2 &&
- Character.isLetter(filename.charAt(0)) &&
- filename.charAt(1) == ':')
-
- ) {
- return normalize(filename);
- }
-
- if (file == null) {
- return new File(filename);
- }
-
- File helpFile = new File(file.getAbsolutePath());
- StringTokenizer tok = new StringTokenizer(filename, File.separator);
- while (tok.hasMoreTokens()) {
- String part = tok.nextToken();
- if (part.equals("..")) {
- helpFile = getParentFile(helpFile);
- if (helpFile == null) {
- String msg = "The file or path you specified ("
- + filename + ") is invalid relative to "
- + file.getPath();
- throw new BuildException(msg);
- }
- } else if (part.equals(".")) {
- // Do nothing here
- } else {
- helpFile = new File(helpFile, part);
- }
- }
-
- return new File(helpFile.getAbsolutePath());
- }
-
- /**
- * "normalize" the given absolute path.
- *
- * This includes:
- *
- * - Uppercase the drive letter if there is one.
- * - Remove redundant slashes after the drive spec.
- * - resolve all ./, .\, ../ and ..\ sequences.
- * - DOS style paths that start with a drive letter will have
- * \ as the separator.
- *
- *
- * @throws java.lang.NullPointerException if the file path is
- * equal to null.
- */
- public File normalize(String path) {
- String orig = path;
-
- path = path.replace('/', File.separatorChar)
- .replace('\\', File.separatorChar);
-
- // make sure we are dealing with an absolute path
- if (!path.startsWith(File.separator) &&
- ! (path.length() >= 2 &&
- Character.isLetter(path.charAt(0)) &&
- path.charAt(1) == ':')
- ) {
- String msg = path + " is not an absolute path";
- throw new BuildException(msg);
- }
-
- boolean dosWithDrive = false;
- String root = null;
- // Eliminate consecutive slashes after the drive spec
- if (path.length() >= 2 &&
- Character.isLetter(path.charAt(0)) &&
- path.charAt(1) == ':') {
-
- dosWithDrive = true;
-
- char[] ca = path.replace('/', '\\').toCharArray();
- StringBuffer sb = new StringBuffer();
- sb.append(Character.toUpperCase(ca[0])).append(':');
-
- for (int i = 2; i < ca.length; i++) {
- if ((ca[i] != '\\') ||
- (ca[i] == '\\' && ca[i - 1] != '\\')
- ) {
- sb.append(ca[i]);
- }
- }
-
- path = sb.toString().replace('\\', File.separatorChar);
- if (path.length() == 2) {
- root = path;
- path = "";
- } else {
- root = path.substring(0, 3);
- path = path.substring(3);
- }
-
- } else {
- if (path.length() == 1) {
- root = File.separator;
- path = "";
- } else if (path.charAt(1) == File.separatorChar) {
- // UNC drive
- root = File.separator+File.separator;
- path = path.substring(2);
- } else {
- root = File.separator;
- path = path.substring(1);
- }
- }
-
- Stack s = new Stack();
- s.push(root);
- StringTokenizer tok = new StringTokenizer(path, File.separator);
- while (tok.hasMoreTokens()) {
- String thisToken = tok.nextToken();
- if (".".equals(thisToken)) {
- continue;
- } else if ("..".equals(thisToken)) {
- if (s.size() < 2) {
- throw new BuildException("Cannot resolve path "+orig);
- } else {
- s.pop();
- }
- } else { // plain component
- s.push(thisToken);
- }
- }
-
- StringBuffer sb = new StringBuffer();
- for (int i=0; i 1) {
- // not before the filesystem root and not after it, since root
- // already contains one
- sb.append(File.separatorChar);
- }
- sb.append(s.elementAt(i));
- }
-
-
- path = sb.toString();
- if (dosWithDrive) {
- path = path.replace('/', '\\');
- }
- return new File(path);
- }
-
- /**
- * Create a temporary file in a given directory.
- *
- * The file denoted by the returned abstract pathname did not
- * exist before this method was invoked, any subsequent invocation
- * of this method will yield a different file name.
- *
- * This method is different to File.createTempFile of JDK 1.2
- * as it doesn't create the file itself and doesn't use platform
- * specific temporary directory when the parentDir attribute is
- * null.
- *
- * @param parentDir Directory to create the temporary file in -
- * current working directory will be assumed if this parameter is
- * null.
- *
- * @since 1.8
- */
- public File createTempFile(String prefix, String suffix, File parentDir) {
-
- File result = null;
- String parent = null;
- if (parentDir != null) {
- parent = parentDir.getPath();
- }
- DecimalFormat fmt = new DecimalFormat("#####");
- synchronized (rand) {
- do {
- result = new File(parent,
- prefix + fmt.format(rand.nextInt())
- + suffix);
- } while (result.exists());
- }
- return result;
- }
-
- /**
- * Compares the contents of two files.
- *
- * simple but sub-optimal comparision algorithm. written for
- * working rather than fast. Better would be a block read into
- * buffers followed by long comparisions apart from the final 1-7
- * bytes.
- *
- * @since 1.9
- */
- public boolean contentEquals(File f1, File f2) throws IOException {
- if (f1.exists() != f2.exists()) {
- return false;
- }
-
- if (!f1.exists()) {
- // two not existing files are equal
- return true;
- }
-
- if (f1.isDirectory() || f2.isDirectory()) {
- // don't want to compare directory contents for now
- return false;
- }
-
- if (f1.equals(f2)) {
- // same filename => true
- return true;
- }
-
- if (f1.length() != f2.length()) {
- // different size =>false
- return false;
- }
-
- InputStream in1 = null;
- InputStream in2 = null;
- try {
- in1 = new BufferedInputStream(new FileInputStream(f1));
- in2 = new BufferedInputStream(new FileInputStream(f2));
-
- int expectedByte = in1.read();
- while (expectedByte != -1) {
- if (expectedByte != in2.read()) {
- return false;
- }
- expectedByte = in1.read();
- }
- if (in2.read() != -1) {
- return false;
- }
- return true;
- } finally {
- if (in1 != null) {
- try {
- in1.close();
- } catch (IOException e) {}
- }
- if (in2 != null) {
- try {
- in2.close();
- } catch (IOException e) {}
- }
- }
- }
-
- /**
- * Emulation of File.getParentFile for JDK 1.1
- *
- * @since 1.10
- */
- public File getParentFile(File f) {
- if (f != null) {
- String p = f.getParent();
- if (p != null) {
- return new File(p);
- }
- }
- return null;
- }
-
- /**
- * Read from reader till EOF
- */
- public static final String readFully(Reader rdr) throws IOException {
- return readFully(rdr, 8192);
- }
-
- /**
- * Read from reader till EOF
- */
- public static final String readFully(Reader rdr, int bufferSize) throws IOException {
- final char[] buffer = new char[bufferSize];
- int bufferLength = 0;
- String text = null;
- StringBuffer textBuffer = null;
- while (bufferLength != -1) {
- bufferLength = rdr.read(buffer);
- if (bufferLength != -1) {
- if (textBuffer == null) {
- textBuffer = new StringBuffer(
- new String(buffer, 0, bufferLength));
- } else {
- textBuffer.append(new String(buffer, 0, bufferLength));
- }
- }
- }
- if (textBuffer != null) {
- text = textBuffer.toString();
- }
- return text;
- }
-}
-
diff --git a/proposal/sandbox/filterreaders/src/testcases/org/apache/tools/ant/taskdefs/CopyTest.java b/proposal/sandbox/filterreaders/src/testcases/org/apache/tools/ant/taskdefs/CopyTest.java
deleted file mode 100644
index f10b7e485..000000000
--- a/proposal/sandbox/filterreaders/src/testcases/org/apache/tools/ant/taskdefs/CopyTest.java
+++ /dev/null
@@ -1,152 +0,0 @@
-/*
- * The Apache Software License, Version 1.1
- *
- * Copyright (c) 2000-2002 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", "Ant", 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.taskdefs;
-
-import org.apache.tools.ant.BuildFileTest;
-import org.apache.tools.ant.Project;
-import org.apache.tools.ant.util.FileUtils;
-import java.io.File;
-import java.io.IOException;
-
-/**
- * Tests FileSet using the Copy task.
- *
- * @author David Rees
- */
-public class CopyTest extends BuildFileTest {
-
- public CopyTest(String name) {
- super(name);
- }
-
- public void setUp() {
- configureProject("src/etc/testcases/taskdefs/copy.xml");
- }
-
- public void test1() {
- executeTarget("test1");
- File f = new File(getProjectDir(), "copytest1.tmp");
- if ( !f.exists()) {
- fail("Copy failed");
- }
- }
-
- public void tearDown() {
- executeTarget("cleanup");
- }
-
- public void test2() {
- executeTarget("test2");
- File f = new File(getProjectDir(), "copytest1dir/copy.xml");
- if ( !f.exists()) {
- fail("Copy failed");
- }
- }
-
- public void test3() {
- executeTarget("test3");
- File file3 = new File(getProjectDir(), "copytest3.tmp");
- assertTrue(file3.exists());
- File file3a = new File(getProjectDir(), "copytest3a.tmp");
- assertTrue(file3a.exists());
- File file3b = new File(getProjectDir(), "copytest3b.tmp");
- assertTrue(file3b.exists());
- File file3c = new File(getProjectDir(), "copytest3c.tmp");
- assertTrue(file3c.exists());
-
- //file length checks rely on touch generating a zero byte file
- if(file3.length()==0) {
- fail("could not overwrite an existing, older file");
- }
- if(file3c.length()!=0) {
- fail("could not force overwrite an existing, newer file");
- }
- if(file3b.length()==0) {
- fail("unexpectedly overwrote an existing, newer file");
- }
-
- //file time checks for java1.2+
- if (Project.getJavaVersion() != Project.JAVA_1_1) {
- assertTrue(file3a.lastModified()==file3.lastModified());
- assertTrue(file3c.lastModified().
- */
-package org.apache.tools.ant.taskdefs;
-
-import org.apache.tools.ant.BuildFileTest;
-import org.apache.tools.ant.Project;
-import org.apache.tools.ant.BuildException;
-import java.io.File;
-
-/**
- * Test the load file task
- *
- * @author Steve Loughran
- * @created 10 December 2001
- */
-public class LoadFileTest extends BuildFileTest {
-
- /**
- * Constructor for the LoadFileTest object
- *
- * @param name Description of Parameter
- */
- public LoadFileTest(String name) {
- super(name);
- }
-
-
- /**
- * The JUnit setup method
- */
- public void setUp() {
- configureProject("src/etc/testcases/taskdefs/loadfile.xml");
- }
-
-
- /**
- * The teardown method for JUnit
- */
- public void tearDown() {
- executeTarget("cleanup");
- }
-
-
- /**
- * A unit test for JUnit
- */
- public void testNoSourcefileDefined() {
- expectBuildException("testNoSourcefileDefined",
- "source file not defined");
- }
-
-
- /**
- * A unit test for JUnit
- */
- public void testNoPropertyDefined() {
- expectBuildException("testNoPropertyDefined",
- "output property not defined");
- }
-
-
- /**
- * A unit test for JUnit
- */
- public void testNoSourcefilefound() {
- expectBuildExceptionContaining("testNoSourcefilefound",
- "File not found",
- "Unable to load file");
- }
-
- /**
- * A unit test for JUnit
- */
- public void testFailOnError()
- throws BuildException {
- expectPropertyUnset("testFailOnError","testFailOnError");
- }
-
-
- /**
- * A unit test for JUnit
- */
- public void testLoadAFile()
- throws BuildException {
- executeTarget("testLoadAFile");
- if(project.getProperty("testLoadAFile").indexOf("eh?")<0) {
- fail("property is not all in the file");
- }
- }
-
-
- /**
- * A unit test for JUnit
- */
- public void testLoadAFileEnc()
- throws BuildException {
- executeTarget("testLoadAFileEnc");
- if(project.getProperty("testLoadAFileEnc")==null) {
- fail("file load failed");
- }
- }
-
- /**
- * A unit test for JUnit
- */
- public void testEvalProps()
- throws BuildException {
- executeTarget("testEvalProps");
- if(project.getProperty("testEvalProps").indexOf("rain")<0) {
- fail("property eval broken");
- }
- }
-
- /**
- * A unit test for JUnit
- */
- public void testFilterChain()
- throws BuildException {
- executeTarget("testFilterChain");
- if(project.getProperty("testFilterChain").indexOf("World!")<0) {
- fail("Filter Chain broken");
- }
- }
-
-
- /**
- * A unit test for JUnit
- */
- public void testOneLine()
- throws BuildException {
- expectPropertySet("testOneLine","testOneLine","1,2,3,4");
-
- }
-}
diff --git a/proposal/sandbox/filterreaders/src/testcases/org/apache/tools/ant/taskdefs/MoveTest.java b/proposal/sandbox/filterreaders/src/testcases/org/apache/tools/ant/taskdefs/MoveTest.java
deleted file mode 100644
index 7830dd7c0..000000000
--- a/proposal/sandbox/filterreaders/src/testcases/org/apache/tools/ant/taskdefs/MoveTest.java
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- * The Apache Software License, Version 1.1
- *
- * Copyright (c) 2000-2002 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", "Ant", 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.taskdefs;
-
-import org.apache.tools.ant.BuildFileTest;
-import org.apache.tools.ant.Project;
-import org.apache.tools.ant.util.FileUtils;
-import java.io.File;
-import java.io.IOException;
-
-/**
- * Tests the Move task.
- *
- * @author Magesh Umasankar
- */
-public class MoveTest extends BuildFileTest {
-
- public MoveTest(String name) {
- super(name);
- }
-
- public void setUp() {
- configureProject("src/etc/testcases/taskdefs/move.xml");
- }
-
- public void tearDown() {
- executeTarget("cleanup");
- }
-
- public void testFilterSet() throws IOException {
- executeTarget("testFilterSet");
- FileUtils fileUtils = FileUtils.newFileUtils();
- File tmp = new File(getProjectDir(), "move.filterset.tmp");
- File check = new File(getProjectDir(), "expected/copy.filterset.filtered");
- assertTrue(tmp.exists());
- assertTrue(fileUtils.contentEquals(tmp, check));
- }
-
- public void testSingleFileFileset() {
- executeTarget("test_single_file_fileset");
- File file = new File(getProjectDir(),
- "copytest_single_file_fileset.tmp");
- assertTrue(file.exists());
- }
-
- public void testFilterChain() throws IOException {
- executeTarget("testFilterChain");
- FileUtils fileUtils = FileUtils.newFileUtils();
- File tmp = new File(getProjectDir(), "move.filterchain.tmp");
- File check = new File(getProjectDir(), "expected/copy.filterset.filtered");
- assertTrue(tmp.exists());
- assertTrue(fileUtils.contentEquals(tmp, check));
- }
-}