EspressReport 6.6

quadbase.util
Class NumericFormat

java.lang.Object
  extended by quadbase.util.NumericFormat
All Implemented Interfaces:
IFormat

public class NumericFormat
extends java.lang.Object
implements IFormat

NumericFormat

NumericalFormat is a utility class to format numeric value. You can specify the no. of decimal point, currency symbol, thousand separator etc.

See Also:
LocaleNumericFormat

Field Summary
 int currencyPos
          currency position, 0 - before number (default), 1 - after negative sign, 2 - after number, 3 - after number and negative sign.
 char currencySymbol
          currency symbol, default none
 int decimal
          decimal point, range from 1 to 6, default 2
 char decimalSep
          decimal point char, default '.'
 boolean leadingZero
          leading zero, 0 or 1
 int negative
          negative position, 0 - before currency sign (default), 1 - after currency sign, 2 - end of number
 boolean oneSymPerPage
          Deprecated. not used.
 int rounding
          no.
 boolean sciExp
          either 0 or 1, invalid when not currency, default 0
 char thousandSep
          thousand separator, if 'N' means no thousand separator.
 
Fields inherited from interface quadbase.util.IFormat
DATETIME, LOCALEDATETIME, LOCALENUMERIC, LOGICAL, NUMERIC
 
Constructor Summary
NumericFormat()
          Create a new numeric format with default values.
 
Method Summary
 java.lang.String format(java.lang.Object obj)
          Define quadbase.util.IFormat.
 int getFormatType()
          Define quadbase.util.IFormat.
 java.lang.String output(double d)
          Output the formatted number.
 void setDefault()
          Set all variables to default value.
 void setFormat(char currSymInit, boolean oneSymPerPageInit, int currencyPosInit, int decimalInit, int roundingInit, int negativeInit, char decimalSepInit, char thousandSepInit, boolean leadingZeroInit)
          Set Numeric format.
 void setScientifExp(int precision)
          Set scientific expression.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

sciExp

public boolean sciExp
either 0 or 1, invalid when not currency, default 0


currencySymbol

public char currencySymbol
currency symbol, default none


oneSymPerPage

@Deprecated
public boolean oneSymPerPage
Deprecated. not used.
Not used. Always false.


currencyPos

public int currencyPos
currency position, 0 - before number (default), 1 - after negative sign, 2 - after number, 3 - after number and negative sign. Invalid when not currency.


decimal

public int decimal
decimal point, range from 1 to 6, default 2


rounding

public int rounding
no. of significant digit, range from 1 to 12, default 1


negative

public int negative
negative position, 0 - before currency sign (default), 1 - after currency sign, 2 - end of number


decimalSep

public char decimalSep
decimal point char, default '.'


thousandSep

public char thousandSep
thousand separator, if 'N' means no thousand separator. 1000, default ','


leadingZero

public boolean leadingZero
leading zero, 0 or 1

Constructor Detail

NumericFormat

public NumericFormat()
Create a new numeric format with default values.

Method Detail

getFormatType

public int getFormatType()
Define quadbase.util.IFormat. Return the type of quadbase.util.IFormat.

Specified by:
getFormatType in interface IFormat
Returns:
IFormat.NUMERIC

format

public java.lang.String format(java.lang.Object obj)
Define quadbase.util.IFormat. Use the doubleValue() method in java.lang.Number to return a formatted string. If the target object is not an instance of Number, use the default toString() method.

Specified by:
format in interface IFormat
Parameters:
obj - The target object
Returns:
Formatted string

setDefault

public void setDefault()
Set all variables to default value.


setScientifExp

public void setScientifExp(int precision)
Set scientific expression.

Parameters:
precision - no of decimal point

setFormat

public void setFormat(char currSymInit,
                      boolean oneSymPerPageInit,
                      int currencyPosInit,
                      int decimalInit,
                      int roundingInit,
                      int negativeInit,
                      char decimalSepInit,
                      char thousandSepInit,
                      boolean leadingZeroInit)
Set Numeric format.

Parameters:
currSymInit - currency symbol
oneSymPerPageInit - not used, always set to false
currencyPosInit - currency position 0-2
decimalInit - no. of decimal point
roundingInit - no. of significant digit
negativeInit - negative symbol position 0-2
decimalSepInit - decimal point symbol
thoudsandSepInit - thousands separator symbol, 'N' means no thousands separator
leadingZeroInit - leading zero

output

public java.lang.String output(double d)
Output the formatted number.

Parameters:
d - number to be formatted
Returns:
formatted value

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

EspressReport 6.6