org.apache.rat.annotation
Class AbstractLicenceAppender

java.lang.Object
  extended by org.apache.rat.annotation.AbstractLicenceAppender
Direct Known Subclasses:
ApacheV2LicenceAppender

public abstract class AbstractLicenceAppender
extends Object

Add a licence header to a document. This appender does not check for the existence of an existing licence header, it is assumed that either a second licence header is intentional or that there is no licence header present already.


Constructor Summary
AbstractLicenceAppender()
           
 
Method Summary
 void append(File document)
          Append the default licence header to the supplied document.
protected  String getFirstLine(int type)
          Get the first line of the licence header formatted for the given type of file.
protected  String getLastLine(int type)
          Get the last line of the licence header formatted for the given type of file.
abstract  String getLicenceHeader(File document)
           
protected  String getLine(int type, String content)
          Get a line of the licence header formatted for the given type of file.
protected  int getType(File document)
          Detect the type of document.
 void setForce(boolean force)
          Set the force flag on this appender.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractLicenceAppender

public AbstractLicenceAppender()
Method Detail

append

public void append(File document)
            throws IOException
Append the default licence header to the supplied document.

Parameters:
document - document to append to.
Throws:
IOException - if there is a problem while reading or writing the file

getType

protected int getType(File document)
Detect the type of document.

Parameters:
document - to retrieve type from.
Returns:
not null

setForce

public void setForce(boolean force)
Set the force flag on this appender. If this flag is set to true then files will be modified directly, otherwise new files will be created alongside the existing files.

Parameters:
force - force flag.

getLicenceHeader

public abstract String getLicenceHeader(File document)
Parameters:
document - document to extract from.
Returns:
Get the licence header of a document.

getFirstLine

protected String getFirstLine(int type)
Get the first line of the licence header formatted for the given type of file.

Parameters:
type - the type of file, see the TYPE_* constants
Returns:
not null

getLastLine

protected String getLastLine(int type)
Get the last line of the licence header formatted for the given type of file.

Parameters:
type - the type of file, see the TYPE_* constants
Returns:
not null

getLine

protected String getLine(int type,
                         String content)
Get a line of the licence header formatted for the given type of file.

Parameters:
type - the type of file, see the TYPE_* constants
content - the content for this line
Returns:
not null


Copyright © 2006–2014 Apache Software Foundation. All rights reserved.