Package org.cyclonedx.util
Class LicenseResolver
- java.lang.Object
-
- org.cyclonedx.util.LicenseResolver
-
public final class LicenseResolver extends java.lang.Object
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static classLicenseResolver.LicenseDetailstatic classLicenseResolver.LicenseEncodingLists possible choices for license text encodingprivate static classLicenseResolver.LicenseListstatic classLicenseResolver.LicenseTextSettingsData class aggregating settings for license text outputprivate static classLicenseResolver.SpdxLicenseMapping
-
Field Summary
Fields Modifier and Type Field Description private static LicenseResolver.LicenseListlicenses
-
Constructor Summary
Constructors Modifier Constructor Description privateLicenseResolver()Private constructor.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description private static LicenseChoicecreateLicenseChoice(java.lang.String licenseId, java.lang.String primaryLicenseUrl, boolean isDeprecatedLicenseId, LicenseResolver.LicenseTextSettings licenseTextSettings)static LicenseChoiceresolve(java.lang.String licenseString)Attempts to resolve the specified license string via SPDX license identifier and expression parsing first.static LicenseChoiceresolve(java.lang.String licenseString, boolean includeLicenseText)Attempts to resolve the specified license string via SPDX license identifier and expression parsing first.(package private) static LicenseChoiceresolve(java.lang.String licenseString, boolean includeLicenseText, com.fasterxml.jackson.databind.ObjectMapper mapper)static LicenseChoiceresolve(java.lang.String licenseString, LicenseResolver.LicenseTextSettings licenseTextSettings)Attempts to resolve the specified license string via SPDX license identifier and expression parsing first.(package private) static LicenseChoiceresolve(java.lang.String licenseString, LicenseResolver.LicenseTextSettings licenseTextSettings, com.fasterxml.jackson.databind.ObjectMapper mapper)private static LicenseChoiceresolveFuzzyMatching(java.lang.String licenseString, LicenseResolver.LicenseTextSettings licenseTextSettings, com.fasterxml.jackson.databind.ObjectMapper mapper)Attempts to perform high-confidence license resolution with unstructured text as input.private static LicenseChoiceresolveLicenseString(java.lang.String licenseString, LicenseResolver.LicenseTextSettings licenseTextSettings, com.fasterxml.jackson.databind.ObjectMapper mapper)Given an SPDX license ID or expression, this method will resolve the license(s) and return a LicenseChoice object.private static java.lang.StringurlNormalize(java.lang.String input)
-
-
-
Field Detail
-
licenses
private static LicenseResolver.LicenseList licenses
-
-
Method Detail
-
resolve
public static LicenseChoice resolve(java.lang.String licenseString)
Attempts to resolve the specified license string via SPDX license identifier and expression parsing first. If SPDX resolution is not successful, the method will attempt fuzzy matching.- Parameters:
licenseString- the license string to resolve- Returns:
- a LicenseChoice object if resolution was successful, or null if unresolved
-
resolve
public static LicenseChoice resolve(java.lang.String licenseString, boolean includeLicenseText)
Attempts to resolve the specified license string via SPDX license identifier and expression parsing first. If SPDX resolution is not successful, the method will attempt fuzzy matching.- Parameters:
licenseString- the license string to resolveincludeLicenseText- specifies is the resolved license will include the entire text of the license- Returns:
- a LicenseChoice object if resolution was successful, or null if unresolved
-
resolve
static LicenseChoice resolve(java.lang.String licenseString, boolean includeLicenseText, com.fasterxml.jackson.databind.ObjectMapper mapper)
-
resolve
public static LicenseChoice resolve(java.lang.String licenseString, LicenseResolver.LicenseTextSettings licenseTextSettings)
Attempts to resolve the specified license string via SPDX license identifier and expression parsing first. If SPDX resolution is not successful, the method will attempt fuzzy matching.- Parameters:
licenseString- the license string to resolvelicenseTextSettings- specifies settings regarding the entire text of the resolved license- Returns:
- a LicenseChoice object if resolution was successful, or null if unresolved
-
resolve
static LicenseChoice resolve(java.lang.String licenseString, LicenseResolver.LicenseTextSettings licenseTextSettings, com.fasterxml.jackson.databind.ObjectMapper mapper)
-
resolveLicenseString
private static LicenseChoice resolveLicenseString(java.lang.String licenseString, LicenseResolver.LicenseTextSettings licenseTextSettings, com.fasterxml.jackson.databind.ObjectMapper mapper) throws java.io.IOException
Given an SPDX license ID or expression, this method will resolve the license(s) and return a LicenseChoice object.- Parameters:
licenseString- the license string to resolvelicenseTextSettings- specifies settings regarding the entire text of the resolved licensemapper- is to provide a Jackson ObjectMapper- Returns:
- a LicenseChoice object if resolved, or null
- Throws:
java.io.IOException- an exception while parsing the license string
-
resolveFuzzyMatching
private static LicenseChoice resolveFuzzyMatching(java.lang.String licenseString, LicenseResolver.LicenseTextSettings licenseTextSettings, com.fasterxml.jackson.databind.ObjectMapper mapper) throws java.io.IOException
Attempts to perform high-confidence license resolution with unstructured text as input.- Parameters:
licenseString- the license string (not the actual license text)licenseTextSettings- specifies settings regarding the entire text of the resolved licensemapper- is to provide a Jackson ObjectMapper- Returns:
- a LicenseChoice object if resolved, otherwise null
- Throws:
java.io.IOException
-
urlNormalize
private static java.lang.String urlNormalize(java.lang.String input)
-
createLicenseChoice
private static LicenseChoice createLicenseChoice(java.lang.String licenseId, java.lang.String primaryLicenseUrl, boolean isDeprecatedLicenseId, LicenseResolver.LicenseTextSettings licenseTextSettings) throws java.io.IOException
- Throws:
java.io.IOException
-
-