javax.json.stream
Interface JsonGeneratorFactory


public interface JsonGeneratorFactory

Factory to create JsonGenerator instances. If a factory instance is configured with some configuration, that would be used to configure the created generator instances.

JsonGenerator can also be created using Json's createGenerator methods. If multiple generator instances are created, then creating them using a generator factory is preferred.

For example:

 JsonGeneratorFactory factory = Json.createGeneratorFactory();
 JsonGenerator generator1 = factory.createGenerator(...);
 JsonGenerator generator2 = factory.createGenerator(...);
 

All of the methods in this class are safe for use by multiple concurrent threads.

Author:
Jitendra Kotamraju

Method Summary
 JsonGenerator createGenerator(OutputStream out)
          Creates a JSON generator which can be used to write JSON text to the specified byte stream.
 JsonGenerator createGenerator(OutputStream out, String encoding)
          Creates a JSON generator which can be used to write JSON text to the specified byte stream.
 JsonGenerator createGenerator(Writer writer)
          Creates a JSON generator which can be used to write JSON text to the specified character stream.
 

Method Detail

createGenerator

JsonGenerator createGenerator(Writer writer)
Creates a JSON generator which can be used to write JSON text to the specified character stream. The created generator is configured with the factory configuration.

Parameters:
writer - i/o writer to which JSON is written

createGenerator

JsonGenerator createGenerator(OutputStream out)
Creates a JSON generator which can be used to write JSON text to the specified byte stream. Characters written to the stream are encoded into bytes using UTF-8 encoding. The created generator is configured with the factory configuration.

Parameters:
out - i/o stream to which JSON is written

createGenerator

JsonGenerator createGenerator(OutputStream out,
                              String encoding)
Creates a JSON generator which can be used to write JSON text to the specified byte stream. Characters written to the stream are encoded into bytes using the specified encoding. The created generator is configured with the factory configuration.

Parameters:
out - i/o stream to which JSON is written
encoding - the name of character encoding of the stream.
Throws:
JsonException - if the named encoding is not supported. The cause of the exception would be UnsupportedEncodingException
See Also:
Charset



Copyright © 2012 Oracle and/or its affiliates. All rights reserved.