Package org.spdx.rdfparser.license
Class LicenseInfoFactory
java.lang.Object
org.spdx.rdfparser.license.LicenseInfoFactory
public class LicenseInfoFactory extends Object
Factory for creating SPDXLicenseInfo objects from a Jena model
- Author:
- Gary O'Neall
-
Field Summary
Fields Modifier and Type Field Description static StringNOASSERTION_LICENSE_NAMEstatic StringNONE_LICENSE_NAME -
Constructor Summary
Constructors Constructor Description LicenseInfoFactory() -
Method Summary
Modifier and Type Method Description static AnyLicenseInfogetLicenseInfoFromModel(IModelContainer modelContainer, org.apache.jena.graph.Node node)Create the appropriate SPDXLicenseInfo from the model and node provided.static StringgetLicenseListVersion()static LicenseExceptiongetListedExceptionById(String id)static SpdxListedLicensegetListedLicenseById(String licenseId)static String[]getSpdxListedLicenseIds()static booleanisSPdxListedExceptionID(String id)static booleanisSpdxListedLicenseID(String licenseID)static AnyLicenseInfoparseSPDXLicenseString(String licenseString)Parses a license string and converts it into a SPDXLicenseInfo object Syntax - A license set must start and end with a parenthesis "(" A conjunctive license set will have and AND after the first licenseInfo term A disjunctive license set will have an OR after the first licenseInfo term If there is no And or Or, then it is converted to a simple license type A space or tab must be used between license ID's and the keywords AND and OR A licenseID must NOT be "AND" or "OR"static AnyLicenseInfoparseSPDXLicenseString(String licenseString, SpdxDocumentContainer container)Parses a license string and converts it into a SPDXLicenseInfo object Syntax - A license set must start and end with a parenthesis "(" A conjunctive license set will have and AND after the first licenseInfo term A disjunctive license set will have an OR after the first licenseInfo term If there is no And or Or, then it is converted to a simple license type A space or tab must be used between license ID's and the keywords AND and OR A licenseID must NOT be "AND" or "OR"
-
Field Details
-
NOASSERTION_LICENSE_NAME
- See Also:
- Constant Field Values
-
NONE_LICENSE_NAME
- See Also:
- Constant Field Values
-
-
Constructor Details
-
LicenseInfoFactory
public LicenseInfoFactory()
-
-
Method Details
-
getLicenseInfoFromModel
public static AnyLicenseInfo getLicenseInfoFromModel(IModelContainer modelContainer, org.apache.jena.graph.Node node) throws InvalidSPDXAnalysisExceptionCreate the appropriate SPDXLicenseInfo from the model and node provided. The appropriate SPDXLicenseInfo subclass object will be chosen based on the class (rdf type) of the node. If there is no rdf type, then the license ID is parsed to determine the type- Parameters:
modelContainer-node-- Returns:
- Throws:
InvalidSPDXAnalysisException
-
getListedLicenseById
public static SpdxListedLicense getListedLicenseById(String licenseId) throws InvalidSPDXAnalysisException- Parameters:
licenseId- SPDX Listed License ID- Returns:
- SPDX listed license or null if the ID is not in the SPDX license list
- Throws:
InvalidSPDXAnalysisException
-
parseSPDXLicenseString
public static AnyLicenseInfo parseSPDXLicenseString(String licenseString, SpdxDocumentContainer container) throws InvalidLicenseStringExceptionParses a license string and converts it into a SPDXLicenseInfo object Syntax - A license set must start and end with a parenthesis "(" A conjunctive license set will have and AND after the first licenseInfo term A disjunctive license set will have an OR after the first licenseInfo term If there is no And or Or, then it is converted to a simple license type A space or tab must be used between license ID's and the keywords AND and OR A licenseID must NOT be "AND" or "OR"- Parameters:
licenseString- String conforming to the syntaxcontainer- Container containing any extractedLicenseInfos - if any extractedLicenseInfos by ID already exist, they will be used. If none exist for an ID, they will be added. If null, a simple Java object will be created for the extractedLicenseInfo.- Returns:
- an SPDXLicenseInfo created from the string
- Throws:
InvalidLicenseStringException
-
parseSPDXLicenseString
public static AnyLicenseInfo parseSPDXLicenseString(String licenseString) throws InvalidLicenseStringExceptionParses a license string and converts it into a SPDXLicenseInfo object Syntax - A license set must start and end with a parenthesis "(" A conjunctive license set will have and AND after the first licenseInfo term A disjunctive license set will have an OR after the first licenseInfo term If there is no And or Or, then it is converted to a simple license type A space or tab must be used between license ID's and the keywords AND and OR A licenseID must NOT be "AND" or "OR"- Parameters:
licenseString- String conforming to the syntax- Returns:
- an SPDXLicenseInfo created from the string
- Throws:
InvalidLicenseStringException
-
isSpdxListedLicenseID
- Parameters:
licenseID-- Returns:
- true if the licenseID belongs to an SPDX listed license
- Throws:
InvalidSPDXAnalysisException
-
getSpdxListedLicenseIds
- Returns:
- Array of all SPDX listed license IDs
-
getLicenseListVersion
- Returns:
- Version of the license list being used by the SPDXLicenseInfoFactory
-
isSPdxListedExceptionID
- Parameters:
id- exception ID- Returns:
- true if the exception ID is a supported SPDX listed exception
-
getListedExceptionById
public static LicenseException getListedExceptionById(String id) throws InvalidSPDXAnalysisException- Parameters:
id-- Returns:
- the standard SPDX license exception or null if the ID is not in the SPDX license list
- Throws:
InvalidSPDXAnalysisException
-