Class SplitTask

java.lang.Object
org.apache.tools.ant.ProjectComponent
org.apache.tools.ant.Task
ise.antelope.tasks.SplitTask
All Implemented Interfaces:
Cloneable

public class SplitTask extends org.apache.tools.ant.Task
This task is similar to the Unix/Linux split utility, it splits a file into a number of smaller pieces. It will also split a property value or a string.
Since:
Ant 1.6
Version:
$Revision: 157 $
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
    Buffer size for read and write operations.

    Fields inherited from class org.apache.tools.ant.Task

    target, taskName, taskType, wrapper

    Fields inherited from class org.apache.tools.ant.ProjectComponent

    description, location, project
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Split the given property, value, or file into pieces.
    void
    setBytes(int b)
    Set the number of bytes per part.
    void
    setFailonerror(boolean fail)
    Determines whether the build should fail if there is an error.
    void
    Split the contents of the given file.
    void
    setLines(int x)
    Set the number of lines per part, default is 1000.
    void
    Where to put the parts.
    void
    The start of the file names to write.
    void
    Split the text value of the given property.
    void
    The linux split command allows modifiers: b for 512, k for 1K, m for 1 Meg.
    void
    Split the given string.

    Methods inherited from class org.apache.tools.ant.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

    Methods inherited from class org.apache.tools.ant.ProjectComponent

    clone, getDescription, getLocation, getProject, setDescription, setLocation, setProject

    Methods inherited from class java.lang.Object

    equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • BUFFER_SIZE

      public static final int BUFFER_SIZE
      Buffer size for read and write operations.
      See Also:
  • Constructor Details

    • SplitTask

      public SplitTask()
  • Method Details

    • setPrefix

      public void setPrefix(String x)
      The start of the file names to write. Files are named using this string, followed by a "." and a number, e.g. x.0, x.1, etc. The Unix/Linux split uses a letter scheme for the suffix, that is not supported here. Should the dot go away? If the user wants a dot, it could be part of this attribute. Right now, the dot is there, and there is no way for the user to make it go away.
      Parameters:
      x - The new prefix value
    • setBytes

      public void setBytes(int b)
      Set the number of bytes per part. This is not a required parameter, the default is to use lines rather than bytes. Use bytes or lines, not both. In general, use bytes or size for binary files, lines for text files.
      Parameters:
      b - number of bytes per part.
    • setSize

      public void setSize(String b)
      The linux split command allows modifiers: b for 512, k for 1K, m for 1 Meg. Use this method for a similar effect. This is not a required parameter, the default is to use lines rather than size. Use bytes or lines, not both. In general, use bytes or size for binary files, lines for text files.
      Parameters:
      b - the number of bytes per part, with an optional modifier. If there is no modifier, treat same as setBytes(int). For example, setSize("100k") is the same as setBytes(100 * 1024). Note that the maximum size must be smaller than Integer.MAX_VALUE (2147483647).
    • setLines

      public void setLines(int x)
      Set the number of lines per part, default is 1000. This is not a required parameter, but is the default setting for splitting. Use bytes or lines, not both. In general, use bytes or size for binary files, lines for text files.
      Parameters:
      x - The number of lines per part.
    • setProperty

      public void setProperty(String p)
      Split the text value of the given property. One of property, value, or file are required.
      Parameters:
      p - the name of the property whose value will be split.
    • setValue

      public void setValue(String v)
      Split the given string. One of property, value, or file are required.
      Parameters:
      v - a string
    • setFile

      public void setFile(File f)
      Split the contents of the given file. One of property, value, or file are required.
      Parameters:
      f - the name of the file
    • setOutputdir

      public void setOutputdir(File d)
      Where to put the parts. If file has been set and output directory has not been set, output to directory containing file.
      Parameters:
      d - the output directory
    • setFailonerror

      public void setFailonerror(boolean fail)
      Determines whether the build should fail if there is an error. Default is true.
      Parameters:
      fail - true or false
    • execute

      public void execute() throws org.apache.tools.ant.BuildException
      Split the given property, value, or file into pieces.
      Overrides:
      execute in class org.apache.tools.ant.Task
      Throws:
      org.apache.tools.ant.BuildException - only if failOnError is true