JsonGeneratorImpl (Jackson-core 2.1.1 API)
Date: 2012-11-11

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.fasterxml.jackson.core.json
Class JsonGeneratorImpl

    java.lang.Object
      com.fasterxml.jackson.core.JsonGenerator
          com.fasterxml.jackson.core.base.GeneratorBase
              com.fasterxml.jackson.core.json.JsonGeneratorImpl

All Implemented Interfaces:
  Versioned, Closeable, Flushable

Direct Known Subclasses:
  UTF8JsonGenerator, WriterBasedJsonGenerator

    public abstract class JsonGeneratorImpl

extends GeneratorBase

Intermediate base class shared by JSON-backed generators like `UTF8JsonGenerator` and `WriterBasedJsonGenerator`.

Since:
  2.1

Nested Class Summary

Nested classes/interfaces inherited from class com.fasterxml.jackson.core.JsonGenerator
`JsonGenerator.Feature`

Field Summary
`protected CharacterEscapes` | `_characterEscapes` Definition of custom character escapes to use for generators created by this factory, if any.
`protected IOContext` | `_ioContext`
`protected int` | `_maximumNonEscapedChar` Value between 128 (0x80) and 65535 (0xFFFF) that indicates highest Unicode code point that will not need escaping; or 0 to indicate that all characters can be represented without escaping.
`protected int[]` | `_outputEscapes` Currently active set of output escape code definitions (whether and how to escape or not) for 7-bit ASCII range (first 128 character codes).
`protected SerializableString` | `_rootValueSeparator` Separator to use, if any, between root-level values.
`protected static int[]` | `sOutputEscapes` This is the default set of escape codes, over 7-bit ASCII range (first 128 character codes), used for single-byte UTF-8 characters.

Fields inherited from class com.fasterxml.jackson.core.base.GeneratorBase
`_cfgNumbersAsStrings, _closed, _features, _objectCodec, _writeContext`

Fields inherited from class com.fasterxml.jackson.core.JsonGenerator
`_cfgPrettyPrinter`

Constructor Summary
`JsonGeneratorImpl(IOContext ctxt, int features, ObjectCodec codec)`

Method Summary
`CharacterEscapes` | `getCharacterEscapes()` Method for accessing custom escapes factory uses for `JsonGenerator`s it creates.
`int` | `getHighestEscapedChar()` Accessor method for testing what is the highest unescaped character configured for this generator.
`JsonGenerator` | `setCharacterEscapes(CharacterEscapes esc)` Method for defining custom escapes factory uses for `JsonGenerator`s it creates.
`JsonGenerator` | `setHighestNonEscapedChar(int charCode)` Method that can be called to request that generator escapes all character codes above specified code point (if positive value); or, to not escape any characters except for ones that must be escaped for the data format (if -1).
`JsonGenerator` | `setRootValueSeparator(SerializableString sep)` Method that allows overriding String used for separating root-level JSON values (default is single space character)
`Version` | `version()` Implemented with detection that tries to find "VERSION.txt" in same package as the implementation class.
`void` | `writeStringField(String fieldName, String value)` Convenience method for outputting a field entry ("member") that has a String value.

Methods inherited from class com.fasterxml.jackson.core.base.GeneratorBase
`_cantHappen, _releaseBuffers, _reportError, _reportUnsupportedOperation, _throwInternal, _verifyValueWrite, _writeSimpleObject, close, copyCurrentEvent, copyCurrentStructure, disable, enable, flush, getCodec, getOutputContext, isClosed, isEnabled, setCodec, useDefaultPrettyPrinter, writeBinary, writeFieldName, writeObject, writeRawValue, writeRawValue, writeRawValue, writeString, writeTree`

Methods inherited from class com.fasterxml.jackson.core.JsonGenerator
`canUseSchema, configure, getOutputTarget, getPrettyPrinter, getSchema, setPrettyPrinter, setSchema, writeArrayFieldStart, writeBinary, writeBinary, writeBinary, writeBinary, writeBinaryField, writeBoolean, writeBooleanField, writeEndArray, writeEndObject, writeFieldName, writeNull, writeNullField, writeNumber, writeNumber, writeNumber, writeNumber, writeNumber, writeNumber, writeNumber, writeNumberField, writeNumberField, writeNumberField, writeNumberField, writeNumberField, writeObjectField, writeObjectFieldStart, writeRaw, writeRaw, writeRaw, writeRaw, writeRaw, writeRawUTF8String, writeStartArray, writeStartObject, writeString, writeString, writeUTF8String`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### sOutputEscapes

    protected static final int[] sOutputEscapes

  This is the default set of escape codes, over 7-bit ASCII range (first 128 character codes), used for single-byte UTF-8 characters.

