public class CharacterType extends PrimitiveType<Character>
Character
type.name, NAME_PATTERN, REFERENCE_TYPE_NAME, signature, typeToken
Constructor and Description |
---|
CharacterType() |
Modifier and Type | Method and Description |
---|---|
<S> Character |
convert(FieldType<S> type,
S value)
|
protected Character |
convertNumber(Number value) |
Character |
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. |
Character |
fromString(String string)
Parse a non-null value previously encoded by
toString(T) . |
Character |
read(ByteReader reader)
Read a value from the given input.
|
void |
skip(ByteReader reader)
Read and discard a value from the given input.
|
String |
toParseableString(Character value)
Encode a possibly null value as a
String for later decoding by fromParseableString() . |
String |
toString(Character value)
Encode a non-null value as a
String for later decoding by fromString() . |
void |
write(ByteWriter writer,
Character value)
Write a value to the given output.
|
compare, equals, hashCode, validate
genericizeForIndex, getDefaultValue, getDefaultValueObject, getEncodingSignature, getKeyRange, getName, getTypeToken, hasPrefix0x00, hasPrefix0xff, 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 Character read(ByteReader reader)
FieldType
public void write(ByteWriter writer, Character value)
FieldType
public void skip(ByteReader reader)
FieldType
public String toString(Character value)
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<Character>
value
- actual value, never nullvalue
acceptable to fromString()
public Character 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<Character>
string
- non-null value previously encoded as a String
by toString(T)
public String toParseableString(Character value)
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 PrimitiveType<Character>
value
- actual value (possibly null)value
acceptable to fromParseableString()
public Character fromParseableString(ParseContext context)
FieldType
toParseableString()
as a self-delimited String
and positioned at the start of the given parsing context.fromParseableString
in class PrimitiveType<Character>
context
- parse context starting with a string previously encoded via toParseableString()
public <S> Character 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 convertibleconvert
in class PrimitiveType<Character>
S
- source field typetype
- the FieldType
of value
value
- the value to convertvalue
converted to this instance's typeprotected Character convertNumber(Number value)
convertNumber
in class PrimitiveType<Character>
Copyright © 2022. All rights reserved.