public class IonTextUtils extends Object
Modifier and Type | Class and Description |
---|---|
static class |
IonTextUtils.SymbolVariant |
Constructor and Description |
---|
IonTextUtils() |
Modifier and Type | Method and Description |
---|---|
static boolean |
isDigit(int codePoint,
int radix) |
static boolean |
isIdentifierPart(int codePoint) |
static boolean |
isIdentifierStart(int codePoint) |
static boolean |
isNumericStop(int codePoint)
Determines whether a given code point is one of the valid Ion numeric
terminators.
|
static boolean |
isOperatorPart(int codePoint) |
static boolean |
isWhitespace(int codePoint)
Ion whitespace is defined as one of the characters space, tab, newline,
and carriage-return.
|
static void |
printBlob(Appendable out,
byte[] value) |
static String |
printBlob(byte[] value) |
static void |
printClob(Appendable out,
byte[] value) |
static String |
printClob(byte[] value) |
static String |
printCodePointAsString(int codePoint)
Builds a String denoting an ASCII-encoded Ion string,
with double-quotes surrounding a single Unicode code point.
|
static void |
printDecimal(Appendable out,
BigDecimal decimal) |
static String |
printDecimal(BigDecimal decimal) |
static void |
printFloat(Appendable out,
double value) |
static void |
printFloat(Appendable out,
Double value) |
static String |
printFloat(double value) |
static String |
printFloat(Double value) |
static void |
printJsonCodePoint(Appendable out,
int codePoint)
Prints a single Unicode code point for use in an ASCII-safe JSON string.
|
static void |
printJsonString(Appendable out,
CharSequence text)
Prints characters as an ASCII-encoded JSON string, including surrounding
double-quotes.
|
static void |
printLongString(Appendable out,
CharSequence text)
Prints characters as an ASCII-encoded Ion "long string",
including surrounding triple-quotes.
|
static String |
printLongString(CharSequence text)
Builds a String denoting an ASCII-encoded Ion "long string",
including surrounding triple-quotes.
|
static void |
printQuotedSymbol(Appendable out,
CharSequence text)
Prints text as a single-quoted Ion symbol.
|
static String |
printQuotedSymbol(CharSequence text)
Builds a String containing a single-quoted Ion symbol.
|
static void |
printString(Appendable out,
CharSequence text)
Prints characters as an ASCII-encoded Ion string, including surrounding
double-quotes.
|
static String |
printString(CharSequence text)
Builds a String denoting an ASCII-encoded Ion string,
including surrounding double-quotes.
|
static void |
printStringCodePoint(Appendable out,
int codePoint)
Prints a single Unicode code point for use in an ASCII-safe Ion string.
|
static void |
printSymbol(Appendable out,
CharSequence text)
Prints the text as an Ion symbol, including surrounding single-quotes if
they are necessary.
|
static String |
printSymbol(CharSequence text)
Prints the text as an Ion symbol, including surrounding single-quotes if
they are necessary.
|
static void |
printSymbolCodePoint(Appendable out,
int codePoint)
Prints a single Unicode code point for use in an ASCII-safe Ion symbol.
|
static IonTextUtils.SymbolVariant |
symbolVariant(CharSequence symbol)
Determines whether the text of a symbol represents an identifier, an
operator, or a symbol that always requires (single) quotes.
|
public static boolean isWhitespace(int codePoint)
codePoint
- the character to test.true
if c
is one of the four legal
Ion whitespace characters.public static boolean isNumericStop(int codePoint)
The slash character '/'
is not itself a valid terminator, but
if the next character is '/'
or '*'
then the number is
followed by a comment. Since this method cannot perform the look-ahead
necessary to make that determination, it returns false
for the
slash.
codePoint
- the Unicode scalar to test.'/'
.public static boolean isDigit(int codePoint, int radix)
public static boolean isIdentifierStart(int codePoint)
public static boolean isIdentifierPart(int codePoint)
public static boolean isOperatorPart(int codePoint)
public static IonTextUtils.SymbolVariant symbolVariant(CharSequence symbol)
symbol
- must be a non-empty string.NullPointerException
- if symbol
is null
.EmptySymbolException
- if symbol
is empty.public static void printStringCodePoint(Appendable out, int codePoint) throws IOException
out
- the stream to receive the data.codePoint
- a Unicode code point.IOException
public static void printSymbolCodePoint(Appendable out, int codePoint) throws IOException
out
- the stream to receive the data.codePoint
- a Unicode code point.IOException
public static void printJsonCodePoint(Appendable out, int codePoint) throws IOException
out
- the stream to receive the data.codePoint
- a Unicode code point.IOException
public static void printString(Appendable out, CharSequence text) throws IOException
text
is null, this prints null.string
.out
- the stream to receive the data.text
- the text to print; may be null
.IOException
- if the Appendable
throws an exception.IllegalArgumentException
- if the text contains invalid UTF-16 surrogates.public static void printJsonString(Appendable out, CharSequence text) throws IOException
text
is null, this prints null
.out
- the stream to receive the JSON data.text
- the text to print; may be null
.IOException
- if the Appendable
throws an exception.IllegalArgumentException
- if the text contains invalid UTF-16 surrogates.public static String printString(CharSequence text)
text
is null, this returns "null.string"
.text
- the text to print; may be null
.IllegalArgumentException
- if the text contains invalid UTF-16 surrogates.public static String printLongString(CharSequence text)
text
is null, this returns "null.string"
.text
- the text to print; may be null
.IllegalArgumentException
- if the text contains invalid UTF-16 surrogates.public static void printLongString(Appendable out, CharSequence text) throws IOException
text
is null, this prints null.string
.out
- the stream to receive the data.text
- the text to print; may be null
.IOException
- if the Appendable
throws an exception.IllegalArgumentException
- if the text contains invalid UTF-16 surrogates.public static String printCodePointAsString(int codePoint)
codePoint
- a Unicode code point.public static void printSymbol(Appendable out, CharSequence text) throws IOException
'+'
are quoted.
If the text
is null, this prints null.symbol
.out
- the stream to receive the Ion data.text
- the symbol text; may be null
.EmptySymbolException
- if text
is empty.IOException
- if the Appendable
throws an exception.printSymbol(CharSequence)
public static String printSymbol(CharSequence text)
'+'
are quoted.
If the text
is null, this returns "null.symbol"
.text
- the symbol text; may be null
.printSymbol(Appendable, CharSequence)
public static void printQuotedSymbol(Appendable out, CharSequence text) throws IOException
text
is null, this prints null.symbol
.out
- the stream to receive the data.text
- the symbol text; may be null
.IOException
- if the Appendable
throws an exception.EmptySymbolException
- if text
is empty.IllegalArgumentException
- if the text contains invalid UTF-16 surrogates.public static String printQuotedSymbol(CharSequence text)
text
is null, this returns "null.symbol"
.text
- the symbol text; may be null
.IllegalArgumentException
- if the text contains invalid UTF-16 surrogates.public static void printDecimal(Appendable out, BigDecimal decimal) throws IOException
IOException
public static String printDecimal(BigDecimal decimal)
public static void printFloat(Appendable out, double value) throws IOException
IOException
public static String printFloat(double value)
public static void printFloat(Appendable out, Double value) throws IOException
IOException
public static void printBlob(Appendable out, byte[] value) throws IOException
IOException
public static String printBlob(byte[] value)
public static void printClob(Appendable out, byte[] value) throws IOException
IOException
public static String printClob(byte[] value)