com.ibm.portal.streaming.json
Interface JSONHandlerFactory


public interface JSONHandlerFactory

Factory that generates handlers for producing and parsing JSON events in a stream based manner.

Since:
7.0.0

Field Summary
static java.lang.String ATTR_CLASS
          name of the class attribute used for instantiation
static java.lang.String DEFAULT_EXTENSION_ID
          ID of the JSONHandlerFactory default extension
static java.lang.String EXTENSION_POINT_ID
          ID of the JSONHandlerFactory extension point
 
Method Summary
 DefaultJsonContentHandler createJsonContentHandler(JsonContentHandler handler)
          Creates a DefaultJsonContentHandler used to write JSON content onto an existing JsonContentHandler.
 DefaultJsonContentHandler createJsonContentHandler(java.io.OutputStream writer, java.nio.charset.Charset charset)
          Creates a DefaultJsonContentHandler used to write JSON content onto a target OutputStream.
 DefaultJsonContentHandler createJsonContentHandler(java.io.Writer writer)
          Creates a DefaultJsonContentHandler used to write JSON content onto a target Writer.
 JsonProducer createJsonCopy(JsonProducer aProducer)
          Construct a producer that is a copy of the content the other producer generates
 JsonDocumentContentHandler createJsonDocumentContentHandler()
          Constructs a JsonContentHandler that builds an JSON object graph.
 JSONHandler createJSONHandler(java.io.OutputStream out)
          Deprecated. use createJsonContentHandler(OutputStream, Charset) instead
 JSONHandler createJSONHandler(java.io.Writer writer)
          Deprecated. use createJsonContentHandler(Writer) instead
 JsonParserOutputStream createJsonParserOutputStream(JsonContentHandler handler, java.nio.charset.Charset charset, int bufferSize)
          Creates a JSON parser that sends the event to the JsonContentHandler.
 JsonParserReader createJsonParserReader(java.io.Reader in)
          Constructs a pull parser for JSON content.
 JsonParserReader createJsonParserReader(java.io.Reader in, int bufferSize)
          Constructs a pull parser for JSON content.
 JsonParserWriter createJsonParserWriter(JsonContentHandler handler)
          Creates a JSON parser that sends the event to the JsonContentHandler.
 JsonProducer createJsonProducer(org.xml.sax.InputSource is)
          Construct a producer that copies the content of the input source to the target
 JsonProducer createJsonProducer(java.io.InputStream is, java.nio.charset.Charset charset)
          Construct a producer that copies the content of the stream to the target
 JsonProducer createJsonProducer(java.io.InputStream is, java.nio.charset.Charset charset, int bufferSize)
          Construct a producer that copies the content of the stream to the target
 JsonProducer createJsonProducer(JsonParserReader aReader)
          Construct a producer that copies the content of the reader
 JsonProducer createJsonProducer(java.lang.Object jsonDocument)
          Construct a producer that transforms the JSON document as returned by JsonDocumentContentHandler.getDocument() into a sequence of JSON events.
 JsonProducer createJsonProducer(java.io.Reader reader)
          Construct a producer that copies the content of the reader to the target
 JsonProducer createJsonProducer(java.io.Reader reader, int bufferSize)
          Construct a producer that copies the content of the reader to the target
 JSONReader createJSONReader(JSONHandler handler)
          Deprecated. use createJsonParserReader(Reader) instead
 JsonRecorder createJsonRecorder()
          Creates an object that can record JSON callbacks and that can then playback this sequence to another handler at a later point in time.
 JsonRecorder createJsonRecorder(int bufferSize)
          Creates an object that can record JSON callbacks and that can then playback this sequence to another handler at a later point in time.
 org.xml.sax.ContentHandler getContentHandler(JsonContentHandler aHandler)
          Create a ContentHandler that can be used to convert XML events into JSON events.
 org.xml.sax.ContentHandler getContentHandler(JsonSchema aSchema, JsonContentHandler aHandler)
          Create a ContentHandler that can be used to convert XML events into JSON events.
 

Field Detail

ATTR_CLASS

static final java.lang.String ATTR_CLASS
name of the class attribute used for instantiation

See Also:
Constant Field Values

DEFAULT_EXTENSION_ID

static final java.lang.String DEFAULT_EXTENSION_ID
ID of the JSONHandlerFactory default extension

See Also:
Constant Field Values

EXTENSION_POINT_ID

static final java.lang.String EXTENSION_POINT_ID
ID of the JSONHandlerFactory extension point

See Also:
Constant Field Values
Method Detail

createJsonContentHandler

