IBM WebSphere Multichannel Bank Transformation Toolkit Javadoc

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

java.lang.Object
  extended by com.ibm.btt.base.types.AbstractConverter
      extended by com.ibm.btt.base.types.ext.NumericStringConverter
All Implemented Interfaces:
Conversion, TypeConstants, java.io.Externalizable, java.io.Serializable

public class NumericStringConverter
extends AbstractConverter

This is the converter for business objects of the Numeric type. It converts 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
          sign rule
protected  char thousandsSeparator
           
 int usePositiveSign
          if using Positive Sign default value is 1 (true)
protected  boolean useThousandsSeparator
           
 
Fields inherited from class com.ibm.btt.base.types.AbstractConverter
keyValuePairs
 
Fields inherited from interface com.ibm.btt.base.types.TypeConstants
amended, CONV_TYPE_DEFAULT, CONV_TYPE_HOST, CONV_TYPE_OUTPUT, CONV_TYPE_SER, CONV_TYPE_XML, disabled, hidden, isAmended, isDisabled, isHidden, isMandatory, isOmitted, isReadOnly, mandatory, omitted, readOnly, TYPE_DEFAULT, TYPE_REGISTRY_INIT_SIZE
 
Constructor Summary
NumericStringConverter()
          Creates a NumericStringConverter object.
NumericStringConverter(java.lang.String[] supportedConversionTypes, java.util.Hashtable keyValuePairs)
          Creates a NumericStringConverter object.
 
Method Summary
 java.lang.Object convertTo(java.lang.Object obj, java.lang.String convType, PropertyDescription pd, boolean byReference, java.util.Locale locale, Hashtable parameters)
          Converts an input object into a proper object handled by the invoker.
 void formatToWriterForType(java.lang.Object value, java.lang.String conversionType, java.io.Writer writer, PropertyDescription descriptor, Hashtable parameters)
          Formats the Object using the specified conversion type and the writer passed as arguments.
 void formatToWriterForType(java.lang.Object value, java.lang.String conversionType, java.io.Writer writer, PropertyDescription descriptor, java.util.Locale locale, Hashtable parameters)
          Formats the Object using the specified conversion type, locale, and writer passed as arguments.
 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 if the String uses 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)
          Sets the parameters using the type's Constants.
protected  void setParameters(java.text.DecimalFormat formatter, PropertyDescription descriptor, Hashtable parameters)
          Sets the parameters using the type's Constants.
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)
          Sets the value of usePositiveSign to the formatter.
protected  void setUseThousandsSeparator(java.text.DecimalFormat formatter, boolean aBoolean)
          Sets the value of useThousandSeparator to aBoolean.
protected  java.lang.Object unformat(java.lang.String aNumberAsString, java.lang.String convType, PropertyDescription descriptor, java.util.Locale locale)
          Converts a String representing a Number into another Number.
protected  java.lang.Object unformat(java.lang.String aNumberAsString, java.lang.String convType, PropertyDescription descriptor, java.util.Locale locale, Hashtable parameters)
          Converts a String representing a Number into another Number.
 java.lang.Object unformatFromReaderForType(java.io.Reader reader, java.lang.String conversionType, PropertyDescription descriptor, Hashtable parameters)
          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, Hashtable parameters)
          Constructs an Object of the correct type using the appropriate conversion type and locale.
 void validateParams(PropertyDescription pd)
          Validates the externally defined parameters for this converter.
 
Methods inherited from class com.ibm.btt.base.types.AbstractConverter
convertFrom, convertFrom, convertFrom, convertFrom, convertFrom, convertTo, convertTo, convertTo, convertTo, formatToWriter, formatToWriter, formatToWriter, formatToWriterForType, formatToWriterForType, getParameters, getSupportedConversionTypes, readExternal, supportsConversionType, unformatFromReader, unformatFromReader, unformatFromReader, unformatFromReader, unformatFromReaderForType, unformatFromReaderForType, writeExternal
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

usePositiveSign

public int usePositiveSign
if using Positive Sign default value is 1 (true)


signRule

public int signRule
sign rule


useThousandsSeparator

protected boolean useThousandsSeparator

decimalPlaces

protected int decimalPlaces

decimalSeparator

protected char decimalSeparator

thousandsSeparator

protected char thousandsSeparator
Constructor Detail

NumericStringConverter

public NumericStringConverter()
                       throws DSETypeException
Creates a NumericStringConverter object.

Throws:
DSETypeException - - If the supportedConversionTypes parameter passed to the superclass is null or empty

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 - - If the supportedConversionTypes parameter passed to the superclass is null or empty
Method Detail

convertTo

public java.lang.Object convertTo(java.lang.Object obj,
                                  java.lang.String convType,
                                  PropertyDescription pd,
                                  boolean byReference,
                                  java.util.Locale locale,
                                  Hashtable parameters)
                           throws DSETypeException
Converts an input object into a proper object handled by the invoker. The invoker can use the output object for different purposes and the type of the object is dependent on the converter. If the byReference parameter is set to true, the conversion, if accepted by the converter, is performed by reference.

Specified by:
convertTo in interface Conversion
Overrides:
convertTo in class AbstractConverter
Parameters:
obj - java.lang.Object
convType - java.lang.String
pd - com.ibm.btt.base.types.PropertyDescription
byReference - boolean
locale - Locale
parameters - com.ibm.btt.base.Hashtable
Returns:
java.lang.Object
Throws:
DSETypeException

