Package org.apache.rat.annotation
Class AbstractLicenseAppender
java.lang.Object
org.apache.rat.annotation.AbstractLicenseAppender
- Direct Known Subclasses:
ApacheV2LicenseAppender
Add a license header to a document. This appender does not check for the
existence of an existing license header, it is assumed that either a second
license header is intentional or that there is no license header present
already.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Append the default license header to the supplied document.protected String
getFirstLine(int type)
Get the first line of the license header formatted for the given type of file.protected String
getLastLine(int type)
Get the last line of the license header formatted for the given type of file.abstract String
getLicenseHeader(File document)
protected String
Get a line of the license header formatted for the given type of file.protected int
Detect the type of document.void
setForce(boolean force)
Set the force flag on this appender.
-
Constructor Details
-
AbstractLicenseAppender
Constructor- Parameters:
log
- The log to use.
-
-
Method Details
-
append
Append the default license 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
Detect the type of document.- Parameters:
document
- to retrieve type from.- Returns:
- not null TODO use existing mechanism to detect the type of a file and record it in the report output, thus we will not need this duplication here.
-
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.
-
getLicenseHeader
- Parameters:
document
- document to extract from.- Returns:
- Get the license header of a document.
-
getFirstLine
Get the first line of the license header formatted for the given type of file.- Parameters:
type
- the type of file, see the TYPE_* constants- Returns:
- not null
-
getLastLine
Get the last line of the license header formatted for the given type of file.- Parameters:
type
- the type of file, see the TYPE_* constants- Returns:
- not null
-
getLine
Get a line of the license header formatted for the given type of file.- Parameters:
type
- the type of file, see the TYPE_* constantscontent
- the content for this line- Returns:
- not null
-