From defe5f24dca001f492ae23092af23083c64540d4 Mon Sep 17 00:00:00 2001 From: Magesh Umasankar Date: Mon, 18 Feb 2002 18:37:50 +0000 Subject: [PATCH] Answer the question: "So what are filterreadersets and filterreaders anyway?" git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@271415 13f79535-47bb-0310-9956-ffa450edef68 --- .../docs/manual/CoreTasks/loadfile.html | 101 ++++++++ .../manual/CoreTypes/filterreaderset.html | 231 ++++++++++++++++++ 2 files changed, 332 insertions(+) create mode 100644 proposal/sandbox/filterreaders/docs/manual/CoreTasks/loadfile.html create mode 100644 proposal/sandbox/filterreaders/docs/manual/CoreTypes/filterreaderset.html diff --git a/proposal/sandbox/filterreaders/docs/manual/CoreTasks/loadfile.html b/proposal/sandbox/filterreaders/docs/manual/CoreTasks/loadfile.html new file mode 100644 index 000000000..5d60d4fd5 --- /dev/null +++ b/proposal/sandbox/filterreaders/docs/manual/CoreTasks/loadfile.html @@ -0,0 +1,101 @@ + + +LoadFile Task + + + + + +

LoadFile

+

Description

+

+ Load a text file into a single property. Unless an encoding is specified, + the encoding of the current locale is used. + +

+ +

Parameters

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
AttributeDescriptionRequired
srcFilesource fileYes
propertyproperty to save toYes
encodingencoding to use when loading the fileNo
failonerrorWhether to halt the build on failureNo, default "true"
evaluatePropertiesflag to enable property evalation in the fileNo, default "false"
+

+The LoadFile task supports nested +FilterReaderSets. + +

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">
+      <filterreaderset>
+        <filterreader classname="org.apache.tools.ant.filters.StripLineBreaks" />
+      </filterreaderset>
+    </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"
+      evaluateProperties="true" />
+
+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/CoreTypes/filterreaderset.html b/proposal/sandbox/filterreaders/docs/manual/CoreTypes/filterreaderset.html new file mode 100644 index 000000000..dd43f40dc --- /dev/null +++ b/proposal/sandbox/filterreaders/docs/manual/CoreTypes/filterreaderset.html @@ -0,0 +1,231 @@ + + + + + FilterReaderSet Type + + + +

FilterReaderSet

+ +

FilterReaderSets are groups of FilterReaders. FilterReaderSets can appear +inside tasks that support this feature.
FilterReaderSets are used for +filtering file contents read in by tasks like LoadFile, etc.
+ +Each FilterReaderSet is composed of nested FilterReader elements. + +

FilterReader

+ +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. + + + + + + + + + + + + +
AttributeDescriptionRequired
classnameThe class name of the filter reader.Yes
+ +

+The following FilterReaders are supplied with the default +distribution. + +

org.apache.tools.ant.filters.StripLineBreaks

+ +This filter reader strips away specific characters +from the data supplied to it. + + + + + + + + + + + + +
Parameter NameParameter ValueRequired
linebreaksCharacters 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}">
+  <filterreaderset>
+    <filterreader classname="org.apache.tools.ant.filters.StripLineBreaks"/>
+  </filterreaderset>
+</loadfile>
+
+ +This treats the '(' and ')' characters as line break characters and +strips them. +
+<loadfile srcfile="${src.file}" property="${src.file.contents}">
+  <filterreaderset>
+    <filterreader classname="org.apache.tools.ant.filters.StripLineBreaks">
+      <param name="linebreaks" value="()"/>
+    </filterreader>
+  </filterreaderset>
+</loadfile>
+
+ +

org.apache.tools.ant.filters.StripJavaComments

+ +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}">
+  <filterreaderset>
+    <filterreader classname="org.apache.tools.ant.filters.StripJavaComments"/>
+  </filterreaderset>
+</loadfile>
+
+ +

org.apache.tools.ant.filters.ReplaceTokens

+ +This filter reader replaces all strings that are +sandwiched between begintoken and endtoken with +user defined values. + + + + + + + + + + + + + + + + + + + + + + + + + + +
Parameter TypeParameter NameParameter ValueRequired
tokencharbegintokenCharacter marking the + beginning of a token. Defaults to @No
tokencharendtokenCharacter marking the + end of a token. Defaults to @No
tokenUser defined String.User defined search StringYes
+

+ +

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}">
+  <filterreaderset>
+    <filterreader classname="org.apache.tools.ant.filters.ReplaceTokens">
+      <param type="token" name="DATE" value="${TODAY}"/>
+    <filterreader/>
+  </filterreaderset>
+</loadfile>
+
+ +

org.apache.tools.ant.filters.HeadFilter

+ +This filter reads the first few lines from the data supplied to it. + + + + + + + + + + + + +
Parameter NameParameter ValueRequired
linesNumber 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}">
+  <filterreaderset>
+    <filterreader classname="org.apache.tools.ant.filters.HeadFilter">
+      <param name="lines" value="15"/>
+    </filterreader>
+  </filterreaderset>
+</loadfile>
+
+ +

org.apache.tools.ant.filters.TailFilter

+ +This filter reads the last few lines from the data supplied to it. + + + + + + + + + + + + +
Parameter NameParameter ValueRequired
linesNumber 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}">
+  <filterreaderset>
+    <filterreader classname="org.apache.tools.ant.filters.TailFilter">
+      <param name="lines" value="15"/>
+    </filterreader>
+  </filterreaderset>
+</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}">
+  <filterreaderset>
+    <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>
+  </filterreaderset>
+</loadfile>
+
+ +
+ +

Copyright © 2001 Apache Software Foundation. All rights +Reserved.