Class JsonGeneratorImpl

    • 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
      • _cfgUnqNames

        protected boolean _cfgUnqNames
        Flag that is set if quoting is not to be added around JSON Object property names.
        Since:
        2.7
    • Constructor Detail

      • JsonGeneratorImpl

        public JsonGeneratorImpl​(IOContext ctxt,
                                 int features,
                                 ObjectCodec codec)
    • Method Detail

      • version

        public Version version()
        Description copied from class: GeneratorBase
        Implemented with standard version number detection algorithm, typically using a simple generated class, with information extracted from Maven project file during build.
        Specified by:
        version in interface Versioned
        Overrides:
        version in class GeneratorBase
      • _checkStdFeatureChanges

        protected void _checkStdFeatureChanges​(int newFeatureFlags,
                                               int changedFeatures)
        Description copied from class: GeneratorBase
        Helper method called to verify changes to standard features.
        Overrides:
        _checkStdFeatureChanges in class GeneratorBase
        Parameters:
        newFeatureFlags - Bitflag of standard features after they were changed
        changedFeatures - Bitflag of standard features for which setting did change
      • 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 0 to indicate no additional escaping is performed.
      • writeStringField

        public final void writeStringField​(String fieldName,
                                           String value)
                                    throws IOException
        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
      • _reportCantWriteValueExpectName

        protected void _reportCantWriteValueExpectName​(String typeMsg)
                                                throws IOException
        Throws:
        IOException