|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.apache.tools.ant.Task | +--net.groboclown.ant.v1.Concat
Concatenates one or more files together. The concatenation joins a collection of files into a single file, in order of the collection's appearance. If the output file already exists, then several options may be used: "append" joins the collection to the end of the file, "overwrite" eliminates the existing contents and replaces it with the collection, and "error" generates a build error when the output file exists.
For filtering, you can set either the global filter (which is by default "no"), or on a file-by-file basis. If the individual's filtering is not set, then it uses the global filtering setting.
Note that filtering should only be applied to non-binary files, since it reads in the file line-by-ine, and outputs the file in the operating system's default CR-LF format.
Attribute | Description | Required |
---|---|---|
outfile | The filename to send the concatenated files to. If the file already exists, then the appropriate action is dicated by the whenexists attribute. | Yes |
whenexists | Behavior when the output file already exists. Applicable values are "overwrite", "append", and "error". Defaults to "overwrite&qupt;. | No |
filtering | "yes" or "no". Indicates whether token filtering should take place during the copy. Defaults to "no". | No |
Since FileSets do not dictate the file order, you must specify each concatenated file in order. Each file is contained in an addfile tag:
Attribute | Description | Required |
---|---|---|
name | The name of the file to insert into the output file. | Yes |
filtering | "yes" or "no". Indicates whether token filtering should take place during the inclusion. Defaults to the concat filtering setting when not specified. | No |
<concat outfile="out.txt"> <addfile name="1.txt" /> <addfile name="2.txt" /> </concat>Concatenate the files "1.txt" and "2.txt" into the file "out.txt". If "out.txt" already exists, then it is replaced by the concatenated text.
<concat outfile="1.txt" whenexists="append"> <addfile name="2.txt" /> </concat>Copies "2.txt" into the file "1.txt". If "1.txt" already exists, then it appends the contents of "2.txt" to the end of "1.txt".
<concat outfile="out.txt" whenexists="error" filtering="yes" > <addfile name="1.txt" filtering="no" /> <addfile name="2.txt" /> <addfile name="3.txt" filtering="yes" /> </concat>Creates a file "out.txt" which contains the contents of "1.txt", followed immediately by the contents of "2.txt", which is followed immediately by the contents of "3.txt". If the file "out.txt" already exists, then a build error is generated. The file "1.txt" does not have any filtering applied to it, while "2.txt" and "3.txt" have filtering.
Inner Class Summary | |
private static class |
Concat.ErrorOperation
|
static class |
Concat.FileOrder
|
private static class |
Concat.OpenOperation
|
private static class |
Concat.Operation
An enumeration... |
Field Summary | |
private static Concat.Operation |
APPEND
|
private static Concat.Operation |
ERROR
|
protected Vector |
fileOrder
|
protected boolean |
filtering
|
protected Concat.Operation |
operation
|
private static String |
OPERATION_LIST
|
private static Concat.Operation[] |
OPERATIONS
|
protected String |
operationType
|
protected File |
outfile
|
private static Concat.Operation |
OVERWRITE
|
Fields inherited from class org.apache.tools.ant.Task |
description, location, project, target, taskName, taskType, wrapper |
Constructor Summary | |
Concat()
|
Method Summary | |
void |
appendFile(BufferedWriter out,
File next,
boolean filter)
Append the given file to the stream. |
Concat.FileOrder |
createAddFile()
Create a new file entry. |
void |
execute()
Execute the task. |
String |
replace(String s,
Hashtable tokens)
Does replacement on the given string using the given token table. |
void |
setFiltering(boolean filtering)
Sets filtering. |
void |
setOutfile(File outfile)
Sets the Outfile attribute of the Cat object |
void |
setWhenExists(String operation)
|
protected void |
validateAttributes()
Ensure we have a consistent and legal set of attributes, and set any internal flags necessary based on different combinations of attributes. |
Methods inherited from class org.apache.tools.ant.Task |
getDescription, getLocation, getOwningTarget, getProject, getRuntimeConfigurableWrapper, getTaskName, init, log, log, maybeConfigure, setDescription, setLocation, setOwningTarget, setProject, setRuntimeConfigurableWrapper, setTaskName, setTaskType |
Methods inherited from class java.lang.Object |
|
Field Detail |
protected File outfile
protected Vector fileOrder
protected boolean filtering
protected Concat.Operation operation
protected String operationType
private static final Concat.Operation ERROR
private static final Concat.Operation OVERWRITE
private static final Concat.Operation APPEND
private static final String OPERATION_LIST
private static final Concat.Operation[] OPERATIONS
Constructor Detail |
public Concat()
Method Detail |
public void setOutfile(File outfile)
outfile
- The new Outfile valuepublic void setWhenExists(String operation)
public Concat.FileOrder createAddFile()
public void setFiltering(boolean filtering)
public void execute() throws org.apache.tools.ant.BuildException
execute
in class org.apache.tools.ant.Task
org.apache.tools.ant.BuildException
- Description of Exceptionpublic void appendFile(BufferedWriter out, File next, boolean filter) throws IOException
protected void validateAttributes() throws org.apache.tools.ant.BuildException
public String replace(String s, Hashtable tokens)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |