|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.text.Format
com.jgoodies.common.format.EmptyFormat
public class EmptyFormat
Wraps a given Format and adds behavior to convert to/from
the empty string. Therefore it holds an empty value
(often null) that is
mapped to/from the empty string. The #format result
of the empty value is the empty string, and the #parse
result of the empty string is the empty value. In all other cases
the formatting and parsing is forwarded to the wrapped Format.
If you want to wrap a DateFormat or NumberFormat, you may use
EmptyDateFormat or EmptyNumberFormat resp.
Examples:
new EmptyFormat(new WeightFormat());
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from class java.text.Format |
|---|
Format.Field |
| Constructor Summary | |
|---|---|
EmptyFormat(Format format)
Constructs an EmptyFormat that wraps the given format to convert null to the empty string and vice versa. |
|
EmptyFormat(Format format,
Object emptyValue)
Constructs an EmptyFormat that wraps the given format to convert the given emptyValue to the empty string
and vice versa. |
|
| Method Summary | |
|---|---|
StringBuffer |
format(Object obj,
StringBuffer toAppendTo,
FieldPosition pos)
If obj is equal to the emptyValue,
toAppendTo is returned. |
AttributedCharacterIterator |
formatToCharacterIterator(Object obj)
|
Object |
parseObject(String source)
If source is empty or whitespace, the emptyValue
is returned. |
Object |
parseObject(String source,
ParsePosition pos)
|
| Methods inherited from class java.text.Format |
|---|
clone, format |
| Methods inherited from class java.lang.Object |
|---|
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public EmptyFormat(Format format)
null to the empty string and vice versa.
format - the format that handles the standard cases
public EmptyFormat(Format format,
Object emptyValue)
emptyValue to the empty string
and vice versa.
format - the format that handles non-null valuesemptyValue - the representation of the empty string| Method Detail |
|---|
public StringBuffer format(Object obj,
StringBuffer toAppendTo,
FieldPosition pos)
If obj is equal to the emptyValue,
toAppendTo is returned. Otherwise the format
is forwarded to the delegate.
format in class Format
public Object parseObject(String source)
throws ParseException
If source is empty or whitespace, the emptyValue
is returned. Otherwise parsing is forwarded to the delegate.
parseObject in class FormatParseException
public final Object parseObject(String source,
ParsePosition pos)
parseObject in class Formatpublic final AttributedCharacterIterator formatToCharacterIterator(Object obj)
formatToCharacterIterator in class Format
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||