Class License
- java.lang.Object
-
- org.apache.tools.ant.ProjectComponent
-
- org.apache.tools.ant.types.DataType
-
- org.apache.ant.cyclonedx.License
-
- All Implemented Interfaces:
java.lang.Cloneable
public class License extends org.apache.tools.ant.types.DataTypeA 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
idattribute the SBOM id of the license is calledlicenseIdhere.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
refidattribute 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>CycloneDxLicenseItemComparatorComparator for CycloneDX License Items.
-
Constructor Summary
Constructors Constructor Description License()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddConfiguredUrl(org.apache.tools.ant.types.resources.URLResource url)Sets the url of the license.static Licensefrom(org.cyclonedx.model.LicenseItem licenseItem)Creates an instance of the License class based on a CylconeDX LicenseItem.protected LicensegetRef()Perform the check for circular references and return the referenced License.voidsetExpression(java.lang.String expression)Sets the SPDX license expression of the license.voidsetLicenseId(java.lang.String id)Sets theidof the license.voidsetName(java.lang.String name)Sets the name of the license.org.cyclonedx.model.LicenseItemtoCycloneDxLicenseItem()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
-
-
-
-
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
-
-
Method Detail
-
setLicenseId
public void setLicenseId(java.lang.String id)
Sets theidof 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.
-
-