T
- array typeE
- array element typepublic abstract class Base64ArrayType<T,E> extends ArrayType<T,E>
String
via Base-64 encoding of raw data. Does not support null arrays.
Note: in order to return a String
that is self-delimiting, toParseableString()
appends
an extra "="
character when the length of the array is equal to 3 (mod 4).
ARRAY_SUFFIX, MAX_DIMENSIONS
name, NAME_PATTERN, REFERENCE_TYPE_NAME, signature, typeToken
Modifier | Constructor and Description |
---|---|
protected |
Base64ArrayType(PrimitiveType<E> elementType,
TypeToken<T> typeToken) |
Modifier and Type | Method and Description |
---|---|
protected T |
checkDecodeLength(int numBytes) |
protected abstract T |
decode(DataInputStream input,
int numBytes) |
protected abstract void |
encode(T array,
DataOutputStream output) |
T |
fromParseableString(ParseContext context)
Parse a value previously encoded by
toParseableString() as a self-delimited String
and positioned at the start of the given parsing context. |
T |
fromString(String string)
Parse a non-null value previously encoded by
toString(T) . |
String |
toParseableString(T array)
Encode a possibly null value as a
String for later decoding by fromParseableString() . |
String |
toParseableString(T array,
boolean base64)
Encode a possibly null value as a
String for later decoding by fromParseableString() . |
String |
toString(T array)
Encode a non-null value as a
String for later decoding by fromString() . |
String |
toString(T array,
boolean base64)
Encode a non-null value as a
String for later decoding by fromString() . |
compare, convert, createArray, equals, getArrayElement, getArrayLength, getDimensions, hashCode
validate
genericizeForIndex, getDefaultValue, getDefaultValueObject, getEncodingSignature, getKeyRange, getName, getTypeToken, hasPrefix0x00, hasPrefix0xff, read, skip, toString, validateAndWrite, write
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
comparing, comparing, comparingDouble, comparingInt, comparingLong, naturalOrder, nullsFirst, nullsLast, reversed, reverseOrder, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong
protected Base64ArrayType(PrimitiveType<E> elementType, TypeToken<T> typeToken)
public T fromString(String string)
FieldType
toString(T)
.
The implementation in FieldType
creates a new ParseContext
based on string
,
delegates to FieldType.toParseableString(T)
to parse it, and verifies that all of string
was consumed
during the parse. Subclasses that override this method should also override toString(T)
.
fromString
in class FieldType<T>
string
- non-null value previously encoded as a String
by toString(T)
public String toString(T array)
FieldType
String
for later decoding by fromString()
.
Each of the characters in the returned String
must be one of the valid XML characters
(tab, newline, carriage return, \u0020 - \ud7ff
, and \ue000 - \fffdf
).
The implementation in FieldType
checks that value
is not null, then delegates to FieldType.toParseableString(T)
.
Subclasses that override this method should also override fromString()
.
toString
in class FieldType<T>
array
- actual value, never nullvalue
acceptable to fromString()
public String toString(T array, boolean base64)
String
for later decoding by fromString()
.
This class supports two String
encodings: base 64 and "list" syntax with square brackets and commas.
The method toString(Object)
returns the base 64 form; this method works exactly the same way but
allows the caller to specify which form to generate. Either form is parseable by fromString()
.
array
- array to encode, never nullbase64
- true for base 64 synax, false for list syntaxvalue
acceptable to fromString()
IllegalArgumentException
- if value
is nullpublic String toParseableString(T array)
FieldType
String
for later decoding by fromParseableString()
.
The string value must be self-delimiting, i.e., decodable even when followed by arbitrary additional characters,
and must not start with whitespace or closing square bracket ("]"
).
In addition, each of the characters in the returned String
must be one of the valid XML characters
(tab, newline, carriage return, \u0020 - \ud7ff
, and \ue000 - \fffdf
).
toParseableString
in class ArrayType<T,E>
array
- actual value (possibly null)value
acceptable to fromParseableString()
public String toParseableString(T array, boolean base64)
String
for later decoding by fromParseableString()
.
This class supports two String
encodings: base 64 and "list" syntax with square brackets and commas.
The method toParseableString(Object)
returns the base 64 form; this method works exactly the same way but
allows the caller to specify which form to generate. Either form is parseable by
fromParseableString()
.
array
- array to encode, possibly nullbase64
- true for base 64 synax, false for list syntaxvalue
acceptable to fromParseableString()
IllegalArgumentException
- if value
is null and this type does not support nullpublic T fromParseableString(ParseContext context)
FieldType
toParseableString()
as a self-delimited String
and positioned at the start of the given parsing context.fromParseableString
in class ArrayType<T,E>
context
- parse context starting with a string previously encoded via toParseableString()
protected abstract void encode(T array, DataOutputStream output) throws IOException
IOException
protected abstract T decode(DataInputStream input, int numBytes) throws IOException
IOException
protected T checkDecodeLength(int numBytes)
Copyright © 2022. All rights reserved.