Class MultiFormatStore

java.lang.Object
org.spdx.storage.simple.ExtendedSpdxStore
org.spdx.jacksonstore.MultiFormatStore
All Implemented Interfaces:
AutoCloseable, org.spdx.storage.IModelStore, org.spdx.storage.ISerializableModelStore

public class MultiFormatStore extends org.spdx.storage.simple.ExtendedSpdxStore implements org.spdx.storage.ISerializableModelStore
Model store that supports multiple serialization formats (JSON, XML, YAML)

Note that the serialization/deserialization methods are synchronized to prevent the format or verbose changing while serializing

Author:
Gary O'Neall
  • Constructor Details

    • MultiFormatStore

      public MultiFormatStore(org.spdx.storage.IModelStore baseStore, MultiFormatStore.Format format, MultiFormatStore.Verbose verbose)
      Parameters:
      baseStore - modelStore to store the results of the deserialization
      format - Format - XML, JSON or YAML
      verbose - How verbose to make the document
    • MultiFormatStore

      public MultiFormatStore(org.spdx.storage.IModelStore baseStore, MultiFormatStore.Format format)
      Default compact version of MultiFormatStore
      Parameters:
      baseStore - modelStore to store the results of the deserialization
      format - Format - XML, JSON or YAML
  • Method Details

    • getFormat

      public MultiFormatStore.Format getFormat()
      Returns:
      the format
    • setFormat

      public void setFormat(MultiFormatStore.Format format)
      Parameters:
      format - the format to set
    • getVerbose

      public MultiFormatStore.Verbose getVerbose()
      Returns:
      the verbose
    • setVerbose

      public void setVerbose(MultiFormatStore.Verbose verbose)
      Parameters:
      verbose - the verbose to set
    • serialize

      public void serialize(OutputStream stream) throws org.spdx.core.InvalidSPDXAnalysisException, IOException
      Specified by:
      serialize in interface org.spdx.storage.ISerializableModelStore
      Throws:
      org.spdx.core.InvalidSPDXAnalysisException
      IOException
    • serialize

      public void serialize(OutputStream stream, @Nullable org.spdx.core.CoreModelObject modelObject) throws org.spdx.core.InvalidSPDXAnalysisException, IOException
      Specified by:
      serialize in interface org.spdx.storage.ISerializableModelStore
      Throws:
      org.spdx.core.InvalidSPDXAnalysisException
      IOException
    • propertyNameToCollectionPropertyName

      public static String propertyNameToCollectionPropertyName(String propertyName)
      Parameters:
      propertyName - name of the singular property
      Returns:
      property name used for an array or collection of these values
    • collectionPropertyNameToPropertyName

      public static String collectionPropertyNameToPropertyName(String collectionPropertyName)
    • deSerialize

      public org.spdx.library.model.v2.SpdxDocument deSerialize(InputStream stream, boolean overwrite) throws org.spdx.core.InvalidSPDXAnalysisException, IOException
      Specified by:
      deSerialize in interface org.spdx.storage.ISerializableModelStore
      Throws:
      org.spdx.core.InvalidSPDXAnalysisException
      IOException
    • clear

      public void clear(String documentNamespace) throws org.spdx.core.InvalidSPDXAnalysisException
      Parameters:
      documentNamespace - Document namespace or Uri
      Throws:
      org.spdx.core.InvalidSPDXAnalysisException - on SPDX parsing errors
    • getDocumentUris

      public Set<String> getDocumentUris() throws org.spdx.core.InvalidSPDXAnalysisException
      Returns:
      set of SPDX V2 document URI's in this model store
      Throws:
      org.spdx.core.InvalidSPDXAnalysisException - on SPDX parsing errors