Class SpdxModelFactory
java.lang.Object
org.spdx.library.SpdxModelFactory
Main entrypoint for the SPDX Java Library
This is a static class used to manage the different versions of the SPDX spec by creating different model classes based on the version of the spec.
Since the release of the SPDX spec version 3.0, the Java classes were generated.
Each generated set of classes generated for a specific version are in a separate library / Jar file.
These generated classes are registered in the Core model registry
The inflateModelObject methods will create an initial object based on the name of the type
- Author:
- Gary O'Neall
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic ObjectgetExternalElement(org.spdx.storage.IModelStore store, String uri, org.spdx.core.IModelCopyManager copyManager, Class<?> type) static ObjectgetExternalElement(org.spdx.storage.IModelStore store, String uri, org.spdx.core.IModelCopyManager copyManager, Class<?> type, String specVersion) static Stringstatic Stream<?> getSpdxObjects(org.spdx.storage.IModelStore store, org.spdx.core.IModelCopyManager copyManager, String typeFilter, String objectUriPrefixFilter, String idPrefix) static org.spdx.core.CoreModelObjectinflateModelObject(org.spdx.storage.IModelStore modelStore, String objectUri, String type, org.spdx.core.IModelCopyManager copyManager, boolean create, String idPrefix) For the most recent spec version supported: If the object exists in the model store, it will be "inflated" back to the Java object.static org.spdx.core.CoreModelObjectinflateModelObject(org.spdx.storage.IModelStore modelStore, String objectUri, String type, org.spdx.core.IModelCopyManager copyManager, String specVersion, boolean create, String idPrefix) If the object exists in the model store, it will be "inflated" back to the Java object.static voidinit()This static method is a convenience to load this class and initialize the supported model versions and initialize the DefaultModelStore with default valuesstatic Enum<?> Converts a URI to enum for the latest supported version of the specstatic Enum<?> Converts a URI to enum
-
Field Details
-
IMPLEMENTATION_VERSION
- See Also:
-
-
Method Details
-
getLatestSpecVersion
- Returns:
- the latest version of the spec supported by the library
-
init
public static void init()This static method is a convenience to load this class and initialize the supported model versions and initialize the DefaultModelStore with default valuesIt should be called before using any other functionality from the library
-
inflateModelObject
public static org.spdx.core.CoreModelObject inflateModelObject(org.spdx.storage.IModelStore modelStore, String objectUri, String type, org.spdx.core.IModelCopyManager copyManager, String specVersion, boolean create, @Nullable String idPrefix) throws org.spdx.core.InvalidSPDXAnalysisException If the object exists in the model store, it will be "inflated" back to the Java object. If the object does not exist AND the create parameter is true, a new object will be created and its inflated form will be returned- Parameters:
modelStore- store to use for the inflated objectobjectUri- URI of the element or SPDX objecttype- Type of the object to createcopyManager- if non-null, implicitly copy any referenced properties from other model storesspecVersion- version of the SPDX spec the object complies withcreate- if true, create the model object ONLY if it does not already existidPrefix- optional prefix used for any new object URI's created in support of this model object- Returns:
- model object of type type
- Throws:
org.spdx.core.InvalidSPDXAnalysisException- on SPDX parsing errors
-
inflateModelObject
public static org.spdx.core.CoreModelObject inflateModelObject(org.spdx.storage.IModelStore modelStore, String objectUri, String type, org.spdx.core.IModelCopyManager copyManager, boolean create, @Nullable String idPrefix) throws org.spdx.core.InvalidSPDXAnalysisException For the most recent spec version supported: If the object exists in the model store, it will be "inflated" back to the Java object. If the object does not exist AND the create parameter is true, a new object will be created and its inflated form will be returned- Parameters:
modelStore- store to use for the inflated objectobjectUri- URI of the external elementtype- Type of the object to createcopyManager- if non-null, implicitly copy any referenced properties from other model storescreate- if true, create the model object ONLY if it does not already existidPrefix- optional prefix used for any new object URI's created in support of this model object- Returns:
- model object of type type
- Throws:
org.spdx.core.InvalidSPDXAnalysisException- on SPDX parsing errors
-
getExternalElement
public static Object getExternalElement(org.spdx.storage.IModelStore store, String uri, @Nullable org.spdx.core.IModelCopyManager copyManager, Class<?> type, String specVersion) throws org.spdx.core.InvalidSPDXAnalysisException - Parameters:
store- store to use for the inflated objecturi- URI of the external elementcopyManager- if non-null, implicitly copy any referenced properties from other model storestype- type hint for creating the correct external elementspecVersion- version of the SPDX spec the object complies with- Returns:
- a java object representing an SPDX element external to model store, collection or document
- Throws:
org.spdx.core.InvalidSPDXAnalysisException- on SPDX parsing errors
-
getExternalElement
public static Object getExternalElement(org.spdx.storage.IModelStore store, String uri, @Nullable org.spdx.core.IModelCopyManager copyManager, Class<?> type) throws org.spdx.core.InvalidSPDXAnalysisException - Parameters:
store- store to use for the inflated objecturi- URI of the external elementcopyManager- if non-null, implicitly copy any referenced properties from other model storestype- type hint for creating the correct external element- Returns:
- a java object representing an SPDX element external to model store, collection or document for the most recent version of the spec supported
- Throws:
org.spdx.core.InvalidSPDXAnalysisException- on SPDX parsing errors
-
uriToEnum
@Nullable public static Enum<?> uriToEnum(String uri, String specVersion) throws org.spdx.core.ModelRegistryException Converts a URI to enum- Parameters:
uri- URI for the Enum individualspecVersion- Version of the spec the enum belongs to- Returns:
- the Enum represented by the individualURI if it exists within the spec model
- Throws:
org.spdx.core.ModelRegistryException- if the spec version does not exist
-
uriToEnum
Converts a URI to enum for the latest supported version of the spec- Parameters:
uri- URI for the Enum individual- Returns:
- the Enum represented by the individualURI if it exists within the spec model
- Throws:
org.spdx.core.ModelRegistryException- if the spec version does not exist
-
getSpdxObjects
public static Stream<?> getSpdxObjects(org.spdx.storage.IModelStore store, @Nullable org.spdx.core.IModelCopyManager copyManager, @Nullable String typeFilter, @Nullable String objectUriPrefixFilter, @Nullable String idPrefix) throws org.spdx.core.InvalidSPDXAnalysisException - Parameters:
store- model storecopyManager- optional copy managertypeFilter- type to filter onobjectUriPrefixFilter- only return objects with URI's starting with this stringidPrefix- optional prefix used for any new object URI's created in support of this model object- Returns:
- stream of objects stored in the model store - an object being any non-primitive type
- Throws:
org.spdx.core.InvalidSPDXAnalysisException- on SPDX parsing errors
-