com.jgoodies.common.format

Class EmptyFormat

public class EmptyFormat extends Format

Wraps a given {@code Format} and adds behavior to convert to/from the empty string. Therefore it holds an empty value (often {@code null}) 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 Format.

If you want to wrap a DateFormat or NumberFormat, you may use EmptyDateFormat or EmptyNumberFormat resp. Examples:

 new EmptyFormat(new WeightFormat());
 

Version: $Revision: 1.5 $

Author: Karsten Lentzsch

Constructor Summary
EmptyFormat(Format format)
Constructs an EmptyFormat that wraps the given format to convert {@code 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 {@code emptyValue} to the empty string and vice versa.

Constructor Detail

EmptyFormat

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

Parameters: format the format that handles the standard cases

EmptyFormat

public EmptyFormat(Format format, Object emptyValue)
Constructs an EmptyFormat that wraps the given format to convert the given {@code emptyValue} to the empty string and vice versa.

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

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