Java Doc for Amount.java in  » Science » jscience-4.3.1 » org » jscience » physics » amount » 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 » org.jscience.physics.amount 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   org.jscience.physics.amount.Amount

Amount
final public class Amount implements Measurable<Q>,Field<Amount<?>>,Serializable,Immutable(Code)

This class represents a determinate or estimated amount for which operations such as addition, subtraction, multiplication and division can be performed (it implements the Field interface).

The nature of an amount can be deduced from its parameterization (compile time) or its Amount.getUnit() unit (run time). Its precision is given by its Amount.getAbsoluteError() error .

Amounts can be Amount.isExact() exact , in which case they can be expressed as an exact long integer in the amount unit. The framework tries to keep amount exact as much as possible. For example:[code] Amount m = Amount.valueOf(33, FOOT).divide(11).times(2); System.out.println(m); System.out.println(m.isExact() ? "exact" : "inexact"); System.out.println(m.getExactValue()); > 6 ft > exact > 6[/code]

Errors (including numeric errors) are calculated using numeric intervals. It is possible to resolve systems of linear equations involving org.jscience.mathematics.vector.Matrix matrices , even if the system is close to singularity; in which case the error associated with some (or all) components of the solution may be large.

By default, non-exact amounts are shown using the plus/minus character ('±') (see AmountFormat ). For example, "(2.0 ± 0.001) km/s" represents a velocity of 2 km/s with an absolute error of ± 1 m/s. Exact amount use an integer notation (no decimal point, e.g. "2000 m").

Operations between different amounts may or may not be authorized based upon the current org.jscience.physics.model.PhysicalModelPhysicalModel . For example, adding Amount<Length> and Amount<Duration> is not allowed by the org.jscience.physics.model.StandardModel StandardModel , but is authorized with the org.jscience.physics.model.RelativisticModel RelativisticModel .


author:
   Jean-Marie Dautelle
version:
   4.0, June 4, 2007
See Also:    * Wikipedia: Measuring


Field Summary
final static  FastMap<Unit<?>, FastMap<Unit<?>, UnitConverter>>CVTR_LOOKUP
    
final static  doubleDECREMENT
    
final static  doubleDOUBLE_RELATIVE_ERROR
    
final static  doubleINCREMENT
    
final static  FastMap<Unit<?>, Unit<?>>INV_LOOKUP
    
final static  FastMap<Unit<?>, FastMap<Unit<?>, Unit<?>>>MULT_LOOKUP
    
final public static  Amount<Dimensionless>ONE
     Holds a dimensionless measure of one (exact).
final protected static  XMLFormat<Amount>XML
     Holds the default XML representation for measures. This representation consists of a value, an unit and an optional error attribute when the measure is not exact. The unit attribute determinates the measurement type.
final public static  Amount<Dimensionless>ZERO
     Holds a dimensionless measure of zero (exact).


Method Summary
public  Amount<Q>abs()
     Returns the absolute value of this measure.
public  booleanapproximates(Amount that)
     Indicates if this measure approximates that measure. Measures are considered approximately equals if their value intervals overlaps.
public  intcompareTo(Measurable<Q> that)
     Compares this measure with the specified measurable object.
Parameters:
  that - the measure to compare with.
public  Amount<Q>copy()
    
public  Amount<Q>divide(long divisor)
     Returns this measure divided by the specified exact divisor (dimensionless).
Parameters:
  divisor - the exact divisor.
public  Amount<Q>divide(double divisor)
     Returns this measure divided by the specified approximate divisor (dimensionless).
Parameters:
  divisor - the approximated divisor.
public  Amount<? extends Quantity>divide(Amount that)
     Returns this measure divided by the one specified.
Parameters:
  that - the measure divisor.
public  doubledoubleValue(Unit<Q> unit)
    
public  booleanequals(Object that)
     Compares this measure against the specified object for strict equality (same value interval and same units).
Parameters:
  that - the object to compare with.
public  doublegetAbsoluteError()
     Returns the value by which the Amount.getEstimatedValue() estimated value may differ from the true value (all stated in base units).
public  doublegetEstimatedValue()
     Returns the estimated value for this measure stated in this measure Amount.getUnit unit .
public  longgetExactValue()
     Returns the exact value for this measure stated in this measure Amount.getUnit unit .
public  doublegetMaximumValue()
     Returns the upper bound interval value for this measure stated in this measure unit.
