Class JsonProduct

java.lang.Object
gov.usgs.earthquake.product.io.JsonProduct

public class JsonProduct extends Object
Product format conversion tools to and from json
  • Constructor Details

    • JsonProduct

      public JsonProduct()
  • Method Details

    • getJsonObject

      public javax.json.JsonObject getJsonObject(Product product) throws Exception
      Convert product object to json.
      Parameters:
      product - a product
      Returns:
      a json object
      Throws:
      Exception - if error occurs
    • getProduct

      public Product getProduct(javax.json.JsonObject json) throws Exception
      Convert json object to product.
      Parameters:
      json - a json object
      Returns:
      a product
      Throws:
      Exception - if error occurs
    • getContentsJson

      public javax.json.JsonObjectBuilder getContentsJson(Map<String,Content> contents) throws Exception
      Convert contents map to json.
      Parameters:
      contents - contents map
      Returns:
      JSOnArrayBuilder
      Throws:
      Exception - if error occurs
    • getContents

      public Map<String,Content> getContents(javax.json.JsonValue json) throws Exception
      Convert contents json to map.
      Parameters:
      json - JsonArray
      Returns:
      Contents map
      Throws:
      Exception - if error occurs
    • getGeometryJson

      public javax.json.JsonObjectBuilder getGeometryJson(Product product) throws Exception
      Create json geometry from product properties.
      Parameters:
      product - a product
      Returns:
      JSON geometry via JsonObjectBuilder
      Throws:
      Exception - if error occurs
    • getId

      public ProductId getId(javax.json.JsonObject json) throws InvalidProductIdException
      Convert json id to ProductId object.
      Parameters:
      json - A JsonObject ID
      Returns:
      a productId
      Throws:
      InvalidProductIdException - if error occurs
    • getIdJson

      public javax.json.JsonObjectBuilder getIdJson(ProductId id) throws Exception
      Convert ProductId to json object.
      Parameters:
      id - A ProductId
      Returns:
      JsonObjectBuilder
      Throws:
      Exception - if error occurs
    • getLinks

      public Map<String,List<URI>> getLinks(javax.json.JsonArray json) throws Exception
      Convert json links to map.
      Parameters:
      json - a Jsonarray
      Returns:
      a Map of links
      Throws:
      Exception - if error occurs
    • getLinksJson

      public javax.json.JsonArrayBuilder getLinksJson(Map<String,List<URI>> links) throws Exception
      Convert links map to json.
      Parameters:
      links - map
      Returns:
      JsonArray of JsonArrayBuilder
      Throws:
      Exception - if error occurs
    • getHistoryJson

      public javax.json.JsonArrayBuilder getHistoryJson(List<ProductSignature> list) throws Exception
      Convert list of type signature history to Json.
      Parameters:
      list - signature history list
      Returns:
      a JsonArrayBuilder
      Throws:
      Exception - if error occurs
    • getHistory

      public static List<ProductSignature> getHistory(javax.json.JsonArray jsonArray) throws Exception
      Converts a Json list of objects to signature history list.
      Parameters:
      jsonArray - JsonArray
      Returns:
      List of ProductSignature
      Throws:
      Exception - if error occurs
    • getProperties

      public Map<String,String> getProperties(javax.json.JsonObject json) throws Exception
      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 Exception
      Convert properties map to json.
      Parameters:
      properties - Map of properties
      Returns:
      JsonObjectBuilder
      Throws:
      Exception - if error occurs