IBM Branch Transformation Toolkit Javadoc

com.ibm.dse.base
Class NumericStringFormat

java.lang.Object
  extended bycom.ibm.dse.base.FormatElement
      extended bycom.ibm.dse.base.FieldFormat
          extended bycom.ibm.dse.base.NumericStringFormat
All Implemented Interfaces:
Cacheable, Externalizable, java.io.Externalizable, java.io.Serializable

public class NumericStringFormat
extends FieldFormat

This class converts an Integer or Long into a formatted String using the java.text.DecimalFormat initialized by attributes of this class.

See Also:
Serialized Form

Field Summary
 java.text.DecimalFormat formatter
           
 boolean showDecimalsSep
          The attribute to indicate if the decimal separator must be showed.
 int signRule
           
 int usePositiveSign
           
 
Fields inherited from class com.ibm.dse.base.FormatElement
dataElementName, externalizer, name
 
Constructor Summary
NumericStringFormat()
          This is the default constructor used to create a NumericStringFormat object.
NumericStringFormat(java.lang.String aName)
          This is the constructor used by the Externalizer to create a NumericStringFormat object.
 
Method Summary
 java.lang.String formatField(DataField aDataField)
          Calls the format method of the java.text.DecimalFormat.
 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.
 java.lang.Object initializeFrom(Tag aTag)
          Initializes a NumericStringFormat with the aTag attributes.
 boolean isShowDecimalsSep()
          Returns the value of the showDecimalsSep property.
 void setDecimalPlaces(int anInt)
          Sets the value of decimalPlaces of the formatter to anInt.
 void setDecimalSeparator(char aDecimalSeparator)
          Sets the value of decimalSeparator of the formatter to aDecimalSeparator.
 void setShowDecimalsSep(boolean newShowDecimalsSep)
          Sets the value of the showDecimalsSep property.
protected  void setSignPolicy()
          Sets the parameters of the formatter using the values of usePositiveSign and signRule.
 void setSignRule(int anInt)
          Sets the value of signRule.
 void setThousandsSeparator(char aChar)
          Sets the value of thousandsSeparator of the formatter to aChar.
 void setUsePositiveSign(int anInt)
          Set the value of usePositiveSign.
 void setUseThousandsSeparator(boolean aBoolean)
          Sets the value of useThousandSeparator to aBoolean.
 java.lang.String toString()
          Returns a visual representation of this format.
 DataField unformatField(java.lang.String aString, DataField aDataField)
          Calls the parse method of the java.text.DecimalFormat.
 
Methods inherited from class com.ibm.dse.base.FieldFormat
format, format, toStrings, unformat, unformat
 
Methods inherited from class com.ibm.dse.base.FormatElement
exceptionInfo, externalizer, extract, format, getDataElementName, getExternalizer, getName, getTagName, isCacheable, isConstant, isItConstant, readExternal, readExternal, readObject, reinitialize, removeExternal, rootDecorated, setDataElementName, setExternalizer, setName, setSize, toTags, unformat, writeExternal, writeExternal
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

usePositiveSign

public int usePositiveSign

formatter

public java.text.DecimalFormat formatter

signRule

public int signRule

showDecimalsSep

public boolean showDecimalsSep
The attribute to indicate if the decimal separator must be showed.

Constructor Detail

NumericStringFormat

public NumericStringFormat()
This is the default constructor used to create a NumericStringFormat object.


NumericStringFormat

public NumericStringFormat(java.lang.String aName)
                    throws java.io.IOException
This is the constructor used by the Externalizer to create a NumericStringFormat object.

Method Detail

formatField

public java.lang.String formatField(DataField aDataField)
                             throws DSEInvalidArgumentException
Calls the format method of the java.text.DecimalFormat.

Specified by:
formatField in class FieldFormat
Parameters:
aDataField - DataField
Returns:
String
Throws:
DSEInvalidArgumentException

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

initializeFrom

public java.lang.Object initializeFrom(Tag aTag)
                                throws java.io.IOException
Initializes a NumericStringFormat with the aTag attributes.

Specified by:
initializeFrom in interface Externalizable
Specified by:
initializeFrom in class FormatElement
Parameters:
aTag - com.ibm.dse.base.Tag
Returns:
java.lang.Object
Throws:
java.io.IOException

isShowDecimalsSep

public boolean isShowDecimalsSep()
Returns the value of the showDecimalsSep property.

Returns:
boolean - The current value of showDecimalsSep.

setDecimalPlaces

public void setDecimalPlaces(int anInt)
Sets the value of decimalPlaces of the formatter to anInt.

Parameters:
anInt - int

setDecimalSeparator

public void setDecimalSeparator(char aDecimalSeparator)
Sets the value of decimalSeparator of the formatter to aDecimalSeparator.

Parameters:
aDecimalSeparator - char

setShowDecimalsSep

public void setShowDecimalsSep(boolean newShowDecimalsSep)
Sets the value of the showDecimalsSep property.

Parameters:
newShowDecimalsSep - boolean - The new value of the property

setSignPolicy

protected void setSignPolicy()
Sets the parameters of the formatter using the values of usePositiveSign and signRule. It is called by the setSignRule() and setUsePositiveSign() methods.


setSignRule

public void setSignRule(int anInt)
Sets the value of signRule. The following values should be used as the parameter: 1 = prefix ==> -123 <+>123 2 = suffix ==> 123- 123<+> 3 = parentheses ==> (123) 123


setThousandsSeparator

public void setThousandsSeparator(char aChar)
Sets the value of thousandsSeparator of the formatter to aChar.


setUsePositiveSign

public void setUsePositiveSign(int anInt)
Set the value of usePositiveSign. The following values should be used as the parameter: 1 = no ==> '-123' '123' or '123-' '123' 2 = yes ==> '-123' '+123' or '123-' '123+' 3 = blank ==> '-123' ' 123' or '123-' '123 '

Parameters:
anInt - int

setUseThousandsSeparator

public void setUseThousandsSeparator(boolean aBoolean)
Sets the value of useThousandSeparator to aBoolean.

Parameters:
aBoolean - boolean

toString

public java.lang.String toString()
Returns a visual representation of this format.

Overrides:
toString in class FormatElement
Returns:
java.lang.String

unformatField

public DataField unformatField(java.lang.String aString,
                               DataField aDataField)
                        throws DSEInvalidArgumentException
Calls the parse method of the java.text.DecimalFormat.

Specified by:
unformatField in class FieldFormat
Parameters:
aString - String
aDataField - DataField
Returns:
DataField
Throws:
DSEInvalidArgumentException

IBM Branch Transformation Toolkit Javadoc

(c) Copyright IBM Corporation 1998, 2005