Package org.spdx.tools
Class SpdxToolsHelper
java.lang.Object
org.spdx.tools.SpdxToolsHelper
Static helper methods for the various tools
- Author:
- Gary O'Neall
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumSupported serialization file types -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic org.spdx.library.model.v3_0_1.core.SpdxDocumentdeserializeDocument(File file, SpdxToolsHelper.SerFileType fileType) Deserializes an SPDX document from a filestatic org.spdx.library.model.v3_0_1.core.SpdxDocumentDeserializes an SPDX document from a filestatic org.spdx.library.model.v2.SpdxDocumentDeserializes an SPDX document from a file, compatible with SPDX version 2static org.spdx.library.model.v2.SpdxDocumentdeserializeDocumentCompatV2(File file, SpdxToolsHelper.SerFileType fileType) Deserializes an SPDX document from a file, compatible with SPDX version 2static voiddeserializeFile(org.spdx.storage.ISerializableModelStore store, File file) Reads SPDX data from a file and stores it in the storestatic SpdxToolsHelper.SerFileTypefileToFileType(File file) Determine the file type based on the file name and extensionstatic org.spdx.storage.ISerializableModelStorefileTypeToStore(SpdxToolsHelper.SerFileType fileType) Determine the appropriate in memory based model store which supports serialization for the fileTypestatic org.spdx.library.model.v3_0_1.core.SpdxDocumentgetDocFromStore(org.spdx.storage.ISerializableModelStore store) Gets an SPDX document from the model storestatic org.spdx.library.model.v2.SpdxDocumentgetDocFromStoreCompatV2(org.spdx.storage.ISerializableModelStore store) Gets an SPDX document from the model store, compatible with SPDX version 2static voidInitializes the model registry and default model storesstatic org.spdx.core.CoreModelObjectreadDocumentFromFile(org.spdx.storage.ISerializableModelStore store, File file) Reads an SPDX Document from a filestatic org.spdx.library.model.v2.SpdxDocumentreadDocumentFromFileCompatV2(org.spdx.storage.ISerializableModelStore store, File file) Reads an SPDX Document from a file, compatible with SPDX version 2static org.spdx.library.model.v3_0_1.core.SpdxDocumentreadDocumentFromFileV3(org.spdx.storage.ISerializableModelStore store, File file) Reads an SPDX Document from a filestatic SpdxToolsHelper.SerFileTypestrToFileType(String str) Determine the file type based on the file extension or stringstatic booleansupportsV2(org.spdx.storage.ISerializableModelStore store) Is the store supporting SPDX version 2static booleansupportsV3(org.spdx.storage.ISerializableModelStore store) Is the store supporting SPDX version 3
-
Constructor Details
-
SpdxToolsHelper
public SpdxToolsHelper()
-
-
Method Details
-
fileTypeToStore
public static org.spdx.storage.ISerializableModelStore fileTypeToStore(SpdxToolsHelper.SerFileType fileType) throws org.spdx.core.InvalidSPDXAnalysisException Determine the appropriate in memory based model store which supports serialization for the fileType- Parameters:
fileType- file type for the store- Returns:
- the appropriate in memory based model store which supports serialization for the fileType
- Throws:
org.spdx.core.InvalidSPDXAnalysisException
-
fileToFileType
Determine the file type based on the file name and extension- Parameters:
file-- Returns:
- the file type based on the file name and file extension
- Throws:
InvalidFileNameException
-
strToFileType
Determine the file type based on the file extension or string- Parameters:
str-- Returns:
- the file type based on the file extension or string
-
deserializeDocumentCompatV2
public static org.spdx.library.model.v2.SpdxDocument deserializeDocumentCompatV2(File file) throws org.spdx.core.InvalidSPDXAnalysisException, IOException, InvalidFileNameException Deserializes an SPDX document from a file, compatible with SPDX version 2- 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.core.InvalidSPDXAnalysisExceptionIOExceptionInvalidFileNameException
-
deserializeDocumentCompatV2
public static org.spdx.library.model.v2.SpdxDocument deserializeDocumentCompatV2(File file, SpdxToolsHelper.SerFileType fileType) throws org.spdx.core.InvalidSPDXAnalysisException, IOException Deserializes an SPDX document from a file, compatible with SPDX version 2- Parameters:
file- file containing an SPDX document in one of the supported SerFileTypesfileType- serialization file type- Returns:
- the SPDX document stored in the file
- Throws:
org.spdx.core.InvalidSPDXAnalysisExceptionIOException
-
deserializeDocumentCompat
public static org.spdx.library.model.v3_0_1.core.SpdxDocument deserializeDocumentCompat(File file) throws org.spdx.core.InvalidSPDXAnalysisException, IOException, InvalidFileNameException Deserializes an SPDX document from a file- 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.core.InvalidSPDXAnalysisExceptionIOExceptionInvalidFileNameException
-
deserializeDocument
public static org.spdx.library.model.v3_0_1.core.SpdxDocument deserializeDocument(File file, SpdxToolsHelper.SerFileType fileType) throws org.spdx.core.InvalidSPDXAnalysisException, IOException Deserializes an SPDX document from a file- Parameters:
file- file containing an SPDX document in one of the supported SerFileTypesfileType- serialization file type- Returns:
- the SPDX document stored in the file
- Throws:
org.spdx.core.InvalidSPDXAnalysisExceptionIOException
-
deserializeFile
public static void deserializeFile(org.spdx.storage.ISerializableModelStore store, File file) throws FileNotFoundException, IOException, org.spdx.core.InvalidSPDXAnalysisException Reads SPDX data from a file and stores it in the store- Parameters:
store- Store where the SPDX data is to be storedfile- File to read the store from- Throws:
FileNotFoundException- If the file is not foundIOException- If there is an error reading the fileorg.spdx.core.InvalidSPDXAnalysisException- If there is a problem in the SPDX document structure
-
supportsV3
public static boolean supportsV3(org.spdx.storage.ISerializableModelStore store) Is the store supporting SPDX version 3- Parameters:
store- model store- Returns:
- true of the model store support SPDX spec version 3
-
supportsV2
public static boolean supportsV2(org.spdx.storage.ISerializableModelStore store) Is the store supporting SPDX version 2- Parameters:
store- model store- Returns:
- true of the model store support SPDX spec version 2
-
readDocumentFromFileV3
public static org.spdx.library.model.v3_0_1.core.SpdxDocument readDocumentFromFileV3(org.spdx.storage.ISerializableModelStore store, File file) throws FileNotFoundException, IOException, org.spdx.core.InvalidSPDXAnalysisException Reads an SPDX Document from a file- Parameters:
store- Store where the document is to be storedfile- File to read the store from- Returns:
- SPDX Document from the store
- Throws:
FileNotFoundException- If the file is not foundIOException- If there is an error reading the fileorg.spdx.core.InvalidSPDXAnalysisException- If there is a problem in the SPDX document structure
-
readDocumentFromFile
public static org.spdx.core.CoreModelObject readDocumentFromFile(org.spdx.storage.ISerializableModelStore store, File file) throws FileNotFoundException, IOException, org.spdx.core.InvalidSPDXAnalysisException Reads an SPDX Document from a file- Parameters:
store- Store where the document is to be storedfile- File to read the store from- Returns:
- SPDX Document from the store
- Throws:
FileNotFoundException- If the file is not foundIOException- If there is an error reading the fileorg.spdx.core.InvalidSPDXAnalysisException- If there is a problem in the SPDX document structure
-
readDocumentFromFileCompatV2
public static org.spdx.library.model.v2.SpdxDocument readDocumentFromFileCompatV2(org.spdx.storage.ISerializableModelStore store, File file) throws FileNotFoundException, IOException, org.spdx.core.InvalidSPDXAnalysisException Reads an SPDX Document from a file, compatible with SPDX version 2- Parameters:
store- Store where the document is to be storedfile- File to read the store from- Returns:
- SPDX Document from the store
- Throws:
FileNotFoundException- If the file is not foundIOException- If there is an error reading the fileorg.spdx.core.InvalidSPDXAnalysisException- If there is a problem in the SPDX document structure
-
getDocFromStore
public static org.spdx.library.model.v3_0_1.core.SpdxDocument getDocFromStore(org.spdx.storage.ISerializableModelStore store) throws org.spdx.core.InvalidSPDXAnalysisException Gets an SPDX document from the model store- Parameters:
store- model store- Returns:
- returns a document if a single document is found in the model store
- Throws:
org.spdx.core.InvalidSPDXAnalysisException
-
getDocFromStoreCompatV2
public static org.spdx.library.model.v2.SpdxDocument getDocFromStoreCompatV2(org.spdx.storage.ISerializableModelStore store) throws org.spdx.core.InvalidSPDXAnalysisException Gets an SPDX document from the model store, compatible with SPDX version 2- Parameters:
store- model store- Returns:
- returns a document if a single document is found in the model store
- Throws:
org.spdx.core.InvalidSPDXAnalysisException
-
initialize
public static void initialize()Initializes the model registry and default model stores
-