JScience v2.0

org.jscience.physics.quantities
Class QuantityFormat

java.lang.Object
  extended by javolution.lang.TextFormat<Quantity>
      extended by org.jscience.physics.quantities.QuantityFormat
Direct Known Subclasses:
QuantityFormat.Decimal

public abstract class QuantityFormat
extends TextFormat<Quantity>

This class provides the interface for formatting and parsing quantities.

Version:
2.0, June 30, 2005
Author:
Jean-Marie Dautelle

Nested Class Summary
static class QuantityFormat.Decimal
          This class represents a decimal quantity format based upon a specific pattern.
 
Nested classes/interfaces inherited from class javolution.lang.TextFormat
TextFormat.Cursor
 
Field Summary
static QuantityFormat EXACT_DIGITS_ONLY
          Holds a quantity format instance for which only digits guaranteed to be exact are written out.
 
Constructor Summary
protected QuantityFormat()
          Base constructor.
 
Method Summary
static QuantityFormat current()
          Deprecated.  
static QuantityFormat getInstance()
          Returns the local quantity format (default EXACT_DIGITS_ONLY).
 Unit getOutputUnit(Quantity q)
          Returns the output unit for the specified quantity.
static void setCurrent(QuantityFormat format)
          Sets the local quantity format.
static void show(java.lang.Class<? extends Quantity> clazz, Unit inUnit)
          Shows instances of the specified class using the specified unit.
 
Methods inherited from class javolution.lang.TextFormat
format, format, parse, parse
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

EXACT_DIGITS_ONLY

public static final QuantityFormat EXACT_DIGITS_ONLY
Holds a quantity format instance for which only digits guaranteed to be exact are written out. In other words, the error is always on the last digit and less than the last digit weight. For example, "1.34 m" means a length between 1.32 m and 1.35 m.

Constructor Detail

QuantityFormat

protected QuantityFormat()
Base constructor.

Method Detail

getInstance

public static QuantityFormat getInstance()
Returns the local quantity format (default EXACT_DIGITS_ONLY).

Returns:
the quantity format for the current thread.

current

public static QuantityFormat current()
Deprecated. 


setCurrent

public static void setCurrent(QuantityFormat format)
Sets the local quantity format.

Parameters:
format - the new format.

getOutputUnit

public Unit getOutputUnit(Quantity q)
Returns the output unit for the specified quantity.

Parameters:
q - the quantity for which the output unit is returned.
Returns:
the output unit.

show

public static void show(java.lang.Class<? extends Quantity> clazz,
                        Unit inUnit)
Shows instances of the specified class using the specified unit.

Parameters:
clazz - the quantity class for which the specified output unit has to be used.
inUnit - the display unit for the specified class instances.

JScience v2.0

Copyright © 2005 JScience.