Class Header
- java.lang.Object
-
- com.mycila.maven.plugin.license.header.Header
-
public final class Header extends Object
TheHeaderclass wraps the license template file, the one which have to be outputted inside the other files.
-
-
Constructor Summary
Constructors Constructor Description Header(HeaderSource location, HeaderSection[] sections)Constructs aHeaderobject pointing to a license template file.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description StringapplyDefinitionAndSections(HeaderDefinition headerDefinition, boolean unix)StringasOneLineString()StringasString()StringbuildForDefinition(HeaderDefinition type, boolean unix)Stringeol(boolean unix)intgetLineCount()String[]getLines()HeaderSourcegetLocation()Returns the location of license template file.intgetMaxLineLength()booleanisMatchForText(Document d, HeaderDefinition headerDefinition, boolean unix, String encoding)booleanisMatchForText(String potentialFileHeader, HeaderDefinition headerDefinition, boolean unix)Determines if a potential file header (typically, the start of the file plus some buffer space) matches this header, as rendered with the specifiedHeaderDefinitionand line-ending.booleanisMatchForText(String expected, String potentialFileHeader, HeaderDefinition headerDefinition, boolean unix)StringtoString()
-
-
-
Constructor Detail
-
Header
public Header(HeaderSource location, HeaderSection[] sections)
Constructs aHeaderobject pointing to a license template file. In case of the template contains replaceable values (declared as ${valuename}), you can set the map of this values.- Parameters:
location- The license template file location.sections- Any applicable header sections for this header- Throws:
IllegalArgumentException- If the header file location is null or if an error occurred while reading the file content.
-
-
Method Detail
-
asString
public String asString()
-
asOneLineString
public String asOneLineString()
-
getLineCount
public int getLineCount()
-
getMaxLineLength
public int getMaxLineLength()
-
getLocation
public HeaderSource getLocation()
Returns the location of license template file.- Returns:
- The URL location.
-
eol
public String eol(boolean unix)
-
buildForDefinition
public String buildForDefinition(HeaderDefinition type, boolean unix)
-
getLines
public String[] getLines()
-
isMatchForText
public boolean isMatchForText(String potentialFileHeader, HeaderDefinition headerDefinition, boolean unix)
Determines if a potential file header (typically, the start of the file plus some buffer space) matches this header, as rendered with the specifiedHeaderDefinitionand line-ending.- Parameters:
potentialFileHeader- the potential file header, usually with some extra buffer linesheaderDefinition- the header definition to render the header withunix- if true, unix line-endings will be used- Returns:
- true if the header is matched
-
isMatchForText
public boolean isMatchForText(String expected, String potentialFileHeader, HeaderDefinition headerDefinition, boolean unix)
-
isMatchForText
public boolean isMatchForText(Document d, HeaderDefinition headerDefinition, boolean unix, String encoding) throws IOException
- Throws:
IOException
-
applyDefinitionAndSections
public String applyDefinitionAndSections(HeaderDefinition headerDefinition, boolean unix)
-
-