| 
 | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.text.Format
java.text.NumberFormat
com.jgoodies.common.format.EmptyNumberFormat
public final class EmptyNumberFormat
Wraps a given NumberFormat and adds behavior to convert to/from
 the empty string. Therefore it holds an empty value 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 NumberFormat.
Examples:
new EmptyNumberFormat(NumberFormat().getInstance()); new EmptyNumberFormat(NumberFormat().getIntegerInstance(), -1);
| Nested Class Summary | 
|---|
| Nested classes/interfaces inherited from class java.text.NumberFormat | 
|---|
| NumberFormat.Field | 
| Field Summary | 
|---|
| Fields inherited from class java.text.NumberFormat | 
|---|
| FRACTION_FIELD, INTEGER_FIELD | 
| Constructor Summary | |
|---|---|
| EmptyNumberFormat(NumberFormat delegate)Constructs an EmptyNumberFormat that wraps the given mandatory format to convert nullto the empty string and vice versa. | |
| EmptyNumberFormat(NumberFormat delegate,
                  int emptyValue)Constructs an EmptyNumberFormat that wraps the given mandatory format to convert the given emptyValueto the empty string
 and vice versa. | |
| EmptyNumberFormat(NumberFormat delegate,
                  Number emptyValue)Constructs an EmptyNumberFormat that wraps the given mandatory format to convert the given emptyValueto the empty string
 and vice versa. | |
| Method Summary | |
|---|---|
|  StringBuffer | format(double number,
       StringBuffer toAppendTo,
       FieldPosition pos) | 
|  StringBuffer | format(long number,
       StringBuffer toAppendTo,
       FieldPosition pos) | 
|  StringBuffer | format(Object obj,
       StringBuffer toAppendTo,
       FieldPosition pos)If objis equal to the emptyValue,toAppendTois returned. | 
|  Number | parse(String source)If sourceis empty or whitespace, the emptyValue
 is returned. | 
|  Number | parse(String source,
      ParsePosition pos) | 
|  Object | parseObject(String source)If sourceis empty or whitespace, the emptyValue
 is returned. | 
| Methods inherited from class java.text.Format | 
|---|
| format, formatToCharacterIterator | 
| Methods inherited from class java.lang.Object | 
|---|
| finalize, getClass, notify, notifyAll, toString, wait, wait, wait | 
| Constructor Detail | 
|---|
public EmptyNumberFormat(NumberFormat delegate)
null to the empty string and vice versa.
delegate - the format that handles the standard cases
NullPointerException - if delegate is null
public EmptyNumberFormat(NumberFormat delegate,
                         int emptyValue)
emptyValue to the empty string
 and vice versa.
delegate - the format that handles non-null valuesemptyValue - the representation of the empty string
NullPointerException - if delegate is null
public EmptyNumberFormat(NumberFormat delegate,
                         Number emptyValue)
emptyValue to the empty string
 and vice versa.
delegate - the format that handles non-null valuesemptyValue - the representation of the empty string
NullPointerException - if delegate is null| 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 NumberFormat
public StringBuffer format(double number,
                           StringBuffer toAppendTo,
                           FieldPosition pos)
format in class NumberFormat
public StringBuffer format(long number,
                           StringBuffer toAppendTo,
                           FieldPosition pos)
format in class NumberFormat
public Object parseObject(String source)
                   throws ParseException
 If source is empty or whitespace, the emptyValue
 is returned. Otherwise parsing is forwarded to the delegate
 - indirectly via parse(String, ParsePosition).
parseObject in class FormatParseException
public Number parse(String source)
             throws ParseException
 If source is empty or whitespace, the emptyValue
 is returned. Otherwise parsing is forwarded to the delegate
 - indirectly via parse(String, ParsePosition).
parse in class NumberFormatParseException
public Number parse(String source,
                    ParsePosition pos)
parse in class NumberFormat| 
 | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||