Class JsonContentHandlerJacksonWrapper

java.lang.Object
org.apache.uima.json.impl.JsonContentHandlerJacksonWrapper
All Implemented Interfaces:
ContentHandler

public class JsonContentHandlerJacksonWrapper extends Object implements ContentHandler
Utility class that generates JSON output for UIMA descriptors and CASs This class is built as a wrapper for a popular open-source implementation of JSON capabilities, "Jackson". Unusually, it implements the ContentHandler interface, so it can be use with the existing code in UIMA which uses content handlers for serialization. Because of this, it wraps the IOExceptions that the Jackson package throws, into SAXExceptions that ContentHandlers throw. Use: Create an instance, specifying the output as a Writer or OutputStream or File (These three forms are supported by the underlying Jackson impl) Specify also if doing pretty-printing Call from other serialization class that does walking (either MetaDataObject_impl or XmiCasSerializer), to this instance This class is exposes the Jackson "Generator" API for streaming, and instances of the Jackson Factory instance for configuring. The caller uses both this class and the Jackson Generator class. This class lets the underlying Jackson PrettyPrinter classes track the indent level. PrettyPrinting is implemented via customization of the Jackson PrettyPrinting classes
  • Field Details

    • SYSTEM_LINE_FEED

      public static final String SYSTEM_LINE_FEED
  • Constructor Details

    • JsonContentHandlerJacksonWrapper

      public JsonContentHandlerJacksonWrapper(Object destination) throws SAXException
      Makes a Json content handler that sends its output to the specified destination
      Parameters:
      destination - - can be a File, an OutputStream, or a Writer
      Throws:
      SAXException - wrapping an IOException
    • JsonContentHandlerJacksonWrapper

      public JsonContentHandlerJacksonWrapper(com.fasterxml.jackson.core.JsonFactory jsonFactory, Object o) throws SAXException
      Makes a Json content handler, using a specified JsonFactory instance that can be configured according to the Jackson implementation. The resulting content handler will send its output to the specified destination
      Parameters:
      jsonFactory - -
      o - - where the output goes
      Throws:
      SAXException - wrapping an IOException
    • JsonContentHandlerJacksonWrapper

      public JsonContentHandlerJacksonWrapper(Object o, boolean isFormattedOutput) throws SAXException
      Makes a Json content handler, and specifies a prettyprinting boolean flag (default is no prettyprinting). The resulting content handler will send its output to the specified destination
      Parameters:
      o - - where the output goes
      isFormattedOutput - -
      Throws:
      SAXException - wrapping an IOException
    • JsonContentHandlerJacksonWrapper

      public JsonContentHandlerJacksonWrapper(com.fasterxml.jackson.core.JsonFactory jsonFactory, Object o, boolean isFormattedOutput) throws SAXException
      Makes a Json content handler, using a specified JsonFactory instance that can be configured according to the Jackson implementation, and specifies a prettyprinting boolean flag (default is no prettyprinting). The resulting content handler will send its output to the specified destination
      Parameters:
      jsonFactory - -
      o - where the output goes
      isFormattedOutput - - true for pretty printing
      Throws:
      SAXException - wrapping an IOException
    • JsonContentHandlerJacksonWrapper

      public JsonContentHandlerJacksonWrapper(com.fasterxml.jackson.core.JsonGenerator jsonGenerator)
      Makes a Json content handler, using a specified JsonGenerator instance
      Parameters:
      jsonGenerator - -
    • JsonContentHandlerJacksonWrapper

      public JsonContentHandlerJacksonWrapper(com.fasterxml.jackson.core.JsonGenerator jsonGenerator, boolean isFormattedOutput)
      Makes a Json content handler, using a specified JsonGenerator instance
      Parameters:
      jsonGenerator - -
      isFormattedOutput - - set to true for prettyprinting, default is false
  • Method Details