|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.text.Format
com.jgoodies.validation.tutorial.formatted.format.DisplayFormat
public final class DisplayFormat
Wraps a given Format
and overrides that null
values are formatted to the empty string.
Examples:
new DisplayFormat(DateFormat.getDateInstance()); new DisplayFormat(new NumberFormat()); new DisplayFormat(new NumberFormat(), true);
Nested Class Summary |
---|
Nested classes/interfaces inherited from class java.text.Format |
---|
Format.Field |
Constructor Summary | |
---|---|
DisplayFormat(Format format)
Constructs an EmptyFormat that wraps the given format
to convert null to the empty string and vice versa. |
|
DisplayFormat(Format format,
boolean showClass)
Constructs an EmptyFormat that wraps the given format
to convert null to the empty string and vice versa. |
Method Summary | |
---|---|
StringBuffer |
format(Object obj,
StringBuffer toAppendTo,
FieldPosition pos)
Formats an object and appends the resulting text to a given string buffer. |
Object |
parseObject(String source,
ParsePosition pos)
Parses text from a string to produce an object. |
Methods inherited from class java.text.Format |
---|
clone, format, formatToCharacterIterator, parseObject |
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public DisplayFormat(Format format)
EmptyFormat
that wraps the given format
to convert null
to the empty string and vice versa.
format
- the format that handles the standard casespublic DisplayFormat(Format format, boolean showClass)
EmptyFormat
that wraps the given format
to convert null
to the empty string and vice versa.
format
- the format that handles the standard casesshowClass
- true to format the value's classMethod Detail |
---|
public StringBuffer format(Object obj, StringBuffer toAppendTo, FieldPosition pos)
pos
argument identifies a field used by
the format, then its indices are set to the beginning and end of
the first such field encountered.
format
in class Format
obj
- The object to formattoAppendTo
- where the text is to be appendedpos
- A FieldPosition
identifying a field
in the formatted text
toAppendTo
,
with formatted text appended
NullPointerException
- if toAppendTo
or
pos
is null
IllegalArgumentException
- if the Format cannot format the given
objectpublic Object parseObject(String source, ParsePosition pos)
parseObject
in class Format
source
- A String
, part of which should be parsed.pos
- A ParsePosition
object with index and error
index information as described above.
Object
parsed from the string. In case of
error, returns null.
NullPointerException
- if pos
is null.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |