Class License

  • All Implemented Interfaces:
    java.lang.Cloneable

    public class License
    extends org.apache.tools.ant.types.DataType
    A license element to be attached to a component.

    Licenses are required to have an id or a name attribute. Due to Ant's own usage of the id attribute the SBOM id of the license is called licenseId here.

    The CycloneDX specification supports more information for a license than this type currently exposes.

    This class is a type exposed by this Ant Library. When using the inherited refid attribute it can reference an instance defined previously - in which case no child elements or other attributes are allowed.

    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.util.Comparator<org.cyclonedx.model.LicenseItem> CycloneDxLicenseItemComparator
      Comparator for CycloneDX License Items.
      • Fields inherited from class org.apache.tools.ant.types.DataType

        checked, ref
      • Fields inherited from class org.apache.tools.ant.ProjectComponent

        description, location, project
    • Constructor Summary

      Constructors 
      Constructor Description
      License()  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addConfiguredUrl​(org.apache.tools.ant.types.resources.URLResource url)
      Sets the url of the license.
      static License from​(org.cyclonedx.model.LicenseItem licenseItem)
      Creates an instance of the License class based on a CylconeDX LicenseItem.
      protected License getRef()
      Perform the check for circular references and return the referenced License.
      void setExpression​(java.lang.String expression)
      Sets the SPDX license expression of the license.
      void setLicenseId​(java.lang.String id)
      Sets the id of the license.
      void setName​(java.lang.String name)
      Sets the name of the license.
      org.cyclonedx.model.LicenseItem toCycloneDxLicenseItem()
      Maps the license to its CycloneDX counterpart.
      • Methods inherited from class org.apache.tools.ant.types.DataType

        checkAttributesAllowed, checkChildrenAllowed, circularReference, clone, dieOnCircularReference, dieOnCircularReference, dieOnCircularReference, getCheckedRef, getCheckedRef, getCheckedRef, getCheckedRef, getCheckedRef, getDataTypeName, getRefid, invokeCircularReferenceCheck, isChecked, isReference, noChildrenAllowed, pushAndInvokeCircularReferenceCheck, setChecked, setRefid, tooManyAttributes, toString
      • Methods inherited from class org.apache.tools.ant.ProjectComponent

        getDescription, getLocation, getProject, log, log, setDescription, setLocation, setProject
      • Methods inherited from class java.lang.Object

        equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • CycloneDxLicenseItemComparator

        public static final java.util.Comparator<org.cyclonedx.model.LicenseItem> CycloneDxLicenseItemComparator
        Comparator for CycloneDX License Items.

        Sorts licenses by id falling back to id before license expressions which are sorted by expression value.

        Since:
        CycloneDX Antlib 0.2
    • Constructor Detail

      • License

        public License()
    • Method Detail

      • setLicenseId

        public void setLicenseId​(java.lang.String id)
        Sets the id of the license.

        Must be a valid SPDX identifier. This library doesn't enforce the SPDX identifier but the CycloneDX Core library does.

        Parameters:
        id - SPDX id of license
      • setName

        public void setName​(java.lang.String name)
        Sets the name of the license.
        Parameters:
        name - license name
      • setExpression

        public void setExpression​(java.lang.String expression)
        Sets the SPDX license expression of the license.
        Parameters:
        expression - license expression
        Since:
        CycloneDX Antlib 0.2
      • addConfiguredUrl

        public void addConfiguredUrl​(org.apache.tools.ant.types.resources.URLResource url)
        Sets the url of the license.

        Even though this is a nested element of the license element, at most one child is allowed.

        Parameters:
        url - url of license
      • toCycloneDxLicenseItem

        public org.cyclonedx.model.LicenseItem toCycloneDxLicenseItem()
        Maps the license to its CycloneDX counterpart.
        Returns:
        CycloneDX version of this instance
      • from

        public static License from​(org.cyclonedx.model.LicenseItem licenseItem)
        Creates an instance of the License class based on a CylconeDX LicenseItem.
        Parameters:
        licenseItem - CycloneDX LicenseItem to tranlate
        Returns:
        mapped License instance
        Since:
        CycloneDX Antlib 0.2
      • getRef

        protected License getRef()
        Perform the check for circular references and return the referenced License.
        Returns:
        License.