public  doublegetMinimumValue()
     Returns the lower bound interval value for this measure stated in this measure unit.
public  doublegetRelativeError()
     Returns the percentage by which the estimated amount may differ from the true amount.
public  Unit<Q>getUnit()
     Returns the unit in which the Amount.getEstimatedValue()estimated value and Amount.getAbsoluteError() absolute error are stated.
public  inthashCode()
     Returns the hash code for this measure.
public  Amount<? extends Quantity>inverse()
     Returns the multiplicative inverse of this measure.
public  booleanisExact()
     Indicates if this measure amount is exact.
public  booleanisGreaterThan(Amount<Q> that)
     Indicates if this measure is ordered after that measure (independently of the measure unit).
public  booleanisLargerThan(Amount<Q> that)
     Compares this measure with that measure ignoring the sign.
public  booleanisLessThan(Amount<Q> that)
     Indicates if this measure is ordered before that measure (independently of the measure unit).
final public  longlongValue(Unit<Q> unit)
    
public  Amount<Q>minus(Amount that)
     Returns the difference of this measure with the one specified.
Parameters:
  that - the measure to be subtracted.
public  Amount<Q>opposite()
     Returns the opposite of this measure.
public  Amount<Q>plus(Amount that)
     Returns the sum of this measure with the one specified.
Parameters:
  that - the measure to be added.
public  Amount<? extends Quantity>pow(int exp)
     Returns this measure raised at the specified exponent.
Parameters:
  exp - the exponent.
public static  Amount<Q>rangeOf(double minimum, double maximum, Unit<Q> unit)
     Returns the measure corresponding to the specified interval stated in the specified unit.
Parameters:
  minimum - the lower bound for the measure value.
Parameters:
  maximum - the upper bound for the measure value.
Parameters:
  unit - the unit for both the minimum and maximum values.
public  Amount<? extends Quantity>root(int n)
     Returns the given root of this measure.
Parameters:
  n - the root's order (n != 0).
public  Amount<? extends Quantity>sqrt()
     Returns the square root of this measure.
public  Amount<Q>times(long factor)
     Returns this measure scaled by the specified exact factor (dimensionless).
Parameters:
  factor - the scaling factor.
public  Amount<Q>times(double factor)
     Returns this measure scaled by the specified approximate factor (dimensionless).
Parameters:
  factor - the scaling factor.
public  Amount<? extends Quantity>times(Amount that)
     Returns the product of this measure with the one specified.
Parameters:
  that - the measure multiplier.
public  Amount<R>to(Unit<R> unit)
     Returns the measure equivalent to this measure but stated in the specified unit.
final public  StringtoString()
     Returns the text representation of this amount as a java.lang.String.
public  TexttoText()
     Returns the text representation of this measure.
public static  Amount<Q>valueOf(long value, Unit<Q> unit)
     Returns the exact measure corresponding to the value stated in the specified unit.
Parameters:
  value - the exact value stated in the specified unit.
Parameters:
  unit - the unit in which the value is stated.
public static  Amount<Q>valueOf(double value, Unit<Q> unit)
     Returns the measure corresponding to an approximate value (double) stated in the specified unit; the precision of the measure is assumed to be the double precision (64 bits IEEE 754 format).
Parameters:
  value - the estimated value (± LSB) stated in the specified unit.
Parameters:
  unit - the unit in which the value is stated.
public static  Amount<Q>valueOf(double value, double error, Unit<Q> unit)
     Returns the measure corresponding to the specified approximate value and measurement error, both stated in the specified unit.
Parameters:
  value - the estimated amount (± error) stated in the specified unit.
Parameters:
  error - the measurement error (absolute).
Parameters:
  unit - the unit in which the amount and the error are stated.
public static  AmountvalueOf(CharSequence csq)
     Returns the measure represented by the specified character sequence.
Parameters:
  csq - the character sequence.

Field Detail
CVTR_LOOKUP
final static FastMap<Unit<?>, FastMap<Unit<?>, UnitConverter>> CVTR_LOOKUP(Code)



DECREMENT
final static double DECREMENT(Code)



DOUBLE_RELATIVE_ERROR
final static double DOUBLE_RELATIVE_ERROR(Code)



INCREMENT
final static double INCREMENT(Code)



INV_LOOKUP
final static FastMap<Unit<?>, Unit<?>> INV_LOOKUP(Code)



