Package gov.usgs.earthquake.product.io
Class JsonProduct
java.lang.Object
gov.usgs.earthquake.product.io.JsonProduct
Product format conversion tools to and from json
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetContents
(javax.json.JsonValue json) Convert contents json to map.javax.json.JsonObjectBuilder
getContentsJson
(Map<String, Content> contents) Convert contents map to json.javax.json.JsonObjectBuilder
getGeometryJson
(Product product) Create json geometry from product properties.static List<ProductSignature>
getHistory
(javax.json.JsonArray jsonArray) Converts a Json list of objects to signature history list.javax.json.JsonArrayBuilder
getHistoryJson
(List<ProductSignature> list) Convert list of type signature history to Json.getId
(javax.json.JsonObject json) Convert json id to ProductId object.javax.json.JsonObjectBuilder
Convert ProductId to json object.javax.json.JsonObject
getJsonObject
(Product product) Convert product object to json.getLinks
(javax.json.JsonArray json) Convert json links to map.javax.json.JsonArrayBuilder
getLinksJson
(Map<String, List<URI>> links) Convert links map to json.getProduct
(javax.json.JsonObject json) Convert json object to product.getProperties
(javax.json.JsonObject json) Convert properties json to map.javax.json.JsonObjectBuilder
getPropertiesJson
(Map<String, String> properties) Convert properties map to json.
-
Constructor Details
-
JsonProduct
public JsonProduct()
-
-
Method Details
-
getJsonObject
Convert product object to json.- Parameters:
product
- a product- Returns:
- a json object
- Throws:
Exception
- if error occurs
-
getProduct
Convert json object to product.- Parameters:
json
- a json object- Returns:
- a product
- Throws:
Exception
- if error occurs
-
getContentsJson
Convert contents map to json.- Parameters:
contents
- contents map- Returns:
- JSOnArrayBuilder
- Throws:
Exception
- if error occurs
-
getContents
Convert contents json to map.- Parameters:
json
- JsonArray- Returns:
- Contents map
- Throws:
Exception
- if error occurs
-
getGeometryJson
Create json geometry from product properties.- Parameters:
product
- a product- Returns:
- JSON geometry via JsonObjectBuilder
- Throws:
Exception
- if error occurs
-
getId
Convert json id to ProductId object.- Parameters:
json
- A JsonObject ID- Returns:
- a productId
- Throws:
InvalidProductIdException
- if error occurs
-
getIdJson
Convert ProductId to json object.- Parameters:
id
- A ProductId- Returns:
- JsonObjectBuilder
- Throws:
Exception
- if error occurs
-
getLinks
Convert json links to map.- Parameters:
json
- a Jsonarray- Returns:
- a Map of links
- Throws:
Exception
- if error occurs
-
getLinksJson
Convert links map to json.- Parameters:
links
- map- Returns:
- JsonArray of JsonArrayBuilder
- Throws:
Exception
- if error occurs
-
getHistoryJson
Convert list of type signature history to Json.- Parameters:
list
- signature history list- Returns:
- a JsonArrayBuilder
- Throws:
Exception
- if error occurs
-
getHistory
Converts a Json list of objects to signature history list.- Parameters:
jsonArray
- JsonArray- Returns:
- List of ProductSignature
- Throws:
Exception
- if error occurs
-
getProperties
Convert properties json to map.- Parameters:
json
- JsonObject properties- Returns:
- A map
- Throws:
Exception
- if error occurs
-
getPropertiesJson
public javax.json.JsonObjectBuilder getPropertiesJson(Map<String, String> properties) throws ExceptionConvert properties map to json.- Parameters:
properties
- Map of properties- Returns:
- JsonObjectBuilder
- Throws:
Exception
- if error occurs
-