Class SpdxModelFactoryCompatV2


  • public class SpdxModelFactoryCompatV2
    extends Object
    Factory class to create ModelObjects based on the type and SPDX Spec Version Types are defined classes in the SpdxConstantsCompatV2 class and map to the standard SPDX model
    Author:
    Gary O'Neall
    • Field Detail

      • SPDX_TYPE_TO_CLASS_V2

        public static Map<String,​Class<?>> SPDX_TYPE_TO_CLASS_V2
      • SPDX_CLASS_TO_TYPE

        public static Map<Class<?>,​String> SPDX_CLASS_TO_TYPE
    • Constructor Detail

      • SpdxModelFactoryCompatV2

        public SpdxModelFactoryCompatV2()
    • Method Detail

      • createSpdxDocumentV2

        public static SpdxDocument createSpdxDocumentV2​(org.spdx.storage.IModelStore modelStore,
                                                        String documentUri,
                                                        org.spdx.core.IModelCopyManager copyManager)
                                                 throws org.spdx.core.InvalidSPDXAnalysisException
        Create an SPDX version 2.X document with default values for creator, created, licenseListVersion, data license and specVersion
        Parameters:
        modelStore - Where to store the SPDX Document
        documentUri - unique URI for the SPDX document
        copyManager - if non-null, allows for copying of properties from other model stores or document URI's when referenced
        Returns:
        Throws:
        org.spdx.core.InvalidSPDXAnalysisException
      • createModelObjectV2

        public static ModelObjectV2 createModelObjectV2​(org.spdx.storage.IModelStore modelStore,
                                                        String documentUri,
                                                        String id,
                                                        String type,
                                                        org.spdx.core.IModelCopyManager copyManager)
                                                 throws org.spdx.core.InvalidSPDXAnalysisException
        Create an SPDX version 2 model object in a model store given the document URI, ID and type
        Parameters:
        modelStore - model store where the object is to be created
        documentUri - document URI for the stored item
        id - for the item
        type - SPDX class or type
        copyManager - if non-null, allows for copying of properties from other model stores or document URI's when referenced
        Returns:
        a ModelObjectV2 of type type
        Throws:
        org.spdx.core.InvalidSPDXAnalysisException
      • getModelObjectV2

        public static ModelObjectV2 getModelObjectV2​(org.spdx.storage.IModelStore modelStore,
                                                     String documentUri,
                                                     String id,
                                                     String type,
                                                     org.spdx.core.IModelCopyManager copyManager,
                                                     boolean create)
                                              throws org.spdx.core.InvalidSPDXAnalysisException
        Create an SPDX spec version 2.X model object in a model store given the document URI, ID and type
        Parameters:
        modelStore - model store where the object is to be created
        documentUri - document URI for the stored item
        id - ID for the item
        type - SPDX class or type
        copyManager - if non-null, allows for copying of properties from other model stores or document URI's when referenced
        create - if true, create the model object if it does not already exist
        Returns:
        a ModelObjectV2 of type type
        Throws:
        org.spdx.core.InvalidSPDXAnalysisException
      • getModelObjectV2

        public static Optional<ModelObjectV2> getModelObjectV2​(org.spdx.storage.IModelStore modelStore,
                                                               String documentUri,
                                                               String id,
                                                               @Nullable
                                                               org.spdx.core.IModelCopyManager copyManager)
                                                        throws org.spdx.core.InvalidSPDXAnalysisException
        Parameters:
        modelStore - Store for the SPDX Spec version 2 model
        documentUri - Document URI for for the ID
        copyManager - Optional copy manager for copying any properties from other model
        id - ID for the model object
        Returns:
        SPDX Version 2 compatible ModelObjectV2 with the ID in the model store
        Throws:
        org.spdx.core.InvalidSPDXAnalysisException
      • typeToClass

        public static Class<? extends Object> typeToClass​(String type)
                                                   throws org.spdx.core.InvalidSPDXAnalysisException
        Parameters:
        type - SPDX Type
        Returns:
        class associated with the type
        Throws:
        org.spdx.core.InvalidSPDXAnalysisException
      • classUriToClass

        public static Class<?> classUriToClass​(String classUri)
                                        throws org.spdx.core.InvalidSPDXAnalysisException
        Parameters:
        classUri - URI for the class type
        Returns:
        class represented by the URI
        Throws:
        org.spdx.core.InvalidSPDXAnalysisException