com.ibm.dse.base.types.ext
Class NumericStringConverter

java.lang.Object
  |
  +--com.ibm.dse.base.types.AbstractConverter
        |
        +--com.ibm.dse.base.types.ext.NumericStringConverter

public class NumericStringConverter
extends AbstractConverter

Converter for business objects of Numeric Type, to convert them into strings, using the java.text.DecimalFormat initialized by attributes of this class.

See Also:
Serialized Form

Field Summary
protected  int decimalPlaces
           
protected  char decimalSeparator
           
 int signRule
           
protected  char thousandsSeparator
           
 int usePositiveSign
           
protected  boolean useThousandsSeparator
           
 
Fields inherited from class com.ibm.dse.base.types.AbstractConverter
keyValuePairs
 
Constructor Summary
NumericStringConverter(java.lang.String[] supportedConversionTypes, java.util.Hashtable keyValuePairs)
          Creates a NumericStringConverter object.
 
Method Summary
 void formatToWriterForType(java.lang.Object value, java.lang.String conversionType, java.io.Writer writer, PropertyDescription descriptor)
          The value passed as an Object is formatted using the specified conversion type and written to the writer passed as argument.
 void formatToWriterForType(java.lang.Object value, java.lang.String conversionType, java.io.Writer writer, PropertyDescription descriptor, java.util.Locale locale)
          The value passed as an Object is formatted using the specified conversion type, locale and writer passed as argument.
 int getDecimalPlaces()
          Returns the number of decimal digits when the String is formatted.
 char getDecimalSeparator()
          Returns the value of decimalSeparator.
 boolean getShowDecimals()
          Returns true if the String formats with decimal places.
 int getSignRule()
          Returns the value of signRule.
 char getThousandsSeparator()
          Returns the value of thousandsSeparator.
 int getUsePositiveSign()
          Returns the value of usePositiveSign.
 boolean getUseThousandsSeparator()
          Returns true the String formats with a thousands separator.
protected  void setDecimalPlaces(java.text.DecimalFormat formatter, int anInt)
          Sets the value of decimalPlaces of the formatter to anInt.
protected  void setDecimalSeparator(java.text.DecimalFormat formatter, char aDecimalSeparator)
          Sets the value of decimalSeparator of the formatter to aDecimalSeparator.
protected  void setParameters(java.text.DecimalFormat formatter, PropertyDescription descriptor)
          Gets the parameters from the descriptor to set the formatter passed.
protected  void setSignPolicy(java.text.DecimalFormat formatter)
          Sets the parameters of the formatter using the values of usePositiveSign and signRule.
protected  void setSignRule(java.text.DecimalFormat formatter, int anInt)
          Sets the value of signRule.
protected  void setThousandsSeparator(java.text.DecimalFormat formatter, char aChar)
          Sets the value of thousandsSeparator of the formatter to aChar.
protected  void setUsePositiveSign(java.text.DecimalFormat formatter, int anInt)
          Set the value of usePositiveSign to the formatter.
protected  void setUseThousandsSeparator(java.text.DecimalFormat formatter, boolean aBoolean)
          Sets the value of useThousandSeparator to aBoolean.
 java.lang.Object unformatFromReaderForType(java.io.Reader reader, java.lang.String conversionType, PropertyDescription descriptor)
          Converts the stream passed to an Object using the appropriate conversion Type.
 java.lang.Object unformatFromReaderForType(java.io.Reader reader, java.lang.String conversionType, PropertyDescription descriptor, java.util.Locale locale)
          Uses the reader passed to construct an Object of the correct Type using the appropriate conversion type and locale.
 
Methods inherited from class com.ibm.dse.base.types.AbstractConverter
formatToWriter, formatToWriter, getParameters, getSupportedConversionTypes, supportsConversionType, unformatFromReader, unformatFromReader
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

usePositiveSign

public int usePositiveSign

signRule

public int signRule

useThousandsSeparator

protected boolean useThousandsSeparator

decimalPlaces

protected int decimalPlaces

decimalSeparator

protected char decimalSeparator

thousandsSeparator

protected char thousandsSeparator
Constructor Detail

NumericStringConverter

public NumericStringConverter(java.lang.String[] supportedConversionTypes,
                              java.util.Hashtable keyValuePairs)
                       throws DSETypeException
Creates a NumericStringConverter object.
Parameters:
supportedConversionTypes - java.lang.String[]
keyValuePairs - java.util.Hashtable
Throws:
DSETypeException - Conversion types passed to superclass is null or empty.
Method Detail

formatToWriterForType

public void formatToWriterForType(java.lang.Object value,
                                  java.lang.String conversionType,
                                  java.io.Writer writer,
                                  PropertyDescription descriptor)
                           throws java.io.IOException,
                                  DSETypeException
The value passed as an Object is formatted using the specified conversion type and written to the writer passed as argument. Parameters required by this converter are first taken from the owner descriptor passed as argument.
Overrides:
formatToWriterForType in class AbstractConverter
Parameters:
value - Object
conversionType - String
writer - Writer
descriptor - PropertyDescription
Throws:
java.io.IOException - An I/O error occurs

