org.carrot2.ant.tasks
Class AbstractLicenseTask

java.lang.Object
  extended by org.apache.tools.ant.ProjectComponent
      extended by org.apache.tools.ant.Task
          extended by org.apache.tools.ant.taskdefs.MatchingTask
              extended by org.carrot2.ant.tasks.AbstractLicenseTask
All Implemented Interfaces:
SelectorContainer
Direct Known Subclasses:
LicenseListTask, LicenseReplaceTask

public abstract class AbstractLicenseTask
extends MatchingTask

A base ANT task for adding, replacing or listing licensing info in class headers or footers.


Field Summary
 
Fields inherited from class org.apache.tools.ant.taskdefs.MatchingTask
fileset
 
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
AbstractLicenseTask()
           
 
Method Summary
protected abstract  void checkLicense(File file)
          Invoked for each file where licensing should be checked.
protected  void checkParameters()
          Checks if all parameters are correct.
 FileSet createFileset()
          Crates a new path with a set of dependency files to scan.
 void execute()
          Executes the task.
protected  String getEncoding()
          Returns current source file encoding or null if none yet.
protected  String readFile(File file)
          Reads a single file into memory.
 void setEncoding(String encoding)
          Set source file encoding.
 void setForce(boolean force)
          Set to true to make the task accept files not ending with the default Java source file suffix.
protected  void writeFile(String string, File file)
          Write a string to file.
 
Methods inherited from class org.apache.tools.ant.taskdefs.MatchingTask
add, addAnd, addContains, addContainsRegexp, addCustom, addDate, addDepend, addDepth, addDifferent, addFilename, addMajority, addModified, addNone, addNot, addOr, addPresent, addSelector, addSize, addType, appendSelector, createExclude, createExcludesFile, createInclude, createIncludesFile, createPatternSet, getDirectoryScanner, getImplicitFileSet, getSelectors, hasSelectors, selectorCount, selectorElements, setCaseSensitive, setDefaultexcludes, setExcludes, setExcludesfile, setFollowSymlinks, setIncludes, setIncludesfile, setProject, XsetIgnore, XsetItems
 
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
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractLicenseTask

public AbstractLicenseTask()
Method Detail

createFileset

public FileSet createFileset()
Crates a new path with a set of dependency files to scan.


checkParameters

protected void checkParameters()
                        throws BuildException
Checks if all parameters are correct.

Throws:
BuildException

execute

public void execute()
             throws BuildException
Executes the task.

Overrides:
execute in class Task
Throws:
BuildException

checkLicense

protected abstract void checkLicense(File file)
                              throws IOException,
                                     BuildException
Invoked for each file where licensing should be checked.

Throws:
IOException
BuildException

setEncoding

public void setEncoding(String encoding)
Set source file encoding.


setForce

public void setForce(boolean force)
Set to true to make the task accept files not ending with the default Java source file suffix.


getEncoding

protected String getEncoding()
Returns current source file encoding or null if none yet.


readFile

protected final String readFile(File file)
                         throws IOException
Reads a single file into memory.

Throws:
IOException

writeFile

protected void writeFile(String string,
                         File file)
                  throws IOException
Write a string to file. The encoding is acquired from getEncoding().

Throws:
IOException


Copyright (c) Dawid Weiss, Stanislaw Osinski