Top Description Fields Constructors Methods
com.amazon.ion.impl

public final Class _Private_IonTextAppender

extends Object
implements Closeable, Flushable
Class Inheritance
All Implemented Interfaces
java.io.Flushable, java.io.Closeable, java.lang.AutoCloseable
Static Imports
com.amazon.ion.impl._Private_IonConstants.MAX_LONG_TEXT_SIZE, ._Private_IonConstants.isHighSurrogate, ._Private_IonConstants.isLowSurrogate, ._Private_IonConstants.makeUnicodeScalar

NOT FOR APPLICATION USE!

Generic text sink that enables optimized output of both ASCII and UTF-16.

Field Summary

Modifier and TypeField and Description
private final char[]
private final boolean
private static final String
private static final String
private static final boolean[]
private static final boolean[]
pack-priv static final String[]
JSON_ESCAPE_CODES

Escapes for U+00 through U+FF, for use in double-quoted JSON strings.

pack-priv static final String[]
LONG_STRING_ESCAPE_CODES

Escapes for U+00 through U+FF, for use in triple-quoted Ion strings.

private final _Private_FastAppendable
public static final boolean[]
private static final String[]
STRING_ESCAPE_CODES

Escapes for U+00 through U+FF, for use in double-quoted Ion strings.

pack-priv static final String[]
SYMBOL_ESCAPE_CODES

Escapes for U+00 through U+FF, for use in single-quoted Ion symbols.

private static final String
public static final String[]

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public void
appendAscii(char c)

public void
public void
appendAscii(CharSequence csq, int start, int end)

public void
appendUtf16(char c)

public void
appendUtf16Surrogate(char leadSurrogate, char trailSurrogate)

private String

Returns:

the string representation in base 10
bigIntegerToString
(final BigInteger
the integer to convert
value
)

Convert BigInteger to a String.

public void
close()

Implements java.io.Closeable.close.

Closes this stream and releases any system resources associated with it.

public void
flush()

Implements java.io.Flushable.flush.

Flushes this stream by writing any buffered output to the underlying stream.

public static _Private_IonTextAppender
forAppendable(Appendable out, Charset
must be either IonTextWriterBuilder#ASCII or IonTextWriterBuilder#UTF8. When ASCII is used, all non-ASCII characters will be escaped. Otherwise, only select code points will be escaped.
charset
)

public static _Private_IonTextAppender
forAppendable(Appendable out)

Doesn't escape non-ASCII characters.

public static _Private_IonTextAppender
public static _Private_IonTextAppender
forOutputStream(OutputStream out, Charset
must be either IonTextWriterBuilder#ASCII or IonTextWriterBuilder#UTF8. When ASCII is used, all non-ASCII characters will be escaped. Otherwise, only select code points will be escaped.
charset
)

private static boolean
is8bitValue(int v)

private static boolean
isDecimalDigit(int codePoint)

public static boolean

Returns:

true if the text is an identifier keyword.
isIdentifierKeyword
(CharSequence
the symbol to check.
text
)

Determines whether the given text matches one of the Ion identifier keywords null, true, or false.

public static boolean
isIdentifierPart(int codePoint)

public static boolean
isIdentifierStart(int codePoint)

public static boolean
isOperatorPart(int codePoint)

public void
printBlob(_Private_IonTextWriterBuilder _options, byte[] value, int start, int len)

public void
printClob(_Private_IonTextWriterBuilder _options, byte[] value, int start, int len)

private void
printClobBytes(byte[] value, int start, int end, String[] escapes)

private final void
public void
public void
printFloat(_Private_IonTextWriterBuilder _options, double value)

public void
public void
printInt(long value)

public void
public final void
printJsonString(CharSequence text)

Print a JSON string

public final void
printLongString(CharSequence text)

Print an Ion triple-quoted string

public final void
printQuotedSymbol(CharSequence text)

Print single-quoted Ion Symbol type

public final void
printString(CharSequence text)

Print an Ion String type

public final void
printSymbol(CharSequence text)

Print an Ion Symbol type.

