Package org.spdx.library.model
Class SpdxModelFactory
java.lang.Object
org.spdx.library.model.SpdxModelFactory
public class SpdxModelFactory extends Object
Factory class to create ModelObjects based on the type
Types are defined classes in the SpdxConstants class and map to the standard SPDX model
- Author:
- Gary O'Neall
-
Field Summary
Fields Modifier and Type Field Description static Map<Class<?>,String>SPDX_CLASS_TO_TYPEstatic Map<String,Class<?>>SPDX_TYPE_TO_CLASS -
Constructor Summary
Constructors Constructor Description SpdxModelFactory() -
Method Summary
Modifier and Type Method Description static Class<?>classUriToClass(String classUri)static ModelObjectcreateModelObject(IModelStore modelStore, String documentUri, String id, String type, ModelCopyManager copyManager)Create a model object in a model store given the document URI, ID and typestatic SpdxDocumentcreateSpdxDocument(IModelStore modelStore, String documentUri, ModelCopyManager copyManager)Create an SPDX document with default values for creator, created, licenseListVersion, data license and specVersionstatic Stream<?>getElements(IModelStore store, String documentUri, ModelCopyManager copyManager, Class<?> spdxClass)static ModelObjectgetModelObject(IModelStore modelStore, String documentUri, String id, String type, ModelCopyManager copyManager, boolean create)Create a model object in a model store given the document URI, ID and typestatic Optional<ModelObject>getModelObject(IModelStore modelStore, String documentUri, String id, ModelCopyManager copyManager)static Class<? extends Object>typeToClass(String type)
-
Field Details
-
Constructor Details
-
SpdxModelFactory
public SpdxModelFactory()
-
-
Method Details
-
createSpdxDocument
public static SpdxDocument createSpdxDocument(IModelStore modelStore, String documentUri, ModelCopyManager copyManager) throws InvalidSPDXAnalysisExceptionCreate an SPDX document with default values for creator, created, licenseListVersion, data license and specVersion- Parameters:
modelStore- Where to store the SPDX DocumentdocumentUri- unique URI for the SPDX documentcopyManager- if non-null, allows for copying of properties from other model stores or document URI's when referenced- Returns:
- Throws:
InvalidSPDXAnalysisException
-
createModelObject
public static ModelObject createModelObject(IModelStore modelStore, String documentUri, String id, String type, ModelCopyManager copyManager) throws InvalidSPDXAnalysisExceptionCreate a model object in a model store given the document URI, ID and type- Parameters:
modelStore- model store where the object is to be createddocumentUri- document URI for the stored itemid- ID for the itemtype- SPDX class or typecopyManager- if non-null, allows for copying of properties from other model stores or document URI's when referenced- Returns:
- a ModelObject of type type
- Throws:
InvalidSPDXAnalysisException
-
getModelObject
public static ModelObject getModelObject(IModelStore modelStore, String documentUri, String id, String type, ModelCopyManager copyManager, boolean create) throws InvalidSPDXAnalysisExceptionCreate a model object in a model store given the document URI, ID and type- Parameters:
modelStore- model store where the object is to be createddocumentUri- document URI for the stored itemid- ID for the itemtype- SPDX class or typecopyManager- if non-null, allows for copying of properties from other model stores or document URI's when referencedcreate- if true, create the model object if it does not already exist- Returns:
- a ModelObject of type type
- Throws:
InvalidSPDXAnalysisException
-
typeToClass
- Parameters:
type- SPDX Type- Returns:
- class associated with the type
- Throws:
InvalidSPDXAnalysisException
-
getElements
public static Stream<?> getElements(IModelStore store, String documentUri, ModelCopyManager copyManager, Class<?> spdxClass) throws InvalidSPDXAnalysisException- Throws:
InvalidSPDXAnalysisException
-
classUriToClass
- Parameters:
classUri- URI for the class type- Returns:
- class represented by the URI
- Throws:
InvalidSPDXAnalysisException
-
getModelObject
public static Optional<ModelObject> getModelObject(IModelStore modelStore, String documentUri, String id, @Nullable ModelCopyManager copyManager) throws InvalidSPDXAnalysisException- Parameters:
modelStore- Store for the modeldocumentUri- Document URI for for the IDcopyManager- Optional copy manager for copying any properties from other modelid- ID for the model object- Returns:
- ModelObject with the ID in the model store
- Throws:
InvalidSPDXAnalysisException
-