### _ioContext

    protected final IOContext _ioContext

### _outputEscapes

    protected int[] _outputEscapes

  Currently active set of output escape code definitions (whether and how to escape or not) for 7-bit ASCII range (first 128 character codes). Defined separately to make potentially customizable

### _maximumNonEscapedChar

    protected int _maximumNonEscapedChar

  Value between 128 (0x80) and 65535 (0xFFFF) that indicates highest Unicode code point that will not need escaping; or 0 to indicate that all characters can be represented without escaping. Typically used to force escaping of some portion of character set; for example to always escape non-ASCII characters (if value was 127).

  NOTE: not all sub-classes make use of this setting.

### _characterEscapes

    protected CharacterEscapes _characterEscapes

  Definition of custom character escapes to use for generators created by this factory, if any. If null, standard data format specific escapes are used.

### _rootValueSeparator

    protected SerializableString _rootValueSeparator

  Separator to use, if any, between root-level values.

  Since:
    2.1

Constructor Detail

### JsonGeneratorImpl

    public JsonGeneratorImpl(IOContext ctxt,
                             int features,
                             ObjectCodec codec)

Method Detail

### setHighestNonEscapedChar

    public JsonGenerator setHighestNonEscapedChar(int charCode)

  Description copied from class: `JsonGenerator`
  Method that can be called to request that generator escapes all character codes above specified code point (if positive value); or, to not escape any characters except for ones that must be escaped for the data format (if -1). To force escaping of all non-ASCII characters, for example, this method would be called with value of 127.

  Note that generators are NOT required to support setting of value higher than 127, because there are other ways to affect quoting (or lack thereof) of character codes between 0 and 127. Not all generators support concept of escaping, either; if so, calling this method will have no effect.

  Default implementation does nothing; sub-classes need to redefine it according to rules of supported data format.

  Overrides:
    `setHighestNonEscapedChar` in class `JsonGenerator`
  Parameters:
    `charCode` - Either -1 to indicate that no additional escaping is to be done; or highest code point not to escape (meaning higher ones will be), if positive value.

### getHighestEscapedChar

    public int getHighestEscapedChar()

  Description copied from class: `JsonGenerator`
  Accessor method for testing what is the highest unescaped character configured for this generator. This may be either positive value (when escaping configuration has been set and is in effect), or 0 to indicate that no additional escaping is in effect. Some generators may not support additional escaping: for example, generators for binary formats that do not use escaping should simply return 0.

  Overrides:
    `getHighestEscapedChar` in class `JsonGenerator`
  Returns:
    Currently active limitation for highest non-escaped character, if defined; or -1 to indicate no additional escaping is performed.

### setCharacterEscapes

    public JsonGenerator setCharacterEscapes(CharacterEscapes esc)

  Description copied from class: `JsonGenerator`
  Method for defining custom escapes factory uses for `JsonGenerator`s it creates.

  Overrides:
    `setCharacterEscapes` in class `JsonGenerator`

### getCharacterEscapes

    public CharacterEscapes getCharacterEscapes()

  Method for accessing custom escapes factory uses for `JsonGenerator`s it creates.

  Overrides:
    `getCharacterEscapes` in class `JsonGenerator`

### setRootValueSeparator

    public JsonGenerator setRootValueSeparator(SerializableString sep)

  Description copied from class: `JsonGenerator`
  Method that allows overriding String used for separating root-level JSON values (default is single space character)

  Overrides:
    `setRootValueSeparator` in class `JsonGenerator`
  Parameters:
    `sep` - Separator to use, if any; null means that no separator is automatically added

### version

    public Version version()

  Description copied from class: `GeneratorBase`
  Implemented with detection that tries to find "VERSION.txt" in same package as the implementation class.

  Specified by:
    `version` in interface `Versioned`
  Overrides:
    `version` in class `GeneratorBase`

### writeStringField

    public final void writeStringField(String fieldName,
                                       String value)
                                throws IOException,
                                       JsonGenerationException

  Description copied from class: `JsonGenerator`
  Convenience method for outputting a field entry ("member") that has a String value. Equivalent to:

        writeFieldName(fieldName);
        writeString(value);

  Note: many performance-sensitive implementations override this method

  Overrides:
    `writeStringField` in class `JsonGenerator`
  Throws:
    `IOException`
    `JsonGenerationException`

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2012 FasterXML. All Rights Reserved.