MULT_LOOKUP
final static FastMap<Unit<?>, FastMap<Unit<?>, Unit<?>>> MULT_LOOKUP(Code)



ONE
final public static Amount<Dimensionless> ONE(Code)
Holds a dimensionless measure of one (exact).



XML
final protected static XMLFormat<Amount> XML(Code)
Holds the default XML representation for measures. This representation consists of a value, an unit and an optional error attribute when the measure is not exact. The unit attribute determinates the measurement type. For example:
 <Amount value="12" unit="µA"/>
represents an electric current measurement.



ZERO
final public static Amount<Dimensionless> ZERO(Code)
Holds a dimensionless measure of zero (exact).





Method Detail
abs
public Amount<Q> abs()(Code)
Returns the absolute value of this measure. |this|.



approximates
public boolean approximates(Amount that)(Code)
Indicates if this measure approximates that measure. Measures are considered approximately equals if their value intervals overlaps. It should be noted that less accurate measurements are more likely to be approximately equals. It is therefore recommended to ensure that the measurement error is not too large before testing for approximate equality. this ≅ that



compareTo
public int compareTo(Measurable<Q> that)(Code)
Compares this measure with the specified measurable object.
Parameters:
  that - the measure to compare with. a negative integer, zero, or a positive integer as this measureis less than, equal to, or greater than that measurable.
throws:
  ConversionException - if the current model does not allows forthese measure to be compared.



copy
public Amount<Q> copy()(Code)



divide
public Amount<Q> divide(long divisor)(Code)
Returns this measure divided by the specified exact divisor (dimensionless).
Parameters:
  divisor - the exact divisor. this / divisor.
throws:
  ArithmeticException - if this measure is exact and the specified divisor is zero.



divide
public Amount<Q> divide(double divisor)(Code)
Returns this measure divided by the specified approximate divisor (dimensionless).
Parameters:
  divisor - the approximated divisor. this / divisor.



divide
public Amount<? extends Quantity> divide(Amount that)(Code)
Returns this measure divided by the one specified.
Parameters:
  that - the measure divisor. this / that.



doubleValue
public double doubleValue(Unit<Q> unit)(Code)



equals
public boolean equals(Object that)(Code)
Compares this measure against the specified object for strict equality (same value interval and same units).
Parameters:
  that - the object to compare with. true if this measure is identical to thatmeasure; false otherwise.



getAbsoluteError
public double getAbsoluteError()(Code)
Returns the value by which the Amount.getEstimatedValue() estimated value may differ from the true value (all stated in base units). the absolute error stated in base units.



getEstimatedValue
public double getEstimatedValue()(Code)
Returns the estimated value for this measure stated in this measure Amount.getUnit unit . the median value of the measure interval.



getExactValue
public long getExactValue() throws AmountException(Code)
Returns the exact value for this measure stated in this measure Amount.getUnit unit . the exact measure value (long) stated in this measure's Amount.getUnit unit
throws:
  AmountException - if this measure is not Amount.isExact()



getMaximumValue
public double getMaximumValue()(Code)
Returns the upper bound interval value for this measure stated in this measure unit. the maximum value.



getMinimumValue
public double getMinimumValue()(Code)
Returns the lower bound interval value for this measure stated in this measure unit. the minimum value.



getRelativeError
public double getRelativeError()(Code)
Returns the percentage by which the estimated amount may differ from the true amount. the relative error.



getUnit
public Unit<Q> getUnit()(Code)
Returns the unit in which the Amount.getEstimatedValue()estimated value and Amount.getAbsoluteError() absolute error are stated. the measure unit.



hashCode
public int hashCode()(Code)
Returns the hash code for this measure. the hash code value.



inverse
public Amount<? extends Quantity> inverse()(Code)
Returns the multiplicative inverse of this measure. If this measure is possibly zero, then the result is unbounded (]-infinity, +infinity[). 1 / this.



isExact
public boolean isExact()(Code)
Indicates if this measure amount is exact. An exact amount is guarantee exact only when stated in this measure unit (e.g. this.longValue()); stating the amount in any other unit may introduce conversion errors. true if this measure is exact;false otherwise.



isGreaterThan
public boolean isGreaterThan(Amount<Q> that)(Code)
Indicates if this measure is ordered after that measure (independently of the measure unit). this.compareTo(that) > 0.



