com.cedarspring.tvm
Class Options

java.lang.Object
  |
  +--com.cedarspring.tvm.Options
All Implemented Interfaces:
java.io.Serializable

class Options
extends java.lang.Object
implements java.io.Serializable

Options
Provides a common scale and rounding scheme for the com.cedarspring.tvm package.

Version:
1.2.2 15-May-2003
Author:
Cedar Spring Software, Inc.

Field Summary
private  boolean roundUp
           
private  int scale
           
(package private) static long serialVersionUID
           
 
Constructor Summary
(package private) Options()
          Construct a default Options object with a scale of 4 decimal places and rounding set to round half up.
(package private) Options(int scale, boolean roundUp)
          Construct a new Options object with specific scale and rounding options.
 
Method Summary
(package private)  java.math.BigDecimal adjScale(java.math.BigDecimal value)
          Adjust the scale and rounding for external presentation of computed values.
(package private)  int getInRounding()
          Gets the internal rounding mode as a Java Constant.
(package private)  int getInScale()
          Gets the internal scale.
(package private)  boolean getRoundUp()
          Recall the Rounding mode
(package private)  int getScale()
          Recall scale (number of decimal positions) of display
(package private)  void setRoundUp(boolean newRoundUp)
          Store Rounding mode.
(package private)  void setScale(int newScale)
          Store scale.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

scale

private int scale

roundUp

private boolean roundUp

serialVersionUID

static final long serialVersionUID
See Also:
Constant Field Values
Constructor Detail

Options

Options()
Construct a default Options object with a scale of 4 decimal places and rounding set to round half up.


Options

Options(int scale,
        boolean roundUp)
Construct a new Options object with specific scale and rounding options. Throws TVMException if scale is negative.

Method Detail

setScale

void setScale(int newScale)
        throws TVMException
Store scale.

TVMException

getScale

int getScale()
Recall scale (number of decimal positions) of display


setRoundUp

void setRoundUp(boolean newRoundUp)
Store Rounding mode.

Parameters:
newRoundUp - Rounding applied to subsequent computations.
  • true: Round half up. If the lost fraction is < .5 the value is rounded away from 0, else it is rounded toward 0.
  • false: Round down. The lost fraction is dropped and does not affect the new tail digit.

getRoundUp

boolean getRoundUp()
Recall the Rounding mode


getInRounding

int getInRounding()
Gets the internal rounding mode as a Java Constant. Used by compute methods for intermediate results.


getInScale

int getInScale()
Gets the internal scale. Used by compute methods for intermediate results.


adjScale

java.math.BigDecimal adjScale(java.math.BigDecimal value)
Adjust the scale and rounding for external presentation of computed values.