Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.jgoodies.binding.formatter
Class EmptyDateFormatter

    java.lang.Object
      javax.swing.JFormattedTextField.AbstractFormatter
          javax.swing.text.DefaultFormatter
              javax.swing.text.InternationalFormatter
                  javax.swing.text.DateFormatter
                      com.jgoodies.binding.formatter.EmptyDateFormatter

All Implemented Interfaces:
  Serializable, Cloneable

    public class EmptyDateFormatter

extends DateFormatter

In addition to its superclass DateFormatter, this class converts to/from the empty string. Therefore it holds an empty value that is the counterpart of the empty string. The Method `#valueToString` converts the empty value to the empty string. And `#stringToValue` converts blank strings to the empty value. In all other cases the conversion is delegated to its superclass.

Often the empty value is `null`. As an alternative you can map the empty string to a given date, for example epoch (January 1, 1970). Examples:

     new EmptyDateFormatter();
     new EmptyDateFormatter(new Date(0));

Version:
  $Revision: 1.2 $
Author:
  Karsten Lentzsch
See Also:
  `Format`, Serialized Form

Constructor Summary
`EmptyDateFormatter()` Constructs an EmptyDateFormatter that converts `null` to the empty string and vice versa.
`EmptyDateFormatter(Date emptyValue)` Constructs an EmptyDateFormatter that converts the given `emptyValue` to the empty string and vice versa.
`EmptyDateFormatter(DateFormat format)` Constructs an EmptyDateFormatter configured with the specified Format; maps `null` to the empty string and vice versa.
`EmptyDateFormatter(DateFormat format, Date emptyValue)` Constructs an EmptyDateFormatter configured with the specified Format; maps `null` to the given `emptyValue` and vice versa.

Method Summary
`Object` | `stringToValue(String text)` Returns the `Object` representation of the `String` `text`.
`String` | `valueToString(Object value)` Returns a String representation of the Object `value`.

Methods inherited from class javax.swing.text.DateFormatter
`setFormat`

Methods inherited from class javax.swing.text.InternationalFormatter
`clone, getActions, getFields, getFormat, getMaximum, getMinimum, install, setFormat, setMaximum, setMinimum`

Methods inherited from class javax.swing.text.DefaultFormatter
`getAllowsInvalid, getCommitsOnValidEdit, getDocumentFilter, getNavigationFilter, getOverwriteMode, getValueClass, setAllowsInvalid, setCommitsOnValidEdit, setOverwriteMode, setValueClass`

Methods inherited from class javax.swing.JFormattedTextField.AbstractFormatter
`getFormattedTextField, invalidEdit, setEditValid, uninstall`

Methods inherited from class java.lang.Object
`equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### EmptyDateFormatter

    public EmptyDateFormatter()

  Constructs an EmptyDateFormatter that converts `null` to the empty string and vice versa.

### EmptyDateFormatter

    public EmptyDateFormatter(DateFormat format)

  Constructs an EmptyDateFormatter configured with the specified Format; maps `null` to the empty string and vice versa.

  Parameters:
    `format` - Format used to dictate legal values

### EmptyDateFormatter

    public EmptyDateFormatter(Date emptyValue)

  Constructs an EmptyDateFormatter that converts the given `emptyValue` to the empty string and vice versa.

  Parameters:
    `emptyValue` - the representation of the empty string

### EmptyDateFormatter

    public EmptyDateFormatter(DateFormat format,
                              Date emptyValue)

  Constructs an EmptyDateFormatter configured with the specified Format; maps `null` to the given `emptyValue` and vice versa.

  Parameters:
    `format` - Format used to dictate legal values
    `emptyValue` - the representation of the empty string

Method Detail

### stringToValue

    public Object stringToValue(String text)
                         throws ParseException

  Returns the `Object` representation of the `String` `text`.

  Unlike its superclass, this class converts blank strings to the empty value.

  Overrides:
    `stringToValue` in class `InternationalFormatter`
  Parameters:
    `text` - `String` to convert
  Returns:
    `Object` representation of text
  Throws:
    `ParseException` - if there is an error in the conversion

### valueToString

    public String valueToString(Object value)
                         throws ParseException

  Returns a String representation of the Object `value`. This invokes `format` on the current `Format`.

  Unlike its superclass, this class converts the empty value to the empty string.

  Overrides:
    `valueToString` in class `InternationalFormatter`
  Parameters:
    `value` - the value to convert
  Returns:
    a String representation of value
  Throws:
    `ParseException` - if there is an error in the conversion

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2002-2006 JGoodies Karsten Lentzsch. All Rights Reserved.