DefaultJsonContentHandler createJsonContentHandler(JsonContentHandler handler)
                                                   throws java.io.IOException
Creates a DefaultJsonContentHandler used to write JSON content onto an existing JsonContentHandler.

Parameters:
handler - the handler that receives the content, not null
Returns:
the handler, not null
Throws:
java.io.IOException

createJsonContentHandler

DefaultJsonContentHandler createJsonContentHandler(java.io.OutputStream writer,
                                                   java.nio.charset.Charset charset)
                                                   throws java.io.IOException
Creates a DefaultJsonContentHandler used to write JSON content onto a target OutputStream. The resulting handler supports the XMLPropertyProvider interface to enable beautification.

Parameters:
writer - the writer that receives the content, not null
charset - the characterset used to create the object
Returns:
the handler, not null
Throws:
java.io.IOException
Since:
7.0.0.1
See Also:
Constants#KEY_INDENT, Constants#KEY_INDENT_AMOUNT

createJsonContentHandler

DefaultJsonContentHandler createJsonContentHandler(java.io.Writer writer)
                                                   throws java.io.IOException
Creates a DefaultJsonContentHandler used to write JSON content onto a target Writer. The resulting handler supports the XMLPropertyProvider interface to enable beautification.

Parameters:
writer - the writer that receives the content, not null
Returns:
the handler, not null
Throws:
java.io.IOException
See Also:
Constants#KEY_INDENT, Constants#KEY_INDENT_AMOUNT

createJsonCopy

JsonProducer createJsonCopy(JsonProducer aProducer)
                            throws java.io.IOException
Construct a producer that is a copy of the content the other producer generates

Parameters:
aProducer - the JSON producer
Returns:
the copy
Throws:
java.io.IOException
Since:
8.0

createJsonDocumentContentHandler

JsonDocumentContentHandler createJsonDocumentContentHandler()
                                                            throws java.io.IOException
Constructs a JsonContentHandler that builds an JSON object graph.

Returns:
the handler, not null
Throws:
java.io.IOException

createJSONHandler

@Deprecated
JSONHandler createJSONHandler(java.io.OutputStream out)
                              throws java.io.IOException
Deprecated. use createJsonContentHandler(OutputStream, Charset) instead

Creates a JSONHandler that allows to convert JSON events into characters that are written to the given writer.

Parameters:
writer - A writer to which the events should be converted.
Returns:
A JSONHandler that writes to the given writer.
Throws:
java.io.IOException

createJSONHandler

@Deprecated
JSONHandler createJSONHandler(java.io.Writer writer)
                              throws java.io.IOException
Deprecated. use createJsonContentHandler(Writer) instead

Creates a JSONHandler that allows to convert JSON events into characters that are written to the given writer.

Parameters:
writer - A writer to which the events should be converted.
Returns:
A JSONHandler that writes to the given writer.
Throws:
java.io.IOException

createJsonParserOutputStream

JsonParserOutputStream createJsonParserOutputStream(JsonContentHandler handler,
                                                    java.nio.charset.Charset charset,
                                                    int bufferSize)
                                                    throws java.io.IOException
Creates a JSON parser that sends the event to the JsonContentHandler. The parser is already initialized but the parsing process must be completed by calling Closeable.close() on the parser.

Parameters:
handler - handler that receives the events, not null
charset - characterset used to parse the JSON markup. If null this defaults to UTF8
bufferSize - buffer size used during character conversion, a value of <=0 indicates that a default buffer size will be used
Returns:
the parser, not null
Throws:
java.io.IOException

createJsonParserReader

JsonParserReader createJsonParserReader(java.io.Reader in)
                                        throws java.io.IOException
Constructs a pull parser for JSON content.

Parameters:
in - the original reader to parse the content from
Returns:
the JSON pull parser
Throws:
java.io.IOException
Since:
7.0.0.1

createJsonParserReader

JsonParserReader createJsonParserReader(java.io.Reader in,
                                        int bufferSize)
                                        throws java.io.IOException
Constructs a pull parser for JSON content.

Parameters:
in - the original reader to parse the content from
bufferSize - the buffer size
Returns:
the JSON pull parser
Throws:
java.io.IOException
Since:
7.0.0.1

createJsonParserWriter

JsonParserWriter createJsonParserWriter(JsonContentHandler handler)
                                        throws java.io.IOException
Creates a JSON parser that sends the event to the JsonContentHandler. The parser is already initialized but the parsing process must be completed by calling Closeable.close() on the parser.