isLargerThan
public boolean isLargerThan(Amount<Q> that)(Code)
Compares this measure with that measure ignoring the sign. |this| > |that|



isLessThan
public boolean isLessThan(Amount<Q> that)(Code)
Indicates if this measure is ordered before that measure (independently of the measure unit). this.compareTo(that) < 0.



longValue
final public long longValue(Unit<Q> unit)(Code)



minus
public Amount<Q> minus(Amount that) throws ConversionException(Code)
Returns the difference of this measure with the one specified.
Parameters:
  that - the measure to be subtracted. this - that.
throws:
  ConversionException - if the current model does not allows forthese quantities to be subtracted.



opposite
public Amount<Q> opposite()(Code)
Returns the opposite of this measure. -this.



plus
public Amount<Q> plus(Amount that) throws ConversionException(Code)
Returns the sum of this measure with the one specified.
Parameters:
  that - the measure to be added. this + that.
throws:
  ConversionException - if the current model does not allows forthese quantities to be added.



pow
public Amount<? extends Quantity> pow(int exp)(Code)
Returns this measure raised at the specified exponent.
Parameters:
  exp - the exponent. thisexp



rangeOf
public static Amount<Q> rangeOf(double minimum, double maximum, Unit<Q> unit)(Code)
Returns the measure corresponding to the specified interval stated in the specified unit.
Parameters:
  minimum - the lower bound for the measure value.
Parameters:
  maximum - the upper bound for the measure value.
Parameters:
  unit - the unit for both the minimum and maximum values. the corresponding measure object.
throws:
  IllegalArgumentException - if minimum > maximum



root
public Amount<? extends Quantity> root(int n)(Code)
Returns the given root of this measure.
Parameters:
  n - the root's order (n != 0). the result of taking the given root of this quantity.
throws:
  ArithmeticException - if n == 0.



sqrt
public Amount<? extends Quantity> sqrt()(Code)
Returns the square root of this measure. sqrt(this)



times
public Amount<Q> times(long factor)(Code)
Returns this measure scaled by the specified exact factor (dimensionless).
Parameters:
  factor - the scaling factor. this · factor.



times
public Amount<Q> times(double factor)(Code)
Returns this measure scaled by the specified approximate factor (dimensionless).
Parameters:
  factor - the scaling factor. this · factor.



times
public Amount<? extends Quantity> times(Amount that)(Code)
Returns the product of this measure with the one specified.
Parameters:
  that - the measure multiplier. this · that.



to
public Amount<R> to(Unit<R> unit)(Code)
Returns the measure equivalent to this measure but stated in the specified unit. The returned measure may not be exact even if this measure is exact due to conversion errors.
Parameters:
  unit - the unit of the measure to be returned. a measure equivalent to this measure but stated in the specified unit.
throws:
  ConversionException - if the current model does not allows forconversion to the specified unit.



toString
final public String toString()(Code)
Returns the text representation of this amount as a java.lang.String. toText().toString()



toText
public Text toText()(Code)
Returns the text representation of this measure. AmountFormat.getInstance().format(this)



valueOf
public static Amount<Q> valueOf(long value, Unit<Q> unit)(Code)
Returns the exact measure corresponding to the value stated in the specified unit.
Parameters:
  value - the exact value stated in the specified unit.
Parameters:
  unit - the unit in which the value is stated. the corresponding measure object.



valueOf
public static Amount<Q> valueOf(double value, Unit<Q> unit)(Code)
Returns the measure corresponding to an approximate value (double) stated in the specified unit; the precision of the measure is assumed to be the double precision (64 bits IEEE 754 format).
Parameters:
  value - the estimated value (± LSB) stated in the specified unit.
Parameters:
  unit - the unit in which the value is stated. the corresponding measure object.



valueOf
public static Amount<Q> valueOf(double value, double error, Unit<Q> unit)(Code)
Returns the measure corresponding to the specified approximate value and measurement error, both stated in the specified unit.
Parameters:
  value - the estimated amount (± error) stated in the specified unit.
Parameters:
  error - the measurement error (absolute).
Parameters:
  unit - the unit in which the amount and the error are stated. the corresponding measure object.
throws:
  IllegalArgumentException - if error < 0.0



valueOf
public static Amount valueOf(CharSequence csq)(Code)
Returns the measure represented by the specified character sequence.
Parameters:
  csq - the character sequence. AmountFormat.getInstance().parse(csq)



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.