formatToWriterForType

public void formatToWriterForType(java.lang.Object value,
                                  java.lang.String conversionType,
                                  java.io.Writer writer,
                                  PropertyDescription descriptor,
                                  java.util.Locale locale)
                           throws java.io.IOException
The value passed as an Object is formatted using the specified conversion type, locale and writer passed as argument. Parameters required by this converter are first taken from the owner descriptor passed as argument.
Overrides:
formatToWriterForType in class AbstractConverter
Parameters:
value - Object
conversionType - String
writer - Writer
descriptor - PropertyDescription
locale - Locale
Throws:
java.io.IOException - An I/O error occurs

getDecimalPlaces

public int getDecimalPlaces()
Returns the number of decimal digits when the String is formatted.
Returns:
int

getDecimalSeparator

public char getDecimalSeparator()
Returns the value of decimalSeparator.
Returns:
char

getShowDecimals

public boolean getShowDecimals()
Returns true if the String formats with decimal places.
Returns:
boolean

getSignRule

public int getSignRule()
Returns the value of signRule.
Returns:
int

getThousandsSeparator

public char getThousandsSeparator()
Returns the value of thousandsSeparator.
Returns:
char

getUsePositiveSign

public int getUsePositiveSign()
Returns the value of usePositiveSign.
Returns:
int

getUseThousandsSeparator

public boolean getUseThousandsSeparator()
Returns true the String formats with a thousands separator.
Returns:
boolean

setDecimalPlaces

protected void setDecimalPlaces(java.text.DecimalFormat formatter,
                                int anInt)
Sets the value of decimalPlaces of the formatter to anInt.
Parameters:
formatter - DecimalFormat
anInt - int

setDecimalSeparator

protected void setDecimalSeparator(java.text.DecimalFormat formatter,
                                   char aDecimalSeparator)
Sets the value of decimalSeparator of the formatter to aDecimalSeparator.
Parameters:
formatter - DecimalFormat
aDecimalSeparator - char

setParameters

protected void setParameters(java.text.DecimalFormat formatter,
                             PropertyDescription descriptor)
Gets the parameters from the descriptor to set the formatter passed.
Parameters:
formatter - java.text.DecimalFormat
descriptor - com.ibm.dse.base.types.PropertyDescription

setSignPolicy

protected void setSignPolicy(java.text.DecimalFormat formatter)
Sets the parameters of the formatter using the values of usePositiveSign and signRule. It is called by the setSignRule() and setUsePositiveSign() methods.
Parameters:
formatter - DecimalFormat

setSignRule

protected void setSignRule(java.text.DecimalFormat formatter,
                           int anInt)
Sets the value of signRule. The following values should be used as the int parameter: .
Parameters:
formatter - DecimalFormat
anInt - int

setThousandsSeparator

protected void setThousandsSeparator(java.text.DecimalFormat formatter,
                                     char aChar)
Sets the value of thousandsSeparator of the formatter to aChar.
Parameters:
formatter - DecimalFormat
aSeparator - char

setUsePositiveSign

protected void setUsePositiveSign(java.text.DecimalFormat formatter,
                                  int anInt)
Set the value of usePositiveSign to the formatter. The following values should be used as the int parameter: .
Parameters:
formatter - DecimalFormat
anInt - int

setUseThousandsSeparator

protected void setUseThousandsSeparator(java.text.DecimalFormat formatter,
                                        boolean aBoolean)
Sets the value of useThousandSeparator to aBoolean.
Parameters:
formatter - DecimalFormat
aBoolean - boolean

unformatFromReaderForType

public java.lang.Object unformatFromReaderForType(java.io.Reader reader,
                                                  java.lang.String conversionType,
                                                  PropertyDescription descriptor)
                                           throws java.io.IOException,
                                                  DSETypeException
Converts the stream passed to an Object using the appropriate conversion Type. Parameters required by this converter are first taken from the owner descriptor passed as argument.
Overrides:
unformatFromReaderForType in class AbstractConverter
Parameters:
reader - Reader
conversionType - String
descriptor - PropertyDescription
Returns:
Object
Throws:
java.io.IOException - An I/O error occurs.
DSETypeException - Unformatting is unsuccessful.

unformatFromReaderForType

public java.lang.Object unformatFromReaderForType(java.io.Reader reader,
                                                  java.lang.String conversionType,
                                                  PropertyDescription descriptor,
                                                  java.util.Locale locale)
                                           throws java.io.IOException,
                                                  DSETypeException
Uses the reader passed to construct an Object of the correct Type using the appropriate conversion type and locale. Parameters required by this converter are first taken from the owner descriptor passed as argument.
Overrides:
unformatFromReaderForType in class AbstractConverter
Parameters:
reader - Reader
conversionType - String
descriptor - PropertyDescription
locale - Locale
Throws:
java.io.IOException - An I/O error occurs.
DSETypeException - Unformatting is unsuccessful.