|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectwt.units.Unit
This Class represents a floating point number with units. It has support
for basic arithmetic operations and unit conversions. It stores the
floating point number at 'double' precision and maintains a record of
significant figures across operations and conversions.
Supported API: false
Extendable: false
Constructor Summary | |
|
Unit()
Supported API: false |
private |
Unit(double valueDouble,
int sigFigs,
int A,
int cd,
int kg,
int K,
int m,
int mol,
int r,
int s,
int sr,
int B)
|
|
Unit(double valueDouble,
int sigFigs,
String unitString)
Supported API: false |
|
Unit(double valueDouble,
String unitString)
Supported API: false |
|
Unit(String valueString,
int sigFigs,
String unitString)
Supported API: false |
|
Unit(String valueString,
String unitString)
Supported API: false |
Method Summary | |
void |
add(Unit unitB)
Adds the specified Unit to this Unit. |
Object |
clone()
Returns a clone of this Unit. |
boolean |
compatible(String unitString)
Returns true if the units represented by the specified units string are compatible with those of this Unit. |
boolean |
compatible(Unit unitB)
Returns true if the units of the specified Unit are compatible with those of this Unit. |
boolean |
containsUnknownUnits()
Returns true if this Unit contains any unknown units. |
double |
convert(String unitString)
Returns a double representing the value of this Unit when converted to the units represented by the specified units string. |
String |
convertToString(String unitString,
int displayDigits)
Returns a string representing the value of this Unit when converted to the units represented by the specified units string, with the specified number of digits. |
private static int |
countSigFigs(String valueString)
Returns the number of significant figures that exist in the specified string representation of a floating point number. |
void |
divide(Unit unitB)
Divides this Unit by the specified Unit. |
private String |
doubleToString(double doubleValue,
int numDigits)
Returns a string representation of the specified double rounded to the specified number of digits. |
boolean |
equals(Object obj)
Returns true if the specified object is an instance of Unit that has units that are compatible with those of this Unit, that has the same number of significant figues as this Unit, and that has a value equal to that of this unit when rounded to significant figures. |
Unit |
factor(String unitString)
Returns a Unit representing the result of factoring this Unit by the units represented by the specified units string. |
private int |
getCloseIndex(char[] unitChars,
int startIndex)
Returns the index of the first occurrance of the CLOSE_PARENTHESIS character in the specified character array, starting at the specified start index. |
private String |
getKnownUnits(String[] systemSymbols)
Returns a units string composed of the specified symbols and representing the portion of the units of this Unit that are not unknown. |
Unit |
getMaximumRoundingEquivalent()
Returns a Unit with the maximum possible value that, when rounded to a number of digits equal to the number of significant figures in the Unit, is equal to this Unit rounded to the same number of digits. |
Unit |
getMaximumRoundingEquivalent(int roundingDigits)
Returns a Unit with the maximum possible value that, when rounded to the specified number of digits, is equal to this Unit rounded to the same number of digits. |
Unit |
getMinimumRoundingEquivalent()
Returns a Unit with the minimum possible value that, when rounded to a number of digits equal to the number of significant figures in the Unit, is equal to this Unit rounded to the same number of digits. |
Unit |
getMinimumRoundingEquivalent(int roundingDigits)
Returns a Unit with the minimum possible value that, when rounded to the specified number of digits, is equal to this Unit rounded to the same number of digits. |
int |
getSigFigs()
Gets the value of the attribute: sigFigs; The number of digits within the value that can be considered significant. |
private String[] |
getSystemSymbols(Hashtable symbolMap)
Returns the set of base symbols that corresponds to the specified symbol map. |
String |
getUnits()
Gets the value of the attribute: units; A derived attribute that generates String based accessors to the units. |
String |
getUnits(Hashtable symbolMap)
Returns a string representation of the units of this Unit, composed of the base symbols corresponding to the specified symbol map. |
private String |
getUnits(String[] systemSymbols)
Returns a string representation of the units of this Unit, composed of the specified base symbols. |
double |
getValue()
Gets the value of the attribute: value; The floating point value. |
String |
getValueString()
Returns the value of this Unit as a string with MAX_SIG_FIGS digits. |
String |
getValueString(Hashtable symbolMap,
int displayDigits)
Returns a string representation of the value of this Unit with the specified number of digits, after conversion to units represented by the base symbols corresponding to the specified symbol map. |
private String |
getValueString(String[] systemSymbols,
int displayDigits)
Returns a string representation of the value of this Unit with the specified number of digits, after conversion to units represented by the specified base symbols. |
int |
hashCode()
|
private void |
loadTables()
Loads the internal symbol table and prefix table that are used for unit conversions. |
static Unit |
lookupSymbol(String symbol)
Returns a Unit corresponding to the specified symbol string. |
void |
multiply(Unit unitB)
Multiplies this Unit by the specified Unit. |
void |
multiply(Unit unitB,
int power)
Multiplies this Unit by the specified Unit raised to the specified power. |
private Unit |
parseUnit(char[] unitChars,
int startIndex,
int endIndex)
Returns a Unit corresponding to the results of parsing the specified character array from the specified start index to the specified end index. |
void |
pow(int power)
Raises this Unit to the specified power. |
void |
readExternal(ObjectInput input)
Reads the non-transient fields of this class from an external source. |
private boolean |
readOldVersion(ObjectInput input,
long readSerialVersionUID,
boolean passThrough,
boolean superDone)
Reads the non-transient fields of this class from an external source, which is not the current version. |
protected boolean |
readVersion(Unit thisObject,
ObjectInput input,
long readSerialVersionUID,
boolean passThrough,
boolean superDone)
Reads the non-transient fields of this class from an external source. |
private double |
roundingEquivalent(double doubleValue,
int roundingDigits,
int roundingDirection)
Returns the largest or smallest double that, when rounded to the specified number of digits, is equal to the specified double rounded to the same number of digits. |
void |
scale(double scale)
Scales this Unit by the specified value. |
void |
setSigFigs(int a_SigFigs)
Sets the value of the attribute: sigFigs; The number of digits within the value that can be considered significant. |
protected void |
setUnits(String a_Units)
Sets the value of the attribute: units; A derived attribute that generates String based accessors to the units. |
void |
setValue(double a_Value)
Sets the value of the attribute: value; The floating point value. |
void |
subtract(Unit unitB)
Subtracts the specified Unit from this Unit. |
String |
toString()
Return a string equivalent to getValueString() + " " + getUnits(). |
String |
toString(Hashtable symbolMap,
int displayDigits)
Return a string equivalent to getValueString(symbolMap,displayDigits) + " " + getUnits(symbolMap,displayDigits). |
private String |
toString(String[] systemSymbols,
int displayDigits)
Return a string equivalent to getValueString(systemSymbols,displayDigits) + " " + getUnits(systemSymbols,displayDigits). |
void |
writeExternal(ObjectOutput output)
Writes the non-transient fields of this class to an external source. |
Methods inherited from class java.lang.Object |
finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
private static final String RESOURCE
private static final String CLASSNAME
public static final String[] BASE_SYMBOLS
BaseSymbolRB
public static final int MAX_SIG_FIGS
private static Hashtable symbolTable
private static Hashtable prefixTable
private static Hashtable systemTable
private double value
private int sigFigs
private int[] baseUnits
private String unknownUnits
static final long serialVersionUID
public static final long EXTERNALIZATION_VERSION_UID
protected static final long OLD_FORMAT_VERSION_UID
public static final char OPEN_PARENTHESIS_CHAR
public static final char CLOSE_PARENTHESIS_CHAR
public static final char MULTIPLY_CHAR
public static final char DIVIDE_CHAR
public static final char POWER_CHAR
public static final String YOTTA_PREFIX
public static final String ZETTA_PREFIX
public static final String EXA_PREFIX
public static final String PETA_PREFIX
public static final String TERA_PREFIX
public static final String GIGA_PREFIX
public static final String MEGA_PREFIX
public static final String KILO_PREFIX
public static final String KILO_PREFIX_ALT
public static final String HECTO_PREFIX
public static final String HECTO_PREFIX_ALT
public static final String DEKA_PREFIX
public static final String DECI_PREFIX
public static final String CENTI_PREFIX
public static final String MILLI_PREFIX
public static final String MICRO_PREFIX
public static final String NANO_PREFIX
public static final String PICO_PREFIX
public static final String FEMTO_PREFIX
public static final String ATTO_PREFIX
public static final String ZEPTO_PREFIX
public static final String YOCTO_PREFIX
public static final double DEGREE_CELSIUS_ADDITIVE_CONSTANT
public static final double DEG_FAHRENHEIT_ADDITIVE_CONSTANT
public static final Unit UNITLESS
public static final Unit AMPERE
public static final Unit ARE
public static final Unit ACRE
public static final Unit ANGSTROM
public static final Unit ARCMIN
public static final Unit ARCSEC
public static final Unit ATM
public static final Unit ATOMIC_MASS
public static final Unit AU
public static final Unit BARN
public static final Unit BAR
public static final Unit BARREL
public static final Unit BECQUEREL
public static final Unit BTU
public static final Unit BIT
public static final Unit BYTE
public static final Unit US_BUSHEL
public static final Unit SPEED_OF_LIGHT
public static final Unit COULOMB
public static final Unit CALORIE
public static final Unit CANDELA
public static final Unit CHAIN
public static final Unit CURIE
public static final Unit CARAT
public static final Unit US_CUP
public static final Unit DAY
public static final Unit DEGREE
public static final Unit DEGREE_CELSIUS
public static final Unit DEG_FAHRENHEIT
public static final Unit DEGREE_RANKINE
public static final Unit DYNE
public static final Unit ERG
public static final Unit ELECTRON_VOLT
public static final Unit FARAD
public static final Unit FATHOM
public static final Unit BOARD_FOOT
public static final Unit FOOTCANDLE
public static final Unit FARADAY
public static final Unit FERMI
public static final Unit FOOTLAMBERT
public static final Unit US_FLUID_OUNCE
public static final Unit UK_FLUID_OUNCE
public static final Unit FOOT
public static final Unit SURVEY_FOOT
public static final Unit GRAM
public static final Unit STANDARD_GRAVITY
public static final Unit CANADIAN_GALLON
public static final Unit UK_GALLON
public static final Unit US_GALLON
public static final Unit GRAM_FORCE
public static final Unit US_GILL
public static final Unit GRADE
public static final Unit GRAIN
public static final Unit GRAY
public static final Unit HENRY
public static final Unit HOUR
public static final Unit HECTARE
public static final Unit HORSEPOWER
public static final Unit HERTZ
public static final Unit INCH
public static final Unit INCHES_MERCURY_ZERO_C
public static final Unit INCHES_MERCURY_60DEG_F
public static final Unit JOULE
public static final Unit KELVIN
public static final Unit KILOGRAM
public static final Unit KILOPOUND_FORCE
public static final Unit NAUTICAL_MPH
public static final Unit KILOMETERS_PER_H
public static final Unit LITER
public static final Unit LAMBERT
public static final Unit POUND_FORCE
public static final Unit POUND_FORCE_ALT
public static final Unit POUND
public static final Unit TROY_POUND
public static final Unit LUMEN
public static final Unit LUX
public static final Unit LIGHT_YEAR
public static final Unit METER
public static final Unit MHO
public static final Unit MILE
public static final Unit US_MILE
public static final Unit MIL
public static final Unit MINUTE
public static final Unit METERS_MERCURY_ZERO_C
public static final Unit MOLE
public static final Unit MILES_PER_GALLON
public static final Unit MILES_PER_HOUR
public static final Unit NEWTON
public static final Unit NIBBLE
public static final Unit NAUTICAL_MILE
public static final Unit OHM
public static final Unit OUNCE
public static final Unit TROY_OUNCE
public static final Unit POISE
public static final Unit PASCAL
public static final Unit PARSEC
public static final Unit POUNDAL
public static final Unit PECK
public static final Unit PHOT
public static final Unit PSI
public static final Unit PINT
public static final Unit PINT_DRY
public static final Unit QUART
public static final Unit QUART_DRY
public static final Unit RADIAN
public static final Unit ROENTGEN
public static final Unit RAD
public static final Unit RADIAN_ALT
public static final Unit ROD
public static final Unit REM
public static final Unit REVOLUTION
public static final Unit RPM
public static final Unit SECOND
public static final Unit SIEMENS
public static final Unit STILB
public static final Unit SLUG
public static final Unit STERADIAN
public static final Unit STERE
public static final Unit STOKES
public static final Unit SIEVERT
public static final Unit TESLA
public static final Unit TABLESPOON
public static final Unit EEC_THERM
public static final Unit SHORT_TON_US
public static final Unit METRIC_TON
public static final Unit LONG_TON_UK
public static final Unit TORR
public static final Unit TEASPOON
public static final Unit MICRON
public static final Unit VOLT
public static final Unit WATT
public static final Unit WEBER
public static final Unit WEEK
public static final Unit YARD
public static final Unit YEAR
public static final String UNITLESS_SYMBOL
public static final String AMPERE_SYMBOL
public static final String ARE_SYMBOL
public static final String ACRE_SYMBOL
public static final String ANGSTROM_SYMBOL
public static final String ARCMIN_SYMBOL
public static final String ARCSEC_SYMBOL
public static final String ATM_SYMBOL
public static final String ATOMIC_MASS_SYMBOL
public static final String AU_SYMBOL
public static final String BARN_SYMBOL
public static final String BAR_SYMBOL
public static final String BARREL_SYMBOL
public static final String BECQUEREL_SYMBOL
public static final String BTU_SYMBOL
public static final String BIT_SYMBOL
public static final String BYTE_SYMBOL
public static final String US_BUSHEL_SYMBOL
public static final String SPEED_OF_LIGHT_SYMBOL
public static final String COULOMB_SYMBOL
public static final String CALORIE_SYMBOL
public static final String CANDELA_SYMBOL
public static final String CHAIN_SYMBOL
public static final String CURIE_SYMBOL
public static final String CARAT_SYMBOL
public static final String US_CUP_SYMBOL
public static final String DAY_SYMBOL
public static final String DEGREE_SYMBOL
public static final String DEGREE_CELSIUS_SYMBOL
public static final String DEG_FAHRENHEIT_SYMBOL
public static final String DEGREE_RANKINE_SYMBOL
public static final String DYNE_SYMBOL
public static final String ERG_SYMBOL
public static final String ELECTRON_VOLT_SYMBOL
public static final String FARAD_SYMBOL
public static final String FATHOM_SYMBOL
public static final String BOARD_FOOT_SYMBOL
public static final String FOOTCANDLE_SYMBOL
public static final String FARADAY_SYMBOL
public static final String FERMI_SYMBOL
public static final String FOOTLAMBERT_SYMBOL
public static final String US_FLUID_OUNCE_SYMBOL
public static final String UK_FLUID_OUNCE_SYMBOL
public static final String FOOT_SYMBOL
public static final String SURVEY_FOOT_SYMBOL
public static final String GRAM_SYMBOL
public static final String STANDARD_GRAVITY_SYMBOL
public static final String CANADIAN_GALLON_SYMBOL
public static final String UK_GALLON_SYMBOL
public static final String US_GALLON_SYMBOL
public static final String GRAM_FORCE_SYMBOL
public static final String US_GILL_SYMBOL
public static final String GRADE_SYMBOL
public static final String GRAIN_SYMBOL
public static final String GRAY_SYMBOL
public static final String HENRY_SYMBOL
public static final String HOUR_SYMBOL
public static final String HECTARE_SYMBOL
public static final String HORSEPOWER_SYMBOL
public static final String HERTZ_SYMBOL
public static final String INCH_SYMBOL
public static final String INCHES_MERCURY_ZERO_C_SYMBOL
public static final String INCHES_MERCURY_60DEG_F_SYMBOL
public static final String JOULE_SYMBOL
public static final String KELVIN_SYMBOL
public static final String KILOGRAM_SYMBOL
public static final String KILOPOUND_FORCE_SYMBOL
public static final String NAUTICAL_MPH_SYMBOL
public static final String KILOMETERS_PER_H_SYMBOL
public static final String LITER_SYMBOL
public static final String LAMBERT_SYMBOL
public static final String POUND_FORCE_SYMBOL
public static final String POUND_FORCE_ALT_SYMBOL
public static final String POUND_SYMBOL
public static final String TROY_POUND_SYMBOL
public static final String LUMEN_SYMBOL
public static final String LUX_SYMBOL
public static final String LIGHT_YEAR_SYMBOL
public static final String METER_SYMBOL
public static final String MHO_SYMBOL
public static final String MILE_SYMBOL
public static final String US_MILE_SYMBOL
public static final String MIL_SYMBOL
public static final String MINUTE_SYMBOL
public static final String METERS_MERCURY_ZERO_C_SYMBOL
public static final String MOLE_SYMBOL
public static final String MILES_PER_GALLON_SYMBOL
public static final String MILES_PER_HOUR_SYMBOL
public static final String NEWTON_SYMBOL
public static final String NAUTICAL_MILE_SYMBOL
public static final String NIBBLE_SYMBOL
public static final String OHM_SYMBOL
public static final String OUNCE_SYMBOL
public static final String TROY_OUNCE_SYMBOL
public static final String POISE_SYMBOL
public static final String PASCAL_SYMBOL
public static final String PARSEC_SYMBOL
public static final String POUNDAL_SYMBOL
public static final String PECK_SYMBOL
public static final String PHOT_SYMBOL
public static final String PSI_SYMBOL
public static final String PINT_SYMBOL
public static final String PINT_DRY_SYMBOL
public static final String QUART_SYMBOL
public static final String QUART_DRY_SYMBOL
public static final String RADIAN_SYMBOL
public static final String ROENTGEN_SYMBOL
public static final String RAD_SYMBOL
public static final String RADIAN_ALT_SYMBOL
public static final String ROD_SYMBOL
public static final String REM_SYMBOL
public static final String REVOLUTION_SYMBOL
public static final String RPM_SYMBOL
public static final String SECOND_SYMBOL
public static final String SIEMENS_SYMBOL
public static final String STILB_SYMBOL
public static final String SLUG_SYMBOL
public static final String STERADIAN_SYMBOL
public static final String STERE_SYMBOL
public static final String STOKES_SYMBOL
public static final String SIEVERT_SYMBOL
public static final String TESLA_SYMBOL
public static final String TABLESPOON_SYMBOL
public static final String EEC_THERM_SYMBOL
public static final String SHORT_TON_US_SYMBOL
public static final String METRIC_TON_SYMBOL
public static final String LONG_TON_UK_SYMBOL
public static final String TORR_SYMBOL
public static final String TEASPOON_SYMBOL
public static final String MICRON_SYMBOL
public static final String VOLT_SYMBOL
public static final String WATT_SYMBOL
public static final String WEBER_SYMBOL
public static final String WEEK_SYMBOL
public static final String YARD_SYMBOL
public static final String YEAR_SYMBOL
Constructor Detail |
public Unit()
public Unit(String valueString, int sigFigs, String unitString) throws WTNumberFormatException, UnitFormatException
valueString
- sigFigs
- unitString
-
WTNumberFormatException
UnitFormatException
public Unit(String valueString, String unitString) throws WTNumberFormatException, UnitFormatException
valueString
- unitString
-
WTNumberFormatException
UnitFormatException
public Unit(double valueDouble, int sigFigs, String unitString) throws UnitFormatException
valueDouble
- sigFigs
- unitString
-
UnitFormatException
public Unit(double valueDouble, String unitString) throws UnitFormatException
valueDouble
- unitString
-
UnitFormatException
private Unit(double valueDouble, int sigFigs, int A, int cd, int kg, int K, int m, int mol, int r, int s, int sr, int B)
valueDouble
- sigFigs
- A
- cd
- kg
- K
- m
- mol
- r
- s
- sr
- B
- Method Detail |
public void writeExternal(ObjectOutput output) throws IOException
writeExternal
in interface Externalizable
output
-
IOException
public void readExternal(ObjectInput input) throws IOException, ClassNotFoundException
readExternal
in interface Externalizable
input
-
IOException
ClassNotFoundException
protected boolean readVersion(Unit thisObject, ObjectInput input, long readSerialVersionUID, boolean passThrough, boolean superDone) throws IOException, ClassNotFoundException
thisObject
- input
- readSerialVersionUID
- passThrough
- superDone
-
IOException
ClassNotFoundException
private boolean readOldVersion(ObjectInput input, long readSerialVersionUID, boolean passThrough, boolean superDone) throws IOException, ClassNotFoundException
input
- readSerialVersionUID
- passThrough
- superDone
-
IOException
ClassNotFoundException
public double getValue()
public void setValue(double a_Value) throws WTPropertyVetoException
a_Value
-
WTPropertyVetoException
public int getSigFigs()
public void setSigFigs(int a_SigFigs) throws WTPropertyVetoException
a_SigFigs
-
WTPropertyVetoException
public String getUnits()
protected void setUnits(String a_Units) throws UnitFormatException, WTPropertyVetoException
a_Units
-
UnitFormatException
WTPropertyVetoException
public void scale(double scale)
scale
- the value that this Unit is scaled by.public void multiply(Unit unitB, int power)
unitB
- the Unit that this Unit is multiplied by.power
- the power that the specified Unit is raised to.public void multiply(Unit unitB)
unitB
- the Unit that this Unit is multiplied by.public void divide(Unit unitB)
unitB
- the Unit that this Unit is divided by.public void pow(int power)
power
- the power that this Unit is raised to.public void add(Unit unitB) throws IncompatibleUnitsException
unitB
- the Unit that is added to this Unit.
IncompatibleUnitsException
- if the units of the specified
Unit are not compatible with those of this Unit.public void subtract(Unit unitB) throws IncompatibleUnitsException
unitB
- the Unit that is subtracted from this Unit.
IncompatibleUnitsException
- if the units of the specified
Unit are not compatible with those of this Unit.public double convert(String unitString) throws IncompatibleUnitsException, UnitFormatException
unitString
- the unit string that represents the units that this
Unit will be converted to.
IncompatibleUnitsException
- if the units represented by
the specified units string are not compatible with those of this Unit.
UnitFormatException
- if the specified units string does
not contain parsable units.public String convertToString(String unitString, int displayDigits) throws IncompatibleUnitsException, UnitFormatException
unitString
- the unit string that represents the units that this
Unit will be converted to.displayDigits
- the number of digits to include in the return
value.
IncompatibleUnitsException
- if the units represented by
the specified units string are not compatible with those of this Unit.
UnitFormatException
- if the specified units string does
not contain parsable units.public Unit factor(String unitString) throws UnitFormatException
unitString
- the unit string that represents the units that this
Unit will be factored by.
UnitFormatException
- if the specified units string does
not contain parsable units.public boolean compatible(Unit unitB)
unitB
- the Unit whose units will be compared with those of this
Unit.
public boolean compatible(String unitString) throws UnitFormatException
unitString
- the unit string that represents the units that will
be compared with those of this Unit.
UnitFormatException
- if the specified units string does
not contain parsable units.public boolean containsUnknownUnits()
public String toString()
getValueString()
,
getUnits()
public String toString(Hashtable symbolMap, int displayDigits) throws UnitFormatException, IncompatibleUnitsException
symbolMap
- displayDigits
-
IncompatibleUnitsException
- if one or more of the units
represented by the specified symbol map is not compatible with the
corresponding internal symbol.
UnitFormatException
- if one or more of the units strings
within the specified symbol map does not contain parsable units.getValueString(Hashtable,int)
,
getUnits(Hashtable)
public String getValueString()
public String getValueString(Hashtable symbolMap, int displayDigits) throws UnitFormatException, IncompatibleUnitsException
symbolMap
- a hashtable representing the base symbols that should
used in the construction of the return string. The hash table should
store replacement symbol strings, keyed by internal symbol strings
from BASE_SYMBOLS.
IncompatibleUnitsException
- if one or more of the units
represented by the specified symbol map is not compatible with the
corresponding internal symbol.
UnitFormatException
- if one or more of the units strings
within the specified symbol map does not contain parsable units.public String getUnits(Hashtable symbolMap) throws UnitFormatException, IncompatibleUnitsException
symbolMap
- a hashtable representing the base symbols that should
used in the construction of the return string. The hash table should
store replacement symbol strings, keyed by internal symbol strings
from BASE_SYMBOLS.
IncompatibleUnitsException
- if one or more of the units
represented by the specified symbol map is not compatible with the
corresponding internal symbol.
UnitFormatException
- if one or more of the units strings
within the specified symbol map does not contain parsable units.public Unit getMinimumRoundingEquivalent(int roundingDigits)
roundingDigits
- the number of digits that will be considered
when constructing the rounding equivalent.
public Unit getMinimumRoundingEquivalent()
public Unit getMaximumRoundingEquivalent(int roundingDigits)
roundingDigits
- the number of digits that will be considered
when constructing the rounding equivalent.
public Unit getMaximumRoundingEquivalent()
public boolean equals(Object obj)
obj
- the object that will be tested for equality with this Unit.
public Object clone()
public static Unit lookupSymbol(String symbol)
symbol
- the symbol representing the Unit to be returned.
private String toString(String[] systemSymbols, int displayDigits) throws UnitFormatException, IncompatibleUnitsException
systemSymbols
- displayDigits
-
UnitFormatException
IncompatibleUnitsException
getValueString(String[],int)
,
#getUnits(String[],int)
private String getValueString(String[] systemSymbols, int displayDigits) throws UnitFormatException, IncompatibleUnitsException
systemSymbols
- a string array representing the base symbols
that should used in the construction of the return string.displayDigits
- the number of digits to include in the return
value.
UnitFormatException
IncompatibleUnitsException
private String getUnits(String[] systemSymbols) throws UnitFormatException, IncompatibleUnitsException
systemSymbols
- the base symbols that should be used in the construction
of the return string.
UnitFormatException
IncompatibleUnitsException
private String getKnownUnits(String[] systemSymbols)
systemSymbols
- the symbols to be used in constructing the known
units string.
private String[] getSystemSymbols(Hashtable symbolMap) throws UnitFormatException
symbolMap
- a hashtable representing the base symbols that should
used in the construction of the return string array. The hash table
should store replacement symbol strings, keyed by internal symbol
strings from BASE_SYMBOLS.
UnitFormatException
private void loadTables()
private static int countSigFigs(String valueString)
valueString
- the string that represents the floating point number.
private String doubleToString(double doubleValue, int numDigits)
doubleValue
- numDigits
-
private Unit parseUnit(char[] unitChars, int startIndex, int endIndex) throws UnitFormatException
unitChars
- the character array to be parsed.startIndex
- the initial index within the specified character
array at which parsing should begin.endIndex
- the final index within the specified character array
at which parsing should stop.
UnitFormatException
private int getCloseIndex(char[] unitChars, int startIndex)
unitChars
- the character array to be scanned.startIndex
- the initial index at which scanning will begin.
private double roundingEquivalent(double doubleValue, int roundingDigits, int roundingDirection)
roundingDigits
- the number of digits that will be considered
when calculating the rounding equivalent.roundingDirection
- the rounding direction, up or down, that
will be used when calculating the rounding equivalent.
public int hashCode()
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |