com.rubecula.jquantity
Class SiUnit

java.lang.Object
  extended bycom.rubecula.util.Item
      extended bycom.rubecula.jquantity.BaseUnit
          extended bycom.rubecula.jquantity.SiUnit
All Implemented Interfaces:
com.rubecula.util.Auditable, Comparable, com.rubecula.util.Identifiable, Measurable, com.rubecula.util.Presentable, Serializable

public class SiUnit
extends BaseUnit

This class represents, in its most primitive form, a unit of the Systeme International (SI). Only the dimension (type) of unit is represented here.

Version:
$Revision: 1.6 $
Author:
Robin Hillyard
See Also:
Serialized Form

Field Summary
private  int _Dimension
          Instance field to define the dimension of this unit, according to values in the table defined above.
protected static int $DimAngle
           
protected static int $DimConcentration
           
protected static int $DimCurrency
           
protected static int $DimCurrent
           
protected static int $DimDegree
           
protected static int $DimLength
           
protected static int $DimLight
           
protected static int $DimMass
           
protected static int $DimMax
           
protected static int $DimNone
           
protected static int $DimTime
           
static SiUnit ANGULAR
           
static SiUnit CURRENT
           
static SiUnit LINEAR
           
static SiUnit LUXAL
           
static SiUnit MASSIVE
           
static SiUnit MOLAR
           
static SiUnit MONETARY
           
static SiUnit NUMERIC
           
static SiUnit TEMPORAL
           
static SiUnit THERMAL
           
 
Fields inherited from class com.rubecula.util.Item
JQUANTITY_TEST
 
Constructor Summary
(package private) SiUnit(int dimension)
          Primary constructor to create a SiUnit.
 
Method Summary
 String audit(String label)
          Method to return a detailed string from an object for debugging purposes.
 BaseUnit flatten()
          Method to reduce a Units tree to a single flattened version.
 Dimensions getDimensions()
          Method to return the dimensions of this Measurable.
 String getIdentifier()
           
 Rational getOffset()
          Method to return the offset of this Measurable.
 Rational getScale()
          Method to return the scale of this Measurable.
 SystemFlag getSystem()
           
 boolean isInSystem(int systemIndex)
          Method to determine if this Measurable is in a certain system of units.
 boolean isNumber()
          Method to determine if this is dimensionless (i.e. unitless).
static void main(String[] args)
           
 com.rubecula.util.Presentable makePresentableInstance(com.rubecula.util.Presentation presentation)
          Instance method to convert a Presentation into a Presentable.
 com.rubecula.util.Presentation present(com.rubecula.util.AttrMap attributes)
          Convert this Presentable object into a Presentation, according to the set of attributes provided.
 String toString()
           
 
Methods inherited from class com.rubecula.jquantity.BaseUnit
isEqual, isParallel, isParallelInSystem
 
Methods inherited from class com.rubecula.util.Item
audit, audit, compareTo, Debug, getClassNameShort, getType, IsDebug, present, SetDebug, test, test, Wrap
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

$DimNone

protected static final int $DimNone
See Also:
Constant Field Values

$DimTime

protected static final int $DimTime
See Also:
Constant Field Values

$DimLength

protected static final int $DimLength
See Also:
Constant Field Values

$DimMass

protected static final int $DimMass
See Also:
Constant Field Values

$DimAngle

protected static final int $DimAngle
See Also:
Constant Field Values

$DimCurrent

protected static final int $DimCurrent
See Also:
Constant Field Values

$DimDegree

protected static final int $DimDegree
See Also:
Constant Field Values

$DimLight

protected static final int $DimLight
See Also:
Constant Field Values

$DimConcentration

protected static final int $DimConcentration
See Also:
Constant Field Values

$DimCurrency

protected static final int $DimCurrency
See Also:
Constant Field Values

$DimMax

protected static final int $DimMax
See Also:
Constant Field Values

NUMERIC

public static final SiUnit NUMERIC

TEMPORAL

public static final SiUnit TEMPORAL

LINEAR

public static final SiUnit LINEAR

MASSIVE

public static final SiUnit MASSIVE

ANGULAR

public static final SiUnit ANGULAR

CURRENT

public static final SiUnit CURRENT

THERMAL

public static final SiUnit THERMAL

LUXAL

public static final SiUnit LUXAL

MOLAR

public static final SiUnit MOLAR

MONETARY

public static final SiUnit MONETARY

_Dimension

private final int _Dimension
Instance field to define the dimension of this unit, according to values in the table defined above.

Constructor Detail

SiUnit

SiUnit(int dimension)
Primary constructor to create a SiUnit.

Parameters:
dimension - which dimension (according to the values defined below).
Method Detail

getDimensions

public Dimensions getDimensions()
Method to return the dimensions of this Measurable.

Returns:
the Dimensions.

getScale

public Rational getScale()
Method to return the scale of this Measurable.

Returns:
the scale.

getOffset

public Rational getOffset()
Method to return the offset of this Measurable.

Returns:
the offset, usually $0.

isInSystem

public boolean isInSystem(int systemIndex)
Method to determine if this Measurable is in a certain system of units.

Overrides:
isInSystem in class BaseUnit
Parameters:
systemIndex - the index of the units system.
Returns:
true of this Measurable belongs to System defined by sysIndex.

flatten

public BaseUnit flatten()
                 throws JQuantityException
Method to reduce a Units tree to a single flattened version.

Returns:
the equivalent FlatUnit.
Throws:
JQuantityException

isNumber

public boolean isNumber()
Method to determine if this is dimensionless (i.e. unitless).

Specified by:
isNumber in interface Measurable
Overrides:
isNumber in class BaseUnit
Returns:
true if not in any System.

toString

public String toString()

getIdentifier

public String getIdentifier()

audit

public String audit(String label)
Method to return a detailed string from an object for debugging purposes.

Parameters:
label - the label to associate with the data. If label is non-null, a more detailed audit will be returned (this normally occurs only at the top level).
Returns:
the detailed string.

present

public com.rubecula.util.Presentation present(com.rubecula.util.AttrMap attributes)
                                       throws com.rubecula.util.PresentationException
Convert this Presentable object into a Presentation, according to the set of attributes provided.

Parameters:
attributes - a map of the attributes desired for the construction of the new presentation (may be empty).
Returns:
an appropriate instance of Presentation.
Throws:
com.rubecula.util.PresentationException - in case of parsing error.

makePresentableInstance

public com.rubecula.util.Presentable makePresentableInstance(com.rubecula.util.Presentation presentation)
                                                      throws com.rubecula.util.PresentationException
Instance method to convert a Presentation into a Presentable. Ideally, this would be a class method, but such a method cannot be defined in an interface. Nor can it be defined in an abstract class with the intention of overriding it in a subclass. Polymorphism just doesn't work that way.
Therefore, the present value (as in fields) of the instance is essentially ignored - only the methods are important.

Parameters:
presentation - of a number to be converted into a Presentable number.
Returns:
a number in the form of a Presentable.
Throws:
com.rubecula.util.PresentationException - in case of parsing error.

main

public static void main(String[] args)

getSystem

public SystemFlag getSystem()