org.formproc.conversion
Class NumberConverter

java.lang.Object
  |
  +--org.formproc.conversion.AbstractTypeConverter
        |
        +--org.formproc.conversion.NumberConverter
All Implemented Interfaces:
TypeConverter

public class NumberConverter
extends AbstractTypeConverter

TypeConverter which converts to a Number. The data objects toString() method will be used to convert the data object to a String first.

This class includes a property parse which controls date parsing with following attributes: type, groupingUsed, maximumFractionDigits, maximumIntegerDigits, minimumFractionDigits, minimumIntegerDigits, parseIntegerOnly, pattern.

Possible values for type attribute are:

  • number
  • currency
  • percent
  • custom

    For possible values for pattern see java.text.DecimalFormat apidocs.

    Author:
    Kalman Laszlo

    Constructor Summary
    NumberConverter()
               
     
    Method Summary
     java.lang.Object convert(java.lang.Object data, java.util.Locale locale)
              Convert the given data object to a Date.
     void loadConfiguration(com.anthonyeden.lib.config.Configuration configuration)
              Load the converter's configuration.
     void setGroupingUsed(java.lang.String groupingUsed)
              Set the grouping used property.
     void setMaximumFractionDigits(java.lang.String maximumFractionDigits)
              Set the maximum fraction digits property.
     void setMaximumIntegerDigits(java.lang.String maximumIntegerDigits)
              Set the maximum integer digits property.
     void setMinimumFractionDigits(java.lang.String minimumFractionDigits)
              Set the minimum fraction digits property.
     void setMinimumIntegerDigits(java.lang.String minimumIntegerDigits)
              Set the minimum integer digits property.
     void setParseIntegerOnly(java.lang.String parseIntegerOnly)
              Set the parse integer only property.
     void setPattern(java.lang.String pattern)
              Set the pattern property.
     
    Methods inherited from class java.lang.Object
    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
     

    Constructor Detail

    NumberConverter

    public NumberConverter()
    Method Detail

    convert

    public java.lang.Object convert(java.lang.Object data,
                                    java.util.Locale locale)
                             throws java.lang.Exception
    Convert the given data object to a Date.

    Parameters:
    data - The data
    locale - The Locale
    Returns:
    The resulting object
    Throws:
    java.lang.Exception

    setGroupingUsed

    public void setGroupingUsed(java.lang.String groupingUsed)
    Set the grouping used property.

    Parameters:
    groupingUsed -

    setMaximumFractionDigits

    public void setMaximumFractionDigits(java.lang.String maximumFractionDigits)
    Set the maximum fraction digits property.

    Parameters:
    maximumFractionDigits -

    setMaximumIntegerDigits

    public void setMaximumIntegerDigits(java.lang.String maximumIntegerDigits)
    Set the maximum integer digits property.

    Parameters:
    maximumIntegerDigits -

    setMinimumFractionDigits

    public void setMinimumFractionDigits(java.lang.String minimumFractionDigits)
    Set the minimum fraction digits property.

    Parameters:
    minimumFractionDigits -

    setMinimumIntegerDigits

    public void setMinimumIntegerDigits(java.lang.String minimumIntegerDigits)
    Set the minimum integer digits property.

    Parameters:
    minimumIntegerDigits -

    setParseIntegerOnly

    public void setParseIntegerOnly(java.lang.String parseIntegerOnly)
    Set the parse integer only property.

    Parameters:
    parseIntegerOnly -

    setPattern

    public void setPattern(java.lang.String pattern)
    Set the pattern property.

    Parameters:
    pattern -

    loadConfiguration

    public void loadConfiguration(com.anthonyeden.lib.config.Configuration configuration)
                           throws com.anthonyeden.lib.config.ConfigurationException
    Load the converter's configuration.

    Specified by:
    loadConfiguration in interface TypeConverter
    Overrides:
    loadConfiguration in class AbstractTypeConverter
    Parameters:
    configuration - The configuration object
    Throws:
    com.anthonyeden.lib.config.ConfigurationException


    Copyright (c) 2001-2003 Anthony Eden. All Rights Reserved.