Java Doc for Unit.java in  » Science » jscience-4.3.1 » javax » measure » unit » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Science » jscience 4.3.1 » javax.measure.unit 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   javax.measure.unit.Unit

Unit
abstract public class Unit implements Serializable(Code)

This class represents a determinate javax.measure.quantity.Quantityquantity (as of length, time, heat, or value) adopted as a standard of measurement.

It is helpful to think of instances of this class as recording the history by which they are created. Thus, for example, the string "g/kg" (which is a dimensionless unit) would result from invoking the method toString() on a unit that was created by dividing a gram unit by a kilogram unit. Yet, "kg" divided by "kg" returns Unit.ONE and not "kg/kg" due to automatic unit factorization.

This class supports the multiplication of offsets units. The result is usually a unit not convertible to its Unit.getStandardUnit standard unit . Such units may appear in derivative quantities. For example °C/m is an unit of gradient, which is common in atmospheric and oceanographic research.

Units raised at rational powers are also supported. For example the cubic root of "liter" is a unit compatible with meter.

Instances of this class are immutable.


author:
   Jean-Marie Dautelle
author:
   Steve Emmerson
author:
   Martin Desruisseaux
version:
   3.2, August 28, 2006
See Also:    * Wikipedia: Units of measurement


Field Summary
final public static  Unit<Dimensionless>ONE
     Holds the dimensionless unit ONE.
final static  HashMap<String, Unit<?>>SYMBOL_TO_UNIT
     Holds the unique symbols collection (base unit or alternate units).

Constructor Summary
protected  Unit()
     Default constructor.

Method Summary
final public  AlternateUnit<A>alternate(String symbol)
     Returns a unit equivalent to this unit but used in expressions to distinguish between quantities of a different nature but of the same dimensions.

Examples of alternate units:[code] Unit RADIAN = ONE.alternate("rad"); Unit NEWTON = METER.times(KILOGRAM).divide(SECOND.pow(2)).alternate("N"); Unit PASCAL = NEWTON.divide(METER.pow(2)).alternate("Pa"); [/code]


Parameters:
  symbol - the new symbol for the alternate unit.
final public  Unit<T>asType(Class<T> type)
     Casts this unit to a parameterized unit of specified nature or throw a ClassCastException if the dimension of the specified quantity and this unit's dimension do not match. For example:[code] Unit LIGHT_YEAR = NonSI.C.times(NonSI.YEAR).asType(Length.class); [/code]
Parameters:
  type - the quantity class identifying the nature of the unit.
final public  CompoundUnit<Q>compound(Unit<Q> subunit)
     Returns the combination of this unit with the specified sub-unit. Compound units are typically used for formatting purpose.
final public  Unit<Q>divide(long divisor)
     Returns the result of dividing this unit by an exact divisor.
