com.jgoodies.common.format

Class EmptyNumberFormat

public final class EmptyNumberFormat extends NumberFormat

Wraps a given {@code 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 {@code #format} result of the empty value is the empty string, and the {@code #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);
 

Version: $Revision: 1.3 $

Author: Karsten Lentzsch

Constructor Summary
EmptyNumberFormat(NumberFormat delegate)
Constructs an EmptyNumberFormat that wraps the given format to convert {@code null} to the empty string and vice versa.
EmptyNumberFormat(NumberFormat delegate, int emptyValue)
Constructs an EmptyNumberFormat that wraps the given format to convert the given {@code emptyValue} to the empty string and vice versa.
EmptyNumberFormat(NumberFormat delegate, Number emptyValue)
Constructs an EmptyNumberFormat that wraps the given format to convert the given {@code emptyValue} to the empty string and vice versa.

Constructor Detail

EmptyNumberFormat

public EmptyNumberFormat(NumberFormat delegate)
Constructs an EmptyNumberFormat that wraps the given format to convert {@code null} to the empty string and vice versa.

Parameters: delegate the format that handles the standard cases

EmptyNumberFormat

public EmptyNumberFormat(NumberFormat delegate, int emptyValue)
Constructs an EmptyNumberFormat that wraps the given format to convert the given {@code emptyValue} to the empty string and vice versa.

Parameters: delegate the format that handles non-{@code null} values emptyValue the representation of the empty string

EmptyNumberFormat

public EmptyNumberFormat(NumberFormat delegate, Number emptyValue)
Constructs an EmptyNumberFormat that wraps the given format to convert the given {@code emptyValue} to the empty string and vice versa.

Parameters: delegate the format that handles non-{@code null} values emptyValue the representation of the empty string

Copyright © 2009-2010 JGoodies Karsten Lentzsch. All Rights Reserved.