Parameters:
handler - handler that receives the events, not null
Returns:
the parser, not null
Throws:
java.io.IOException

createJsonProducer

JsonProducer createJsonProducer(org.xml.sax.InputSource is)
                                throws java.io.IOException
Construct a producer that copies the content of the input source to the target

Parameters:
is - the source of the JSON data
Returns:
the actual data source
Throws:
java.io.IOException

createJsonProducer

JsonProducer createJsonProducer(java.io.InputStream is,
                                java.nio.charset.Charset charset)
                                throws java.io.IOException
Construct a producer that copies the content of the stream to the target

Parameters:
is - the source of the JSON data
charset - the characterset
Returns:
the producer that consumes the reader
Throws:
java.io.IOException
Since:
8.0

createJsonProducer

JsonProducer createJsonProducer(java.io.InputStream is,
                                java.nio.charset.Charset charset,
                                int bufferSize)
                                throws java.io.IOException
Construct a producer that copies the content of the stream to the target

Parameters:
is - the source of the JSON data
charset - the characterset
bufferSize - the buffer size
Returns:
the producer that consumes the reader
Throws:
java.io.IOException
Since:
8.0

createJsonProducer

JsonProducer createJsonProducer(JsonParserReader aReader)
                                throws java.io.IOException
Construct a producer that copies the content of the reader

Parameters:
aReader - the reader to copy from
Returns:
the producer wrapper
Throws:
java.io.IOException
Since:
8.0.0.1

createJsonProducer

JsonProducer createJsonProducer(java.lang.Object jsonDocument)
                                throws java.io.IOException
Construct a producer that transforms the JSON document as returned by JsonDocumentContentHandler.getDocument() into a sequence of JSON events. This method can also convert java script objects as returned by a ScriptEngine into JSON callbacks.

Parameters:
jsonDocument - the document
Returns:
the producer that transforms the document into a JSON stream
Throws:
java.io.IOException
Since:
8.0.0.1

createJsonProducer

JsonProducer createJsonProducer(java.io.Reader reader)
                                throws java.io.IOException
Construct a producer that copies the content of the reader to the target

Parameters:
reader - the source of the JSON data
Returns:
the producer that consumes the reader
Throws:
java.io.IOException
Since:
8.0

createJsonProducer

JsonProducer createJsonProducer(java.io.Reader reader,
                                int bufferSize)
                                throws java.io.IOException
Construct a producer that copies the content of the reader to the target

Parameters:
reader - the source of the JSON data
bufferSize - the buffer size
Returns:
the producer that consumes the reader
Throws:
java.io.IOException
Since:
8.0

createJSONReader

@Deprecated
JSONReader createJSONReader(JSONHandler handler)
                            throws java.io.IOException
Deprecated. use createJsonParserReader(Reader) instead

Creates a JSONReader that allows to convert characters read from the given reader into JSON events

Parameters:
handler - The handler where the events will be delegated to.
Returns:
A JSONHandler that reads from the given reader.
Throws:
java.io.IOException

createJsonRecorder

JsonRecorder createJsonRecorder()
                                throws java.io.IOException
Creates an object that can record JSON callbacks and that can then playback this sequence to another handler at a later point in time.

Returns:
the recorder
Throws:
java.io.IOException
Since:
8.0.0.1

createJsonRecorder

JsonRecorder createJsonRecorder(int bufferSize)
                                throws java.io.IOException
Creates an object that can record JSON callbacks and that can then playback this sequence to another handler at a later point in time.

Parameters:
bufferSize - size of the string buffer used for json strings.
Returns:
the recorder
Throws:
java.io.IOException
Since:
8.0.0.1

getContentHandler

org.xml.sax.ContentHandler getContentHandler(JsonContentHandler aHandler)
                                             throws java.io.IOException
Create a ContentHandler that can be used to convert XML events into JSON events. Use the optional XMLPropertyProvider interface on the ContentHandler to associate a JsonSchema with the handler.

Parameters:
aHandler - the target json handler
Returns:
the XML content handler
Throws:
java.io.IOException
Since:
8.0

getContentHandler

org.xml.sax.ContentHandler getContentHandler(JsonSchema aSchema,
                                             JsonContentHandler aHandler)
                                             throws java.io.IOException
Create a ContentHandler that can be used to convert XML events into JSON events. Use the optional XMLPropertyProvider interface on the ContentHandler to associate a JsonSchema with the handler.

Parameters:
aSchema - the JSON schema that contols the XML to JSON conversion
aHandler - the target json handler
Returns:
the XML content handler
Throws:
java.io.IOException
Since:
8.0