diff --git a/manual/Tasks/concat.html b/manual/Tasks/concat.html index 513797ce7..71aba6148 100644 --- a/manual/Tasks/concat.html +++ b/manual/Tasks/concat.html @@ -124,6 +124,15 @@ be used.
false
true, the task applies the filterchain to each + input after applying
fixlastline
. If this attribute is false, concat + will apply the filterchain only once to the already concatenated inputs. Filtering of +
header
and footer
is not affected by this setting.
+ Since Ant 1.10.10false
cbuf
.
+ * @param cbuf The array to be read into.
+ * @param off The offset.
+ * @param len The length to read.
+ * @exception IOException - possibly thrown by the reads to the
+ * reader objects.
+ */
+ @Override
+ public int read(char[] cbuf, int off, int len)
+ throws IOException {
+
+ int amountRead = 0;
+ while (getReader() != null) {
+ int nRead = getReader().read(cbuf, off, len);
+ if (nRead == -1 || nRead == 0) {
+ nextReader();
+ } else {
+ len -= nRead;
+ off += nRead;
+ amountRead += nRead;
+ if (len == 0) {
+ return amountRead;
+ }
+ }
+ }
+ if (amountRead == 0) {
+ return -1;
+ }
+ return amountRead;
+ }
+
+ /**
+ * Close the current reader
+ */
+ @Override
+ public void close() throws IOException {
+ if (reader != null) {
+ reader.close();
+ }
+ }
private boolean isFixLastLine() {
return fixLastLine && textBuffer == null;
@@ -386,8 +462,14 @@ public class Concat extends Task implements ResourceCollection {
result.setManagingComponent(this);
return result;
}
- Reader resourceReader = getFilteredReader(
- new MultiReader<>(c.iterator(), resourceReaderFactory));
+ Reader resourceReader;
+ if(filterBeforeConcat) {
+ resourceReader = new MultiReader<>(c.iterator(),
+ resourceReaderFactory, true);
+ } else {
+ resourceReader = getFilteredReader(
+ new MultiReader<>(c.iterator(), resourceReaderFactory, false));
+ }
Reader rdr;
if (header == null && footer == null) {
rdr = resourceReader;
@@ -416,7 +498,7 @@ public class Concat extends Task implements ResourceCollection {
}
}
rdr = new MultiReader<>(Arrays.asList(readers).iterator(),
- identityReaderFactory);
+ identityReaderFactory, false);
}
return outputEncoding == null ? new ReaderInputStream(rdr)
: new ReaderInputStream(rdr, outputEncoding);
@@ -454,6 +536,9 @@ public class Concat extends Task implements ResourceCollection {
/** Stores the binary attribute */
private boolean binary;
+ /** Stores the filterBeforeConcat attribute */
+ private boolean filterBeforeConcat;
+
// Child elements.
/**
@@ -779,6 +864,17 @@ public class Concat extends Task implements ResourceCollection {
this.binary = binary;
}
+ /**
+ * Set the filterBeforeConcat attribute. If true, concat will filter each
+ * input through the filterchain before concatenating the results. This
+ * allows to e.g. use the FileTokenizer to tokenize each input.
+ * @param filterBeforeConcat if true, filter each input before concatenation
+ * @since Ant 1.10.10
+ */
+ public void setFilterBeforeConcat(final boolean filterBeforeConcat) {
+ this.filterBeforeConcat = filterBeforeConcat;
+ }
+
/**
* Execute the concat task.
*/
diff --git a/src/tests/antunit/taskdefs/concat-test.xml b/src/tests/antunit/taskdefs/concat-test.xml
index c596d904d..82182ffb2 100644
--- a/src/tests/antunit/taskdefs/concat-test.xml
+++ b/src/tests/antunit/taskdefs/concat-test.xml
@@ -118,6 +118,50 @@
+