public class Unit
extends java.lang.Object
This class only support exponents for the base SI units in the range -64 to
+63. Any operation which produces an exponent outside of this range will
result in a Unit
object with undefined exponents.
Modifier and Type | Field and Description |
---|---|
static Unit |
A
The electric current unit ampere (A)
|
private static int |
A_SHIFT |
private static Unit[] |
allUnits
An array containing all units defined.
|
private static java.util.Hashtable |
base |
static Unit |
C
The electric charge unit coulomb (C).
|
static Unit |
cd
The luminous intensity unit candela (cd)
|
private static int |
cd_SHIFT |
static Unit |
F
The capacitance unit farad (F).
|
static Unit |
Gy
The absorbed dose unit gray (Gy).
|
static Unit |
Hz
The frequency unit hertz (Hz).
|
static Unit |
J
The energy unit joule (J).
|
static Unit |
K
The temperature unit kelvin (K)
|
private static int |
K_SHIFT |
static Unit |
kat
The catalytic activity unit katal (kat).
|
static Unit |
kg
The mass unit kilogram (kg)
|
private static int |
kg_SHIFT |
static Unit |
lx
The illuminance unit lux (lx).
|
static Unit |
m
The length unit meter (m)
|
static Unit |
m_s
The speed unit meter per second (m/s)
|
static Unit |
m_s2
The acceleration unit meter per second squared (m/s 2 )
|
private static int |
m_SHIFT |
static Unit |
m2
The area unit square meter(m 2 )
|
static Unit |
m3
The volume unit cubic meter (m 3 )
|
private static long |
MASK |
static Unit |
mol
The amount of substance unit mole (mol)
|
private static int |
mol_SHIFT |
static Unit |
N
The force unit newton (N).
|
private java.lang.String |
name |
static Unit |
Ohm
The electric resistance unit ohm.
|
static Unit |
Pa
The pressure unit pascal (Pa).
|
static Unit |
rad
The angle unit radians (rad)
|
private static int |
rad_SHIFT |
static Unit |
s
The time unit second (s)
|
static Unit |
S
The electric conductance unit siemens (S).
|
private static int |
s_SHIFT |
static Unit |
T
The magnetic flux density unit tesla (T).
|
private long |
type |
static Unit |
unity
No Unit (Unity)
|
private static long |
UNITY |
static Unit |
V
The electric potential difference unit volt (V).
|
static Unit |
W
The power unit watt (W).
|
static Unit |
Wb
The magnetic flux unit weber (Wb).
|
private static long |
x_MASK |
private static int |
x_SHIFT |
private static long |
ZERO |
Modifier | Constructor and Description |
---|---|
private |
Unit(java.lang.String name,
long type)
Creates a new
Unit instance. |
Modifier and Type | Method and Description |
---|---|
(package private) Unit |
add(Unit that)
Returns a new
Unit that is the addition of this Unit
and the Unit specified. |
private static void |
addSIname(int si,
java.lang.String name,
java.lang.StringBuffer numerator,
java.lang.StringBuffer denominator) |
private static java.lang.String |
computeName(long type) |
private static long |
createType(int x,
int rad,
int cd,
int mol,
int A,
int K,
int kg,
int s,
int m)
Create a type field from the base SI unit exponent values.
|
(package private) Unit |
div(Unit that)
Returns a new
Unit that is the division of this Unit
and the Unit specified |
boolean |
equals(java.lang.Object obj)
Checks whether this
Unit object is equal to the specified
Unit object. |
(package private) static Unit |
find(long type)
Finds a
Unit based on a type. |
int |
hashCode()
Returns the hash code for this object.
|
private boolean |
isSpecial()
Checks whether the unit has a special type, i.e.
|
(package private) Unit |
mul(Unit that)
Returns a new
Unit that is the multiplication of this
Unit and the Unit specified |
(package private) Unit |
sub(Unit that)
Returns a new
Unit that is the subtraction between this
Unit and the Unit specified. |
java.lang.String |
toString()
Returns a
String object representing the Unit |
private static final long UNITY
private static final long ZERO
private static final long MASK
private static final int m_SHIFT
private static final int s_SHIFT
private static final int kg_SHIFT
private static final int K_SHIFT
private static final int A_SHIFT
private static final int mol_SHIFT
private static final int cd_SHIFT
private static final int rad_SHIFT
private static final int x_SHIFT
private static final long x_MASK
public static final Unit unity
public static final Unit m
public static final Unit s
public static final Unit kg
public static final Unit K
public static final Unit A
public static final Unit mol
public static final Unit cd
public static final Unit m_s
public static final Unit m_s2
public static final Unit m2
public static final Unit m3
public static final Unit Hz
hertz is expressed in SI units as 1/s
public static final Unit N
N is expressed in SI units as m·kg/s 2
public static final Unit Pa
Pa is equal to N/m 2 or is expressed in SI units as kg/m·s 2
public static final Unit J
joule is equal to N·m or is expressed in SI units as m 2 ·kg/s 2
public static final Unit W
watt is equal to J/s or is expressed in SI units as m 2 ·kg/s 3
public static final Unit C
coulomb is expressed in SI units as s·A
public static final Unit V
volt is equal to W/A or is expressed in SI units as m 2 ·kg/s 3 ·A
public static final Unit F
farad is equal to C/V or is expressed in SI units as s 4 ·A 2 /m 2 ·kg
public static final Unit Ohm
ohm is equal to V/A or is expressed in SI units as m 2 ·kg/s 3 ·A 2
public static final Unit S
siemens is equal to A/V or is expressed in SI units as s 3 ·A 2 /m 2 ·kg
public static final Unit Wb
weber is equal to V·s or is expressed in SI units as m 2 ·kg/s 2 ·A
public static final Unit T
tesla is equal to Wb/m 2 or is expressed in SI units as kg/s 2 ·A
public static final Unit lx
lux is expressed in SI units as cd/m 2
public static final Unit Gy
Gy is equal to J/kg or is expressed in SI units as m 2 /s 2
public static final Unit kat
katal is expressed in SI units as mol/s
public static final Unit rad
private static final Unit[] allUnits
private static java.util.Hashtable base
private final java.lang.String name
private final long type
private Unit(java.lang.String name, long type)
Unit
instance.name
- the name of the Unit
type
- the type of the Unit
private static long createType(int x, int rad, int cd, int mol, int A, int K, int kg, int s, int m)
public boolean equals(java.lang.Object obj)
Unit
object is equal to the specified
Unit
object. The Unit
objects are considered equal
if their exponents are equal.equals
in class java.lang.Object
obj
- the Unit
object that should be checked for equalityUnit
object is equal to this
Unit
object.public int hashCode()
hashCode
in class java.lang.Object
Unit mul(Unit that)
Unit
that is the multiplication of this
Unit
and the Unit
specifiedthat
- the Unit
that will be multiplied with this
Unit
Unit
that is the multiplication of this
Unit
and the Unit
specifiedjava.lang.RuntimeException
- if both Unit
s are specialisSpecial()
Unit div(Unit that)
Unit
that is the division of this Unit
and the Unit
specifiedthat
- the Unit
that this Unit
will be divided
withUnit
that is the division of this Unit
and the Unit
specifiedjava.lang.RuntimeException
- if both Unit
s are specialisSpecial()
Unit add(Unit that)
Unit
that is the addition of this Unit
and the Unit
specified.that
- the Unit
that should be added to this
Unit
Unit
that is the addition of this Unit
and the Unit
specified.java.lang.RuntimeException
- if the two Unit
s are not the sameUnit sub(Unit that)
Unit
that is the subtraction between this
Unit
and the Unit
specified.that
- the Unit
that will be subtracted from this
Unit
Unit
that is the subtraction between this
Unit
and the Unit
specified.java.lang.RuntimeException
- if the Unit
specified is not the same
as this Unit
static Unit find(long type)
Unit
based on a type. If the Unit
is not
found, it will be created and added to the list of all units under a null
name.type
- the type of the Unit
to findUnit
public java.lang.String toString()
String
object representing the Unit
toString
in class java.lang.Object
String
object representing the Unit
private static java.lang.String computeName(long type)
private static void addSIname(int si, java.lang.String name, java.lang.StringBuffer numerator, java.lang.StringBuffer denominator)
private boolean isSpecial()