Class UTF8JsonGenerator

All Implemented Interfaces:
Closeable, Flushable, AutoCloseable, Versioned

public class UTF8JsonGenerator extends JsonGeneratorBase
  • Field Details

    • BYTE_u

      private static final byte BYTE_u
      See Also:
    • BYTE_0

      private static final byte BYTE_0
      See Also:
    • BYTE_LBRACKET

      private static final byte BYTE_LBRACKET
      See Also:
    • BYTE_RBRACKET

      private static final byte BYTE_RBRACKET
      See Also:
    • BYTE_LCURLY

      private static final byte BYTE_LCURLY
      See Also:
    • BYTE_RCURLY

      private static final byte BYTE_RCURLY
      See Also:
    • BYTE_BACKSLASH

      private static final byte BYTE_BACKSLASH
      See Also:
    • BYTE_COMMA

      private static final byte BYTE_COMMA
      See Also:
    • BYTE_COLON

      private static final byte BYTE_COLON
      See Also:
    • MAX_BYTES_TO_BUFFER

      private static final int MAX_BYTES_TO_BUFFER
      See Also:
    • HEX_BYTES_UPPER

      private static final byte[] HEX_BYTES_UPPER
    • HEX_BYTES_LOWER

      private static final byte[] HEX_BYTES_LOWER
    • NULL_BYTES

      private static final byte[] NULL_BYTES
    • TRUE_BYTES

      private static final byte[] TRUE_BYTES
    • FALSE_BYTES

      private static final byte[] FALSE_BYTES
    • _outputStream

      protected final OutputStream _outputStream
      Underlying output stream used for writing JSON content.
    • _quoteChar

      protected final byte _quoteChar
      Character used for quoting JSON Object property names and String values.
    • _outputBuffer

      protected byte[] _outputBuffer
      Intermediate buffer in which contents are buffered before being written using _outputStream.
    • _outputTail

      protected int _outputTail
      Pointer to the position right beyond the last character to output (end marker; may be past the buffer)
    • _outputEnd

      protected final int _outputEnd
      End marker of the output buffer; one past the last valid position within the buffer.
    • _outputMaxContiguous

      protected final int _outputMaxContiguous
      Maximum number of chars that we know will always fit in the output buffer after escaping
    • _charBuffer

      protected char[] _charBuffer
      Intermediate buffer in which characters of a String are copied before being encoded.
    • _charBufferLength

      protected final int _charBufferLength
      Length of _charBuffer
    • _entityBuffer

      protected byte[] _entityBuffer
      6 character temporary buffer allocated if needed, for constructing escape sequences
    • _bufferRecyclable

      protected boolean _bufferRecyclable
      Flag that indicates whether the output buffer is recycable (and needs to be returned to recycler once we are done) or not.
  • Constructor Details

  • Method Details

    • setCharacterEscapes

      public JsonGenerator setCharacterEscapes(CharacterEscapes esc)
      Description copied from class: JsonGenerator
      Method for defining custom escapes factory uses for JsonGenerators it creates.

      Default implementation does nothing and simply returns this instance.

      Specified by:
      setCharacterEscapes in class JsonGeneratorBase
      Parameters:
      esc - CharacterEscapes to configure this generator to use, if any; null if none
      Returns:
      This generator, to allow call chaining
    • streamWriteOutputTarget

      public Object streamWriteOutputTarget()
      Description copied from class: JsonGenerator
      Method that can be used to get access to object that is used as target for generated output; this is usually either OutputStream or Writer, depending on what generator was constructed with. Note that returned value may be null in some cases; including case where implementation does not want to exposed raw source to caller. In cases where output has been decorated, object returned here is the decorated version; this allows some level of interaction between users of generator and decorator object.

      In general use of this accessor should be considered as "last effort", i.e. only used if no other mechanism is applicable.

      NOTE: was named getOutputTarget() in Jackson 2.x.

      Specified by:
      streamWriteOutputTarget in class JsonGenerator
      Returns:
      Output target this generator was configured with
    • streamWriteOutputBuffered

      public int streamWriteOutputBuffered()
      Description copied from class: JsonGenerator
      Method for verifying amount of content that is buffered by generator but not yet flushed to the underlying target (stream, writer), in units (byte, char) that the generator implementation uses for buffering; or -1 if this information is not available. Unit used is often the same as the unit of underlying target (that is, byte for OutputStream, char for Writer), but may differ if buffering is done before encoding. Default JSON-backed implementations do use matching units.

      NOTE: was named getOutputBuffered() in Jackson 2.x.

      Specified by:
      streamWriteOutputBuffered in class JsonGenerator
      Returns:
      Amount of content buffered in internal units, if amount known and accessible; -1 if not accessible.
    • writeName

      public JsonGenerator writeName(String name) throws JacksonException
      Description copied from class: JsonGenerator
      Method for writing an Object Property name (JSON String surrounded by double quotes: syntactically identical to a JSON String value), possibly decorated by white space if pretty-printing is enabled.

      Property names can only be written in Object context (check out JSON specification for details), when Object Property name is expected (property names alternate with values).

      Specified by:
      writeName in class JsonGenerator
      Parameters:
      name - Name of the Object Property to write
      Returns:
      This generator, to allow call chaining
      Throws:
      JacksonException
    • writeName

      public JsonGenerator writeName(SerializableString name) throws JacksonException
      Description copied from class: JsonGenerator
      Method similar to JsonGenerator.writeName(String), main difference being that it may perform better as some of processing (such as quoting of certain characters, or encoding into external encoding if supported by generator) can be done just once and reused for later calls.

      Default implementation simple uses unprocessed name container in serialized String; implementations are strongly encouraged to make use of more efficient methods argument object has.

      Overrides:
      writeName in class GeneratorBase
      Parameters:
      name - Pre-encoded name of the Object Property to write
      Returns:
      This generator, to allow call chaining
      Throws:
      JacksonException
    • _writeUnq

      private final void _writeUnq(SerializableString name) throws JacksonException
      Throws:
      JacksonException
    • writeStartArray

      public JsonGenerator writeStartArray() throws JacksonException
      Description copied from class: JsonGenerator
      Method for writing starting marker of a Array value (for JSON this is character '['; plus possible white space decoration if pretty-printing is enabled).

      Array values can be written in any context where values are allowed: meaning everywhere except for when a property name is expected.

      Specified by:
      writeStartArray in class JsonGenerator
      Returns:
      This generator, to allow call chaining
      Throws:
      JacksonException
    • writeStartArray

      public JsonGenerator writeStartArray(Object forValue) throws JacksonException
      Description copied from class: JsonGenerator
      Method for writing start marker of an Array value, similar to JsonGenerator.writeStartArray(), but also specifying what is the Java object that the Array Object being written represents (if any); null may be passed if not known or not applicable. This value is accessible from context as "current value"
      Specified by:
      writeStartArray in class JsonGenerator
      Parameters:
      forValue - Java Object that Array being written represents, if any (or null if not known or not applicable)
      Returns:
      This generator, to allow call chaining
      Throws:
      JacksonException
    • writeStartArray

      public JsonGenerator writeStartArray(Object forValue, int len) throws JacksonException
      Description copied from class: JsonGenerator
      Method for writing start marker of an Array value, similar to JsonGenerator.writeStartArray(), but also specifying what is the Java object that the Array Object being written represents (if any) and how many elements will be written for the array before calling JsonGenerator.writeEndArray().
      Overrides:
      writeStartArray in class JsonGeneratorBase
      Parameters:
      forValue - Java Object that Array being written represents, if any (or null if not known or not applicable)
      len - Number of elements this Array will have: actual number of values written (before matching call to JsonGenerator.writeEndArray() MUST match; generator MAY verify this is the case (and SHOULD if format itself encodes length)
      Returns:
      This generator, to allow call chaining
      Throws:
      JacksonException
    • writeEndArray

      public JsonGenerator writeEndArray() throws JacksonException
      Description copied from class: JsonGenerator
      Method for writing closing marker of a JSON Array value (character ']'; plus possible white space decoration if pretty-printing is enabled).

      Marker can be written if the innermost structured type is Array.

      Specified by:
      writeEndArray in class JsonGenerator
      Returns:
      This generator, to allow call chaining
      Throws:
      JacksonException
    • writeStartObject

      public JsonGenerator writeStartObject() throws JacksonException
      Description copied from class: JsonGenerator
      Method for writing starting marker of an Object value (character '{'; plus possible white space decoration if pretty-printing is enabled).

      Object values can be written in any context where values are allowed: meaning everywhere except for when a property name is expected.

      Specified by:
      writeStartObject in class JsonGenerator
      Returns:
      This generator, to allow call chaining
      Throws:
      JacksonException
    • writeStartObject

      public JsonGenerator writeStartObject(Object forValue) throws JacksonException
      Description copied from class: JsonGenerator
      Method for writing starting marker of an Object value to represent the given Java Object value. Argument is offered as metadata, but more importantly it should be assigned as the "current value" for the Object content that gets constructed and initialized.

      Object values can be written in any context where values are allowed: meaning everywhere except for when a property name is expected.

      Specified by:
      writeStartObject in class JsonGenerator
      Parameters:
      forValue - Java Object that Object being written represents, if any (or null if not known or not applicable)
      Returns:
      This generator, to allow call chaining
      Throws:
      JacksonException
    • writeStartObject

      public JsonGenerator writeStartObject(Object forValue, int size) throws JacksonException
      Description copied from class: JsonGenerator
      Method for writing starting marker of an Object value to represent the given Java Object value. Argument is offered as metadata, but more importantly it should be assigned as the "current value" for the Object content that gets constructed and initialized. In addition, caller knows number of key/value pairs ("properties") that will get written for the Object value: this is relevant for some format backends (but not, as an example, for JSON).

      Object values can be written in any context where values are allowed: meaning everywhere except for when a property name is expected.

      Overrides:
      writeStartObject in class JsonGeneratorBase
      Parameters:
      forValue - Object value to be written (assigned as "current value" for the Object context that gets created)
      size - Number of key/value pairs this Object will have: actual number of entries written (before matching call to JsonGenerator.writeEndObject() MUST match; generator MAY verify this is the case (and SHOULD if format itself encodes length)
      Returns:
      This generator, to allow call chaining
      Throws:
      JacksonException
    • writeEndObject

      public JsonGenerator writeEndObject() throws JacksonException
      Description copied from class: JsonGenerator
      Method for writing closing marker of an Object value (character '}'; plus possible white space decoration if pretty-printing is enabled).

      Marker can be written if the innermost structured type is Object, and the last written event was either a complete value, or START-OBJECT marker (see JSON specification for more details).

      Specified by:
      writeEndObject in class JsonGenerator
      Returns:
      This generator, to allow call chaining
      Throws:
      JacksonException
    • _writePPName

      protected final void _writePPName(String name) throws JacksonException
      Throws:
      JacksonException
    • _writePPName

      protected final void _writePPName(SerializableString name) throws JacksonException
      Throws:
      JacksonException
    • writeString

      public JsonGenerator writeString(String text) throws JacksonException
      Description copied from class: JsonGenerator
      Method for outputting a String value. Depending on context this means either array element, (object) property value or a stand-alone (root-level value) String; but in all cases, String will be surrounded in double quotes, and contents will be properly escaped as required by JSON specification.
      Specified by:
      writeString in class JsonGenerator
      Parameters:
      text - String value to write
      Returns:
      This generator, to allow call chaining
      Throws:
      JacksonException
    • writeString

      public JsonGenerator writeString(Reader reader, int len) throws JacksonException
      Description copied from class: JsonGenerator
      Method for outputting a String value. Depending on context this means either array element, (object) property value or a stand alone String; but in all cases, String will be surrounded in double quotes, and contents will be properly escaped as required by JSON specification. If len is < 0, then write all contents of the reader. Otherwise, write only len characters.

      Note: actual length of content available may exceed len but cannot be less than it: if not enough content available, a StreamWriteException will be thrown.

      Overrides:
      writeString in class GeneratorBase
      Parameters:
      reader - Reader to use for reading Text value to write
      len - Maximum Length of Text value to read (in chars, non-negative) if known; -1 to indicate "read and write it all"
      Returns:
      This generator, to allow call chaining
      Throws:
      JacksonException
    • writeString

      public JsonGenerator writeString(char[] text, int offset, int len) throws JacksonException
      Description copied from class: JsonGenerator
      Method for outputting a String value. Depending on context this means either array element, (object) property value or a stand alone String; but in all cases, String will be surrounded in double quotes, and contents will be properly escaped as required by JSON specification.
      Specified by:
      writeString in class JsonGenerator
      Parameters:
      text - Buffer that contains String value to write
      offset - Offset in buffer of the first character of String value to write
      len - Length of the String value (in characters) to write
      Returns:
      This generator, to allow call chaining
      Throws:
      JacksonException
    • writeString

      public JsonGenerator writeString(SerializableString text) throws JacksonException
      Description copied from class: JsonGenerator
      Method similar to JsonGenerator.writeString(String), but that takes SerializableString which can make this potentially more efficient to call as generator may be able to reuse quoted and/or encoded representation.

      Default implementation just calls JsonGenerator.writeString(String); sub-classes should override it with more efficient implementation if possible.

      Overrides:
      writeString in class GeneratorBase
      Parameters:
      text - Pre-encoded String value to write
      Returns:
      This generator, to allow call chaining
      Throws:
      JacksonException
    • writeRawUTF8String

      public JsonGenerator writeRawUTF8String(byte[] text, int offset, int len) throws JacksonException
      Description copied from class: JsonGenerator
      Method similar to JsonGenerator.writeString(String) but that takes as its input a UTF-8 encoded String that is to be output as-is, without additional escaping (type of which depends on data format; backslashes for JSON). However, quoting that data format requires (like double-quotes for JSON) will be added around the value if and as necessary.

      Note that some backends may choose not to support this method: for example, if underlying destination is a Writer using this method would require UTF-8 decoding. If so, implementation may instead choose to throw a UnsupportedOperationException due to ineffectiveness of having to decode input.

      Specified by:
      writeRawUTF8String in class JsonGenerator
      Parameters:
      text - Buffer that contains String value to write
      offset - Offset in buffer of the first byte of String value to write
      len - Length of the String value (in characters) to write
      Returns:
      This generator, to allow call chaining
      Throws:
      JacksonException
    • writeUTF8String

      public JsonGenerator writeUTF8String(byte[] text, int offset, int len) throws JacksonException
      Description copied from class: JsonGenerator
      Method similar to JsonGenerator.writeString(String) but that takes as its input a UTF-8 encoded String which has not been escaped using whatever escaping scheme data format requires (for JSON that is backslash-escaping for control characters and double-quotes; for other formats something else). This means that textual JSON backends need to check if value needs JSON escaping, but otherwise can just be copied as is to output. Also, quoting that data format requires (like double-quotes for JSON) will be added around the value if and as necessary.

      Note that some backends may choose not to support this method: for example, if underlying destination is a Writer using this method would require UTF-8 decoding. In this case generator implementation may instead choose to throw a UnsupportedOperationException due to ineffectiveness of having to decode input.

      Specified by:
      writeUTF8String in class JsonGenerator
      Parameters:
      text - Buffer that contains String value to write
      offset - Offset in buffer of the first byte of String value to write
      len - Length of the String value (in characters) to write
      Returns:
      This generator, to allow call chaining
      Throws:
      JacksonException
    • writeRaw

      public JsonGenerator writeRaw(String text) throws JacksonException
      Description copied from class: JsonGenerator
      Method that will force generator to copy input text verbatim with no modifications (including that no escaping is done and no separators are added even if context [array, object] would otherwise require such). If such separators are desired, use JsonGenerator.writeRawValue(String) instead.

      Note that not all generator implementations necessarily support such by-pass methods: those that do not will throw UnsupportedOperationException.

      Specified by:
      writeRaw in class JsonGenerator
      Parameters:
      text - Textual contents to include as-is in output.
      Returns:
      This generator, to allow call chaining
      Throws:
      JacksonException
    • writeRaw

      public JsonGenerator writeRaw(String text, int offset, int len) throws JacksonException
      Description copied from class: JsonGenerator
      Method that will force generator to copy input text verbatim with no modifications (including that no escaping is done and no separators are added even if context [array, object] would otherwise require such). If such separators are desired, use JsonGenerator.writeRawValue(String) instead.

      Note that not all generator implementations necessarily support such by-pass methods: those that do not will throw UnsupportedOperationException.

      Specified by:
      writeRaw in class JsonGenerator
      Parameters:
      text - String that has contents to include as-is in output
      offset - Offset within text of the first character to output
      len - Length of content (from text, starting at offset offset) to output
      Returns:
      This generator, to allow call chaining
      Throws:
      JacksonException
    • writeRaw

      public JsonGenerator writeRaw(SerializableString text) throws JacksonException
      Description copied from class: JsonGenerator
      Method that will force generator to copy input text verbatim with no modifications (including that no escaping is done and no separators are added even if context [array, object] would otherwise require such). If such separators are desired, use JsonGenerator.writeRawValue(String) instead.

      Note that not all generator implementations necessarily support such by-pass methods: those that do not will throw UnsupportedOperationException.

      The default implementation delegates to JsonGenerator.writeRaw(String); other backends that support raw inclusion of text are encouraged to implement it in more efficient manner (especially if they use UTF-8 encoding).

      Overrides:
      writeRaw in class JsonGenerator
      Parameters:
      text - Pre-encoded textual contents to included in output
      Returns:
      This generator, to allow call chaining
      Throws:
      JacksonException
    • writeRawValue

      public JsonGenerator writeRawValue(SerializableString text) throws JacksonException
      Description copied from class: JsonGenerator
      Method similar to JsonGenerator.writeRawValue(String), but potentially more efficient as it may be able to use pre-encoded content (similar to JsonGenerator.writeRaw(SerializableString).
      Overrides:
      writeRawValue in class GeneratorBase
      Parameters:
      text - Pre-encoded textual contents to included in output
      Returns:
      This generator, to allow call chaining
      Throws:
      JacksonException
    • writeRaw

      public JsonGenerator writeRaw(char[] cbuf, int offset, int len) throws JacksonException
      Description copied from class: JsonGenerator
      Method that will force generator to copy input text verbatim with no modifications (including that no escaping is done and no separators are added even if context [array, object] would otherwise require such). If such separators are desired, use JsonGenerator.writeRawValue(String) instead.

      Note that not all generator implementations necessarily support such by-pass methods: those that do not will throw UnsupportedOperationException.

      Specified by:
      writeRaw in class JsonGenerator
      Parameters:
      cbuf - Buffer that has contents to include as-is in output
      offset - Offset within text of the first character to output
      len - Length of content (from text, starting at offset offset) to output
      Returns:
      This generator, to allow call chaining
      Throws:
      JacksonException
    • writeRaw

      public JsonGenerator writeRaw(char ch) throws JacksonException
      Description copied from class: JsonGenerator
      Method that will force generator to copy input text verbatim with no modifications (including that no escaping is done and no separators are added even if context [array, object] would otherwise require such). If such separators are desired, use JsonGenerator.writeRawValue(String) instead.

      Note that not all generator implementations necessarily support such by-pass methods: those that do not will throw UnsupportedOperationException.

      Specified by:
      writeRaw in class JsonGenerator
      Parameters:
      ch - Character to included in output
      Returns:
      This generator, to allow call chaining
      Throws:
      JacksonException
    • _writeSegmentedRaw

      private final void _writeSegmentedRaw(char[] cbuf, int offset, int len) throws JacksonException
      Helper method called when it is possible that output of raw section to output may cross buffer boundary
      Throws:
      JacksonException
    • _writeRawSegment

      private void _writeRawSegment(char[] cbuf, int offset, int end) throws JacksonException
      Helper method that is called for segmented write of raw content when explicitly outputting a segment of longer thing. Caller has to take care of ensuring there's no split surrogate pair at the end (that is, last char cannot be first part of a surrogate char pair).
      Throws:
      JacksonException
    • writeBinary

      public JsonGenerator writeBinary(Base64Variant b64variant, byte[] data, int offset, int len) throws JacksonException
      Description copied from class: JsonGenerator
      Method that will output given chunk of binary data as base64 encoded, as a complete String value (surrounded by double quotes). This method defaults

      Note: because JSON Strings cannot contain unescaped linefeeds, if linefeeds are included (as per last argument), they must be escaped. This adds overhead for decoding without improving readability. Alternatively if linefeeds are not included, resulting String value may violate the requirement of base64 RFC which mandates line-length of 76 characters and use of linefeeds. However, all JsonParser implementations are required to accept such "long line base64"; as do typical production-level base64 decoders.

      Specified by:
      writeBinary in class JsonGenerator
      Parameters:
      b64variant - Base64 variant to use: defines details such as whether padding is used (and if so, using which character); what is the maximum line length before adding linefeed, and also the underlying alphabet to use.
      data - Buffer that contains binary data to write
      offset - Offset in data of the first byte of data to write
      len - Length of data to write
      Returns:
      This generator, to allow call chaining
      Throws:
      JacksonException
    • writeBinary

      public int writeBinary(Base64Variant b64variant, InputStream data, int dataLength) throws JacksonException
      Description copied from class: JsonGenerator
      Method similar to JsonGenerator.writeBinary(Base64Variant,byte[],int,int), but where input is provided through a stream, allowing for incremental writes without holding the whole input in memory.
      Overrides:
      writeBinary in class GeneratorBase
      Parameters:
      b64variant - Base64 variant to use
      data - InputStream to use for reading binary data to write. Will not be closed after successful write operation
      dataLength - (optional) number of bytes that will be available; or -1 to be indicate it is not known. If a positive length is given, data MUST provide at least that many bytes: if not, an exception will be thrown. Note that implementations need not support cases where length is not known in advance; this depends on underlying data format: JSON output does NOT require length, other formats may.
      Returns:
      Number of bytes read from data and written as binary payload
      Throws:
      JacksonException
    • writeNumber

      public JsonGenerator writeNumber(short s) throws JacksonException
      Description copied from class: JsonGenerator
      Method for outputting given value as JSON number. Can be called in any context where a value is expected (Array value, Object property value, root-level value). Additional white space may be added around the value if pretty-printing is enabled.
      Specified by:
      writeNumber in class JsonGenerator
      Parameters:
      s - Number value to write
      Returns:
      This generator, to allow call chaining
      Throws:
      JacksonException
    • _writeQuotedShort

      private final void _writeQuotedShort(short s) throws JacksonException
      Throws:
      JacksonException
    • writeNumber

      public JsonGenerator writeNumber(int i) throws JacksonException
      Description copied from class: JsonGenerator
      Method for outputting given value as JSON number. Can be called in any context where a value is expected (Array value, Object property value, root-level value). Additional white space may be added around the value if pretty-printing is enabled.
      Specified by:
      writeNumber in class JsonGenerator
      Parameters:
      i - Number value to write
      Returns:
      This generator, to allow call chaining
      Throws:
      JacksonException
    • _writeQuotedInt

      private final void _writeQuotedInt(int i) throws JacksonException
      Throws:
      JacksonException
    • writeNumber

      public JsonGenerator writeNumber(long l) throws JacksonException
      Description copied from class: JsonGenerator
      Method for outputting given value as JSON number. Can be called in any context where a value is expected (Array value, Object property value, root-level value). Additional white space may be added around the value if pretty-printing is enabled.
      Specified by:
      writeNumber in class JsonGenerator
      Parameters:
      l - Number value to write
      Returns:
      This generator, to allow call chaining
      Throws:
      JacksonException
    • _writeQuotedLong

      private final void _writeQuotedLong(long l) throws JacksonException
      Throws:
      JacksonException
    • writeNumber

      public JsonGenerator writeNumber(BigInteger value) throws JacksonException
      Description copied from class: JsonGenerator
      Method for outputting given value as JSON number. Can be called in any context where a value is expected (Array value, Object property value, root-level value). Additional white space may be added around the value if pretty-printing is enabled.
      Specified by:
      writeNumber in class JsonGenerator
      Parameters:
      value - Number value to write
      Returns:
      This generator, to allow call chaining
      Throws:
      JacksonException
    • writeNumber

      public JsonGenerator writeNumber(double d) throws JacksonException
      Description copied from class: JsonGenerator
      Method for outputting indicate JSON numeric value. Can be called in any context where a value is expected (Array value, Object property value, root-level value). Additional white space may be added around the value if pretty-printing is enabled.
      Specified by:
      writeNumber in class JsonGenerator
      Parameters:
      d - Number value to write
      Returns:
      This generator, to allow call chaining
      Throws:
      JacksonException
    • writeNumber

      public JsonGenerator writeNumber(float f) throws JacksonException
      Description copied from class: JsonGenerator
      Method for outputting indicate JSON numeric value. Can be called in any context where a value is expected (Array value, Object property value, root-level value). Additional white space may be added around the value if pretty-printing is enabled.
      Specified by:
      writeNumber in class JsonGenerator
      Parameters:
      f - Number value to write
      Returns:
      This generator, to allow call chaining
      Throws:
      JacksonException
    • writeNumber

      public JsonGenerator writeNumber(BigDecimal value) throws JacksonException
      Description copied from class: JsonGenerator
      Method for outputting indicate JSON numeric value. Can be called in any context where a value is expected (Array value, Object property value, root-level value). Additional white space may be added around the value if pretty-printing is enabled.
      Specified by:
      writeNumber in class JsonGenerator
      Parameters:
      value - Number value to write
      Returns:
      This generator, to allow call chaining
      Throws:
      JacksonException
    • writeNumber

      public JsonGenerator writeNumber(String encodedValue) throws JacksonException
      Description copied from class: JsonGenerator
      Write method that can be used for custom numeric types that can not be (easily?) converted to "standard" Java number types; or, for special formatting with formats that allow this (CSV). Because numbers are not surrounded by double quotes, regular JsonGenerator.writeString(String) method cannot be used; nor JsonGenerator.writeRaw(String) because that does not properly handle value separators needed in Array or Object contexts.

      Note: because of lack of type safety, some generator implementations will not be able to implement this method. For example, some binary formats require type information for encoding; similarly for generator-wrappers around Java objects or TreeNodes. If implementation does not implement this method, it should a StreamWriteException).

      Specified by:
      writeNumber in class JsonGenerator
      Parameters:
      encodedValue - Textual (possibly formatted) number representation to write
      Returns:
      This generator, to allow call chaining
      Throws:
      JacksonException
    • writeNumber

      public JsonGenerator writeNumber(char[] encodedValueBuffer, int offset, int length) throws JacksonException
      Description copied from class: JsonGenerator
      Overloaded version of JsonGenerator.writeNumber(String) with same semantics but possibly more efficient operation.
      Overrides:
      writeNumber in class JsonGenerator
      Parameters:
      encodedValueBuffer - Buffer that contains the textual number representation to write
      offset - Offset of the first character of value to write
      length - Length of the value (in characters) to write
      Returns:
      This generator, to allow call chaining
      Throws:
      JacksonException
    • _writeQuotedRaw

      private final void _writeQuotedRaw(String value) throws JacksonException
      Throws:
      JacksonException
    • _writeQuotedRaw

      private void _writeQuotedRaw(char[] text, int offset, int length) throws JacksonException
      Throws:
      JacksonException
    • writeBoolean

      public JsonGenerator writeBoolean(boolean state) throws JacksonException
      Description copied from class: JsonGenerator
      Method for outputting literal JSON boolean value (one of Strings 'true' and 'false'). Can be called in any context where a value is expected (Array value, Object property value, root-level value). Additional white space may be added around the value if pretty-printing is enabled.
      Specified by:
      writeBoolean in class JsonGenerator
      Parameters:
      state - Boolean value to write
      Returns:
      This generator, to allow call chaining
      Throws:
      JacksonException
    • writeNull

      public JsonGenerator writeNull() throws JacksonException
      Description copied from class: JsonGenerator
      Method for outputting literal JSON null value. Can be called in any context where a value is expected (Array value, Object property value, root-level value). Additional white space may be added around the value if pretty-printing is enabled.
      Specified by:
      writeNull in class JsonGenerator
      Returns:
      This generator, to allow call chaining
      Throws:
      JacksonException
    • _verifyValueWrite

      protected final void _verifyValueWrite(String typeMsg) throws JacksonException
      Description copied from class: GeneratorBase
      Method called before trying to write a value (scalar or structured), to verify that this is legal in current output state, as well as to output separators if and as necessary.
      Specified by:
      _verifyValueWrite in class GeneratorBase
      Parameters:
      typeMsg - Additional message used for generating exception message if value output is NOT legal in current generator output state.
      Throws:
      JacksonException - if there is a problem in trying to write a value
    • flush

      public void flush() throws JacksonException
      Description copied from class: JsonGenerator
      Method called to flush any buffered content to the underlying target (output stream, writer), and to flush the target itself as well.
      Specified by:
      flush in interface Flushable
      Specified by:
      flush in class JsonGenerator
      Throws:
      JacksonException
    • _closeInput

      protected void _closeInput() throws JacksonException
      Specified by:
      _closeInput in class GeneratorBase
      Throws:
      JacksonException
    • _releaseBuffers

      protected void _releaseBuffers()
      Description copied from class: GeneratorBase
      Method called to release any buffers generator may be holding, once generator is being closed.
      Specified by:
      _releaseBuffers in class GeneratorBase
    • _writeBytes

      private final void _writeBytes(byte[] bytes) throws JacksonException
      Throws:
      JacksonException
    • _writeBytes

      private final void _writeBytes(byte[] bytes, int offset, int len) throws JacksonException
      Throws:
      JacksonException
    • _writeStringSegments

      private final void _writeStringSegments(String text, boolean addQuotes) throws JacksonException
      Method called when String to write is long enough not to fit completely in temporary copy buffer. If so, we will actually copy it in small enough chunks so it can be directly fed to single-segment writes (instead of maximum slices that would fit in copy buffer)
      Throws:
      JacksonException
    • _writeStringSegments

      private final void _writeStringSegments(char[] cbuf, int offset, int totalLen) throws JacksonException
      Method called when character sequence to write is long enough that its maximum encoded and escaped form is not guaranteed to fit in the output buffer. If so, we will need to choose smaller output chunks to write at a time.
      Throws:
      JacksonException
    • _writeStringSegments

      private final void _writeStringSegments(String text, int offset, int totalLen) throws JacksonException
      Throws:
      JacksonException
    • _writeStringSegment

      private final void _writeStringSegment(char[] cbuf, int offset, int len) throws JacksonException
      This method called when the string content is already in a char buffer, and its maximum total encoded and escaped length cannot exceed size of the output buffer. Caller must ensure that there is enough space in output buffer, assuming case of all non-escaped ASCII characters, as well as potentially enough space for other cases (but not necessarily flushed)
      Throws:
      JacksonException
    • _writeStringSegment

      private final void _writeStringSegment(String text, int offset, int len) throws JacksonException
      Throws:
      JacksonException
    • _writeStringSegment2

      private final void _writeStringSegment2(char[] cbuf, int offset, int end) throws JacksonException
      Secondary method called when content contains characters to escape, and/or multi-byte UTF-8 characters.
      Throws:
      JacksonException
    • _writeStringSegment2

      private final void _writeStringSegment2(String text, int offset, int end) throws JacksonException
      Throws:
      JacksonException
    • _writeStringSegmentASCII2

      private final void _writeStringSegmentASCII2(char[] cbuf, int offset, int end) throws JacksonException
      Same as _writeStringSegment2(char[], ...)invalid input: '<'/code., but with additional escaping for high-range code points
      Throws:
      JacksonException
    • _writeStringSegmentASCII2

      private final void _writeStringSegmentASCII2(String text, int offset, int end) throws JacksonException
      Throws:
      JacksonException
    • _writeCustomStringSegment2

      private final void _writeCustomStringSegment2(char[] cbuf, int offset, int end) throws JacksonException
      Same as _writeStringSegmentASCII2(char[], ...)invalid input: '<'/code., but with additional checking for completely custom escapes
      Throws:
      JacksonException
    • _writeCustomStringSegment2

      private final void _writeCustomStringSegment2(String text, int offset, int end) throws JacksonException
      Throws:
      JacksonException
    • _writeCustomEscape

      private final int _writeCustomEscape(byte[] outputBuffer, int outputPtr, SerializableString esc, int remainingChars) throws JacksonException
      Throws:
      JacksonException
    • _handleLongCustomEscape

      private final int _handleLongCustomEscape(byte[] outputBuffer, int outputPtr, int outputEnd, byte[] raw, int remainingChars) throws JacksonException
      Throws:
      JacksonException
    • _writeUTF8Segments

      private final void _writeUTF8Segments(byte[] utf8, int offset, int totalLen) throws JacksonException
      Method called when UTF-8 encoded (but NOT yet escaped!) content is not guaranteed to fit in the output buffer after escaping; as such, we just need to chunk writes.
      Throws:
      JacksonException
    • _writeUTF8Segment

      private final void _writeUTF8Segment(byte[] utf8, int offset, int len) throws JacksonException
      Throws:
      JacksonException
    • _writeUTF8Segment2

      private final void _writeUTF8Segment2(byte[] utf8, int offset, int len) throws JacksonException
      Throws:
      JacksonException
    • _writeBinary

      protected final void _writeBinary(Base64Variant b64variant, byte[] input, int inputPtr, int inputEnd) throws JacksonException
      Throws:
      JacksonException
    • _writeBinary

      protected final int _writeBinary(Base64Variant b64variant, InputStream data, byte[] readBuffer, int bytesLeft) throws JacksonException
      Throws:
      JacksonException
    • _writeBinary

      protected final int _writeBinary(Base64Variant b64variant, InputStream data, byte[] readBuffer) throws JacksonException
      Throws:
      JacksonException
    • _readMore

      private final int _readMore(InputStream in, byte[] readBuffer, int inputPtr, int inputEnd, int maxRead) throws JacksonException
      Throws:
      JacksonException
    • _outputRawMultiByteChar

      private final int _outputRawMultiByteChar(int ch, char[] cbuf, int inputOffset, int inputEnd) throws JacksonException
      Method called to output a character that is beyond range of 1- and 2-byte UTF-8 encodings, when outputting "raw" text (meaning it is not to be escaped or quoted)
      Throws:
      JacksonException
    • _outputSurrogates

      protected final void _outputSurrogates(int surr1, int surr2) throws JacksonException
      Throws:
      JacksonException
    • _outputSurrogatePair

      private int _outputSurrogatePair(char highSurrogate, char lowSurrogate, int outputPtr)
    • _outputMultiByteChar

      private final int _outputMultiByteChar(int ch, int outputPtr) throws JacksonException
      Parameters:
      ch -
      outputPtr - Position within output buffer to append multi-byte in
      Returns:
      New output position after appending
      Throws:
      JacksonException
    • _writeNull

      private final void _writeNull() throws JacksonException
      Throws:
      JacksonException
    • _writeGenericEscape

      private int _writeGenericEscape(int charToEscape, int outputPtr) throws JacksonException
      Method called to write a generic Unicode escape for given character.
      Parameters:
      charToEscape - Character to escape using escape sequence (\\uXXXX)
      Throws:
      JacksonException
    • _flushBuffer

      protected final void _flushBuffer() throws JacksonException
      Throws:
      JacksonException
    • getHexBytes

      private byte[] getHexBytes()
    • _isStartOfSurrogatePair

      private static boolean _isStartOfSurrogatePair(int ch)
    • _isEndOfSurrogatePair

      private static boolean _isEndOfSurrogatePair(int ch)