Class StringToList

java.lang.Object
org.codehaus.mojo.license.utils.StringToList
Direct Known Subclasses:
AbstractAddThirdPartyMojo.ExcludedLicenses, AbstractAddThirdPartyMojo.IncludedLicenses

public class StringToList extends Object
Object to convert in mojo a parameter from a some simple String to a List. See (http://jira.codehaus.org/browse/MLICENSE-53).
Since:
1.4
Author:
tchemit dev@tchemit.fr
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
    Regular expression to split license list with a pipe character: "|".
  • Constructor Summary

    Constructors
    Constructor
    Description
     
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected void
    Adds one license name, dropping the whitespace around it and ignoring it when there is nothing else left.
     
    static String[]
    trimmedStringSplit(String stringToSplit)
    Splits a String by the pipe character and trims it.
    It allows, for example, to write lengthy license merge lists not written as a 400 characters long, hard to read line, but as a list of lines separated by a pipe character.
    Example, instead of writing the following XML:

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • LIST_OF_LICENSES_REG_EX

      public static final String LIST_OF_LICENSES_REG_EX
      Regular expression to split license list with a pipe character: "|".
      See Also:
  • Constructor Details

    • StringToList

      public StringToList()
    • StringToList

      public StringToList(String data) throws org.apache.maven.plugin.MojoExecutionException
      Parameters:
      data - a list of licenses or a URL
      Throws:
      org.apache.maven.plugin.MojoExecutionException
  • Method Details

    • trimmedStringSplit

      public static String[] trimmedStringSplit(String stringToSplit)
      Splits a String by the pipe character and trims it.
      It allows, for example, to write lengthy license merge lists not written as a 400 characters long, hard to read line, but as a list of lines separated by a pipe character.
      Example, instead of writing the following XML:
      Righteous license 2.1|The righteous extra long named super rights granting license version 2.1|Hidden right license 2.1|The completely unfair "all your rights belong to us" license version 2.1
      
      write:
      Righteous license 2.1
          |The righteous extra long named super rights granting
           license version 2.1
          |Hidden right license 2.1
          |The completely unfair "all your rights belong to us"
           license version 2.1
      
      
      Parameters:
      stringToSplit - String to split.
      Returns:
      Split and trimmed string.
    • getData

      public List<String> getData()
    • addEntryToList

      protected void addEntryToList(String data)
      Adds one license name, dropping the whitespace around it and ignoring it when there is nothing else left.

      The names arrive straight out of the POM, so they carry whatever the XML formatter left behind. A list whose entries are long enough gets broken over several lines, either by hand or by a formatter:

      <includedLicenses>
        Apache License 2.0
        |MIT License
      </includedLicenses>
      
      Parameters:
      data - the license name