nl.openedge.baritus.converters
Class DecimalLocaleConverter

java.lang.Object
  extended bynl.openedge.baritus.converters.BaseLocaleConverter
      extended bynl.openedge.baritus.converters.DecimalLocaleConverter
All Implemented Interfaces:
Converter, Formatter, LocaleConverter
Direct Known Subclasses:
ByteLocaleConverter, DoubleLocaleConverter, FloatLocaleConverter, LongLocaleConverter, ShortLocaleConverter

public abstract class DecimalLocaleConverter
extends BaseLocaleConverter

Modified LocaleConverter implementation for this framework

Author:
Yauheny Mikulski, Eelco Hillenius

Field Summary
protected  java.util.regex.Pattern nonDigitPattern
           
 
Fields inherited from class nl.openedge.baritus.converters.BaseLocaleConverter
locale, locPattern, pattern
 
Constructor Summary
DecimalLocaleConverter()
          Create a LocaleConverter that will throw a ConversionException if a conversion error occurs.
DecimalLocaleConverter(java.util.Locale locale)
          Create a LocaleConverter that will throw a ConversionException if a conversion error occurs.
DecimalLocaleConverter(java.util.Locale locale, java.lang.String pattern)
          Create a LocaleConverter that will throw a ConversionException if a conversion error occurs.
DecimalLocaleConverter(java.util.Locale locale, java.lang.String pattern, boolean locPattern)
          Create a LocaleConverter that will throw a ConversionException if a conversion error occurs.
 
Method Summary
 java.lang.String format(java.lang.Object value, java.lang.String pattern)
          Convert the specified input object into a locale-sensitive output string
protected  java.text.DecimalFormat getFormat(java.lang.String pattern)
          get format and optionally apply pattern if given
protected  java.lang.Number getNumber(java.lang.Object value, java.lang.String pattern)
          translate value to a number optionally using the supplied pattern
protected  java.lang.Object parse(java.lang.Object value, java.lang.String pattern)
          Convert the specified locale-sensitive input object into an output object of the specified type.
 
Methods inherited from class nl.openedge.baritus.converters.BaseLocaleConverter
convert, convert, convert, getLocale, getPattern, setLocale, setPattern
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface nl.openedge.baritus.converters.LocaleConverter
convert
 

Field Detail

nonDigitPattern

protected java.util.regex.Pattern nonDigitPattern
Constructor Detail

DecimalLocaleConverter

public DecimalLocaleConverter()
Create a LocaleConverter that will throw a ConversionException if a conversion error occurs. The locale is the default locale for this instance of the Java Virtual Machine and an unlocalized pattern is used for the convertion.


DecimalLocaleConverter

public DecimalLocaleConverter(java.util.Locale locale)
Create a LocaleConverter that will throw a ConversionException if a conversion error occurs. No pattern is used for the convertion.

Parameters:
locale - The locale

DecimalLocaleConverter

public DecimalLocaleConverter(java.util.Locale locale,
                              java.lang.String pattern)
Create a LocaleConverter that will throw a ConversionException if a conversion error occurs. An unlocalized pattern is used for the convertion.

Parameters:
locale - The locale
pattern - The convertion pattern

DecimalLocaleConverter

public DecimalLocaleConverter(java.util.Locale locale,
                              java.lang.String pattern,
                              boolean locPattern)
Create a LocaleConverter that will throw a ConversionException if a conversion error occurs.

Parameters:
locale - The locale
pattern - The convertion pattern
locPattern - Indicate whether the pattern is localized or not
Method Detail

parse

protected java.lang.Object parse(java.lang.Object value,
                                 java.lang.String pattern)
                          throws java.text.ParseException
Convert the specified locale-sensitive input object into an output object of the specified type.

Specified by:
parse in class BaseLocaleConverter
Parameters:
value - The input object to be converted
pattern - The pattern is used for the conversion
Throws:
ConversionException - if conversion cannot be performed successfully
java.text.ParseException

format

public java.lang.String format(java.lang.Object value,
                               java.lang.String pattern)
                        throws java.lang.IllegalArgumentException
Convert the specified input object into a locale-sensitive output string

Parameters:
value - The input object to be formatted
pattern - The pattern is used for the conversion
Throws:
java.lang.IllegalArgumentException - if formatting cannot be performed successfully

getFormat

protected java.text.DecimalFormat getFormat(java.lang.String pattern)
get format and optionally apply pattern if given

Parameters:
pattern - pattern or null
Returns:
DecimalFormat formatter instance

getNumber

protected java.lang.Number getNumber(java.lang.Object value,
                                     java.lang.String pattern)
                              throws ConversionException
translate value to a number optionally using the supplied pattern

Parameters:
value - the value to convert
pattern - the patter to use (optional)
Returns:
Number
Throws:
ConversionException


Copyright © 2003-2004 Open Edge. All Rights Reserved.