Package htsjdk.beta.io.bundle
Class BundleJSON
java.lang.Object
htsjdk.beta.io.bundle.BundleJSON
Methods for serializing and deserializing Bundles to and from JSON strings.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic Bundle
Create a Bundle from a jsonString.Create a Bundle from jsonString using a custom class that implementsIOPath
for all resources.toBundleList
(String jsonString) Create a Listfrom a jsonString. toBundleList
(String jsonString, Function<String, T> ioPathConstructor) Create a Listfrom a jsonString, using a custom class that implements IOPath
for all resources.static String
Serialize a bundle to a JSON string representation.static String
Convert a (non-empty) List of Bundles to a JSON array string representation.
-
Field Details
-
BUNDLE_EXTENSION
- See Also:
-
JSON_PROPERTY_SCHEMA
- See Also:
-
JSON_PROPERTY_SCHEMA_NAME
- See Also:
-
JSON_PROPERTY_SCHEMA_VERSION
- See Also:
-
JSON_PROPERTY_PRIMARY
- See Also:
-
JSON_PROPERTY_PATH
- See Also:
-
JSON_PROPERTY_FORMAT
- See Also:
-
JSON_SCHEMA_NAME
- See Also:
-
JSON_SCHEMA_VERSION
- See Also:
-
-
Constructor Details
-
BundleJSON
public BundleJSON()
-
-
Method Details
-
toJSON
Serialize a bundle to a JSON string representation. All resources in the bundle must beIOPathResource
s for serialization to succeed. Stream resources cannot be serialized.- Parameters:
bundle
- theBundle
to serialize to JSON- Returns:
- a JSON string representation of this bundle
- Throws:
IllegalArgumentException
- if any resource in bundle is not an IOPathResources.
-
toJSON
Convert a (non-empty) List of Bundles to a JSON array string representation.- Parameters:
bundles
- a List of Bundles to serialize to JSON- Returns:
- a JSON string (array) representation of the list of bundles
-
toBundle
Create a Bundle from a jsonString.- Parameters:
jsonString
- a valid JSON string conforming to the bundle schema (for compatibility, a bundle list is also accepted, as long as it only contains a single bundle)- Returns:
- a
Bundle
created from jsonString
-
toBundle
public static <T extends IOPath> Bundle toBundle(String jsonString, Function<String, T> ioPathConstructor) Create a Bundle from jsonString using a custom class that implementsIOPath
for all resources. (For compatibility, a bundle list string is also accepted, as long as it only contains a single bundle).- Type Parameters:
T
- the IOPath-derived type to use for IOPathResources- Parameters:
jsonString
- a valid JSON string conforming to the bundle schemaioPathConstructor
- a function that takes a string and returns an IOPath-derived class of type- Returns:
- a newly created
Bundle
-
toBundleList
public static <T extends IOPath> List<Bundle> toBundleList(String jsonString, Function<String, T> ioPathConstructor) Create a Listfrom a jsonString, using a custom class that implements IOPath
for all resources.- Type Parameters:
T
- IOPath-derived class to use for IOPathResources- Parameters:
jsonString
- the json string must conform to the bundle schema, and may contain an array or single objectioPathConstructor
- constructor to use to create the backing IOPath for all resources- Returns:
- List
-
toBundleList
Create a Listfrom a jsonString.
-