Parameters:
  divisor - the exact divisor.(e.g.
final public  Unit<Q>divide(double divisor)
     Returns the result of dividing this unit by an approximate divisor.
Parameters:
  divisor - the approximate divisor.
final public  Unit<? extends Quantity>divide(Unit that)
     Returns the quotient of this unit with the one specified.
Parameters:
  that - the unit divisor.
abstract public  booleanequals(Object that)
     Indicates if the specified unit can be considered equals to the one specified.
Parameters:
  that - the object to compare to.
final public  UnitConvertergetConverterTo(Unit that)
     Returns a converter of numeric values from this unit to another unit.
Parameters:
  that - the unit to which to convert the numeric values.
final public  DimensiongetDimension()
     Returns the dimension of this unit (depends upon the current dimensional Dimension.Model model ).
abstract public  Unit<? super Q>getStandardUnit()
     Returns the BaseUnit base unit , AlternateUnit alternateunit or product of base units and alternate units this unit is derived from.
abstract public  inthashCode()
     Returns the hash code for this unit.
final public  Unit<? extends Quantity>inverse()
     Returns the inverse of this unit.
final public  booleanisCompatible(Unit that)
     Indicates if this unit is compatible with the unit specified. Units don't need to be equals to be compatible.
public  booleanisStandardUnit()
     Indicates if this unit is a standard unit (base units and alternate units are standard units).
final public  Unit<Q>plus(double offset)
     Returns the result of adding an offset to this unit.
final public  Unit<? extends Quantity>pow(int n)
     Returns a unit equals to this unit raised to an exponent.
Parameters:
  n - the exponent.
final public  Unit<? extends Quantity>root(int n)
     Returns a unit equals to the given root of this unit.
Parameters:
  n - the root's order.
final public  Unit<Q>times(long factor)
     Returns the result of multiplying this unit by an exact factor.
final public  Unit<Q>times(double factor)
     Returns the result of multiplying this unit by a an approximate factor
Parameters:
  factor - the approximate factor (e.g.
final public  Unit<? extends Quantity>times(Unit that)
     Returns the product of this unit with the one specified.
Parameters:
  that - the unit multiplicand.
abstract public  UnitConvertertoStandardUnit()
     Returns the converter from this unit to its system unit.
final public  StringtoString()
     Returns the standard String representation of this unit. This representation is not affected by locale.
final public  Unit<Q>transform(UnitConverter operation)
     Returns the unit derived from this unit using the specified converter. The converter does not need to be linear.
public static  Unit<? extends Quantity>valueOf(CharSequence csq)
     Returns a unit instance that is defined from the specified character sequence using the UnitFormat.getInstancestandard unit format .

Examples of valid entries (all for meters per second squared) are:

  • m*s-2
  • m/s²
  • m·s-²
  • m*s**-2
  • m^+1 s^-2


Parameters:
  csq - the character sequence to parse.

Field Detail
ONE
final public static Unit<Dimensionless> ONE(Code)
Holds the dimensionless unit ONE.



SYMBOL_TO_UNIT
final static HashMap<String, Unit<?>> SYMBOL_TO_UNIT(Code)
Holds the unique symbols collection (base unit or alternate units).




Constructor Detail
Unit
protected Unit()(Code)
Default constructor.




Method Detail
alternate
final public AlternateUnit<A> alternate(String symbol)(Code)
Returns a unit equivalent to this unit but used in expressions to distinguish between quantities of a different nature but of the same dimensions.

Examples of alternate units:[code] Unit RADIAN = ONE.alternate("rad"); Unit NEWTON = METER.times(KILOGRAM).divide(SECOND.pow(2)).alternate("N"); Unit PASCAL = NEWTON.divide(METER.pow(2)).alternate("Pa"); [/code]


Parameters:
  symbol - the new symbol for the alternate unit. the alternate unit.
throws:
  UnsupportedOperationException - if this unit is not a standard unit.
throws:
  IllegalArgumentException - if the specified symbol is already associated to a different unit.



asType
final public Unit<T> asType(Class<T> type) throws ClassCastException(Code)
Casts this unit to a parameterized unit of specified nature or throw a ClassCastException if the dimension of the specified quantity and this unit's dimension do not match. For example:[code] Unit LIGHT_YEAR = NonSI.C.times(NonSI.YEAR).asType(Length.class); [/code]
Parameters:
  type - the quantity class identifying the nature of the unit. this unit parameterized with the specified type.
throws:
  ClassCastException - if the dimension of this unit is different from the specified quantity dimension.
throws:
  UnsupportedOperationException - if the specified quantity classdoes not have a public static field named "UNIT" holding the standard unit for the quantity.



compound
final public CompoundUnit<Q> compound(Unit<Q> subunit)(Code)
Returns the combination of this unit with the specified sub-unit. Compound units are typically used for formatting purpose. Examples of compound units:[code] HOUR_MINUTE = NonSI.HOUR.compound(NonSI.MINUTE); DEGREE_MINUTE_SECOND_ANGLE = NonSI.DEGREE_ANGLE.compound( NonSI.DEGREE_MINUTE).compound(NonSI.SECOND_ANGLE); [/code]
Parameters:
  subunit - the sub-unit to combine with this unit. the corresponding compound unit.



divide
final public Unit<Q> divide(long divisor)(Code)
Returns the result of dividing this unit by an exact divisor.
Parameters:
  divisor - the exact divisor.(e.g. QUART = GALLON_LIQUID_US.divide(4)). this.transform(new RationalConverter(1 , divisor))



divide
final public Unit<Q> divide(double divisor)(Code)
Returns the result of dividing this unit by an approximate divisor.
Parameters:
  divisor - the approximate divisor. this.transform(new MultiplyConverter(1.0 / divisor))



divide
final public Unit<? extends Quantity> divide(Unit that)(Code)
Returns the quotient of this unit with the one specified.
Parameters:
  that - the unit divisor. this / that



equals
abstract public boolean equals(Object that)(Code)
Indicates if the specified unit can be considered equals to the one specified.
Parameters:
  that - the object to compare to. true if this unit is considered equal to that unit; false otherwise.



getConverterTo
final public UnitConverter getConverterTo(Unit that) throws ConversionException(Code)
Returns a converter of numeric values from this unit to another unit.
Parameters:
  that - the unit to which to convert the numeric values. the converter from this unit to that unit.
throws:
  ConversionException - if the conveter cannot be constructed(e.g. !this.isCompatible(that)).



getDimension
final public Dimension getDimension()(Code)
Returns the dimension of this unit (depends upon the current dimensional Dimension.Model model ). the dimension of this unit for the current model.



getStandardUnit
abstract public Unit<? super Q> getStandardUnit()(Code)
Returns the BaseUnit base unit , AlternateUnit alternateunit or product of base units and alternate units this unit is derived from. The standard unit identifies the "type" of javax.measure.quantity.Quantity quantity for which this unit is employed. For example:[code] boolean isAngularVelocity(Unit u) { return u.getStandardUnit().equals(RADIAN.divide(SECOND)); } assert(REVOLUTION.divide(MINUTE).isAngularVelocity()); [/code]

Note: Having the same system unit is not sufficient to ensure that a converter exists between the two units (e.g. °C/m and K/m).

the system unit this unit is derived from.



hashCode
abstract public int hashCode()(Code)
Returns the hash code for this unit. this unit hashcode value.



inverse
final public Unit<? extends Quantity> inverse()(Code)
Returns the inverse of this unit. 1 / this



isCompatible
final public boolean isCompatible(Unit that)(Code)
Indicates if this unit is compatible with the unit specified. Units don't need to be equals to be compatible. For example:[code] RADIAN.equals(ONE) == false RADIAN.isCompatible(ONE) == true [/code]
Parameters:
  that - the other unit. this.getDimension().equals(that.getDimension())
See Also:   Unit.getDimension()



isStandardUnit
public boolean isStandardUnit()(Code)
Indicates if this unit is a standard unit (base units and alternate units are standard units). The standard unit identifies the "type" of javax.measure.quantity.Quantity quantity for which the unit is employed. getStandardUnit().equals(this)



plus
final public Unit<Q> plus(double offset)(Code)
Returns the result of adding an offset to this unit. The returned unit is convertible with all units that are convertible with this unit.
Parameters:
  offset - the offset added (expressed in this unit,e.g. CELSIUS = KELVIN.plus(273.15)). this.transform(new AddConverter(offset))



pow
final public Unit<? extends Quantity> pow(int n)(Code)
Returns a unit equals to this unit raised to an exponent.
Parameters:
  n - the exponent. the result of raising this unit to the exponent.



root
final public Unit<? extends Quantity> root(int n)(Code)
Returns a unit equals to the given root of this unit.
Parameters:
  n - the root's order. the result of taking the given root of this unit.
throws:
  ArithmeticException - if n == 0.



times
final public Unit<Q> times(long factor)(Code)
Returns the result of multiplying this unit by an exact factor.
Parameters:
  factor - the exact scale factor(e.g. KILOMETER = METER.times(1000)). this.transform(new RationalConverter(factor, 1))



times
final public Unit<Q> times(double factor)(Code)
Returns the result of multiplying this unit by a an approximate factor
Parameters:
  factor - the approximate factor (e.g. ELECTRON_MASS = KILOGRAM.times(9.10938188e-31)). this.transform(new MultiplyConverter(factor))



times
final public Unit<? extends Quantity> times(Unit that)(Code)
Returns the product of this unit with the one specified.
Parameters:
  that - the unit multiplicand. this * that



toStandardUnit
abstract public UnitConverter toStandardUnit()(Code)
Returns the converter from this unit to its system unit. this.getConverterTo(this.getSystemUnit())



toString
final public String toString()(Code)
Returns the standard String representation of this unit. This representation is not affected by locale. Locale-sensitive unit formatting and parsing is handled by the MeasureFormat class and its subclasses. UnitFormat.getStandardInstance().format(this)



transform
final public Unit<Q> transform(UnitConverter operation)(Code)
Returns the unit derived from this unit using the specified converter. The converter does not need to be linear. For example:[code] Unit DECIBEL = Unit.ONE.transform( new LogConverter(10).inverse().concatenate( new RationalConverter(1, 10)));[/code]
Parameters:
  operation - the converter from the transformed unit to this unit. the unit after the specified transformation.



valueOf
public static Unit<? extends Quantity> valueOf(CharSequence csq)(Code)
Returns a unit instance that is defined from the specified character sequence using the UnitFormat.getInstancestandard unit format .

Examples of valid entries (all for meters per second squared) are:

  • m*s-2
  • m/s²
  • m·s-²
  • m*s**-2
  • m^+1 s^-2


Parameters:
  csq - the character sequence to parse. UnitFormat.getStandardInstance().parse(csq, new ParsePosition(0))
throws:
  IllegalArgumentException - if the specified character sequencecannot be correctly parsed (e.g. symbol unknown).



Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.