@CatalogedBy(value=TextSerializers.class) public interface TextSerializer extends CatalogType
Text
instances that converts an input
string into a formatted Text
instance, or a Text
instance
into the string representation.
Custom implementations can be registered using
the GameRegistry
.
Modifier and Type | Method and Description |
---|---|
Text |
deserialize(String input)
Returns a
Text instance from an appropriately formatted string. |
default Text |
deserializeUnchecked(String input)
Tries to return a
Text instance from the provided input string. |
String |
serialize(Text text)
Returns a string representation of the provided
Text in a format
that will be accepted by this TextSerializer 's
deserialize(String) method. |
default String |
serializeSingle(Text text)
Returns a string representation of only the provided
Text
(without any children) in a format that will be accepted by this
TextSerializer 's deserialize(String) method. |
getId, getName
String serialize(Text text)
Text
in a format
that will be accepted by this TextSerializer
's
deserialize(String)
method.text
- The text to serializedefault String serializeSingle(Text text)
Text
(without any children) in a format that will be accepted by this
TextSerializer
's deserialize(String)
method.text
- The text to serializeText deserialize(String input) throws TextParseException
Text
instance from an appropriately formatted string.input
- The raw input to parse into a textTextParseException
- If an error occurs while parsing the textdefault Text deserializeUnchecked(String input)
Text
instance from the provided input string.
However, if the input string is not of a valid format, the returned
Text
object will be of the raw input, rather than throwing an
exception.input
- The raw input to try to parse into a text