Mobile Sensor API Version 1.2

javax.microedition.sensor
Class Unit

java.lang.Object
  extended by javax.microedition.sensor.Unit

public class Unit
extends java.lang.Object

The Unit represents the unit of the measured data values. This class has a static factory method for creating new Unit instances. The factory method MUST always return the same object when the same symbol is passed in.

Naming

Symbols and names of units and related quantities are listed in the following tables. The aim is to promote the usage of internationally accepted and standardized units, thus SI units and derivatives are listed here in the first two tables. Also the most common convenience units (mainly English) are listed. The last table is for convenience units.

When using any of the listed units, the corresponding symbol from the table MUST be passed to the factory method exactly alike. If new symbols are needed, the symbol MUST be chosen to be unique by prefixing the unit symbol with the same inverted domain name that is used in naming Java packages, for example:

 private static final Unit COWS_PER_SECOND = Unit
                .getUnit("com.some_company.cow/s");
 

However, there is an exception to the rule: if the unit is well known and the its abbreviation is well established and not ambiguous, the name can be used as such, for example:

 private static final Unit NMI = Unit.getUnit("nmi"); //nautical-mile
 

The format of unit symbols follows C programming language conventions and mathematical operators, short summary here:

Add +
Divide /
Multiply *
Power ^
Subtract -

Parentheses are used if the order of operations is otherwise unclear, for example, the symbol for "joule per kilogram kelvin" is "J/(kg*K)".

Scaling

One thing to notice is scaling. The scaling factor can be obtained from ChannelInfo with the method ChannelInfo.getScale(). The scaling factor, which differs from 0, has notable effect on how data values are interpreted, see definition of ChannelInfo.getScale() for more details. Basic units and scaling MUST be used instead of adding SI prefixes (such as nano, milli, and kilo) to units. For example, instead of using milliseconds ("ms") and scaling factor 0, basic unit second ("s") MUST be used with the scaling factor -3.

Relation to quantity

Related quantities are listed in the third column of the tables. The relation of the unit to the quantity is a many-to-many relationship. For example, pascal, the unit of pressure, can be used as the unit of pressure or stress. The temperature quantity has many unit alternatives: kelvin, degree Celsius, or Fahrenheit. If there are many quantities listed for one unit in the tables below, the quantities are separated with "/".

SI units
Symbol Name Quantity
A ampere electric_current
Bq becquerel activity
C coulomb electric_charge
cd candela luminous_intensity
Celsius degree Celsius temperature
F farad capacitance
Gy gray absorbed_dose/specific_energy/kerma
H henry inductance
Hz hertz frequency
J joule energy/work/quantity_of_heat
K kelvin temperature
kat katal catalytic_activity
kg kilogram mass
lm lumen luminous_flux
lx lux illuminance
m meter length
mol mole amount_of_substance
N newton force
ohm ohm electric_resistance
Pa pascal pressure/stress
rad radian plane_angle
s second time/duration
S siemens electric_conductance
sr steradian solid_angle
Sv sievert dose_equivalent
T tesla magnetic_flux_density
V volt electric_potential_difference
W watt power/radiant_flux
Wb weber magnetic_flux
SI unit derivates
Symbol Name Quantity
m^-1 reciprocal meter wave_number
A/m ampere per meter magnetic_field_strength
A/m^2 ampere per square meter current_density
C/kg coulomb per kilogram exposure
C/m^2 coulomb per square meter electric_flux_density
C/m^3 coulomb per cubic meter electric_charge_density
cd/m^2 candela per square meter luminance
F/m farad per meter permittivity
Gy/s gray per second absorbed_dose_rate
H/m henry per meter permeability
J/(kg*K) joule per kilogram kelvin specific_heat_capacity/specific_entropy
J/(mol*K) joule per mole kelvin molar_entropy/molar_heat_capacity
J/K joule per kelvin heat_capacity/entropy
J/kg joule per kilogram specific_energy
J/m^3 joule per cubic meter energy_density
J/mol joule per mole molar_energy
kat/m^3 katal per cubic meter catalytic_concentration
kg/m^3 kilogram per cubic meter mass_density
m/s meter per second velocity
m/s^2 meter per square second acceleration
m^2 square meter area
m^3 cubic meter volume
m^3/kg cubic meter per kilogram specific_volume
mol/m^3 mol per cubic meter amount_of_substance_concentration
N*m newton meter moment_of_force
N/m newton per meter surface_tension
Pa*s pascal second dynamic_viscosity
rad/s radian per second angular_velocity
rad/s2 radian per second squared angular_acceleration
W/(m*K) watt per meter kelvin thermal_conductivity
W/(m^2*sr) watt per square meter steradian radiance
V/m volt per meter electric_field_strength
W/m^2 watt per square meter heat_flux_density/irradiance
W/sr watt per steradian radiant_intensity
Convenience units
Symbol Name Quantity
atm atmosphere pressure/stress
bar bar pressure/stress
bpm beats per minute heart_rate
boolean boolean logical_value
byte byte data_size
cal calorie energy
degree degree plane_angle
Fahrenheit Fahrenheit temperature
ft foot length
G gravitational constant acceleration
hp horsepower power
in inch length
lb pound mass
mi mile length
mmHg millimeter of mercury pressure/blood_pressure
oz ounce mass
% percent percentage
pixel pixel length
yd yard length
unit unit unit


Method Summary
static Unit getUnit(java.lang.String symbol)
          The method returns the Unit that matches the given symbol.
 java.lang.String toString()
          Returns the symbol of the Unit
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

getUnit

public static Unit getUnit(java.lang.String symbol)

The method returns the Unit that matches the given symbol. The given symbol can be one of the listed symbols or a new one. All new symbols MUST follow the format stated in the class description. The returned object MUST be the same for every request with the same symbol.

Parameters:
symbol - the symbol of the unit
Returns:
Unit with the given symbol
Throws:
java.lang.NullPointerException - if the symbol is null
java.lang.IllegalArgumentException - if the symbol is empty string

toString

public java.lang.String toString()

Returns the symbol of the Unit

Overrides:
toString in class java.lang.Object
Returns:
the symbol of the Unit

Mobile Sensor API Version 1.2

Copyright © 2005-2008 Nokia Corporation. All Rights Reserved.
Java is a trademark of Sun Microsystems, Inc.