Package org.apache.johnzon.core
Class JsonGeneratorImpl
- java.lang.Object
-
- org.apache.johnzon.core.JsonGeneratorImpl
-
- All Implemented Interfaces:
jakarta.json.stream.JsonGenerator
,Closeable
,Flushable
,Serializable
,AutoCloseable
,JsonChars
class JsonGeneratorImpl extends Object implements jakarta.json.stream.JsonGenerator, JsonChars, Serializable
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
JsonGeneratorImpl.GeneratorState
-
Field Summary
Fields Modifier and Type Field Description private char[]
buffer
private int
bufferPos
private BufferStrategy.BufferProvider<char[]>
bufferProvider
private boolean
closed
private int
depth
private static String
INDENT
private boolean
prettyPrint
private HStack<JsonGeneratorImpl.GeneratorState>
state
private static String
UNICODE_PREFIX
private static String
UNICODE_PREFIX_HELPER
private Writer
writer
-
Fields inherited from interface org.apache.johnzon.core.JsonChars
BACKSPACE, COMMA_CHAR, COMMA_EVENT, CR, DOT, END_ARRAY, END_ARRAY_CHAR, END_OBJECT, END_OBJECT_CHAR, EOF, EOL, ESCAPE_CHAR, EVT_MAP, EXP_LOWERCASE, EXP_UPPERCASE, FALSE_A, FALSE_E, FALSE_F, FALSE_L, FALSE_S, FORMFEED, KEY_NAME, KEY_SEPARATOR, KEY_SEPARATOR_EVENT, MINUS, NINE, NULL, NULL_L, NULL_N, NULL_U, PLUS, QUOTE_CHAR, SPACE, START_ARRAY, START_ARRAY_CHAR, START_OBJECT, START_OBJECT_CHAR, TAB, TRUE_E, TRUE_R, TRUE_T, TRUE_U, VALUE_FALSE, VALUE_NULL, VALUE_NUMBER, VALUE_STRING, VALUE_TRUE, ZERO
-
-
Constructor Summary
Constructors Constructor Description JsonGeneratorImpl(Writer writer, BufferStrategy.BufferProvider<char[]> bufferProvider, boolean prettyPrint)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private void
alignState()
private void
checkArrayOrValue()
private static void
checkDoubleRange(double value)
private void
checkObject()
void
close()
private JsonGeneratorImpl.GeneratorState
currentState()
void
flush()
private void
flushBuffer()
private void
justWrite(char value)
private void
justWrite(String value)
private void
prepareValue()
private void
swapState(JsonGeneratorImpl.GeneratorState newState)
private static String
toUnicode(char c)
jakarta.json.stream.JsonGenerator
write(boolean value)
jakarta.json.stream.JsonGenerator
write(double value)
jakarta.json.stream.JsonGenerator
write(int value)
jakarta.json.stream.JsonGenerator
write(long value)
jakarta.json.stream.JsonGenerator
write(jakarta.json.JsonValue value)
jakarta.json.stream.JsonGenerator
write(String value)
jakarta.json.stream.JsonGenerator
write(String name, boolean value)
jakarta.json.stream.JsonGenerator
write(String name, double value)
jakarta.json.stream.JsonGenerator
write(String name, int value)
jakarta.json.stream.JsonGenerator
write(String name, long value)
jakarta.json.stream.JsonGenerator
write(String name, jakarta.json.JsonValue value)
jakarta.json.stream.JsonGenerator
write(String name, String value)
jakarta.json.stream.JsonGenerator
write(String name, BigDecimal value)
jakarta.json.stream.JsonGenerator
write(String name, BigInteger value)
jakarta.json.stream.JsonGenerator
write(BigDecimal value)
jakarta.json.stream.JsonGenerator
write(BigInteger value)
private void
writeCachedKey(String name)
jakarta.json.stream.JsonGenerator
writeEnd()
private void
writeEol()
private void
writeEscaped0(String value)
private void
writeIndent()
private void
writeInt0(int i)
private void
writeJsonValue(jakarta.json.JsonValue value)
private void
writeJsonValue(String name, jakarta.json.JsonValue value)
jakarta.json.stream.JsonGenerator
writeKey(String key)
private void
writeLong0(long i)
jakarta.json.stream.JsonGenerator
writeNull()
jakarta.json.stream.JsonGenerator
writeNull(String name)
jakarta.json.stream.JsonGenerator
writeStartArray()
jakarta.json.stream.JsonGenerator
writeStartArray(String name)
jakarta.json.stream.JsonGenerator
writeStartObject()
jakarta.json.stream.JsonGenerator
writeStartObject(String name)
private void
writeValue(int value)
private void
writeValue(long value)
private void
writeValue(String value)
private void
writeValueAsJsonString(String value)
-
-
-
Field Detail
-
writer
private final transient Writer writer
-
bufferProvider
private final BufferStrategy.BufferProvider<char[]> bufferProvider
-
buffer
private final char[] buffer
-
bufferPos
private int bufferPos
-
prettyPrint
private final boolean prettyPrint
-
INDENT
private static final String INDENT
- See Also:
- Constant Field Values
-
depth
private int depth
-
closed
private boolean closed
-
state
private final HStack<JsonGeneratorImpl.GeneratorState> state
-
UNICODE_PREFIX
private static final String UNICODE_PREFIX
- See Also:
- Constant Field Values
-
UNICODE_PREFIX_HELPER
private static final String UNICODE_PREFIX_HELPER
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
JsonGeneratorImpl
JsonGeneratorImpl(Writer writer, BufferStrategy.BufferProvider<char[]> bufferProvider, boolean prettyPrint)
-
-
Method Detail
-
writeEol
private void writeEol()
-
writeIndent
private void writeIndent()
-
writeCachedKey
private void writeCachedKey(String name)
-
writeStartObject
public jakarta.json.stream.JsonGenerator writeStartObject()
- Specified by:
writeStartObject
in interfacejakarta.json.stream.JsonGenerator
-
writeStartObject
public jakarta.json.stream.JsonGenerator writeStartObject(String name)
- Specified by:
writeStartObject
in interfacejakarta.json.stream.JsonGenerator
-
writeStartArray
public jakarta.json.stream.JsonGenerator writeStartArray()
- Specified by:
writeStartArray
in interfacejakarta.json.stream.JsonGenerator
-
writeStartArray
public jakarta.json.stream.JsonGenerator writeStartArray(String name)
- Specified by:
writeStartArray
in interfacejakarta.json.stream.JsonGenerator
-
writeJsonValue
private void writeJsonValue(String name, jakarta.json.JsonValue value)
-
writeJsonValue
private void writeJsonValue(jakarta.json.JsonValue value)
-
write
public jakarta.json.stream.JsonGenerator write(String name, jakarta.json.JsonValue value)
- Specified by:
write
in interfacejakarta.json.stream.JsonGenerator
-
write
public jakarta.json.stream.JsonGenerator write(String name, String value)
- Specified by:
write
in interfacejakarta.json.stream.JsonGenerator
-
write
public jakarta.json.stream.JsonGenerator write(String name, BigInteger value)
- Specified by:
write
in interfacejakarta.json.stream.JsonGenerator
-
write
public jakarta.json.stream.JsonGenerator write(String name, BigDecimal value)
- Specified by:
write
in interfacejakarta.json.stream.JsonGenerator
-
write
public jakarta.json.stream.JsonGenerator write(String name, int value)
- Specified by:
write
in interfacejakarta.json.stream.JsonGenerator
-
write
public jakarta.json.stream.JsonGenerator write(String name, long value)
- Specified by:
write
in interfacejakarta.json.stream.JsonGenerator
-
write
public jakarta.json.stream.JsonGenerator write(String name, double value)
- Specified by:
write
in interfacejakarta.json.stream.JsonGenerator
-
write
public jakarta.json.stream.JsonGenerator write(String name, boolean value)
- Specified by:
write
in interfacejakarta.json.stream.JsonGenerator
-
writeNull
public jakarta.json.stream.JsonGenerator writeNull(String name)
- Specified by:
writeNull
in interfacejakarta.json.stream.JsonGenerator
-
writeEnd
public jakarta.json.stream.JsonGenerator writeEnd()
- Specified by:
writeEnd
in interfacejakarta.json.stream.JsonGenerator
-
write
public jakarta.json.stream.JsonGenerator write(jakarta.json.JsonValue value)
- Specified by:
write
in interfacejakarta.json.stream.JsonGenerator
-
write
public jakarta.json.stream.JsonGenerator write(String value)
- Specified by:
write
in interfacejakarta.json.stream.JsonGenerator
-
write
public jakarta.json.stream.JsonGenerator write(BigDecimal value)
- Specified by:
write
in interfacejakarta.json.stream.JsonGenerator
-
write
public jakarta.json.stream.JsonGenerator write(BigInteger value)
- Specified by:
write
in interfacejakarta.json.stream.JsonGenerator
-
write
public jakarta.json.stream.JsonGenerator write(int value)
- Specified by:
write
in interfacejakarta.json.stream.JsonGenerator
-
write
public jakarta.json.stream.JsonGenerator write(long value)
- Specified by:
write
in interfacejakarta.json.stream.JsonGenerator
-
write
public jakarta.json.stream.JsonGenerator write(double value)
- Specified by:
write
in interfacejakarta.json.stream.JsonGenerator
-
write
public jakarta.json.stream.JsonGenerator write(boolean value)
- Specified by:
write
in interfacejakarta.json.stream.JsonGenerator
-
writeNull
public jakarta.json.stream.JsonGenerator writeNull()
- Specified by:
writeNull
in interfacejakarta.json.stream.JsonGenerator
-
writeKey
public jakarta.json.stream.JsonGenerator writeKey(String key)
- Specified by:
writeKey
in interfacejakarta.json.stream.JsonGenerator
-
close
public void close()
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Specified by:
close
in interfacejakarta.json.stream.JsonGenerator
-
flush
public void flush()
-
flushBuffer
private void flushBuffer()
-
writeEscaped0
private void writeEscaped0(String value)
-
toUnicode
private static String toUnicode(char c)
-
justWrite
private void justWrite(String value)
-
justWrite
private void justWrite(char value)
-
checkObject
private void checkObject()
-
checkArrayOrValue
private void checkArrayOrValue()
-
checkDoubleRange
private static void checkDoubleRange(double value)
-
prepareValue
private void prepareValue()
-
alignState
private void alignState()
-
swapState
private void swapState(JsonGeneratorImpl.GeneratorState newState)
-
currentState
private JsonGeneratorImpl.GeneratorState currentState()
-
writeValueAsJsonString
private void writeValueAsJsonString(String value)
-
writeValue
private void writeValue(String value)
-
writeValue
private void writeValue(int value)
-
writeValue
private void writeValue(long value)
-
writeLong0
private void writeLong0(long i)
-
writeInt0
private void writeInt0(int i)
-
-