Concat (Apache Ant API)
Description: declaration: package: org.apache.tools.ant.taskdefs, class: Concat

# Class Concat

java.lang.Object
org.apache.tools.ant.ProjectComponent
org.apache.tools.ant.Task
org.apache.tools.ant.taskdefs.Concat

All Implemented Interfaces:
  `Cloneable, Iterable<Resource>, ResourceCollection`

public class Concat extends Task implements ResourceCollection
This class contains the 'concat' task, used to concatenate a series of files into a single stream. The destination of this stream may be the system console, or a file. The following is a sample invocation:

    <concat destfile="${build.dir}/index.xml"
      append="false">

      <fileset dir="${xml.root.dir}"
        includes="*.xml" />

    </concat>

- ## Nested Class Summary

  Nested Classes
  Modifier and Type
  Class
  Description
  `static class`
  `Concat.TextElement`
  sub element points to a file or contains text

- ## Field Summary

  ### Fields inherited from class Task

  `target, taskName, taskType, wrapper`
  Modifier and Type
  Field
  Description
  `protected Target`
  `target`
  Deprecated.
  since 1.6.x.
  `protected String`
  `taskName`
  Deprecated.
  since 1.6.x.
  `protected String`
  `taskType`
  Deprecated.
  since 1.6.x.
  `protected RuntimeConfigurable`
  `wrapper`
  Deprecated.
  since 1.6.x.

  ### Fields inherited from class ProjectComponent

  `description, location, project`
  Modifier and Type
  Field
  Description
  `protected String`
  `description`
  Deprecated.
  since 1.6.x.
  `protected Location`
  `location`
  Deprecated.
  since 1.6.x.
  `protected Project`
  `project`
  Deprecated.
  since 1.6.x.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `Concat()`
  Construct a new Concat task.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `add(ResourceCollection c)`
  Add an arbitrary ResourceCollection.
  `void`
  `addFilelist(FileList list)`
  List of files to concatenate.
  `void`
  `addFileset(FileSet set)`
  Set of files to concatenate.
  `void`
  `addFilterChain(FilterChain filterChain)`
  Adds a FilterChain.
  `void`
  `addFooter(Concat.TextElement footerToAdd)`
  Add a footer to the concatenated output
  `void`
  `addHeader(Concat.TextElement headerToAdd)`
  Add a header to the concatenated output
  `void`
  `addText(String text)`
  This method adds text which appears in the 'concat' element.
  `Path`
  `createPath()`
  Path of files to concatenate.
  `void`
  `execute()`
  Execute the concat task.
  `boolean`
  `isFilesystemOnly()`
  Implement ResourceCollection.
  `Iterator<Resource>`
  `iterator()`
  Implement ResourceCollection.
  `void`
  `reset()`
  Reset state to default.
  `void`
  `setAppend(boolean append)`
  Sets the behavior when the destination exists.
  `void`
  `setBinary(boolean binary)`
  Set the binary attribute.
  `void`
  `setDest(Resource dest)`
  Set the resource to write to.
  `void`
  `setDestfile(File destinationFile)`
  Sets the destination file, or uses the console if not specified.
  `void`
  `setEncoding(String encoding)`
  Sets the character encoding
  `void`
  `setEol(FixCRLF.CrLf crlf)`
  Specify the end of line to find and to add if not present at end of each input file.
  `void`
  `setFilterBeforeConcat(boolean filterBeforeConcat)`
  Set the filterBeforeConcat attribute.
  `void`
  `setFixLastLine(boolean fixLastLine)`
  Append line.separator to files that do not end with a line.separator, default false.
  `void`
  `setForce(boolean forceOverwrite)`
  Deprecated.
  use #setOverwrite instead
  `void`
  `setForceReadOnly(boolean f)`
  Whether read-only destinations will be overwritten.
  `void`
  `setIgnoreEmpty(boolean ignoreEmpty)`
  Sets the behavior when no source resource files are available.
  `void`
  `setOutputEncoding(String outputEncoding)`
  Sets the character encoding for outputting
  `void`
  `setOverwrite(boolean forceOverwrite)`
  Force overwrite existing destination file
  `void`
  `setResourceName(String resourceName)`
  Set the name that will be reported by the exposed `Resource`.
  `void`
  `setWriter(Writer outputWriter)`
  Set the output writer.
  `int`
  `size()`
  Implement ResourceCollection.

  ### Methods inherited from class Task

  `bindToOwner, getOwningTarget, getRuntimeConfigurableWrapper, getTaskName, getTaskType, getWrapper, handleErrorFlush, handleErrorOutput, handleFlush, handleInput, handleOutput, init, isInvalid, log, log, log, log, maybeConfigure, perform, reconfigure, setOwningTarget, setRuntimeConfigurableWrapper, setTaskName, setTaskType`
  Modifier and Type
  Method
  Description
  `final void`
  `bindToOwner(Task owner)`
  Bind a task to another; use this when configuring a newly created task to do work on behalf of another.
  `Target`
  `getOwningTarget()`
  Returns the container target of this task.
  `RuntimeConfigurable`
  `getRuntimeConfigurableWrapper()`
  Returns the wrapper used for runtime configuration.
  `String`
  `getTaskName()`
  Returns the name to use in logging messages.
  `String`
  `getTaskType()`
  Return the type of task.
  `protected RuntimeConfigurable`
  `getWrapper()`
  Return the runtime configurable structure for this task.
  `protected void`
  `handleErrorFlush(String output)`
  Handles an error line by logging it with the WARN priority.
  `protected void`
  `handleErrorOutput(String output)`
  Handles an error output by logging it with the WARN priority.
  `protected void`
  `handleFlush(String output)`
  Handles output by logging it with the INFO priority.
  `protected int`
  `handleInput(byte[] buffer, int offset, int length)`
  Handle an input request by this task.
  `protected void`
  `handleOutput(String output)`
  Handles output by logging it with the INFO priority.
  `void`
  `init()`
  Called by the project to let the task initialize properly.
  `protected final boolean`
  `isInvalid()`
  Has this task been marked invalid?
  `void`
  `log(String msg)`
  Logs a message with the default (INFO) priority.
  `void`
  `log(String msg, int msgLevel)`
  Logs a message with the given priority.
  `void`
  `log(String msg, Throwable t, int msgLevel)`
  Logs a message with the given priority.
  `void`
  `log(Throwable t, int msgLevel)`
  Logs a message with the given priority.
  `void`
  `maybeConfigure()`
  Configures this task - if it hasn't been done already.
  `final void`
  `perform()`
  Performs this task if it's still valid, or gets a replacement version and performs that otherwise.
  `void`
  `reconfigure()`
  Force the task to be reconfigured from its RuntimeConfigurable.
  `void`
  `setOwningTarget(Target target)`
  Sets the target container of this task.
  `void`
  `setRuntimeConfigurableWrapper(RuntimeConfigurable wrapper)`
  Sets the wrapper to be used for runtime configuration.
  `void`
  `setTaskName(String name)`
  Sets the name to use in logging messages.
  `void`
  `setTaskType(String type)`
  Sets the name with which the task has been invoked.

  ### Methods inherited from class ProjectComponent

  `clone, getDescription, getLocation, getProject, setDescription, setLocation, setProject`
  Modifier and Type
  Method
  Description
  `Object`
  `clone()`
  `String`
  `getDescription()`
  Returns the description of the current action.
  `Location`
  `getLocation()`
  Returns the file/location where this task was defined.
  `Project`
  `getProject()`
  Returns the project to which this component belongs.
  `void`
  `setDescription(String desc)`
  Sets a description of the current action.
  `void`
  `setLocation(Location location)`
  Sets the file/location where this task was defined.
  `void`
  `setProject(Project project)`
  Sets the project object of this component.

  ### Methods inherited from class Object

  `equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

  ### Methods inherited from interface Iterable

  `forEach, spliterator`

  ### Methods inherited from interface ResourceCollection

  `isEmpty, stream`
  Modifier and Type
  Method
  Description
  `default boolean`
  `isEmpty()`
  Learn whether this `ResourceCollection` is empty.
  `default Stream<? extends Resource>`
  `stream()`
  Return a `Stream` over this `ResourceCollection`.

- ## Constructor Details

  - ### Concat

    public Concat()
    Construct a new Concat task.

- ## Method Details

  - ### reset

    public void reset()
    Reset state to default.

  - ### setDestfile

    public void setDestfile(File destinationFile)
    Sets the destination file, or uses the console if not specified.
    Parameters:
      `destinationFile` - the destination file

  - ### setDest

    public void setDest(Resource dest)
    Set the resource to write to.
    Parameters:
      `dest` - the Resource to write to.
    Since:
      Ant 1.8

  - ### setAppend

    public void setAppend(boolean append)
    Sets the behavior when the destination exists. If set to `true` the task will append the stream data an `Appendable` resource; otherwise existing content will be overwritten. Defaults to `false`.
    Parameters:
      `append` - if true append output.

  - ### setEncoding

    public void setEncoding(String encoding)
    Sets the character encoding
    Parameters:
      `encoding` - the encoding of the input stream and unless outputencoding is set, the outputstream.

  - ### setOutputEncoding

    public void setOutputEncoding(String outputEncoding)
    Sets the character encoding for outputting
    Parameters:
      `outputEncoding` - the encoding for the output file
    Since:
      Ant 1.6

  - ### setForce

    @Deprecated public void setForce(boolean forceOverwrite)
    Deprecated.
    use #setOverwrite instead
    Force overwrite existing destination file
    Parameters:
      `forceOverwrite` - if true always overwrite, otherwise only overwrite if the output file is older any of the input files.
    Since:
      Ant 1.6

  - ### setOverwrite

    public void setOverwrite(boolean forceOverwrite)
    Force overwrite existing destination file
    Parameters:
      `forceOverwrite` - if true always overwrite, otherwise only overwrite if the output file is older any of the input files.
    Since:
      Ant 1.8.2

  - ### setForceReadOnly

    public void setForceReadOnly(boolean f)
    Whether read-only destinations will be overwritten.

    Defaults to false

    Parameters:
      `f` - boolean
    Since:
      Ant 1.8.2

  - ### setIgnoreEmpty

    public void setIgnoreEmpty(boolean ignoreEmpty)
    Sets the behavior when no source resource files are available. If set to `false` the destination file will always be created. Defaults to `true`.
    Parameters:
      `ignoreEmpty` - if false, honour destination file creation.
    Since:
      Ant 1.8.0

  - ### setResourceName

    public void setResourceName(String resourceName)
    Set the name that will be reported by the exposed `Resource`.
    Parameters:
      `resourceName` - to set
    Since:
      Ant 1.8.3

  - ### createPath

    public Path createPath()
    Path of files to concatenate.
    Returns:
      the path used for concatenating
    Since:
      Ant 1.6

  - ### addFileset

    public void addFileset(FileSet set)
    Set of files to concatenate.
    Parameters:
      `set` - the set of files

  - ### addFilelist

    public void addFilelist(FileList list)
    List of files to concatenate.
    Parameters:
      `list` - the list of files

  - ### add

    public void add(ResourceCollection c)
    Add an arbitrary ResourceCollection.
    Parameters:
      `c` - the ResourceCollection to add.
    Since:
      Ant 1.7

  - ### addFilterChain

    public void addFilterChain(FilterChain filterChain)
    Adds a FilterChain.
    Parameters:
      `filterChain` - a filterchain to filter the concatenated input
    Since:
      Ant 1.6

  - ### addText

    public void addText(String text)
    This method adds text which appears in the 'concat' element.
    Parameters:
      `text` - the text to be concatenated.

  - ### addHeader

    public void addHeader(Concat.TextElement headerToAdd)
    Add a header to the concatenated output
    Parameters:
      `headerToAdd` - the header
    Since:
      Ant 1.6

  - ### addFooter

    public void addFooter(Concat.TextElement footerToAdd)
    Add a footer to the concatenated output
    Parameters:
      `footerToAdd` - the footer
    Since:
      Ant 1.6

  - ### setFixLastLine

    public void setFixLastLine(boolean fixLastLine)
    Append line.separator to files that do not end with a line.separator, default false.
    Parameters:
      `fixLastLine` - if true make sure each input file has new line on the concatenated stream
    Since:
      Ant 1.6

  - ### setEol

    public void setEol(FixCRLF.CrLf crlf)
    Specify the end of line to find and to add if not present at end of each input file. This attribute is used in conjunction with fixlastline.
    Parameters:
      `crlf` - the type of new line to add - cr, mac, lf, unix, crlf, or dos
    Since:
      Ant 1.6

  - ### setWriter

    public void setWriter(Writer outputWriter)
    Set the output writer. This is to allow concat to be used as a nested element.
    Parameters:
      `outputWriter` - the output writer.
    Since:
      Ant 1.6

  - ### setBinary

    public void setBinary(boolean binary)
    Set the binary attribute. If true, concat will concatenate the files byte for byte. This mode does not allow any filtering or other modifications to the input streams. The default value is false.
    Parameters:
      `binary` - if true, enable binary mode.
    Since:
      Ant 1.6.2

  - ### setFilterBeforeConcat

    public void setFilterBeforeConcat(boolean filterBeforeConcat)
    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.
    Parameters:
      `filterBeforeConcat` - if true, filter each input before concatenation
    Since:
      Ant 1.10.10

  - ### execute

    public void execute()
    Execute the concat task.
    Overrides:
      `execute` in class `Task`

  - ### iterator

    public Iterator<Resource> iterator()
    Implement ResourceCollection.
    Specified by:
      `iterator` in interface `Iterable<Resource>`
    Returns:
      Iterator<Resource>.

  - ### size

    public int size()
    Implement ResourceCollection.
    Specified by:
      `size` in interface `ResourceCollection`
    Returns:
      1.

  - ### isFilesystemOnly

    public boolean isFilesystemOnly()
    Implement ResourceCollection.
    Specified by:
      `isFilesystemOnly` in interface `ResourceCollection`
    Returns:
      false.