public static boolean

Returns:

true if the given symbol requires quoting.
symbolNeedsQuoting
(CharSequence
must be a non-empty string.
symbol
,
boolean
indicates whether the caller wants operators to be quoted; if true then operator symbols like != will return true. has looser quoting requirements than other containers.
quoteOperators
)

Determines whether the text of a symbol requires (single) quotes.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

_fixedIntBufferback to summary
private final char[] _fixedIntBuffer

ONLY FOR USE BY printInt(long).

escapeNonAsciiback to summary
private final boolean escapeNonAscii
HEX_4_PREFIXback to summary
private static final String HEX_4_PREFIX
HEX_8_PREFIXback to summary
private static final String HEX_8_PREFIX
IDENTIFIER_FOLLOW_CHAR_FLAGSback to summary
private static final boolean[] IDENTIFIER_FOLLOW_CHAR_FLAGS
IDENTIFIER_START_CHAR_FLAGSback to summary
private static final boolean[] IDENTIFIER_START_CHAR_FLAGS
JSON_ESCAPE_CODESback to summary
pack-priv static final String[] JSON_ESCAPE_CODES

Escapes for U+00 through U+FF, for use in double-quoted JSON strings. This includes escapes for all LATIN-1 code points U+80 through U+FF.

LONG_STRING_ESCAPE_CODESback to summary
pack-priv static final String[] LONG_STRING_ESCAPE_CODES

Escapes for U+00 through U+FF, for use in triple-quoted Ion strings. This includes escapes for all LATIN-1 code points U+80 through U+FF.

myAppendableback to summary
private final _Private_FastAppendable myAppendable
OPERATOR_CHAR_FLAGSback to summary
public static final boolean[] OPERATOR_CHAR_FLAGS
STRING_ESCAPE_CODESback to summary
private static final String[] STRING_ESCAPE_CODES

Escapes for U+00 through U+FF, for use in double-quoted Ion strings. This includes escapes for all LATIN-1 code points U+80 through U+FF.

SYMBOL_ESCAPE_CODESback to summary
pack-priv static final String[] SYMBOL_ESCAPE_CODES

Escapes for U+00 through U+FF, for use in single-quoted Ion symbols. This includes escapes for all LATIN-1 code points U+80 through U+FF.

TRIPLE_QUOTESback to summary
private static final String TRIPLE_QUOTES
ZERO_PADDINGback to summary
public static final String[] ZERO_PADDING

Constructor Detail

_Private_IonTextAppenderback to summary
pack-priv _Private_IonTextAppender(_Private_FastAppendable out, boolean escapeNonAscii)

Method Detail

appendAsciiback to summary
public void appendAscii(char c) throws IOException
appendAsciiback to summary
public void appendAscii(CharSequence csq) throws IOException
appendAsciiback to summary
public void appendAscii(CharSequence csq, int start, int end) throws IOException
appendUtf16back to summary
public void appendUtf16(char c) throws IOException
appendUtf16Surrogateback to summary
public void appendUtf16Surrogate(char leadSurrogate, char trailSurrogate) throws IOException
bigIntegerToStringback to summary
private String bigIntegerToString(final BigInteger value)

Convert BigInteger to a String.

The current implementation of BigInteger#toString() is suboptimal speed-wise, as it uses non-native division for arbitrary-sized integers to convert the binary representation to a string. This is inefficient for integers that can fit into a Long, where native division can be used to convert the long to its string representation, which is currently implemented in Long#toString().

This method delegates to Long#toString() if it's possible to do so, which results in a speedup from 2x to 5x.

Parameters
value:BigInteger

the integer to convert

Returns:String

the string representation in base 10

closeback to summary
public void close() throws IOException

Implements java.io.Closeable.close.

Doc from java.io.Closeable.close.

Closes this stream and releases any system resources associated with it. If the stream is already closed then invoking this method has no effect.

As noted in AutoCloseable#close(), cases where the close may fail require careful attention. It is strongly advised to relinquish the underlying resources and to internally mark the Closeable as closed, prior to throwing the IOException.

