Package quadbase.util

Class NumericFormat

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

public class NumericFormat extends 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:
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    int
    currency position, 0 - before number (default), 1 - after negative sign, 2 - after number, 3 - after number and negative sign.
    char
    Deprecated.
    int
    decimal point, range from 1 to 6, default 2
    char
    decimal point char, default '.'
    boolean
    leading zero, 0 or 1
    int
    negative position, 0 - before currency sign (default), 1 - after currency sign, 2 - end of number
    boolean
    Deprecated.
    not used.
    int
    no.
    boolean
    either 0 or 1, invalid when not currency, default 0
    char
    thousand separator, if 'N' means no thousand separator.

    Fields inherited from interface quadbase.util.IFormat

    DATETIME, LOCALEDATETIME, LOCALENUMERIC, LOGICAL, NUMERIC
  • Constructor Summary

    Constructors
    Constructor
    Description
    Create a new numeric format with default values.
  • Method Summary

    Modifier and Type
    Method
    Description
    Define quadbase.util.IFormat.
    Get custom multi-character currency symbol Deprecates the old char type currency symbol variable "currencySymbol"
    int
    Define quadbase.util.IFormat.
    output(double d)
    Output the formatted number.
    void
    setCustomCurrency(String customCurrency)
    Set custom multi-character currency symbol Deprecates the old char type currency symbol variable "currencySymbol"
    void
    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
    setFormat(char currSymInit, boolean oneSymPerPageInit, int currencyPosInit, int decimalInit, int roundingInit, int negativeInit, char decimalSepInit, char thousandSepInit, boolean leadingZeroInit, String customCurrency)
    Set Numeric format.
    void
    setScientifExp(int precision)
    Set scientific expression
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Field Details

    • sciExp

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

      @Deprecated public char currencySymbol
      Deprecated.
      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 Details

    • NumericFormat

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

    • getCustomCurrency

      public String getCustomCurrency()
      Get custom multi-character currency symbol Deprecates the old char type currency symbol variable "currencySymbol"
    • setCustomCurrency

      public void setCustomCurrency(String customCurrency)
      Set custom multi-character currency symbol Deprecates the old char type currency symbol variable "currencySymbol"
    • 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 String format(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
      leadingZeroInit - leading zero
      thoudsandSepInit - thousands separator symbol, 'N' means no thousands separator
    • setFormat

      public void setFormat(char currSymInit, boolean oneSymPerPageInit, int currencyPosInit, int decimalInit, int roundingInit, int negativeInit, char decimalSepInit, char thousandSepInit, boolean leadingZeroInit, String customCurrency)
      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
      leadingZeroInit - leading zero
      customCurrency - custom currency sign
      thoudsandSepInit - thousands separator symbol, 'N' means no thousands separator
    • output

      public String output(double d)
      Output the formatted number.
      Parameters:
      d - number to be formatted
      Returns:
      formatted value
    • toString

      public String toString()
      Overrides:
      toString in class Object