Class Header


  • public final class Header
    extends Object
    The Header class wraps the license template file, the one which have to be outputted inside the other files.
    • Constructor Detail

      • Header

        public Header​(HeaderSource location,
                      HeaderSection[] sections)
        Constructs a Header object 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)
      • 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 specified HeaderDefinition and line-ending.
        Parameters:
        potentialFileHeader - the potential file header, usually with some extra buffer lines
        headerDefinition - the header definition to render the header with
        unix - 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)
      • applyDefinitionAndSections

        public String applyDefinitionAndSections​(HeaderDefinition headerDefinition,
                                                 boolean unix)