Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 32 additions & 1 deletion src/main/java/org/spdx/tools/SpdxToolsHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@
*/
public class SpdxToolsHelper {

/**
* Supported serialization file types
*/
public enum SerFileType {
JSON, RDFXML, XML, XLS, XLSX, YAML, TAG, RDFTTL, JSONLD
}
Expand All @@ -84,6 +87,9 @@ public enum SerFileType {
}

/**
* Determine the appropriate in memory based model store which supports
* serialization for the fileType
*
* @param fileType
* file type for the store
* @return the appropriate in memory based model store which supports
Expand Down Expand Up @@ -129,6 +135,8 @@ public static ISerializableModelStore fileTypeToStore(SerFileType fileType)
}

/**
* Determine the file type based on the file name and extension
*
* @param file
* @return the file type based on the file name and file extension
* @throws InvalidFileNameException
Expand Down Expand Up @@ -188,6 +196,8 @@ public static SerFileType fileToFileType(File file)
}

/**
* Determine the file type based on the file extension or string
*
* @param str
* @return the file type based on the file extension or string
*/
Expand All @@ -197,6 +207,9 @@ public static SerFileType strToFileType(String str) {
}

/**
* Deserializes an SPDX document from a file,
* compatible with SPDX version 2
*
* @param file
* file containing an SPDX document with the standard file
* extension for the serialization formats
Expand All @@ -215,6 +228,9 @@ public static SpdxDocument deserializeDocumentCompatV2(File file)
return readDocumentFromFileCompatV2(store, file);
}
/**
* Deserializes an SPDX document from a file,
* compatible with SPDX version 2
*
* @param file
* file containing an SPDX document in one of the supported
* SerFileTypes
Expand All @@ -235,6 +251,8 @@ public static SpdxDocument deserializeDocumentCompatV2(File file,
}

/**
* Deserializes an SPDX document from a file
*
* @param file
* file containing an SPDX document with the standard file
* extension for the serialization formats
Expand All @@ -253,6 +271,8 @@ public static org.spdx.library.model.v3_0_1.core.SpdxDocument deserializeDocumen
return readDocumentFromFileV3(store, file);
}
/**
* Deserializes an SPDX document from a file
*
* @param file
* file containing an SPDX document in one of the supported
* SerFileTypes
Expand Down Expand Up @@ -308,6 +328,8 @@ public static void deserializeFile(ISerializableModelStore store, File file) thr
}

/**
* Is the store supporting SPDX version 3
*
* @param store model store
* @return true of the model store support SPDX spec version 3
*/
Expand All @@ -316,6 +338,8 @@ public static boolean supportsV3(ISerializableModelStore store) {
}

/**
* Is the store supporting SPDX version 2
*
* @param store model store
* @return true of the model store support SPDX spec version 2
*/
Expand Down Expand Up @@ -358,7 +382,9 @@ public static CoreModelObject readDocumentFromFile(ISerializableModelStore store
}

/**
* Reads an SPDX Document from a file
* Reads an SPDX Document from a file,
* compatible with SPDX version 2
*
* @param store Store where the document is to be stored
* @param file File to read the store from
* @return SPDX Document from the store
Expand All @@ -375,6 +401,8 @@ public static SpdxDocument readDocumentFromFileCompatV2(ISerializableModelStore
}

/**
* Gets an SPDX document from the model store
*
* @param store model store
* @return returns a document if a single document is found in the model store
* @throws InvalidSPDXAnalysisException
Expand All @@ -395,6 +423,9 @@ public static org.spdx.library.model.v3_0_1.core.SpdxDocument getDocFromStore(IS
}

/**
* Gets an SPDX document from the model store,
* compatible with SPDX version 2
*
* @param store model store
* @return returns a document if a single document is found in the model store
* @throws InvalidSPDXAnalysisException
Expand Down