Class EntityJsonParser


  • public class EntityJsonParser
    extends Object
    A parser for EntityJSON and StructuredObject. Obtain via EntityJsonParserBuilder.
    Author:
    Bruce Skingle
    • Field Detail

      • JSON_SCHEMA_SCHEMA_URL

        public static final URL JSON_SCHEMA_SCHEMA_URL
      • ENTITY_JSON_SCHEMA_URL

        public static final URL ENTITY_JSON_SCHEMA_URL
      • ENTITY_JSON_EXAMPLE_URL

        public static final URL ENTITY_JSON_EXAMPLE_URL
      • STRUCTURED_OBJECT_SCHEMA_URL

        public static final URL STRUCTURED_OBJECT_SCHEMA_URL
    • Method Detail

      • parseEntityJson

        public EntityJson parseEntityJson​(URL instanceUrl)
                                   throws SchemaValidationException,
                                          InvalidInstanceException
        Parse an EntityJSON instance from the given URL. Callers may prefer to catch EntityJSONException and treat all failures in the same way.
        Parameters:
        instanceUrl - A URL pointing to the JSON representation of an EntityJSON instance.
        Returns:
        An EntityJSON instance.
        Throws:
        SchemaValidationException - If the given instance does not meet the general EntityJSON schema.
        InvalidInstanceException - If the given instance is structurally invalid.
      • parseEntityJson

        public EntityJson parseEntityJson​(Object instanceSource,
                                          Reader instanceReader)
                                   throws SchemaValidationException,
                                          InvalidInstanceException
        Parse an EntityJSON instance from the given URL. Callers may prefer to catch EntityJSONException and treat all failures in the same way.
        Parameters:
        instanceSource - An object describing the source of the instance, typically an instance of java.net.URL or java.io.File.
        instanceReader - A Reader containing the JSON representation of an EntityJSON instance.
        Returns:
        An EntityJSON instance.
        Throws:
        SchemaValidationException - If the given instance does not meet the general EntityJSON schema.
        InvalidInstanceException - If the given instance is structurally invalid.
      • parseEntityJson

        public EntityJson parseEntityJson​(Object instanceSource,
                                          com.fasterxml.jackson.databind.node.ObjectNode instance)
                                   throws SchemaValidationException,
                                          InvalidInstanceException
        Parse an EntityJSON instance from the given URL. Callers may prefer to catch EntityJSONException and treat all failures in the same way.
        Parameters:
        instanceSource - An object describing the source of the instance, typically an instance of java.net.URL or java.io.File.
        instance - A JSON ObjectNode containing the JSON representation of an EntityJSON instance.
        Returns:
        An EntityJSON instance.
        Throws:
        SchemaValidationException - If the given instance does not meet the general EntityJSON schema.
        InvalidInstanceException - If the given instance is structurally invalid.
      • parseStructuredObject

        public StructuredObject parseStructuredObject​(URL instanceUrl)
                                               throws SchemaValidationException,
                                                      InvalidInstanceException
        Parse a single StructuredObject instance from the given URL. Callers may prefer to catch EntityJSONException and treat all failures in the same way.
        Parameters:
        instanceUrl - A URL pointing to the JSON representation of a StructuredObject instance.
        Returns:
        A StructuredObject instance.
        Throws:
        SchemaValidationException - If the given instance does not meet the general EntityJSON schema.
        InvalidInstanceException - If the given instance is structurally invalid.
      • parseStructuredObject

        public StructuredObject parseStructuredObject​(Object instanceSource,
                                                      Reader instanceReader)
                                               throws SchemaValidationException,
                                                      InvalidInstanceException
        Parse a single StructuredObject instance from the given URL. Callers may prefer to catch EntityJSONException and treat all failures in the same way.
        Parameters:
        instanceSource - An object describing the source of the instance, typically an instance of java.net.URL or java.io.File.
        instanceReader - A Reader containing the JSON representation of a single StructuredObject instance.
        Returns:
        A StructuredObject instance.
        Throws:
        SchemaValidationException - If the given instance does not meet the general EntityJSON schema.
        InvalidInstanceException - If the given instance is structurally invalid.
      • parseStructuredObject

        public StructuredObject parseStructuredObject​(Object instanceSource,
                                                      com.fasterxml.jackson.databind.node.ObjectNode instance)
                                               throws SchemaValidationException
        Parse a single StructuredObject instance from the given URL. Callers may prefer to catch EntityJSONException and treat all failures in the same way.
        Parameters:
        instanceSource - An object describing the source of the instance, typically an instance of java.net.URL or java.io.File.
        instance - A JSON ObjectNode containing the JSON representation of a single StructuredObject instance.
        Returns:
        An StructuredObject instance.
        Throws:
        SchemaValidationException - If the given instance does not meet the general EntityJSON schema.
        InvalidInstanceException - If the given instance is structurally invalid.