org.codehaus.jackson
Enum JsonGenerator.Feature

java.lang.Object
  extended by java.lang.Enum<JsonGenerator.Feature>
      extended by org.codehaus.jackson.JsonGenerator.Feature
All Implemented Interfaces:
Serializable, Comparable<JsonGenerator.Feature>
Enclosing class:
JsonGenerator

public static enum JsonGenerator.Feature
extends Enum<JsonGenerator.Feature>

Enumeration that defines all togglable features for generators.


Enum Constant Summary
AUTO_CLOSE_JSON_CONTENT
          Feature that determines what happens when the generator is closed while there are still unmatched JsonToken.START_ARRAY or JsonToken.START_OBJECT entries in output content.
AUTO_CLOSE_TARGET
          Feature that determines whether generator will automatically close underlying output target that is NOT owned by the generator.
ESCAPE_NON_ASCII
          Feature that specifies that all characters beyond 7-bit ASCII range (i.e.
FLUSH_PASSED_TO_STREAM
          Feature that specifies that calls to JsonGenerator.flush() will cause matching flush() to underlying OutputStream or Writer; if disabled this will not be done.
QUOTE_FIELD_NAMES
          Feature that determines whether JSON Object field names are quoted using double-quotes, as specified by JSON specification or not.
QUOTE_NON_NUMERIC_NUMBERS
          Feature that determines whether "exceptional" (not real number) float/double values are output as quoted strings.
WRITE_NUMBERS_AS_STRINGS
          Feature that forces all Java numbers to be written as JSON strings.
 
Method Summary
static int collectDefaults()
          Method that calculates bit set (flags) of all features that are enabled by default.
 boolean enabledByDefault()
           
 int getMask()
           
static JsonGenerator.Feature valueOf(String name)
          Returns the enum constant of this type with the specified name.
static JsonGenerator.Feature[] values()
          Returns an array containing the constants of this enum type, in the order they are declared.
 
Methods inherited from class java.lang.Enum
clone, compareTo, equals, finalize, getDeclaringClass, hashCode, name, ordinal, toString, valueOf
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Enum Constant Detail

AUTO_CLOSE_TARGET

public static final JsonGenerator.Feature AUTO_CLOSE_TARGET
Feature that determines whether generator will automatically close underlying output target that is NOT owned by the generator. If disabled, calling application has to separately close the underlying OutputStream and Writer instances used to create the generator. If enabled, generator will handle closing, as long as generator itself gets closed: this happens when end-of-input is encountered, or generator is closed by a call to JsonGenerator.close().

Feature is enabled by default.


AUTO_CLOSE_JSON_CONTENT

public static final JsonGenerator.Feature AUTO_CLOSE_JSON_CONTENT
Feature that determines what happens when the generator is closed while there are still unmatched JsonToken.START_ARRAY or JsonToken.START_OBJECT entries in output content. If enabled, such Array(s) and/or Object(s) are automatically closed; if disabled, nothing specific is done.

Feature is enabled by default.


QUOTE_FIELD_NAMES

public static final JsonGenerator.Feature QUOTE_FIELD_NAMES
Feature that determines whether JSON Object field names are quoted using double-quotes, as specified by JSON specification or not. Ability to disable quoting was added to support use cases where they are not usually expected, which most commonly occurs when used straight from Javascript.


QUOTE_NON_NUMERIC_NUMBERS

public static final JsonGenerator.Feature QUOTE_NON_NUMERIC_NUMBERS
Feature that determines whether "exceptional" (not real number) float/double values are output as quoted strings. The values checked are Double.Nan, Double.POSITIVE_INFINITY and Double.NEGATIVE_INIFINTY (and associated Float values). If feature is disabled, these numbers are still output using associated literal values, resulting in non-conformant output.

Feature is enabled by default.


WRITE_NUMBERS_AS_STRINGS

public static final JsonGenerator.Feature WRITE_NUMBERS_AS_STRINGS
Feature that forces all Java numbers to be written as JSON strings. Default state is 'false', meaning that Java numbers are to be serialized using basic numeric serialization (as JSON numbers, integral or floating point). If enabled, all such numeric values are instead written out as JSON Strings.

One use case is to avoid problems with Javascript limitations: since Javascript standard specifies that all number handling should be done using 64-bit IEEE 754 floating point values, result being that some 64-bit integer values can not be accurately represent (as mantissa is only 51 bit wide).

Feature is disabled by default.

Since:
1.3

FLUSH_PASSED_TO_STREAM

public static final JsonGenerator.Feature FLUSH_PASSED_TO_STREAM
Feature that specifies that calls to JsonGenerator.flush() will cause matching flush() to underlying OutputStream or Writer; if disabled this will not be done. Main reason to disable this feature is to prevent flushing at generator level, if it is not possible to prevent method being called by other code (like ObjectMapper or third party libraries).

Feature is enabled by default.

Since:
1.7

ESCAPE_NON_ASCII

public static final JsonGenerator.Feature ESCAPE_NON_ASCII
Feature that specifies that all characters beyond 7-bit ASCII range (i.e. code points of 128 and above) need to be output using format-specific escapes (for JSON, backslash escapes), if format uses escaping mechanisms (which is generally true for textual formats but not for binary formats).

Since:
1.8
Method Detail

values

public static JsonGenerator.Feature[] values()
Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:
for (JsonGenerator.Feature c : JsonGenerator.Feature.values())
    System.out.println(c);

Returns:
an array containing the constants of this enum type, in the order they are declared

valueOf

public static JsonGenerator.Feature valueOf(String name)
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)

Parameters:
name - the name of the enum constant to be returned.
Returns:
the enum constant with the specified name
Throws:
IllegalArgumentException - if this enum type has no constant with the specified name
NullPointerException - if the argument is null

collectDefaults

public static int collectDefaults()
Method that calculates bit set (flags) of all features that are enabled by default.


enabledByDefault

public boolean enabledByDefault()

getMask

public int getMask()