Exceptions
IOException:
if an I/O error occurs
flushback to summary
public void flush() throws IOException

Implements java.io.Flushable.flush.

Doc from java.io.Flushable.flush.

Flushes this stream by writing any buffered output to the underlying stream.

Exceptions
IOException:
If an I/O error occurs
forAppendableback to summary
public static _Private_IonTextAppender forAppendable(Appendable out, Charset charset)
Parameters
charset:Charset

must be either IonTextWriterBuilder#ASCII or IonTextWriterBuilder#UTF8. When ASCII is used, all non-ASCII characters will be escaped. Otherwise, only select code points will be escaped.

forAppendableback to summary
public static _Private_IonTextAppender forAppendable(Appendable out)

Doesn't escape non-ASCII characters.

forFastAppendableback to summary
public static _Private_IonTextAppender forFastAppendable(_Private_FastAppendable out, Charset charset)
forOutputStreamback to summary
public static _Private_IonTextAppender forOutputStream(OutputStream out, Charset charset)
Parameters
charset:Charset

must be either IonTextWriterBuilder#ASCII or IonTextWriterBuilder#UTF8. When ASCII is used, all non-ASCII characters will be escaped. Otherwise, only select code points will be escaped.

is8bitValueback to summary
private static boolean is8bitValue(int v)
isDecimalDigitback to summary
private static boolean isDecimalDigit(int codePoint)
isIdentifierKeywordback to summary
public static boolean isIdentifierKeyword(CharSequence text)

Determines whether the given text matches one of the Ion identifier keywords null, true, or false.

This does not check for non-identifier keywords such as null.int.

Parameters
text:CharSequence

the symbol to check.

Returns:boolean

true if the text is an identifier keyword.

isIdentifierPartback to summary
public static boolean isIdentifierPart(int codePoint)
isIdentifierStartback to summary
public static boolean isIdentifierStart(int codePoint)
isOperatorPartback to summary
public static boolean isOperatorPart(int codePoint)
printBlobback to summary
public void printBlob(_Private_IonTextWriterBuilder _options, byte[] value, int start, int len) throws IOException
printClobback to summary
public void printClob(_Private_IonTextWriterBuilder _options, byte[] value, int start, int len) throws IOException
printClobBytesback to summary
private void printClobBytes(byte[] value, int start, int end, String[] escapes) throws IOException
printCodePointsback to summary
private final void printCodePoints(CharSequence text, String[] escapes) throws IOException
printDecimalback to summary
public void printDecimal(_Private_IonTextWriterBuilder _options, BigDecimal value) throws IOException
printFloatback to summary
public void printFloat(_Private_IonTextWriterBuilder _options, double value) throws IOException
printFloatback to summary
public void printFloat(_Private_IonTextWriterBuilder _options, Double value) throws IOException
printIntback to summary
public void printInt(long value) throws IOException
printIntback to summary
public void printInt(BigInteger value) throws IOException
printJsonStringback to summary
public final void printJsonString(CharSequence text) throws IOException

Print a JSON string

printLongStringback to summary
public final void printLongString(CharSequence text) throws IOException

Print an Ion triple-quoted string

printQuotedSymbolback to summary
public final void printQuotedSymbol(CharSequence text) throws IOException

Print single-quoted Ion Symbol type

printStringback to summary
public final void printString(CharSequence text) throws IOException

Print an Ion String type

printSymbolback to summary
public final void printSymbol(CharSequence text) throws IOException

Print an Ion Symbol type. This method will check if symbol needs quoting

symbolNeedsQuotingback to summary
public static boolean symbolNeedsQuoting(CharSequence symbol, boolean quoteOperators)

Determines whether the text of a symbol requires (single) quotes.

Parameters
symbol:CharSequence

must be a non-empty string.

quoteOperators:boolean

indicates whether the caller wants operators to be quoted; if true then operator symbols like != will return true. has looser quoting requirements than other containers.

Returns:boolean

true if the given symbol requires quoting.

Exceptions
NullPointerException:
if symbol is null.