com.jmw.tzap
Class TextZapTask

java.lang.Object
  extended by org.apache.tools.ant.ProjectComponent
      extended by org.apache.tools.ant.Task
          extended by com.jmw.tzap.TextZapTask

public class TextZapTask
extends org.apache.tools.ant.Task

Ant Task designed to run Filters on a set of documents

Author:
Judah Wischnitzer
See Also:
AbstractFilter, FilterFile

Field Summary
protected  java.io.File destDir
          The output directory
protected  java.lang.String fileEncoding
          File encoding defaults to the system property
protected  java.util.TreeMap fileMap
          Map of the files to be processed
protected  FilterFile[] files
          The files to be processed
protected  java.util.ArrayList<org.apache.tools.ant.types.FileSet> filesets
          FileSets added to this task
protected  java.util.ArrayList filterCollection
          Collection of filters added to this task
protected  AbstractFilter[] filters
          An array of the filters added to this task
protected  java.io.File inFile
          The input file
protected  org.apache.tools.ant.types.Mapper mapperElement
          Filename mapper
protected  java.io.File outFile
          The output file
protected  boolean overwrite
          Overwrite flag
protected  FileSaver saver
          Custom saver, optional
 
Fields inherited from class org.apache.tools.ant.Task
description, location, target, taskName, taskType, wrapper
 
Fields inherited from class org.apache.tools.ant.ProjectComponent
project
 
Constructor Summary
TextZapTask()
          Constructor for the TextZapTask object
 
Method Summary
 void add(AbstractFilter filter)
          Adds an output filter
 void addConfigured(FileSaver saver)
           
 void addConfiguredFilter(Filter filter)
          Adds an output filter
 void addFileSet(org.apache.tools.ant.types.FileSet fs)
          adds a fileset
protected  void assembleFiles()
          Goes through each FileSet and adds its files to the fileSet map and ultimately to the files array.
protected  void buildMap(java.io.File fromDir, java.io.File toDir, java.lang.String[] names, org.apache.tools.ant.util.FileNameMapper mapper)
          Compares source files to destination files to see if they should be copied, if the overwrite flag is false.
protected  org.apache.tools.ant.util.FileNameMapper chooseMapper()
          Selects the proper mapper.
 org.apache.tools.ant.types.Mapper createMapper()
          Defines a mapper to map source to destination files.
 void execute()
          Execute the task by calling the execute method of each Filter
 void setDestDir(java.io.File s)
          sets the output directory
 void setEncoding(java.lang.String s)
          sets the file encoding
 void setInFile(java.io.File s)
          sets a single file for analysis
 void setOutFile(java.io.File s)
          sets the output file
 void setOverwrite(boolean o)
          sets overwrite flag.
protected  void validateAttributes()
          Ensure we have a consistent and legal set of attributes, and be sure that each Filters has the correct attributes.
 
Methods inherited from class org.apache.tools.ant.Task
getDescription, getLocation, getOwningTarget, getRuntimeConfigurableWrapper, getTaskName, getTaskType, getWrapper, handleErrorFlush, handleErrorOutput, handleFlush, handleInput, handleOutput, init, isInvalid, log, log, maybeConfigure, perform, reconfigure, setDescription, setLocation, setOwningTarget, setRuntimeConfigurableWrapper, setTaskName, setTaskType
 
Methods inherited from class org.apache.tools.ant.ProjectComponent
getProject, setProject
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

filesets

protected java.util.ArrayList<org.apache.tools.ant.types.FileSet> filesets
FileSets added to this task


filterCollection

protected java.util.ArrayList filterCollection
Collection of filters added to this task


filters

protected AbstractFilter[] filters
An array of the filters added to this task


files

protected FilterFile[] files
The files to be processed


fileMap

protected java.util.TreeMap fileMap
Map of the files to be processed


inFile

protected java.io.File inFile
The input file


outFile

protected java.io.File outFile
The output file


destDir

protected java.io.File destDir
The output directory


overwrite

protected boolean overwrite
Overwrite flag


fileEncoding

protected java.lang.String fileEncoding
File encoding defaults to the system property


mapperElement

protected org.apache.tools.ant.types.Mapper mapperElement
Filename mapper


saver

protected FileSaver saver
Custom saver, optional

Constructor Detail

TextZapTask

public TextZapTask()
Constructor for the TextZapTask object

Method Detail

setInFile

public void setInFile(java.io.File s)
sets a single file for analysis

Parameters:
s - the name of the file

setOutFile

public void setOutFile(java.io.File s)
sets the output file

Parameters:
s - the file

setDestDir

public void setDestDir(java.io.File s)
sets the output directory

Parameters:
s - the file

setEncoding

public void setEncoding(java.lang.String s)
sets the file encoding

Parameters:
s - the file encoding

addConfiguredFilter

public void addConfiguredFilter(Filter filter)
Adds an output filter

Parameters:
filter - the object that creates the filters

add

public void add(AbstractFilter filter)
Adds an output filter

Parameters:
filter - the object that creates the filters

addFileSet

public void addFileSet(org.apache.tools.ant.types.FileSet fs)
adds a fileset

Parameters:
fs - the files sets to be analyzed

setOverwrite

public void setOverwrite(boolean o)
sets overwrite flag. This flag tells the task whether or not to check if the files being overwritten are newer than the original files.

Parameters:
o - the overwrite value

createMapper

public org.apache.tools.ant.types.Mapper createMapper()
                                               throws org.apache.tools.ant.BuildException
Defines a mapper to map source to destination files.

Returns:
Description of the Return Value
Throws:
org.apache.tools.ant.BuildException - Description of the Exception

addConfigured

public void addConfigured(FileSaver saver)

execute

public void execute()
             throws org.apache.tools.ant.BuildException
Execute the task by calling the execute method of each Filter

Overrides:
execute in class org.apache.tools.ant.Task
Throws:
org.apache.tools.ant.BuildException - if the processing fails

validateAttributes

protected void validateAttributes()
                           throws org.apache.tools.ant.BuildException
Ensure we have a consistent and legal set of attributes, and be sure that each Filters has the correct attributes.

Throws:
org.apache.tools.ant.BuildException - if the processing fails

assembleFiles

protected void assembleFiles()
                      throws org.apache.tools.ant.BuildException
Goes through each FileSet and adds its files to the fileSet map and ultimately to the files array.

Throws:
org.apache.tools.ant.BuildException - if something goes wrong

chooseMapper

protected org.apache.tools.ant.util.FileNameMapper chooseMapper()
Selects the proper mapper. Defaults to IdentityMapper

Returns:
Description of the Return Value

buildMap

protected void buildMap(java.io.File fromDir,
                        java.io.File toDir,
                        java.lang.String[] names,
                        org.apache.tools.ant.util.FileNameMapper mapper)
Compares source files to destination files to see if they should be copied, if the overwrite flag is false. If the overwrite flag is true (deafult), then all files will be included.

Parameters:
fromDir - Description of the Parameter
toDir - Description of the Parameter
names - Description of the Parameter
mapper - Description of the Parameter