public class CharacterArrayType extends ArrayType<char[],Character>
char[]
array type. Does not support null arrays.
We use the same encoding as StringType
.
ARRAY_SUFFIX, MAX_DIMENSIONS
name, NAME_PATTERN, REFERENCE_TYPE_NAME, signature, typeToken
Constructor and Description |
---|
CharacterArrayType() |
Modifier and Type | Method and Description |
---|---|
<S> char[] |
convert(FieldType<S> type,
S value)
|
protected char[] |
createArray(List<Character> elements)
Create a new array instance containing the given elements.
|
protected Character |
getArrayElement(char[] array,
int index)
Get an element from the given array.
|
protected int |
getArrayLength(char[] array)
Get the length of the given array.
|
boolean |
hasPrefix0x00()
Determine whether any of this field type's encoded values start with a
0x00 byte. |
boolean |
hasPrefix0xff()
Determine whether any of this field type's encoded values start with a
0xff byte. |
char[] |
read(ByteReader reader)
Read a value from the given input.
|
void |
skip(ByteReader reader)
Read and discard a value from the given input.
|
void |
write(ByteWriter writer,
char[] array)
Write a value to the given output.
|
compare, equals, fromParseableString, getDimensions, hashCode, toParseableString
validate
fromString, genericizeForIndex, getDefaultValue, getDefaultValueObject, getEncodingSignature, getKeyRange, getName, getTypeToken, toString, toString, validateAndWrite
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
comparing, comparing, comparingDouble, comparingInt, comparingLong, naturalOrder, nullsFirst, nullsLast, reversed, reverseOrder, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong
public char[] read(ByteReader reader)
FieldType
public void write(ByteWriter writer, char[] array)
FieldType
public void skip(ByteReader reader)
FieldType
public boolean hasPrefix0x00()
FieldType
0x00
byte.
Certain optimizations are possible when this is not the case. It is safe for this method to always return true.
Note: changing the return value of this method usually means changing the binary encoding, resulting in an incompatible type.
The implementation in FieldType
returns true
.
hasPrefix0x00
in class FieldType<char[]>
0x00
existspublic boolean hasPrefix0xff()
FieldType
0xff
byte.
Certain optimizations are possible when this is not the case. It is safe for this method to always return true.
Note: changing the return value of this method usually means changing the binary encoding, resulting in an incompatible type.
The implementation in FieldType
returns true
.
hasPrefix0xff
in class FieldType<char[]>
0xff
existsprotected int getArrayLength(char[] array)
ArrayType
getArrayLength
in class ArrayType<char[],Character>
array
- non-null arrayprotected Character getArrayElement(char[] array, int index)
ArrayType
getArrayElement
in class ArrayType<char[],Character>
array
- non-null arrayindex
- index of target element in array
index
protected char[] createArray(List<Character> elements)
ArrayType
createArray
in class ArrayType<char[],Character>
elements
- content for the new arraypublic <S> char[] convert(FieldType<S> type, S value)
FieldType
FieldType
into a value of this FieldType
.
For a non-null value
, the implementation in FieldType
first checks whether the value
is already
a valid value for this type; if so, the value is returned. Otherwise, it invokes type.
toString(value)
to convert value
into a String
, and then attempts to parse that string via
this.
fromString()
; if the parse fails, an IllegalArgumentException
is thrown.
If value
is null, the implementation in FieldType
returns null, unless this type does not support null
values, in which case an IllegalArgumentException
is thrown.
Special handling also exists for certain conversions between built-in types:
value != 0
char
and a String
of length one are convertible (other String
s are not)char[]
array and a String
are convertibleCopyright © 2022. All rights reserved.