formatToWriterForType

public void formatToWriterForType(java.lang.Object value,
                                  java.lang.String conversionType,
                                  java.io.Writer writer,
                                  PropertyDescription descriptor,
                                  Hashtable parameters)
                           throws java.io.IOException,
                                  DSETypeException
Formats the Object using the specified conversion type and the writer passed as arguments. This method gets the parameters required for the conversion from the Hashtable passed as an argument.

Overrides:
formatToWriterForType in class AbstractConverter
Parameters:
value - Object
conversionType - String
writer - Writer
descriptor - PropertyDescription
parameters - com.ibm.btt.base.Hashtable
Throws:
java.io.IOException - - If an I/O error occurs
DSETypeException

formatToWriterForType

public void formatToWriterForType(java.lang.Object value,
                                  java.lang.String conversionType,
                                  java.io.Writer writer,
                                  PropertyDescription descriptor,
                                  java.util.Locale locale,
                                  Hashtable parameters)
                           throws java.io.IOException
Formats the Object using the specified conversion type, locale, and writer passed as arguments. This method first tries to get the parameters required for the conversion from the Hashtable passed as an argument. If it does not find the parameters there, the method then tries the descriptor passed as an argument.

Overrides:
formatToWriterForType in class AbstractConverter
Parameters:
value - Object
conversionType - String
writer - Writer
descriptor - PropertyDescription
locale - Locale
parameters - com.ibm.btt.base.Hashtable
Throws:
java.io.IOException - - If 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 if the String uses 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)
Sets the parameters using the type's Constants.

Parameters:
formatter - java.text.DecimalFormat
descriptor - com.ibm.btt.base.types.PropertyDescription

setParameters

protected void setParameters(java.text.DecimalFormat formatter,
                             PropertyDescription descriptor,
                             Hashtable parameters)
Sets the parameters using the type's Constants.

Parameters:
formatter - java.text.DecimalFormat
descriptor - com.ibm.btt.base.types.PropertyDescription
parameters - com.ibm.btt.base.Hashtable

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 must be used for 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.


setUsePositiveSign

protected void setUsePositiveSign(java.text.DecimalFormat formatter,
                                  int anInt)
Sets the value of usePositiveSign to the formatter. The following values must be used for 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

unformat

protected java.lang.Object unformat(java.lang.String aNumberAsString,
                                    java.lang.String convType,
                                    PropertyDescription descriptor,
                                    java.util.Locale locale)
                             throws DSETypeException
Converts a String representing a Number into another Number.

Overrides:
unformat in class AbstractConverter
Returns:
java.lang.Object
Throws:
DSETypeException

unformat

protected java.lang.Object unformat(java.lang.String aNumberAsString,
                                    java.lang.String convType,
                                    PropertyDescription descriptor,
                                    java.util.Locale locale,
                                    Hashtable parameters)
                             throws DSETypeException
Converts a String representing a Number into another Number.

Overrides:
unformat in class AbstractConverter
Returns:
java.lang.Object
Throws:
DSETypeException

unformatFromReaderForType

public java.lang.Object unformatFromReaderForType(java.io.Reader reader,
                                                  java.lang.String conversionType,
                                                  PropertyDescription descriptor,
                                                  Hashtable parameters)
                                           throws java.io.IOException,
                                                  DSETypeException
Converts the stream passed to an Object using the appropriate conversion type. This method first tries to get the parameters required for the conversion from the Hashtable passed as an argument. If it does not find the parameters there, the method then tries the descriptor passed as an argument.

Overrides:
unformatFromReaderForType in class AbstractConverter
Parameters:
reader - Reader
conversionType - String
descriptor - PropertyDescription
parameters - com.ibm.btt.base.Hashtable
Returns:
Object
Throws:
java.io.IOException - - If an I/O error occurs
DSETypeException - - If unformatting is unsuccessful

unformatFromReaderForType

public java.lang.Object unformatFromReaderForType(java.io.Reader reader,
                                                  java.lang.String conversionType,
                                                  PropertyDescription descriptor,
                                                  java.util.Locale locale,
                                                  Hashtable parameters)
                                           throws java.io.IOException,
                                                  DSETypeException
Constructs an Object of the correct type using the appropriate conversion type and locale. This method first tries to get the parameters required for the conversion from the Hashtable passed as an argument. If it does not find the parameters there, the method then tries the descriptor passed as an argument.

Overrides:
unformatFromReaderForType in class AbstractConverter
Parameters:
reader - Reader
conversionType - String
descriptor - PropertyDescription
locale - Locale
parameters - com.ibm.btt.base.Hashtable
Throws:
java.io.IOException - - If an I/O error occurs
DSETypeException - - If uUnformatting is unsuccessful

validateParams

public void validateParams(PropertyDescription pd)
                    throws DSETypeException
Validates the externally defined parameters for this converter.

Specified by:
validateParams in interface Conversion
Overrides:
validateParams in class AbstractConverter
Parameters:
pd - com.ibm.btt.base.types.PropertyDescription
Throws:
DSETypeException - - If parameter validation fails

IBM WebSphere Multichannel Bank Transformation Toolkit Javadoc

(c) Copyright IBM Corporation 1998, 2011