Class SpdxToolsHelper

java.lang.Object
org.spdx.tools.SpdxToolsHelper

public class SpdxToolsHelper
extends Object
Static helper methods for the various tools
Author:
Gary O'Neall
  • Constructor Details

  • Method Details

    • fileTypeToStore

      public static org.spdx.storage.ISerializableModelStore fileTypeToStore​(SpdxToolsHelper.SerFileType fileType) throws org.spdx.library.InvalidSPDXAnalysisException
      Parameters:
      fileType - file type for the store
      Returns:
      the appropriate in memory based model store which supports serialization for the fileType
      Throws:
      org.spdx.library.InvalidSPDXAnalysisException
    • fileToFileType

      public static SpdxToolsHelper.SerFileType fileToFileType​(File file) throws InvalidFileNameException
      Parameters:
      file -
      Returns:
      the file type based on the file name and file extension
      Throws:
      InvalidFileNameException
    • strToFileType

      public static SpdxToolsHelper.SerFileType strToFileType​(String str)
      Parameters:
      str -
      Returns:
      the file type based on the file extension or string
    • deserializeDocument

      public static org.spdx.library.model.SpdxDocument deserializeDocument​(File file) throws org.spdx.library.InvalidSPDXAnalysisException, IOException, InvalidFileNameException
      Parameters:
      file - file containing an SPDX document with the standard file extension for the serialization formats
      Returns:
      the SPDX document stored in the file
      Throws:
      org.spdx.library.InvalidSPDXAnalysisException
      IOException
      InvalidFileNameException
    • deserializeDocument

      public static org.spdx.library.model.SpdxDocument deserializeDocument​(File file, SpdxToolsHelper.SerFileType fileType) throws org.spdx.library.InvalidSPDXAnalysisException, IOException
      Parameters:
      file - file containing an SPDX document in one of the supported SerFileTypes
      fileType - serialization file type
      Returns:
      the SPDX document stored in the file
      Throws:
      org.spdx.library.InvalidSPDXAnalysisException
      IOException
    • readDocumentFromFile

      public static org.spdx.library.model.SpdxDocument readDocumentFromFile​(org.spdx.storage.ISerializableModelStore store, File file) throws FileNotFoundException, IOException, org.spdx.library.InvalidSPDXAnalysisException
      Reads an SPDX Document from a file
      Parameters:
      store - Store where the document is to be stored
      file - File to read the store from
      Returns:
      SPDX Document from the store
      Throws:
      FileNotFoundException - If the file is not found
      IOException - If there is an error reading the file
      org.spdx.library.InvalidSPDXAnalysisException - If there is a problem in the SPDX document structure