Purple Code

com.purpletech.graph
Interface Unit

All Known Implementing Classes:
CurrencyMapper, IntegerUnit

public interface Unit

A Unit maps an int to a string representation. It also provides a natural interval (UnitInterval).

The int represents some value. The actual meaning of this value is completely dependent on the particular unit the implementing class represents. But since it's an int, we can optimize our calculations and our display code, and then provide a mapping to String or to double for display or storage purposes.

Version:
$Id: Unit.java,v 1.2 2001/10/30 12:20:51 alex Exp $
Author:
Alex

Method Summary
 int fromObject(java.lang.Object val)
          converts from an Object representing an actual value in the real units to an int.
 int fromString(java.lang.String val)
          converts from a String representing an actual value in the real units to an int.
 UnitInterval getUnitInterval()
           
 java.lang.String toString(int val)
          converts from int to a String representation of this unit
 java.lang.String toString(java.lang.Object val)
          converts from some Object type to a String representation of this unit
 

Method Detail

toString

public java.lang.String toString(int val)
converts from int to a String representation of this unit


toString

public java.lang.String toString(java.lang.Object val)
converts from some Object type to a String representation of this unit

Parameters:
val - an object containing the value, usually a number wrapper

fromString

public int fromString(java.lang.String val)
               throws java.text.ParseException
converts from a String representing an actual value in the real units to an int.

Parameters:
val - a String representing an actual value in the real units
Returns:
an int in the abstract scale
java.text.ParseException

fromObject

public int fromObject(java.lang.Object val)
converts from an Object representing an actual value in the real units to an int.

Parameters:
val - a String representing an actual value in the real units
Returns:
an int in the abstract scale

getUnitInterval

public UnitInterval getUnitInterval()

Documentation generated March 5 2003