public abstract class TextContext extends FormatContext
A context for plain text parsing/formatting. This context provides
the TextFormat to parse/format objects
of any class. If not superseded, the text format for a class is specified
by the DefaultTextFormat
annotation.
A text context always returns the most specialized format. If a class
has no default format annotation (inherited or not), then the default
Object format (which calls Object.toString())
is returned. A predefined format exists for the following standard types:
| Modifier | Constructor and Description |
|---|---|
protected |
TextContext()
Default constructor.
|
| Modifier and Type | Method and Description |
|---|---|
static TextContext |
enter()
Enters and returns a new text context instance.
|
static Appendable |
format(Object obj,
Appendable dest)
Formats the specified object using its current
format (convenience method). |
static <T> TextFormat<T> |
getFormat(Class<? extends T> type)
Returns the text format for the specified type.
|
protected abstract <T> TextFormat<T> |
searchFormat(Class<? extends T> type)
Searches the most specialized format for the specified type.
|
abstract <T> void |
setFormat(Class<? extends T> type,
TextFormat<T> newFormat)
Sets the text format for the specified type (and its sub-types).
|
current, current, enter, enterInner, exit, getOuter, inherit, innerpublic static TextContext enter()
public static <T> TextFormat<T> getFormat(Class<? extends T> type)
public abstract <T> void setFormat(Class<? extends T> type, TextFormat<T> newFormat)
public static Appendable format(Object obj, Appendable dest) throws IOException
format (convenience method).IOExceptionprotected abstract <T> TextFormat<T> searchFormat(Class<? extends T> type)
Copyright © 2017. All rights reserved.