diff --git a/.gitignore b/.gitignore
deleted file mode 100644
index afa3539..0000000
--- a/.gitignore
+++ /dev/null
@@ -1,12 +0,0 @@
-target/
-pom.xml.tag
-pom.xml.releaseBackup
-pom.xml.versionsBackup
-pom.xml.next
-release.properties
-dependency-reduced-pom.xml
-buildNumber.properties
-.mvn/timing.properties
-/.settings/
-/.classpath
-/.project
diff --git a/pom.xml b/pom.xml
index a15dba4..0f419d9 100644
--- a/pom.xml
+++ b/pom.xml
@@ -6,7 +6,7 @@
https://kenai.com/projects/jsr-275
======================================================================= -->
-
+
This class represents a converter adding a constant offset
- * to numeric values ( Instances of this class are immutable. This class represents a exponential converter of limited precision.
- * Such converter is typically used to create inverse of logarithmic unit.
- *
- * Instances of this class are immutable. This class represents a linear converter. A converter is linear if
- * {@link LinearConverter#concatenate Concatenation} of linear converters
- * always result into a linear converter. This class represents a logarithmic converter of limited precision.
- * Such converter is typically used to create logarithmic unit.
- * For example:[code]
- * Unit Instances of this class are immutable. This class represents a converter multiplying numeric values by a
- * constant scaling factor ( Instances of this class are immutable. This class represents a converter multiplying numeric values by an
- * exact scaling factor (represented as the quotient of two
- * Instances of this class are immutable. This class represents a converter of numeric values. It is not required for sub-classes to be immutable
- * (e.g. currency converter). Sub-classes must ensure unicity of the {@link #IDENTITY identity}
- * converter. In other words, if the result of an operation is equivalent
- * to the identity converter, then the unique {@link #IDENTITY} instance
- * should be returned. Note: Implementations must ensure that the {@link #IDENTITY} instance
- * is returned if the resulting converter is an identity
- * converter. extends Comparable
extends Comparable
int
value of this measurable when
diff --git a/src/main/java/javax/measure/Measure.java b/src/main/java/javax/measure/Measure.java
index 7f87bad..c71d74c 100644
--- a/src/main/java/javax/measure/Measure.java
+++ b/src/main/java/javax/measure/Measure.java
@@ -80,13 +80,12 @@
*/
package javax.measure;
-import java.io.Serializable;
import java.math.BigDecimal;
import java.math.MathContext;
import java.text.ParsePosition;
-import javax.measure.converter.UnitConverter;
import javax.measure.quantity.Quantity;
+import javax.measure.unit.UnitConverter;
import javax.measure.unit.Unit;
/**
@@ -143,10 +142,9 @@
*
* @author Jean-Marie Dautelle
* @author Werner Keil
- * @version 1.0.4 ($Revision: 76 $), $Date: 2009-12-03 23:53:52 +0100 (Do, 03 Dez 2009) $
+ * @version 1.1.2 ($Revision: 102 $), $Date: 2010-02-07 23:46:37 +0100 (So, 07 Feb 2010) $
*/
-public abstract class Measure implements Measurable
,
- Serializable {
+public abstract class Measure
extends Number implements Measurable
{
/**
*
@@ -193,7 +191,7 @@ public long round(Unit
unit) {
* @throws ArithmeticException if the result is inexact and the quotient
* has a non-terminating decimal expansion.
*/
- public Measure
toSI() {
+ public Measure
toSI() { // TODO needed?
return to(this.getUnit().toSI());
}
@@ -312,20 +310,32 @@ public int hashCode() {
}
/**
- * Returns the
String
representation of this measure. The
- * string produced for a given measure is always the same; it is not
+ * Returns the standard String
representation of this measure.
+ * The string produced for a given measure is always the same; it is not
* affected by locale. This means that it can be used as a canonical string
* representation for exchanging measure, or as a key for a Hashtable, etc.
* Locale-sensitive measure formatting and parsing is handled by the
* {@link MeasureFormat} class and its subclasses.
*
- * @return UnitFormat.getInternational().format(this)
+ * @return UnitFormat.getStandard().format(this)
*/
@Override
public String toString() {
return MeasureFormat.getStandard().format(this);
}
+ /**
+ * Returns the locale String
representation of this measure
+ * (usually nicer looking than {@link #toString}. The
+ * string produced for a given measure is not always the same depending
+ * on the locale.
+ *
+ * @return UnitFormat.getInstance().format(this)
+ */
+// public String toStringLocale() {
+// return MeasureFormat.getInstance().format(this);
+// }
+
// Implements Measurable
public final int intValue(Unit unit) throws ArithmeticException {
long longValue = longValue(unit);
@@ -343,12 +353,20 @@ public long longValue(Unit
unit) throws ArithmeticException {
}
return (long) result;
}
+
+ public long longValue() {
+ return longValue(getUnit());
+ }
// Implements Measurable
public final float floatValue(Unit
unit) {
return (float) doubleValue(unit);
}
+ public final float floatValue() {
+ return floatValue(getUnit());
+ }
+
/**
* Casts this measure to a parameterized unit of specified nature or throw a
*
ClassCastException
if the dimension of the specified
@@ -369,7 +387,7 @@ public final float floatValue(Unit unit) {
@SuppressWarnings("unchecked")
public
double
based).0.0
- * (would result in identity converter).
- */
- public AddConverter(double offset) {
- if (offset == 0.0) {
- throw new IllegalArgumentException("Would result in identity converter");
- }
- this.offset = offset;
- }
-
- /**
- * Returns the offset value for this add converter.
- *
- * @return the offset value.
- */
- public double getOffset() {
- return offset;
- }
-
- @Override
- public UnitConverter concatenate(UnitConverter converter) {
- if (converter instanceof AddConverter) {
- double newOffset = offset + ((AddConverter) converter).offset;
- return newOffset == 0.0 ? IDENTITY : new AddConverter(newOffset);
- } else {
- return super.concatenate(converter);
- }
- }
-
- @Override
- public AddConverter inverse() {
- return new AddConverter(-offset);
- }
-
- @Override
- public double convert(double value) {
- return value + offset;
- }
-
- @Override
- public BigDecimal convert(BigDecimal value, MathContext ctx) throws ArithmeticException {
- return value.add(BigDecimal.valueOf(offset), ctx);
- }
-
- @Override
- public final String toString() {
- return "AddConverter(" + offset + ")";
- }
-
- @Override
- public boolean equals(Object obj) {
- if (!(obj instanceof AddConverter)) {
- return false;
- }
- AddConverter that = (AddConverter) obj;
- return this.offset == that.offset;
- }
-
- @Override
- public int hashCode() {
- long bits = Double.doubleToLongBits(offset);
- return (int) (bits ^ (bits >>> 32));
- }
-}
\ No newline at end of file
diff --git a/src/main/java/javax/measure/converter/ConversionException.java b/src/main/java/javax/measure/converter/ConversionException.java
deleted file mode 100644
index 1bf40c8..0000000
--- a/src/main/java/javax/measure/converter/ConversionException.java
+++ /dev/null
@@ -1,134 +0,0 @@
-/**
- * JEAN-MARIE DAUTELLE, WERNER KEIL ARE WILLING TO LICENSE THIS SPECIFICATION TO YOU ONLY UPON THE CONDITION THAT YOU ACCEPT ALL OF THE TERMS CONTAINED IN THIS LICENSE AGREEMENT ("AGREEMENT"). PLEASE READ THE TERMS AND CONDITIONS OF THIS AGREEMENT CAREFULLY. BY DOWNLOADING THIS SPECIFICATION, YOU ACCEPT THE TERMS AND CONDITIONS OF THIS AGREEMENT. IF YOU ARE NOT WILLING TO BE BOUND BY THEM, SELECT THE "DECLINE" BUTTON AT THE BOTTOM OF THIS PAGE AND THE DOWNLOADING PROCESS WILL NOT CONTINUE.
- *
- * Specification: JSR 275 - Units Specification ("Specification")
- *
- * Version: 0.9.4
- * Status: Pre-FCS Public Release
- * Release: December 4, 2009
- *
- * Copyright 2005-2009 Jean-Marie Dautelle, Werner Keil
- * All rights reserved.
- *
- *
- * NOTICE
- *
- * The Specification is protected by copyright and the information described therein may be protected by one or more U.S. patents, foreign patents, or pending applications. Except as provided under the following license, no part of the Specification may be reproduced in any form by any means without the prior written authorization of Jean-Marie Dautelle, Werner Keil and its
- * licensors, if any. Any use of the Specification and the information described therein will be governed by the terms and conditions of this Agreement.
- *
- *
- * Subject to the terms and conditions of this license, including your compliance with Paragraphs 1, 2 and 3 below, Jean-Marie Dautelle and Werner Keil hereby grant you a fully-paid, non-exclusive, non-transferable, limited license (without the right to sublicense) under Jean-Marie Dautelle and Werner Keil's intellectual property rights to:
- *
- * 1. Review the Specification for the purposes of evaluation. This includes: (i) developing implementations of the Specification for your internal, non-commercial use; (ii) discussing the Specification with any third party; and (iii) excerpting brief portions of the Specification in oral or written communications which discuss the Specification provided that such excerpts do not in the aggregate constitute a significant portion of the Specification.
- *
- * 2. Distribute implementations of the Specification to third parties for their testing and evaluation use, provided that any such implementation:
- *
- * (i) does not modify, subset, superset or otherwise extend the Licensor Name Space, or include any public or protected packages, classes, Java interfaces, fields or methods within the Licensor Name Space other than those required/authorized by the Specification or Specifications being implemented;
- *
- * (ii) is clearly and prominently marked with the word "UNTESTED" or "EARLY ACCESS" or "INCOMPATIBLE" or "UNSTABLE" or "BETA" in any list of available builds and in proximity to every link initiating its download, where the list or link is under Licensee's control; and
- *
- * (iii) includes the following notice:
- * "This is an implementation of an early-draft specification developed under the Java Community Process (JCP) and is made available for testing and evaluation purposes only. The code is not compatible with any specification of the JCP."
- *
- * 3. Distribute applications written to the Specification to third parties for their testing and evaluation use, provided that any such application includes the following notice:
- * "This is an application written to interoperate with an early-draft specification developed under the Java Community Process (JCP) and is made available for testing and evaluation purposes only. The code is not compatible with any specification of the JCP."
- *
- * The grant set forth above concerning your distribution of implementations of the Specification is contingent upon your agreement to terminate development and distribution of your implementation of early draft upon final completion of the Specification. If you fail to do so, the foregoing grant shall be considered null and void.
- *
- * Other than this limited license, you acquire no right, title or interest in or to the Specification or any other Jean-Marie Dautelle and Werner Keil intellectual property, and the Specification may only be used in accordance with the license terms set forth herein. This license will expire on the earlier of: (a) two (2) years from the date of Release listed above; (b) the date on which the final version of the Specification is publicly released; or (c) the date on which the Java Specification Request (JSR) to which the Specification corresponds is withdrawn. In addition, this license will terminate immediately without notice from Jean-Marie Dautelle, Werner Keil if you fail to comply with any provision of this license. Upon termination, you must cease use of or destroy the Specification.
- *
- * "Licensor Name Space" means the public class or interface declarations whose names begin with "java", "javax", "org.jscience" or their equivalents in any subsequent naming convention adopted through the Java Community Process, or any recognized successors or replacements thereof
- *
- *
- * TRADEMARKS
- *
- * No right, title, or interest in or to any trademarks, service marks, or trade names of Jean-Marie Dautelle, Werner Keil or Jean-Marie Dautelle and Werner Keil's licensors is granted hereunder. Java and Java-related logos, marks and names are trademarks or registered trademarks of Sun Microsystems, Inc. in the U.S. and other countries.
- *
- *
- * DISCLAIMER OF WARRANTIES
- *
- * THE SPECIFICATION IS PROVIDED "AS IS" AND IS EXPERIMENTAL AND MAY CONTAIN DEFECTS OR DEFICIENCIES WHICH CANNOT OR WILL NOT BE CORRECTED BY JEAN-MARIE DAUTELLE, WERNER KEIL. JEAN-MARIE DAUTELLE AND WERNER KEIL MAKE NO REPRESENTATIONS OR WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT THAT THE CONTENTS OF THE SPECIFICATION ARE SUITABLE FOR ANY PURPOSE OR THAT ANY PRACTICE OR IMPLEMENTATION OF SUCH CONTENTS WILL NOT INFRINGE ANY THIRD PARTY PATENTS, COPYRIGHTS, TRADE SECRETS OR OTHER RIGHTS. This document does not represent any commitment to release or implement any portion of the Specification in any product.
- *
- * THE SPECIFICATION COULD INCLUDE TECHNICAL INACCURACIES OR TYPOGRAPHICAL ERRORS. CHANGES ARE PERIODICALLY ADDED TO THE INFORMATION THEREIN; THESE CHANGES WILL BE INCORPORATED INTO NEW VERSIONS OF THE SPECIFICATION, IF ANY. JEAN-MARIE DAUTELL AND WERNER KEIL MAY MAKE IMPROVEMENTS AND/OR CHANGES TO THE PRODUCT(S) AND/OR THE PROGRAM(S) DESCRIBED IN THE SPECIFICATION AT ANY TIME. Any use of such changes in the Specification will be governed by the then-current license for the applicable version of the Specification.
- *
- *
- * LIMITATION OF LIABILITY
- *
- * TO THE EXTENT NOT PROHIBITED BY LAW, IN NO EVENT WILL JEAN-MARIE DAUTELLE, WERNER KEIL OR THEIR LICENSORS BE LIABLE FOR ANY DAMAGES, INCLUDING WITHOUT LIMITATION, LOST REVENUE, PROFITS OR DATA, OR FOR SPECIAL, INDIRECT, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF OR RELATED TO ANY FURNISHING, PRACTICING, MODIFYING OR ANY USE OF THE SPECIFICATION, EVEN IF JEAN-MARIE DAUTELLE, WERNER KEIL AND/OR ITS LICENSORS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
- *
- * You will hold Jean-Marie Dautelle, Werner Keil (and its licensors) harmless from any claims based on your use of the Specification for any purposes other than the limited right of evaluation as described above, and from any claims that later versions or releases of any Specification furnished to you are incompatible with the Specification provided to you under this license.
- *
- *
- * RESTRICTED RIGHTS LEGEND
- *
- * If this Software is being acquired by or on behalf of the U.S. Government or by a U.S. Government prime contractor or subcontractor (at any tier), then the Government's rights in the Software and accompanying documentation shall be only as set forth in this license; this is in
- * accordance with 48 C.F.R. 227.7201 through 227.7202-4 (for Department of Defense (DoD) acquisitions) and with 48 C.F.R. 2.101 and 12.212 (for non-DoD acquisitions).
- *
- *
- * REPORT
- *
- * You may wish to report any ambiguities, inconsistencies or inaccuracies you may find in connection with your evaluation of the Specification ("Feedback"). To the extent that you provide Jean-Marie Dautelle, Werner Keil with any Feedback, you hereby: (i) agree that such Feedback is provided on a non-proprietary and non-confidential basis, and (ii) grant Jean-Marie Dautelle, Werner Keil a perpetual, non-exclusive, worldwide, fully paid-up, irrevocable license, with the right to sublicense through multiple levels of sublicensees, to incorporate, disclose, and use without limitation the Feedback for any purpose related to the Specification and future versions, implementations, and test suites thereof.
- *
- *
- * GENERAL TERMS
- *
- * Any action related to this Agreement will be governed by California law and controlling U.S. federal law. The U.N. Convention for the International Sale of Goods and the choice of law rules of any jurisdiction will not apply.
- *
- * The Specification is subject to U.S. export control laws and may be subject to export or import regulations in other countries. Licensee agrees to comply strictly with all such laws and regulations and acknowledges that it has the responsibility to obtain such licenses to export, re-export or import as may be required after delivery to Licensee.
- *
- * This Agreement is the parties' entire agreement relating to its subject matter. It supersedes all prior or contemporaneous oral or written communications, proposals, conditions, representations and warranties and prevails over any conflicting or additional terms of any quote, order, acknowledgment, or other communication between the parties relating to its subject matter during the term of this Agreement. No modification to this Agreement will be binding, unless in writing and signed by an authorized representative of each party.
- */
-package javax.measure.converter;
-
-/**
- * Signals that a problem of some sort has occurred either when creating a
- * converter between two units or during the conversion itself.
- *
- * @author Jean-Marie Dautelle
- * @author Werner Keil
- * @version 0.9.3 ($Revision: 76 $), $Date: 2009-12-03 23:53:52 +0100 (Do, 03 Dez 2009) $
- */
-public class ConversionException extends Exception {
-
- /**
- *
- */
- private static final long serialVersionUID = -2846245619420930853L;
-
- /**
- * Constructs a ConversionException
with no detail message.
- */
- public ConversionException() {
- super();
- }
-
- /**
- * Constructs a ConversionException
with the specified detail
- * message.
- *
- * @param message the detail message.
- */
- public ConversionException(String message) {
- super(message);
- }
-
- /**
- * Constructs a ConversionException
with the specified detail
- * message and cause.
- *
- * @param message the detail message.
- * @param cause the cause of the exception.
- */
- public ConversionException(String message, Throwable cause) {
- super(message, cause);
- }
-
- /**
- * Constructs a ConversionException
with the cause.
- *
- * @param cause the cause of the exception.
- */
- public ConversionException(Throwable cause) {
- super(cause);
- }
-}
\ No newline at end of file
diff --git a/src/main/java/javax/measure/converter/ExpConverter.java b/src/main/java/javax/measure/converter/ExpConverter.java
deleted file mode 100644
index dae8b9b..0000000
--- a/src/main/java/javax/measure/converter/ExpConverter.java
+++ /dev/null
@@ -1,167 +0,0 @@
-/**
- * JEAN-MARIE DAUTELLE, WERNER KEIL ARE WILLING TO LICENSE THIS SPECIFICATION TO YOU ONLY UPON THE CONDITION THAT YOU ACCEPT ALL OF THE TERMS CONTAINED IN THIS LICENSE AGREEMENT ("AGREEMENT"). PLEASE READ THE TERMS AND CONDITIONS OF THIS AGREEMENT CAREFULLY. BY DOWNLOADING THIS SPECIFICATION, YOU ACCEPT THE TERMS AND CONDITIONS OF THIS AGREEMENT. IF YOU ARE NOT WILLING TO BE BOUND BY THEM, SELECT THE "DECLINE" BUTTON AT THE BOTTOM OF THIS PAGE AND THE DOWNLOADING PROCESS WILL NOT CONTINUE.
- *
- * Specification: JSR 275 - Units Specification ("Specification")
- *
- * Version: 0.9.4
- * Status: Pre-FCS Public Release
- * Release: December 4, 2009
- *
- * Copyright 2005-2009 Jean-Marie Dautelle, Werner Keil
- * All rights reserved.
- *
- *
- * NOTICE
- *
- * The Specification is protected by copyright and the information described therein may be protected by one or more U.S. patents, foreign patents, or pending applications. Except as provided under the following license, no part of the Specification may be reproduced in any form by any means without the prior written authorization of Jean-Marie Dautelle, Werner Keil and its
- * licensors, if any. Any use of the Specification and the information described therein will be governed by the terms and conditions of this Agreement.
- *
- *
- * Subject to the terms and conditions of this license, including your compliance with Paragraphs 1, 2 and 3 below, Jean-Marie Dautelle and Werner Keil hereby grant you a fully-paid, non-exclusive, non-transferable, limited license (without the right to sublicense) under Jean-Marie Dautelle and Werner Keil's intellectual property rights to:
- *
- * 1. Review the Specification for the purposes of evaluation. This includes: (i) developing implementations of the Specification for your internal, non-commercial use; (ii) discussing the Specification with any third party; and (iii) excerpting brief portions of the Specification in oral or written communications which discuss the Specification provided that such excerpts do not in the aggregate constitute a significant portion of the Specification.
- *
- * 2. Distribute implementations of the Specification to third parties for their testing and evaluation use, provided that any such implementation:
- *
- * (i) does not modify, subset, superset or otherwise extend the Licensor Name Space, or include any public or protected packages, classes, Java interfaces, fields or methods within the Licensor Name Space other than those required/authorized by the Specification or Specifications being implemented;
- *
- * (ii) is clearly and prominently marked with the word "UNTESTED" or "EARLY ACCESS" or "INCOMPATIBLE" or "UNSTABLE" or "BETA" in any list of available builds and in proximity to every link initiating its download, where the list or link is under Licensee's control; and
- *
- * (iii) includes the following notice:
- * "This is an implementation of an early-draft specification developed under the Java Community Process (JCP) and is made available for testing and evaluation purposes only. The code is not compatible with any specification of the JCP."
- *
- * 3. Distribute applications written to the Specification to third parties for their testing and evaluation use, provided that any such application includes the following notice:
- * "This is an application written to interoperate with an early-draft specification developed under the Java Community Process (JCP) and is made available for testing and evaluation purposes only. The code is not compatible with any specification of the JCP."
- *
- * The grant set forth above concerning your distribution of implementations of the Specification is contingent upon your agreement to terminate development and distribution of your implementation of early draft upon final completion of the Specification. If you fail to do so, the foregoing grant shall be considered null and void.
- *
- * Other than this limited license, you acquire no right, title or interest in or to the Specification or any other Jean-Marie Dautelle and Werner Keil intellectual property, and the Specification may only be used in accordance with the license terms set forth herein. This license will expire on the earlier of: (a) two (2) years from the date of Release listed above; (b) the date on which the final version of the Specification is publicly released; or (c) the date on which the Java Specification Request (JSR) to which the Specification corresponds is withdrawn. In addition, this license will terminate immediately without notice from Jean-Marie Dautelle, Werner Keil if you fail to comply with any provision of this license. Upon termination, you must cease use of or destroy the Specification.
- *
- * "Licensor Name Space" means the public class or interface declarations whose names begin with "java", "javax", "org.jscience" or their equivalents in any subsequent naming convention adopted through the Java Community Process, or any recognized successors or replacements thereof
- *
- *
- * TRADEMARKS
- *
- * No right, title, or interest in or to any trademarks, service marks, or trade names of Jean-Marie Dautelle, Werner Keil or Jean-Marie Dautelle and Werner Keil's licensors is granted hereunder. Java and Java-related logos, marks and names are trademarks or registered trademarks of Sun Microsystems, Inc. in the U.S. and other countries.
- *
- *
- * DISCLAIMER OF WARRANTIES
- *
- * THE SPECIFICATION IS PROVIDED "AS IS" AND IS EXPERIMENTAL AND MAY CONTAIN DEFECTS OR DEFICIENCIES WHICH CANNOT OR WILL NOT BE CORRECTED BY JEAN-MARIE DAUTELLE, WERNER KEIL. JEAN-MARIE DAUTELLE AND WERNER KEIL MAKE NO REPRESENTATIONS OR WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT THAT THE CONTENTS OF THE SPECIFICATION ARE SUITABLE FOR ANY PURPOSE OR THAT ANY PRACTICE OR IMPLEMENTATION OF SUCH CONTENTS WILL NOT INFRINGE ANY THIRD PARTY PATENTS, COPYRIGHTS, TRADE SECRETS OR OTHER RIGHTS. This document does not represent any commitment to release or implement any portion of the Specification in any product.
- *
- * THE SPECIFICATION COULD INCLUDE TECHNICAL INACCURACIES OR TYPOGRAPHICAL ERRORS. CHANGES ARE PERIODICALLY ADDED TO THE INFORMATION THEREIN; THESE CHANGES WILL BE INCORPORATED INTO NEW VERSIONS OF THE SPECIFICATION, IF ANY. JEAN-MARIE DAUTELL AND WERNER KEIL MAY MAKE IMPROVEMENTS AND/OR CHANGES TO THE PRODUCT(S) AND/OR THE PROGRAM(S) DESCRIBED IN THE SPECIFICATION AT ANY TIME. Any use of such changes in the Specification will be governed by the then-current license for the applicable version of the Specification.
- *
- *
- * LIMITATION OF LIABILITY
- *
- * TO THE EXTENT NOT PROHIBITED BY LAW, IN NO EVENT WILL JEAN-MARIE DAUTELLE, WERNER KEIL OR THEIR LICENSORS BE LIABLE FOR ANY DAMAGES, INCLUDING WITHOUT LIMITATION, LOST REVENUE, PROFITS OR DATA, OR FOR SPECIAL, INDIRECT, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF OR RELATED TO ANY FURNISHING, PRACTICING, MODIFYING OR ANY USE OF THE SPECIFICATION, EVEN IF JEAN-MARIE DAUTELLE, WERNER KEIL AND/OR ITS LICENSORS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
- *
- * You will hold Jean-Marie Dautelle, Werner Keil (and its licensors) harmless from any claims based on your use of the Specification for any purposes other than the limited right of evaluation as described above, and from any claims that later versions or releases of any Specification furnished to you are incompatible with the Specification provided to you under this license.
- *
- *
- * RESTRICTED RIGHTS LEGEND
- *
- * If this Software is being acquired by or on behalf of the U.S. Government or by a U.S. Government prime contractor or subcontractor (at any tier), then the Government's rights in the Software and accompanying documentation shall be only as set forth in this license; this is in
- * accordance with 48 C.F.R. 227.7201 through 227.7202-4 (for Department of Defense (DoD) acquisitions) and with 48 C.F.R. 2.101 and 12.212 (for non-DoD acquisitions).
- *
- *
- * REPORT
- *
- * You may wish to report any ambiguities, inconsistencies or inaccuracies you may find in connection with your evaluation of the Specification ("Feedback"). To the extent that you provide Jean-Marie Dautelle, Werner Keil with any Feedback, you hereby: (i) agree that such Feedback is provided on a non-proprietary and non-confidential basis, and (ii) grant Jean-Marie Dautelle, Werner Keil a perpetual, non-exclusive, worldwide, fully paid-up, irrevocable license, with the right to sublicense through multiple levels of sublicensees, to incorporate, disclose, and use without limitation the Feedback for any purpose related to the Specification and future versions, implementations, and test suites thereof.
- *
- *
- * GENERAL TERMS
- *
- * Any action related to this Agreement will be governed by California law and controlling U.S. federal law. The U.N. Convention for the International Sale of Goods and the choice of law rules of any jurisdiction will not apply.
- *
- * The Specification is subject to U.S. export control laws and may be subject to export or import regulations in other countries. Licensee agrees to comply strictly with all such laws and regulations and acknowledges that it has the responsibility to obtain such licenses to export, re-export or import as may be required after delivery to Licensee.
- *
- * This Agreement is the parties' entire agreement relating to its subject matter. It supersedes all prior or contemporaneous oral or written communications, proposals, conditions, representations and warranties and prevails over any conflicting or additional terms of any quote, order, acknowledgment, or other communication between the parties relating to its subject matter during the term of this Agreement. No modification to this Agreement will be binding, unless in writing and signed by an authorized representative of each party.
- */
-package javax.measure.converter;
-
-import java.math.BigDecimal;
-import java.math.MathContext;
-
-/**
- * Math.E
for
- * the Natural Logarithm).
- */
- public ExpConverter(double base) {
- this.base = base;
- this.logOfBase = Math.log(base);
- }
-
- /**
- * Returns the exponential base of this converter.
- *
- * @return the exponential base (e.g. Math.E
for
- * the Natural Exponential).
- */
- public double getBase() {
- return base;
- }
-
- @Override
- public UnitConverter inverse() {
- return new LogConverter(base);
- }
-
- @Override
- public final String toString() {
- return "ExpConverter("+ base + ")";
- }
-
- @Override
- public boolean equals(Object obj) {
- if (!(obj instanceof ExpConverter))
- return false;
- ExpConverter that = (ExpConverter) obj;
- return this.base == that.base;
- }
-
- @Override
- public int hashCode() {
- long bits = Double.doubleToLongBits(base);
- return (int) (bits ^ (bits >>> 32));
- }
-
- @Override
- public double convert(double amount) {
- return Math.exp(logOfBase * amount);
- }
-
- @Override
- public BigDecimal convert(BigDecimal value, MathContext ctx) throws ArithmeticException {
- return BigDecimal.valueOf(convert(value.doubleValue())); // Reverts to double conversion.
- }
-}
diff --git a/src/main/java/javax/measure/converter/LinearConverter.java b/src/main/java/javax/measure/converter/LinearConverter.java
deleted file mode 100644
index 76835e9..0000000
--- a/src/main/java/javax/measure/converter/LinearConverter.java
+++ /dev/null
@@ -1,186 +0,0 @@
-/**
- * JEAN-MARIE DAUTELLE, WERNER KEIL ARE WILLING TO LICENSE THIS SPECIFICATION TO YOU ONLY UPON THE CONDITION THAT YOU ACCEPT ALL OF THE TERMS CONTAINED IN THIS LICENSE AGREEMENT ("AGREEMENT"). PLEASE READ THE TERMS AND CONDITIONS OF THIS AGREEMENT CAREFULLY. BY DOWNLOADING THIS SPECIFICATION, YOU ACCEPT THE TERMS AND CONDITIONS OF THIS AGREEMENT. IF YOU ARE NOT WILLING TO BE BOUND BY THEM, SELECT THE "DECLINE" BUTTON AT THE BOTTOM OF THIS PAGE AND THE DOWNLOADING PROCESS WILL NOT CONTINUE.
- *
- * Specification: JSR 275 - Units Specification ("Specification")
- *
- * Version: 0.9.4
- * Status: Pre-FCS Public Release
- * Release: December 4, 2009
- *
- * Copyright 2005-2009 Jean-Marie Dautelle, Werner Keil
- * All rights reserved.
- *
- *
- * NOTICE
- *
- * The Specification is protected by copyright and the information described therein may be protected by one or more U.S. patents, foreign patents, or pending applications. Except as provided under the following license, no part of the Specification may be reproduced in any form by any means without the prior written authorization of Jean-Marie Dautelle, Werner Keil and its
- * licensors, if any. Any use of the Specification and the information described therein will be governed by the terms and conditions of this Agreement.
- *
- *
- * Subject to the terms and conditions of this license, including your compliance with Paragraphs 1, 2 and 3 below, Jean-Marie Dautelle and Werner Keil hereby grant you a fully-paid, non-exclusive, non-transferable, limited license (without the right to sublicense) under Jean-Marie Dautelle and Werner Keil's intellectual property rights to:
- *
- * 1. Review the Specification for the purposes of evaluation. This includes: (i) developing implementations of the Specification for your internal, non-commercial use; (ii) discussing the Specification with any third party; and (iii) excerpting brief portions of the Specification in oral or written communications which discuss the Specification provided that such excerpts do not in the aggregate constitute a significant portion of the Specification.
- *
- * 2. Distribute implementations of the Specification to third parties for their testing and evaluation use, provided that any such implementation:
- *
- * (i) does not modify, subset, superset or otherwise extend the Licensor Name Space, or include any public or protected packages, classes, Java interfaces, fields or methods within the Licensor Name Space other than those required/authorized by the Specification or Specifications being implemented;
- *
- * (ii) is clearly and prominently marked with the word "UNTESTED" or "EARLY ACCESS" or "INCOMPATIBLE" or "UNSTABLE" or "BETA" in any list of available builds and in proximity to every link initiating its download, where the list or link is under Licensee's control; and
- *
- * (iii) includes the following notice:
- * "This is an implementation of an early-draft specification developed under the Java Community Process (JCP) and is made available for testing and evaluation purposes only. The code is not compatible with any specification of the JCP."
- *
- * 3. Distribute applications written to the Specification to third parties for their testing and evaluation use, provided that any such application includes the following notice:
- * "This is an application written to interoperate with an early-draft specification developed under the Java Community Process (JCP) and is made available for testing and evaluation purposes only. The code is not compatible with any specification of the JCP."
- *
- * The grant set forth above concerning your distribution of implementations of the Specification is contingent upon your agreement to terminate development and distribution of your implementation of early draft upon final completion of the Specification. If you fail to do so, the foregoing grant shall be considered null and void.
- *
- * Other than this limited license, you acquire no right, title or interest in or to the Specification or any other Jean-Marie Dautelle and Werner Keil intellectual property, and the Specification may only be used in accordance with the license terms set forth herein. This license will expire on the earlier of: (a) two (2) years from the date of Release listed above; (b) the date on which the final version of the Specification is publicly released; or (c) the date on which the Java Specification Request (JSR) to which the Specification corresponds is withdrawn. In addition, this license will terminate immediately without notice from Jean-Marie Dautelle, Werner Keil if you fail to comply with any provision of this license. Upon termination, you must cease use of or destroy the Specification.
- *
- * "Licensor Name Space" means the public class or interface declarations whose names begin with "java", "javax", "org.jscience" or their equivalents in any subsequent naming convention adopted through the Java Community Process, or any recognized successors or replacements thereof
- *
- *
- * TRADEMARKS
- *
- * No right, title, or interest in or to any trademarks, service marks, or trade names of Jean-Marie Dautelle, Werner Keil or Jean-Marie Dautelle and Werner Keil's licensors is granted hereunder. Java and Java-related logos, marks and names are trademarks or registered trademarks of Sun Microsystems, Inc. in the U.S. and other countries.
- *
- *
- * DISCLAIMER OF WARRANTIES
- *
- * THE SPECIFICATION IS PROVIDED "AS IS" AND IS EXPERIMENTAL AND MAY CONTAIN DEFECTS OR DEFICIENCIES WHICH CANNOT OR WILL NOT BE CORRECTED BY JEAN-MARIE DAUTELLE, WERNER KEIL. JEAN-MARIE DAUTELLE AND WERNER KEIL MAKE NO REPRESENTATIONS OR WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT THAT THE CONTENTS OF THE SPECIFICATION ARE SUITABLE FOR ANY PURPOSE OR THAT ANY PRACTICE OR IMPLEMENTATION OF SUCH CONTENTS WILL NOT INFRINGE ANY THIRD PARTY PATENTS, COPYRIGHTS, TRADE SECRETS OR OTHER RIGHTS. This document does not represent any commitment to release or implement any portion of the Specification in any product.
- *
- * THE SPECIFICATION COULD INCLUDE TECHNICAL INACCURACIES OR TYPOGRAPHICAL ERRORS. CHANGES ARE PERIODICALLY ADDED TO THE INFORMATION THEREIN; THESE CHANGES WILL BE INCORPORATED INTO NEW VERSIONS OF THE SPECIFICATION, IF ANY. JEAN-MARIE DAUTELL AND WERNER KEIL MAY MAKE IMPROVEMENTS AND/OR CHANGES TO THE PRODUCT(S) AND/OR THE PROGRAM(S) DESCRIBED IN THE SPECIFICATION AT ANY TIME. Any use of such changes in the Specification will be governed by the then-current license for the applicable version of the Specification.
- *
- *
- * LIMITATION OF LIABILITY
- *
- * TO THE EXTENT NOT PROHIBITED BY LAW, IN NO EVENT WILL JEAN-MARIE DAUTELLE, WERNER KEIL OR THEIR LICENSORS BE LIABLE FOR ANY DAMAGES, INCLUDING WITHOUT LIMITATION, LOST REVENUE, PROFITS OR DATA, OR FOR SPECIAL, INDIRECT, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF OR RELATED TO ANY FURNISHING, PRACTICING, MODIFYING OR ANY USE OF THE SPECIFICATION, EVEN IF JEAN-MARIE DAUTELLE, WERNER KEIL AND/OR ITS LICENSORS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
- *
- * You will hold Jean-Marie Dautelle, Werner Keil (and its licensors) harmless from any claims based on your use of the Specification for any purposes other than the limited right of evaluation as described above, and from any claims that later versions or releases of any Specification furnished to you are incompatible with the Specification provided to you under this license.
- *
- *
- * RESTRICTED RIGHTS LEGEND
- *
- * If this Software is being acquired by or on behalf of the U.S. Government or by a U.S. Government prime contractor or subcontractor (at any tier), then the Government's rights in the Software and accompanying documentation shall be only as set forth in this license; this is in
- * accordance with 48 C.F.R. 227.7201 through 227.7202-4 (for Department of Defense (DoD) acquisitions) and with 48 C.F.R. 2.101 and 12.212 (for non-DoD acquisitions).
- *
- *
- * REPORT
- *
- * You may wish to report any ambiguities, inconsistencies or inaccuracies you may find in connection with your evaluation of the Specification ("Feedback"). To the extent that you provide Jean-Marie Dautelle, Werner Keil with any Feedback, you hereby: (i) agree that such Feedback is provided on a non-proprietary and non-confidential basis, and (ii) grant Jean-Marie Dautelle, Werner Keil a perpetual, non-exclusive, worldwide, fully paid-up, irrevocable license, with the right to sublicense through multiple levels of sublicensees, to incorporate, disclose, and use without limitation the Feedback for any purpose related to the Specification and future versions, implementations, and test suites thereof.
- *
- *
- * GENERAL TERMS
- *
- * Any action related to this Agreement will be governed by California law and controlling U.S. federal law. The U.N. Convention for the International Sale of Goods and the choice of law rules of any jurisdiction will not apply.
- *
- * The Specification is subject to U.S. export control laws and may be subject to export or import regulations in other countries. Licensee agrees to comply strictly with all such laws and regulations and acknowledges that it has the responsibility to obtain such licenses to export, re-export or import as may be required after delivery to Licensee.
- *
- * This Agreement is the parties' entire agreement relating to its subject matter. It supersedes all prior or contemporaneous oral or written communications, proposals, conditions, representations and warranties and prevails over any conflicting or additional terms of any quote, order, acknowledgment, or other communication between the parties relating to its subject matter during the term of this Agreement. No modification to this Agreement will be binding, unless in writing and signed by an authorized representative of each party.
- */
-package javax.measure.converter;
-
-import java.math.BigDecimal;
-import java.math.MathContext;
-
-/**
- * convert(u + v) == convert(u) + convert(v)
and
- * convert(r * u) == r * convert(u)
. For linear converters the
- * following property always hold:[code]
- * y1 = c1.convert(x1);
- * y2 = c2.convert(x2);
- * // then y1*y2 == c1.concatenate(c2).convert(x1*x2)
- * [/code] Math.E
for
- * the Natural Logarithm).
- */
- public LogConverter(double base) {
- this.base = base;
- logOfBase = Math.log(base);
- }
-
- /**
- * Returns the logarithmic base of this converter.
- *
- * @return the logarithmic base (e.g. Math.E
for
- * the Natural Logarithm).
- */
- public double getBase() {
- return base;
- }
-
- @Override
- public UnitConverter inverse() {
- return new ExpConverter(base);
- }
-
- @Override
- public final String toString() {
- return "LogConverter("+ base + ")";
- }
-
- @Override
- public boolean equals(Object obj) {
- if (!(obj instanceof LogConverter))
- return false;
- LogConverter that = (LogConverter) obj;
- return this.base == that.base;
- }
-
- @Override
- public int hashCode() {
- long bits = Double.doubleToLongBits(base);
- return (int) (bits ^ (bits >>> 32));
- }
-
- @Override
- public double convert(double amount) {
- return Math.log(amount) / logOfBase;
- }
-
- @Override
- public BigDecimal convert(BigDecimal value, MathContext ctx) throws ArithmeticException {
- return BigDecimal.valueOf(convert(value.doubleValue())); // Reverts to double conversion.
- }
-}
diff --git a/src/main/java/javax/measure/converter/MultiplyConverter.java b/src/main/java/javax/measure/converter/MultiplyConverter.java
deleted file mode 100644
index 79008df..0000000
--- a/src/main/java/javax/measure/converter/MultiplyConverter.java
+++ /dev/null
@@ -1,171 +0,0 @@
-/**
- * JEAN-MARIE DAUTELLE, WERNER KEIL ARE WILLING TO LICENSE THIS SPECIFICATION TO YOU ONLY UPON THE CONDITION THAT YOU ACCEPT ALL OF THE TERMS CONTAINED IN THIS LICENSE AGREEMENT ("AGREEMENT"). PLEASE READ THE TERMS AND CONDITIONS OF THIS AGREEMENT CAREFULLY. BY DOWNLOADING THIS SPECIFICATION, YOU ACCEPT THE TERMS AND CONDITIONS OF THIS AGREEMENT. IF YOU ARE NOT WILLING TO BE BOUND BY THEM, SELECT THE "DECLINE" BUTTON AT THE BOTTOM OF THIS PAGE AND THE DOWNLOADING PROCESS WILL NOT CONTINUE.
- *
- * Specification: JSR 275 - Units Specification ("Specification")
- *
- * Version: 0.9.4
- * Status: Pre-FCS Public Release
- * Release: December 4, 2009
- *
- * Copyright 2005-2009 Jean-Marie Dautelle, Werner Keil
- * All rights reserved.
- *
- *
- * NOTICE
- *
- * The Specification is protected by copyright and the information described therein may be protected by one or more U.S. patents, foreign patents, or pending applications. Except as provided under the following license, no part of the Specification may be reproduced in any form by any means without the prior written authorization of Jean-Marie Dautelle, Werner Keil and its
- * licensors, if any. Any use of the Specification and the information described therein will be governed by the terms and conditions of this Agreement.
- *
- *
- * Subject to the terms and conditions of this license, including your compliance with Paragraphs 1, 2 and 3 below, Jean-Marie Dautelle and Werner Keil hereby grant you a fully-paid, non-exclusive, non-transferable, limited license (without the right to sublicense) under Jean-Marie Dautelle and Werner Keil's intellectual property rights to:
- *
- * 1. Review the Specification for the purposes of evaluation. This includes: (i) developing implementations of the Specification for your internal, non-commercial use; (ii) discussing the Specification with any third party; and (iii) excerpting brief portions of the Specification in oral or written communications which discuss the Specification provided that such excerpts do not in the aggregate constitute a significant portion of the Specification.
- *
- * 2. Distribute implementations of the Specification to third parties for their testing and evaluation use, provided that any such implementation:
- *
- * (i) does not modify, subset, superset or otherwise extend the Licensor Name Space, or include any public or protected packages, classes, Java interfaces, fields or methods within the Licensor Name Space other than those required/authorized by the Specification or Specifications being implemented;
- *
- * (ii) is clearly and prominently marked with the word "UNTESTED" or "EARLY ACCESS" or "INCOMPATIBLE" or "UNSTABLE" or "BETA" in any list of available builds and in proximity to every link initiating its download, where the list or link is under Licensee's control; and
- *
- * (iii) includes the following notice:
- * "This is an implementation of an early-draft specification developed under the Java Community Process (JCP) and is made available for testing and evaluation purposes only. The code is not compatible with any specification of the JCP."
- *
- * 3. Distribute applications written to the Specification to third parties for their testing and evaluation use, provided that any such application includes the following notice:
- * "This is an application written to interoperate with an early-draft specification developed under the Java Community Process (JCP) and is made available for testing and evaluation purposes only. The code is not compatible with any specification of the JCP."
- *
- * The grant set forth above concerning your distribution of implementations of the Specification is contingent upon your agreement to terminate development and distribution of your implementation of early draft upon final completion of the Specification. If you fail to do so, the foregoing grant shall be considered null and void.
- *
- * Other than this limited license, you acquire no right, title or interest in or to the Specification or any other Jean-Marie Dautelle and Werner Keil intellectual property, and the Specification may only be used in accordance with the license terms set forth herein. This license will expire on the earlier of: (a) two (2) years from the date of Release listed above; (b) the date on which the final version of the Specification is publicly released; or (c) the date on which the Java Specification Request (JSR) to which the Specification corresponds is withdrawn. In addition, this license will terminate immediately without notice from Jean-Marie Dautelle, Werner Keil if you fail to comply with any provision of this license. Upon termination, you must cease use of or destroy the Specification.
- *
- * "Licensor Name Space" means the public class or interface declarations whose names begin with "java", "javax", "org.jscience" or their equivalents in any subsequent naming convention adopted through the Java Community Process, or any recognized successors or replacements thereof
- *
- *
- * TRADEMARKS
- *
- * No right, title, or interest in or to any trademarks, service marks, or trade names of Jean-Marie Dautelle, Werner Keil or Jean-Marie Dautelle and Werner Keil's licensors is granted hereunder. Java and Java-related logos, marks and names are trademarks or registered trademarks of Sun Microsystems, Inc. in the U.S. and other countries.
- *
- *
- * DISCLAIMER OF WARRANTIES
- *
- * THE SPECIFICATION IS PROVIDED "AS IS" AND IS EXPERIMENTAL AND MAY CONTAIN DEFECTS OR DEFICIENCIES WHICH CANNOT OR WILL NOT BE CORRECTED BY JEAN-MARIE DAUTELLE, WERNER KEIL. JEAN-MARIE DAUTELLE AND WERNER KEIL MAKE NO REPRESENTATIONS OR WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT THAT THE CONTENTS OF THE SPECIFICATION ARE SUITABLE FOR ANY PURPOSE OR THAT ANY PRACTICE OR IMPLEMENTATION OF SUCH CONTENTS WILL NOT INFRINGE ANY THIRD PARTY PATENTS, COPYRIGHTS, TRADE SECRETS OR OTHER RIGHTS. This document does not represent any commitment to release or implement any portion of the Specification in any product.
- *
- * THE SPECIFICATION COULD INCLUDE TECHNICAL INACCURACIES OR TYPOGRAPHICAL ERRORS. CHANGES ARE PERIODICALLY ADDED TO THE INFORMATION THEREIN; THESE CHANGES WILL BE INCORPORATED INTO NEW VERSIONS OF THE SPECIFICATION, IF ANY. JEAN-MARIE DAUTELL AND WERNER KEIL MAY MAKE IMPROVEMENTS AND/OR CHANGES TO THE PRODUCT(S) AND/OR THE PROGRAM(S) DESCRIBED IN THE SPECIFICATION AT ANY TIME. Any use of such changes in the Specification will be governed by the then-current license for the applicable version of the Specification.
- *
- *
- * LIMITATION OF LIABILITY
- *
- * TO THE EXTENT NOT PROHIBITED BY LAW, IN NO EVENT WILL JEAN-MARIE DAUTELLE, WERNER KEIL OR THEIR LICENSORS BE LIABLE FOR ANY DAMAGES, INCLUDING WITHOUT LIMITATION, LOST REVENUE, PROFITS OR DATA, OR FOR SPECIAL, INDIRECT, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF OR RELATED TO ANY FURNISHING, PRACTICING, MODIFYING OR ANY USE OF THE SPECIFICATION, EVEN IF JEAN-MARIE DAUTELLE, WERNER KEIL AND/OR ITS LICENSORS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
- *
- * You will hold Jean-Marie Dautelle, Werner Keil (and its licensors) harmless from any claims based on your use of the Specification for any purposes other than the limited right of evaluation as described above, and from any claims that later versions or releases of any Specification furnished to you are incompatible with the Specification provided to you under this license.
- *
- *
- * RESTRICTED RIGHTS LEGEND
- *
- * If this Software is being acquired by or on behalf of the U.S. Government or by a U.S. Government prime contractor or subcontractor (at any tier), then the Government's rights in the Software and accompanying documentation shall be only as set forth in this license; this is in
- * accordance with 48 C.F.R. 227.7201 through 227.7202-4 (for Department of Defense (DoD) acquisitions) and with 48 C.F.R. 2.101 and 12.212 (for non-DoD acquisitions).
- *
- *
- * REPORT
- *
- * You may wish to report any ambiguities, inconsistencies or inaccuracies you may find in connection with your evaluation of the Specification ("Feedback"). To the extent that you provide Jean-Marie Dautelle, Werner Keil with any Feedback, you hereby: (i) agree that such Feedback is provided on a non-proprietary and non-confidential basis, and (ii) grant Jean-Marie Dautelle, Werner Keil a perpetual, non-exclusive, worldwide, fully paid-up, irrevocable license, with the right to sublicense through multiple levels of sublicensees, to incorporate, disclose, and use without limitation the Feedback for any purpose related to the Specification and future versions, implementations, and test suites thereof.
- *
- *
- * GENERAL TERMS
- *
- * Any action related to this Agreement will be governed by California law and controlling U.S. federal law. The U.N. Convention for the International Sale of Goods and the choice of law rules of any jurisdiction will not apply.
- *
- * The Specification is subject to U.S. export control laws and may be subject to export or import regulations in other countries. Licensee agrees to comply strictly with all such laws and regulations and acknowledges that it has the responsibility to obtain such licenses to export, re-export or import as may be required after delivery to Licensee.
- *
- * This Agreement is the parties' entire agreement relating to its subject matter. It supersedes all prior or contemporaneous oral or written communications, proposals, conditions, representations and warranties and prevails over any conflicting or additional terms of any quote, order, acknowledgment, or other communication between the parties relating to its subject matter during the term of this Agreement. No modification to this Agreement will be binding, unless in writing and signed by an authorized representative of each party.
- */
-package javax.measure.converter;
-
-import java.math.BigDecimal;
-import java.math.MathContext;
-
-/**
- * double
based).1.0
- * (would result in identity converter)
- */
- public MultiplyConverter(double factor) {
- if (factor == 1.0)
- throw new IllegalArgumentException("Would result in identity converter");
- this.factor = factor;
- }
-
- /**
- * Returns the scale factor of this converter.
- *
- * @return the scale factor.
- */
- public double getFactor() {
- return factor;
- }
-
- @Override
- public UnitConverter concatenate(UnitConverter converter) {
- if (converter instanceof MultiplyConverter) {
- double newfactor = factor * ((MultiplyConverter) converter).factor;
- return newfactor == 1.0 ? IDENTITY : new MultiplyConverter(newfactor);
- } else
- return super.concatenate(converter);
- }
-
- @Override
- public MultiplyConverter inverse() {
- return new MultiplyConverter(1.0 / factor);
- }
-
- @Override
- public double convert(double value) {
- return value * factor;
- }
-
- @Override
- public BigDecimal convert(BigDecimal value, MathContext ctx) throws ArithmeticException {
- return value.multiply(BigDecimal.valueOf(factor), ctx);
- }
-
- @Override
- public final String toString() {
- return "MultiplyConverter("+ factor + ")";
- }
-
- @Override
- public boolean equals(Object obj) {
- if (!(obj instanceof MultiplyConverter))
- return false;
- MultiplyConverter that = (MultiplyConverter) obj;
- return this.factor == that.factor;
- }
-
- @Override
- public int hashCode() {
- long bits = Double.doubleToLongBits(factor);
- return (int)(bits ^ (bits >>> 32));
- }
-}
diff --git a/src/main/java/javax/measure/converter/RationalConverter.java b/src/main/java/javax/measure/converter/RationalConverter.java
deleted file mode 100644
index db140fe..0000000
--- a/src/main/java/javax/measure/converter/RationalConverter.java
+++ /dev/null
@@ -1,204 +0,0 @@
-/**
- * JEAN-MARIE DAUTELLE, WERNER KEIL ARE WILLING TO LICENSE THIS SPECIFICATION TO YOU ONLY UPON THE CONDITION THAT YOU ACCEPT ALL OF THE TERMS CONTAINED IN THIS LICENSE AGREEMENT ("AGREEMENT"). PLEASE READ THE TERMS AND CONDITIONS OF THIS AGREEMENT CAREFULLY. BY DOWNLOADING THIS SPECIFICATION, YOU ACCEPT THE TERMS AND CONDITIONS OF THIS AGREEMENT. IF YOU ARE NOT WILLING TO BE BOUND BY THEM, SELECT THE "DECLINE" BUTTON AT THE BOTTOM OF THIS PAGE AND THE DOWNLOADING PROCESS WILL NOT CONTINUE.
- *
- * Specification: JSR 275 - Units Specification ("Specification")
- *
- * Version: 0.9.4
- * Status: Pre-FCS Public Release
- * Release: December 4, 2009
- *
- * Copyright 2005-2009 Jean-Marie Dautelle, Werner Keil
- * All rights reserved.
- *
- *
- * NOTICE
- *
- * The Specification is protected by copyright and the information described therein may be protected by one or more U.S. patents, foreign patents, or pending applications. Except as provided under the following license, no part of the Specification may be reproduced in any form by any means without the prior written authorization of Jean-Marie Dautelle, Werner Keil and its
- * licensors, if any. Any use of the Specification and the information described therein will be governed by the terms and conditions of this Agreement.
- *
- *
- * Subject to the terms and conditions of this license, including your compliance with Paragraphs 1, 2 and 3 below, Jean-Marie Dautelle and Werner Keil hereby grant you a fully-paid, non-exclusive, non-transferable, limited license (without the right to sublicense) under Jean-Marie Dautelle and Werner Keil's intellectual property rights to:
- *
- * 1. Review the Specification for the purposes of evaluation. This includes: (i) developing implementations of the Specification for your internal, non-commercial use; (ii) discussing the Specification with any third party; and (iii) excerpting brief portions of the Specification in oral or written communications which discuss the Specification provided that such excerpts do not in the aggregate constitute a significant portion of the Specification.
- *
- * 2. Distribute implementations of the Specification to third parties for their testing and evaluation use, provided that any such implementation:
- *
- * (i) does not modify, subset, superset or otherwise extend the Licensor Name Space, or include any public or protected packages, classes, Java interfaces, fields or methods within the Licensor Name Space other than those required/authorized by the Specification or Specifications being implemented;
- *
- * (ii) is clearly and prominently marked with the word "UNTESTED" or "EARLY ACCESS" or "INCOMPATIBLE" or "UNSTABLE" or "BETA" in any list of available builds and in proximity to every link initiating its download, where the list or link is under Licensee's control; and
- *
- * (iii) includes the following notice:
- * "This is an implementation of an early-draft specification developed under the Java Community Process (JCP) and is made available for testing and evaluation purposes only. The code is not compatible with any specification of the JCP."
- *
- * 3. Distribute applications written to the Specification to third parties for their testing and evaluation use, provided that any such application includes the following notice:
- * "This is an application written to interoperate with an early-draft specification developed under the Java Community Process (JCP) and is made available for testing and evaluation purposes only. The code is not compatible with any specification of the JCP."
- *
- * The grant set forth above concerning your distribution of implementations of the Specification is contingent upon your agreement to terminate development and distribution of your implementation of early draft upon final completion of the Specification. If you fail to do so, the foregoing grant shall be considered null and void.
- *
- * Other than this limited license, you acquire no right, title or interest in or to the Specification or any other Jean-Marie Dautelle and Werner Keil intellectual property, and the Specification may only be used in accordance with the license terms set forth herein. This license will expire on the earlier of: (a) two (2) years from the date of Release listed above; (b) the date on which the final version of the Specification is publicly released; or (c) the date on which the Java Specification Request (JSR) to which the Specification corresponds is withdrawn. In addition, this license will terminate immediately without notice from Jean-Marie Dautelle, Werner Keil if you fail to comply with any provision of this license. Upon termination, you must cease use of or destroy the Specification.
- *
- * "Licensor Name Space" means the public class or interface declarations whose names begin with "java", "javax", "org.jscience" or their equivalents in any subsequent naming convention adopted through the Java Community Process, or any recognized successors or replacements thereof
- *
- *
- * TRADEMARKS
- *
- * No right, title, or interest in or to any trademarks, service marks, or trade names of Jean-Marie Dautelle, Werner Keil or Jean-Marie Dautelle and Werner Keil's licensors is granted hereunder. Java and Java-related logos, marks and names are trademarks or registered trademarks of Sun Microsystems, Inc. in the U.S. and other countries.
- *
- *
- * DISCLAIMER OF WARRANTIES
- *
- * THE SPECIFICATION IS PROVIDED "AS IS" AND IS EXPERIMENTAL AND MAY CONTAIN DEFECTS OR DEFICIENCIES WHICH CANNOT OR WILL NOT BE CORRECTED BY JEAN-MARIE DAUTELLE, WERNER KEIL. JEAN-MARIE DAUTELLE AND WERNER KEIL MAKE NO REPRESENTATIONS OR WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT THAT THE CONTENTS OF THE SPECIFICATION ARE SUITABLE FOR ANY PURPOSE OR THAT ANY PRACTICE OR IMPLEMENTATION OF SUCH CONTENTS WILL NOT INFRINGE ANY THIRD PARTY PATENTS, COPYRIGHTS, TRADE SECRETS OR OTHER RIGHTS. This document does not represent any commitment to release or implement any portion of the Specification in any product.
- *
- * THE SPECIFICATION COULD INCLUDE TECHNICAL INACCURACIES OR TYPOGRAPHICAL ERRORS. CHANGES ARE PERIODICALLY ADDED TO THE INFORMATION THEREIN; THESE CHANGES WILL BE INCORPORATED INTO NEW VERSIONS OF THE SPECIFICATION, IF ANY. JEAN-MARIE DAUTELL AND WERNER KEIL MAY MAKE IMPROVEMENTS AND/OR CHANGES TO THE PRODUCT(S) AND/OR THE PROGRAM(S) DESCRIBED IN THE SPECIFICATION AT ANY TIME. Any use of such changes in the Specification will be governed by the then-current license for the applicable version of the Specification.
- *
- *
- * LIMITATION OF LIABILITY
- *
- * TO THE EXTENT NOT PROHIBITED BY LAW, IN NO EVENT WILL JEAN-MARIE DAUTELLE, WERNER KEIL OR THEIR LICENSORS BE LIABLE FOR ANY DAMAGES, INCLUDING WITHOUT LIMITATION, LOST REVENUE, PROFITS OR DATA, OR FOR SPECIAL, INDIRECT, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF OR RELATED TO ANY FURNISHING, PRACTICING, MODIFYING OR ANY USE OF THE SPECIFICATION, EVEN IF JEAN-MARIE DAUTELLE, WERNER KEIL AND/OR ITS LICENSORS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
- *
- * You will hold Jean-Marie Dautelle, Werner Keil (and its licensors) harmless from any claims based on your use of the Specification for any purposes other than the limited right of evaluation as described above, and from any claims that later versions or releases of any Specification furnished to you are incompatible with the Specification provided to you under this license.
- *
- *
- * RESTRICTED RIGHTS LEGEND
- *
- * If this Software is being acquired by or on behalf of the U.S. Government or by a U.S. Government prime contractor or subcontractor (at any tier), then the Government's rights in the Software and accompanying documentation shall be only as set forth in this license; this is in
- * accordance with 48 C.F.R. 227.7201 through 227.7202-4 (for Department of Defense (DoD) acquisitions) and with 48 C.F.R. 2.101 and 12.212 (for non-DoD acquisitions).
- *
- *
- * REPORT
- *
- * You may wish to report any ambiguities, inconsistencies or inaccuracies you may find in connection with your evaluation of the Specification ("Feedback"). To the extent that you provide Jean-Marie Dautelle, Werner Keil with any Feedback, you hereby: (i) agree that such Feedback is provided on a non-proprietary and non-confidential basis, and (ii) grant Jean-Marie Dautelle, Werner Keil a perpetual, non-exclusive, worldwide, fully paid-up, irrevocable license, with the right to sublicense through multiple levels of sublicensees, to incorporate, disclose, and use without limitation the Feedback for any purpose related to the Specification and future versions, implementations, and test suites thereof.
- *
- *
- * GENERAL TERMS
- *
- * Any action related to this Agreement will be governed by California law and controlling U.S. federal law. The U.N. Convention for the International Sale of Goods and the choice of law rules of any jurisdiction will not apply.
- *
- * The Specification is subject to U.S. export control laws and may be subject to export or import regulations in other countries. Licensee agrees to comply strictly with all such laws and regulations and acknowledges that it has the responsibility to obtain such licenses to export, re-export or import as may be required after delivery to Licensee.
- *
- * This Agreement is the parties' entire agreement relating to its subject matter. It supersedes all prior or contemporaneous oral or written communications, proposals, conditions, representations and warranties and prevails over any conflicting or additional terms of any quote, order, acknowledgment, or other communication between the parties relating to its subject matter during the term of this Agreement. No modification to this Agreement will be binding, unless in writing and signed by an authorized representative of each party.
- */
-package javax.measure.converter;
-
-import java.math.BigDecimal;
-import java.math.BigInteger;
-import java.math.MathContext;
-
-/**
- * BigInteger
numbers).divisor <= 0
- * @throws IllegalArgumentException if dividend == divisor
- */
- public RationalConverter(BigInteger dividend, BigInteger divisor) {
- if (divisor.compareTo(BigInteger.ZERO) <= 0)
- throw new IllegalArgumentException("Negative or zero divisor");
- if (dividend.equals(divisor))
- throw new IllegalArgumentException("Would result in identity converter");
- this.dividend = dividend; // Exact conversion.
- this.divisor = divisor; // Exact conversion.
- }
-
- /**
- * Returns the integer dividend for this rational converter.
- *
- * @return this converter dividend.
- */
- public BigInteger getDividend() {
- return dividend;
- }
-
- /**
- * Returns the integer (positive) divisor for this rational converter.
- *
- * @return this converter divisor.
- */
- public BigInteger getDivisor() {
- return divisor;
- }
-
- @Override
- public double convert(double value) {
- return value * toDouble(dividend) / toDouble(divisor);
- }
-
- // Optimization of BigInteger.doubleValue() (implementation too inneficient).
- private static double toDouble(BigInteger integer) {
- return (integer.bitLength() < 64) ? integer.longValue() : integer.doubleValue();
- }
-
- @Override
- public BigDecimal convert(BigDecimal value, MathContext ctx) throws ArithmeticException {
- return value.multiply(new BigDecimal(dividend, ctx), ctx).divide(new BigDecimal(divisor, ctx), ctx);
- }
-
- @Override
- public UnitConverter concatenate(UnitConverter converter) {
- if (converter instanceof RationalConverter) {
- RationalConverter that = (RationalConverter) converter;
- BigInteger dividend = this.getDividend().multiply(that.getDividend());
- BigInteger divisor = this.getDivisor().multiply(that.getDivisor());
- BigInteger gcd = dividend.gcd(divisor);
- dividend = dividend.divide(gcd);
- divisor = divisor.divide(gcd);
- return (dividend.equals(BigInteger.ONE) && divisor.equals(BigInteger.ONE))
- ? IDENTITY : new RationalConverter(dividend, divisor);
- } else
- return super.concatenate(converter);
- }
-
- @Override
- public RationalConverter inverse() {
- return dividend.signum() == -1 ? new RationalConverter(getDivisor().negate(), getDividend().negate())
- : new RationalConverter(getDivisor(), getDividend());
- }
-
- @Override
- public final String toString() {
- return "RationalConverter("+ dividend + "," + divisor + ")";
- }
-
- @Override
- public boolean equals(Object obj) {
- if (!(obj instanceof RationalConverter))
- return false;
- RationalConverter that = (RationalConverter) obj;
- return this.dividend.equals(that.dividend) &&
- this.divisor.equals(that.divisor);
- }
-
- @Override
- public int hashCode() {
- return dividend.hashCode() + divisor.hashCode();
- }
-}
diff --git a/src/main/java/javax/measure/converter/UnitConverter.java b/src/main/java/javax/measure/converter/UnitConverter.java
deleted file mode 100644
index 4d14766..0000000
--- a/src/main/java/javax/measure/converter/UnitConverter.java
+++ /dev/null
@@ -1,291 +0,0 @@
-/**
- * JEAN-MARIE DAUTELLE, WERNER KEIL ARE WILLING TO LICENSE THIS SPECIFICATION TO YOU ONLY UPON THE CONDITION THAT YOU ACCEPT ALL OF THE TERMS CONTAINED IN THIS LICENSE AGREEMENT ("AGREEMENT"). PLEASE READ THE TERMS AND CONDITIONS OF THIS AGREEMENT CAREFULLY. BY DOWNLOADING THIS SPECIFICATION, YOU ACCEPT THE TERMS AND CONDITIONS OF THIS AGREEMENT. IF YOU ARE NOT WILLING TO BE BOUND BY THEM, SELECT THE "DECLINE" BUTTON AT THE BOTTOM OF THIS PAGE AND THE DOWNLOADING PROCESS WILL NOT CONTINUE.
- *
- * Specification: JSR 275 - Units Specification ("Specification")
- *
- * Version: 0.9.4
- * Status: Pre-FCS Public Release
- * Release: December 4, 2009
- *
- * Copyright 2005-2009 Jean-Marie Dautelle, Werner Keil
- * All rights reserved.
- *
- *
- * NOTICE
- *
- * The Specification is protected by copyright and the information described therein may be protected by one or more U.S. patents, foreign patents, or pending applications. Except as provided under the following license, no part of the Specification may be reproduced in any form by any means without the prior written authorization of Jean-Marie Dautelle, Werner Keil and its
- * licensors, if any. Any use of the Specification and the information described therein will be governed by the terms and conditions of this Agreement.
- *
- *
- * Subject to the terms and conditions of this license, including your compliance with Paragraphs 1, 2 and 3 below, Jean-Marie Dautelle and Werner Keil hereby grant you a fully-paid, non-exclusive, non-transferable, limited license (without the right to sublicense) under Jean-Marie Dautelle and Werner Keil's intellectual property rights to:
- *
- * 1. Review the Specification for the purposes of evaluation. This includes: (i) developing implementations of the Specification for your internal, non-commercial use; (ii) discussing the Specification with any third party; and (iii) excerpting brief portions of the Specification in oral or written communications which discuss the Specification provided that such excerpts do not in the aggregate constitute a significant portion of the Specification.
- *
- * 2. Distribute implementations of the Specification to third parties for their testing and evaluation use, provided that any such implementation:
- *
- * (i) does not modify, subset, superset or otherwise extend the Licensor Name Space, or include any public or protected packages, classes, Java interfaces, fields or methods within the Licensor Name Space other than those required/authorized by the Specification or Specifications being implemented;
- *
- * (ii) is clearly and prominently marked with the word "UNTESTED" or "EARLY ACCESS" or "INCOMPATIBLE" or "UNSTABLE" or "BETA" in any list of available builds and in proximity to every link initiating its download, where the list or link is under Licensee's control; and
- *
- * (iii) includes the following notice:
- * "This is an implementation of an early-draft specification developed under the Java Community Process (JCP) and is made available for testing and evaluation purposes only. The code is not compatible with any specification of the JCP."
- *
- * 3. Distribute applications written to the Specification to third parties for their testing and evaluation use, provided that any such application includes the following notice:
- * "This is an application written to interoperate with an early-draft specification developed under the Java Community Process (JCP) and is made available for testing and evaluation purposes only. The code is not compatible with any specification of the JCP."
- *
- * The grant set forth above concerning your distribution of implementations of the Specification is contingent upon your agreement to terminate development and distribution of your implementation of early draft upon final completion of the Specification. If you fail to do so, the foregoing grant shall be considered null and void.
- *
- * Other than this limited license, you acquire no right, title or interest in or to the Specification or any other Jean-Marie Dautelle and Werner Keil intellectual property, and the Specification may only be used in accordance with the license terms set forth herein. This license will expire on the earlier of: (a) two (2) years from the date of Release listed above; (b) the date on which the final version of the Specification is publicly released; or (c) the date on which the Java Specification Request (JSR) to which the Specification corresponds is withdrawn. In addition, this license will terminate immediately without notice from Jean-Marie Dautelle, Werner Keil if you fail to comply with any provision of this license. Upon termination, you must cease use of or destroy the Specification.
- *
- * "Licensor Name Space" means the public class or interface declarations whose names begin with "java", "javax", "org.jscience" or their equivalents in any subsequent naming convention adopted through the Java Community Process, or any recognized successors or replacements thereof
- *
- *
- * TRADEMARKS
- *
- * No right, title, or interest in or to any trademarks, service marks, or trade names of Jean-Marie Dautelle, Werner Keil or Jean-Marie Dautelle and Werner Keil's licensors is granted hereunder. Java and Java-related logos, marks and names are trademarks or registered trademarks of Sun Microsystems, Inc. in the U.S. and other countries.
- *
- *
- * DISCLAIMER OF WARRANTIES
- *
- * THE SPECIFICATION IS PROVIDED "AS IS" AND IS EXPERIMENTAL AND MAY CONTAIN DEFECTS OR DEFICIENCIES WHICH CANNOT OR WILL NOT BE CORRECTED BY JEAN-MARIE DAUTELLE, WERNER KEIL. JEAN-MARIE DAUTELLE AND WERNER KEIL MAKE NO REPRESENTATIONS OR WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT THAT THE CONTENTS OF THE SPECIFICATION ARE SUITABLE FOR ANY PURPOSE OR THAT ANY PRACTICE OR IMPLEMENTATION OF SUCH CONTENTS WILL NOT INFRINGE ANY THIRD PARTY PATENTS, COPYRIGHTS, TRADE SECRETS OR OTHER RIGHTS. This document does not represent any commitment to release or implement any portion of the Specification in any product.
- *
- * THE SPECIFICATION COULD INCLUDE TECHNICAL INACCURACIES OR TYPOGRAPHICAL ERRORS. CHANGES ARE PERIODICALLY ADDED TO THE INFORMATION THEREIN; THESE CHANGES WILL BE INCORPORATED INTO NEW VERSIONS OF THE SPECIFICATION, IF ANY. JEAN-MARIE DAUTELL AND WERNER KEIL MAY MAKE IMPROVEMENTS AND/OR CHANGES TO THE PRODUCT(S) AND/OR THE PROGRAM(S) DESCRIBED IN THE SPECIFICATION AT ANY TIME. Any use of such changes in the Specification will be governed by the then-current license for the applicable version of the Specification.
- *
- *
- * LIMITATION OF LIABILITY
- *
- * TO THE EXTENT NOT PROHIBITED BY LAW, IN NO EVENT WILL JEAN-MARIE DAUTELLE, WERNER KEIL OR THEIR LICENSORS BE LIABLE FOR ANY DAMAGES, INCLUDING WITHOUT LIMITATION, LOST REVENUE, PROFITS OR DATA, OR FOR SPECIAL, INDIRECT, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF OR RELATED TO ANY FURNISHING, PRACTICING, MODIFYING OR ANY USE OF THE SPECIFICATION, EVEN IF JEAN-MARIE DAUTELLE, WERNER KEIL AND/OR ITS LICENSORS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
- *
- * You will hold Jean-Marie Dautelle, Werner Keil (and its licensors) harmless from any claims based on your use of the Specification for any purposes other than the limited right of evaluation as described above, and from any claims that later versions or releases of any Specification furnished to you are incompatible with the Specification provided to you under this license.
- *
- *
- * RESTRICTED RIGHTS LEGEND
- *
- * If this Software is being acquired by or on behalf of the U.S. Government or by a U.S. Government prime contractor or subcontractor (at any tier), then the Government's rights in the Software and accompanying documentation shall be only as set forth in this license; this is in
- * accordance with 48 C.F.R. 227.7201 through 227.7202-4 (for Department of Defense (DoD) acquisitions) and with 48 C.F.R. 2.101 and 12.212 (for non-DoD acquisitions).
- *
- *
- * REPORT
- *
- * You may wish to report any ambiguities, inconsistencies or inaccuracies you may find in connection with your evaluation of the Specification ("Feedback"). To the extent that you provide Jean-Marie Dautelle, Werner Keil with any Feedback, you hereby: (i) agree that such Feedback is provided on a non-proprietary and non-confidential basis, and (ii) grant Jean-Marie Dautelle, Werner Keil a perpetual, non-exclusive, worldwide, fully paid-up, irrevocable license, with the right to sublicense through multiple levels of sublicensees, to incorporate, disclose, and use without limitation the Feedback for any purpose related to the Specification and future versions, implementations, and test suites thereof.
- *
- *
- * GENERAL TERMS
- *
- * Any action related to this Agreement will be governed by California law and controlling U.S. federal law. The U.N. Convention for the International Sale of Goods and the choice of law rules of any jurisdiction will not apply.
- *
- * The Specification is subject to U.S. export control laws and may be subject to export or import regulations in other countries. Licensee agrees to comply strictly with all such laws and regulations and acknowledges that it has the responsibility to obtain such licenses to export, re-export or import as may be required after delivery to Licensee.
- *
- * This Agreement is the parties' entire agreement relating to its subject matter. It supersedes all prior or contemporaneous oral or written communications, proposals, conditions, representations and warranties and prevails over any conflicting or additional terms of any quote, order, acknowledgment, or other communication between the parties relating to its subject matter during the term of this Agreement. No modification to this Agreement will be binding, unless in writing and signed by an authorized representative of each party.
- */
-package javax.measure.converter;
-
-import java.io.Serializable;
-import java.math.BigDecimal;
-import java.math.MathContext;
-
-/**
- * ONE.convert(x) == x
). This instance is unique.
- * (
- */
- public static final UnitConverter IDENTITY = new Identity();
-
- /**
- * Default constructor.
- */
- protected UnitConverter() {
- }
-
- /**
- * Returns the inverse of this converter. If x
is a valid
- * value, then x == inverse().convert(convert(x))
to within
- * the accuracy of computer arithmetic.
- *
- * @return the inverse of this converter.
- */
- public abstract UnitConverter inverse();
-
- /**
- * Converts a double
value.
- *
- * @param value the numeric value to convert.
- * @return the double
value after conversion.
- */
- public abstract double convert(double value);
-
- /**
- * Converts a {@link BigDecimal} value.
- *
- * @param value the numeric value to convert.
- * @param ctx the math context being used for conversion.
- * @return the decimal value after conversion.
- * @throws ArithmeticException if the result is inexact but the
- * rounding mode is MathContext.UNNECESSARY
or
- * mathContext.precision == 0
and the quotient has a
- * non-terminating decimal expansion.
- */
- public abstract BigDecimal convert(BigDecimal value, MathContext ctx) throws ArithmeticException;
-
- /**
- * Indicates whether this converter is considered to be the the same as the
- * one specified.
- *
- * @param cvtr the converter with which to compare.
- * @return true
if the specified object is a converter
- * considered equals to this converter;false
otherwise.
- */
- @Override
- public abstract boolean equals(Object cvtr);
-
- /**
- * Returns a hash code value for this converter. Equals object have equal
- * hash codes.
- *
- * @return this converter hash code value.
- * @see #equals
- */
- @Override
- public abstract int hashCode();
-
- /**
- * Concatenates this converter with another converter. The resulting
- * converter is equivalent to first converting by the specified converter,
- * and then converting by this converter.
- *
- * UML Diagram
- *
- *
- * @author Jean-Marie Dautelle
- * @version 1.0, April 15, 2009
- */
-package javax.measure.converter;
diff --git a/src/main/java/javax/measure/quantity/Action.java b/src/main/java/javax/measure/quantity/Action.java
index 2e89191..a887534 100644
--- a/src/main/java/javax/measure/quantity/Action.java
+++ b/src/main/java/javax/measure/quantity/Action.java
@@ -98,6 +98,6 @@ public interface Action extends Quantity {
/**
* Holds the SI unit (Système International d'Unités) for this quantity.
*/
- public final static Unit
extends DerivedUnit{ @@ -182,5 +181,15 @@ public int hashCode() { return _symbol.hashCode(); } + @Override + public Dimension getDimension() { + return _parent.getDimension(); + } + + @Override + public UnitConverter getDimensionalTransform() { + return _parent.getDimensionalTransform(); + } + private static final long serialVersionUID = 1L; } \ No newline at end of file diff --git a/src/main/java/javax/measure/unit/AnnotatedUnit.java b/src/main/java/javax/measure/unit/AnnotatedUnit.java index aa2cc60..209f483 100644 --- a/src/main/java/javax/measure/unit/AnnotatedUnit.java +++ b/src/main/java/javax/measure/unit/AnnotatedUnit.java @@ -80,7 +80,6 @@ */ package javax.measure.unit; -import javax.measure.converter.UnitConverter; import javax.measure.quantity.Quantity; /** @@ -103,7 +102,7 @@ * respectively. * * @author Jean-Marie Dautelle - * @version 1.0.1 ($Revision: 76 $), $Date: 2009-12-03 23:53:52 +0100 (Do, 03 Dez 2009) $ + * @version 1.0.1 ($Revision: 89 $), $Date: 2010-01-31 23:15:22 +0100 (So, 31 Jän 2010) $ */ public class AnnotatedUnitextends DerivedUnit{ diff --git a/src/main/java/javax/measure/unit/BaseUnit.java b/src/main/java/javax/measure/unit/BaseUnit.java index 8e9b620..c040a42 100644 --- a/src/main/java/javax/measure/unit/BaseUnit.java +++ b/src/main/java/javax/measure/unit/BaseUnit.java @@ -80,7 +80,6 @@ */ package javax.measure.unit; -import javax.measure.converter.UnitConverter; import javax.measure.quantity.Quantity; /** @@ -96,7 +95,7 @@ * the base units of a specific {@link SystemOfUnits}. * * @author Jean-Marie Dautelle - * @version 1.0.1 ($Revision: 76 $), $Date: 2009-12-03 23:53:52 +0100 (Do, 03 Dez 2009) $ + * @version 1.0.1 ($Revision: 89 $), $Date: 2010-01-31 23:15:22 +0100 (So, 31 Jän 2010) $ * @see * Wikipedia: SI base unit */ @@ -105,7 +104,7 @@ public class BaseUnitextends Unit{ /** * Holds the symbol. */ - private final String _symbol; + private final String symbol; /** * Creates a base unit having the specified symbol. @@ -115,7 +114,7 @@ public class BaseUnitextends Unit{ * associated to a different unit. */ public BaseUnit(String symbol) { - _symbol = symbol; + this.symbol = symbol; // Checks if the symbol is associated to a different unit. synchronized (Unit.SYMBOL_TO_UNIT) { Unit> unit = Unit.SYMBOL_TO_UNIT.get(symbol); @@ -134,7 +133,7 @@ public BaseUnit(String symbol) { * @return this base unit symbol. */ public String getSymbol() { - return _symbol; + return symbol; } @Override @@ -144,12 +143,12 @@ public boolean equals(Object that) { if (!(that instanceof BaseUnit>)) return false; BaseUnit> thatUnit = (BaseUnit>) that; - return this._symbol.equals(thatUnit._symbol); + return this.symbol.equals(thatUnit.symbol); } @Override public int hashCode() { - return _symbol.hashCode(); + return symbol.hashCode(); } @Override @@ -162,5 +161,16 @@ public UnitConverter getConverterToSI() { return UnitConverter.IDENTITY; } + @Override + public Dimension getDimension() { + return Dimension.getModel().getDimension(this); + } + + @Override + public UnitConverter getDimensionalTransform() { + return Dimension.getModel().getTransform(this); + } + private static final long serialVersionUID = 1L; + } diff --git a/src/main/java/javax/measure/unit/CompoundUnit.java b/src/main/java/javax/measure/unit/CompoundUnit.java index 8fa913f..7aa0b9f 100644 --- a/src/main/java/javax/measure/unit/CompoundUnit.java +++ b/src/main/java/javax/measure/unit/CompoundUnit.java @@ -80,7 +80,6 @@ */ package javax.measure.unit; -import javax.measure.converter.UnitConverter; import javax.measure.quantity.Quantity; /** @@ -96,7 +95,7 @@ * [/code] * * @author Jean-Marie Dautelle - * @version 1.0.1 ($Revision: 76 $), $Date: 2009-12-03 23:53:52 +0100 (Do, 03 Dez 2009) $ + * @version 1.0.1 ($Revision: 89 $), $Date: 2010-01-31 23:15:22 +0100 (So, 31 Jän 2010) $ */ public final class CompoundUnitextends DerivedUnit{ diff --git a/src/main/java/javax/measure/unit/Dimension.java b/src/main/java/javax/measure/unit/Dimension.java index 874d02e..d4bf31f 100644 --- a/src/main/java/javax/measure/unit/Dimension.java +++ b/src/main/java/javax/measure/unit/Dimension.java @@ -82,7 +82,7 @@ import java.io.Serializable; -import javax.measure.converter.UnitConverter; +import javax.measure.unit.UnitConverter; import javax.measure.quantity.Dimensionless; /** @@ -96,9 +96,9 @@ * @author Jean-Marie Dautelle * @author Werner Keil * - * @version 1.0.3 ($Revision: 76 $), $Date: 2009-12-03 23:53:52 +0100 (Do, 03 Dez 2009) $ - * @see - * Wikipedia: Dimensional Analysis + * @version 1.0.3 ($Revision: 89 $), $Date: 2010-01-31 23:15:22 +0100 (So, 31 Jän 2010) $ + * @see + * BIPM: SI Brochure Chapter 1.3 */ public final class Dimension implements Serializable { @@ -138,9 +138,9 @@ public final class Dimension implements Serializable { public static final Dimension ELECTRIC_CURRENT = new Dimension('I'); /** - * Holds temperature dimension (Q). + * Holds temperature dimension (Θ). */ - public static final Dimension TEMPERATURE = new Dimension('Q'); + public static final Dimension TEMPERATURE = new Dimension('Θ'); /** * Holds amount of substance dimension (N). @@ -162,7 +162,7 @@ public final class Dimension implements Serializable { * * @param symbol the associated symbol. */ - public Dimension(char symbol) { + private Dimension(char symbol) { pseudoUnit = new BaseUnit("[" + symbol + "]"); } @@ -182,8 +182,8 @@ private Dimension(Unit> pseudoUnit) { * @param that the dimension multiplicand. * @return this * that
*/ - public final Dimension times(Dimension that) { - return new Dimension(this.pseudoUnit.times(that.pseudoUnit)); + public final Dimension multiply(Dimension that) { + return new Dimension(this.pseudoUnit.multiply(that.pseudoUnit)); } /** diff --git a/src/main/java/javax/measure/unit/NonSI.java b/src/main/java/javax/measure/unit/NonSI.java index fd7d1af..ed4d5e6 100644 --- a/src/main/java/javax/measure/unit/NonSI.java +++ b/src/main/java/javax/measure/unit/NonSI.java @@ -88,8 +88,6 @@ import java.util.HashSet; import java.util.Set; -import javax.measure.converter.LogConverter; -import javax.measure.converter.RationalConverter; import javax.measure.quantity.*; /** @@ -99,7 +97,7 @@ * * @author Jean-Marie Dautelle * @author Werner Keil - * @version 1.8 ($Revision: 76 $), $Date: 2009-12-03 23:53:52 +0100 (Do, 03 Dez 2009) $ + * @version 1.8 ($Revision: 89 $), $Date: 2010-01-31 23:15:22 +0100 (So, 31 Jän 2010) $ */ public final class NonSI extends SystemOfUnits { @@ -162,7 +160,7 @@ public static NonSI getInstance() { * A dimensionless unit equals topi
(standard name *Ï€
). */ - public static final UnitPI = nonSI(Unit.ONE.times(StrictMath.PI)); + public static final Unit PI = nonSI(Unit.ONE.multiply(StrictMath.PI)); /** * A dimensionless unit equals to 0.01
(standard name @@ -193,7 +191,7 @@ public static NonSI getInstance() { * A unit of length equal to0.3048 m
(standard name *ft
). */ - public static final UnitFOOT = nonSI(METRE.times( + public static final Unit FOOT = nonSI(METRE.multiply( INTERNATIONAL_FOOT_DIVIDEND).divide(INTERNATIONAL_FOOT_DIViSOR)); /** @@ -201,13 +199,13 @@ public static NonSI getInstance() { * foot_survey_us
). See also: foot */ - public static final UnitFOOT_SURVEY_US = nonSI(METRE.times(1200).divide(3937)); + public static final Unit FOOT_SURVEY_US = nonSI(METRE.multiply(1200).divide(3937)); /** * A unit of length equal to 0.9144 m
(standard name *yd
). */ - public static final UnitYARD = nonSI(FOOT.times(3)); + public static final Unit YARD = nonSI(FOOT.multiply(3)); /** * A unit of length equal to 0.0254 m
(standard name @@ -219,14 +217,14 @@ public static NonSI getInstance() { * A unit of length equal to1609.344 m
(standard name *mi
). */ - public static final UnitMILE = nonSI(METRE.times(1609344).divide( + public static final Unit MILE = nonSI(METRE.multiply(1609344).divide( 1000)); /** * A unit of length equal to 1852.0 m
(standard name *nmi
). */ - public static final UnitNAUTICAL_MILE = nonSI(METRE.times(1852)); + public static final Unit NAUTICAL_MILE = nonSI(METRE.multiply(1852)); /** * A unit of length equal to 1E-10 m
(standard name @@ -238,13 +236,13 @@ public static NonSI getInstance() { * A unit of length equal to the average distance from the center of the * Earth to the center of the Sun (standard nameua
). */ - public static final UnitASTRONOMICAL_UNIT = nonSI(METRE.times(149597870691.0)); + public static final Unit ASTRONOMICAL_UNIT = nonSI(METRE.multiply(149597870691.0)); /** * A unit of length equal to the distance that light travels in one year * through a vacuum (standard name ly
). */ - public static final UnitLIGHT_YEAR = nonSI(METRE.times(9.460528405e15)); + public static final Unit LIGHT_YEAR = nonSI(METRE.multiply(9.460528405e15)); /** * A unit of length equal to the distance at which a star would appear to @@ -253,7 +251,7 @@ public static NonSI getInstance() { * in the direction perpendicular to the direction to the star (standard * name pc
). */ - public static final UnitPARSEC = nonSI(METRE.times(30856770e9)); + public static final Unit PARSEC = nonSI(METRE.multiply(30856770e9)); /** * A unit of length equal to 0.013837 {@link #INCH}
exactly (standard name @@ -261,7 +259,7 @@ public static NonSI getInstance() { * * @see #PIXEL */ - public static final UnitPOINT = nonSI(INCH.times(13837).divide( + public static final Unit POINT = nonSI(INCH.multiply(13837).divide( 1000000)); /** @@ -284,17 +282,17 @@ public static NonSI getInstance() { * A unit of duration equal to 60 s
(standard name *min
). */ - public static final UnitMINUTE = nonSI(SI.SECOND.times(60)); + public static final Unit MINUTE = nonSI(SI.SECOND.multiply(60)); /** * A unit of duration equal to 60 {@link #MINUTE}
(standard nameh
). */ - public static final UnitHOUR = nonSI(MINUTE.times(60)); + public static final Unit HOUR = nonSI(MINUTE.multiply(60)); /** * A unit of duration equal to 24 {@link #HOUR}
(standard named
). */ - public static final UnitDAY = nonSI(HOUR.times(24)); + public static final Unit DAY = nonSI(HOUR.multiply(24)); /** * A unit of duration equal to the time required for a complete rotation of @@ -302,26 +300,26 @@ public static NonSI getInstance() { * meridian, equal to 23 hours, 56 minutes, 4.09 seconds (standard name * day_sidereal
). */ - public static final UnitDAY_SIDEREAL = nonSI(SECOND.times(86164.09)); + public static final Unit DAY_SIDEREAL = nonSI(SECOND.multiply(86164.09)); /** * A unit of duration equal to 7 {@link #DAY} (standard name * week
). */ - public static final UnitWEEK = nonSI(DAY.times(7)); + public static final Unit WEEK = nonSI(DAY.multiply(7)); /** * A unit of duration equal to 365 {@link #DAY} (standard name * year
). */ - public static final UnitYEAR_CALENDAR = nonSI(DAY.times(365)); + public static final Unit YEAR_CALENDAR = nonSI(DAY.multiply(365)); /** * A unit of duration equal to one complete revolution of the earth about * the sun, relative to the fixed stars, or 365 days, 6 hours, 9 minutes, * 9.54 seconds (standard name year_sidereal
). */ - public static final UnitYEAR_SIDEREAL = nonSI(SECOND.times(31558149.54)); + public static final Unit YEAR_SIDEREAL = nonSI(SECOND.multiply(31558149.54)); /** * The Julian year, as used in astronomy and other sciences, is a time unit @@ -329,7 +327,7 @@ public static NonSI getInstance() { * "year" (symbol "a" from the Latin annus, annata) used in various * scientific contexts. */ - public static final Unit YEAR_JULIEN = nonSI(SECOND.times(31557600)); + public static final Unit YEAR_JULIEN = nonSI(SECOND.multiply(31557600)); // //////// // Mass // @@ -338,19 +336,19 @@ public static NonSI getInstance() { * A unit of mass equal to 1/12 the mass of the carbon-12 atom (standard * name u
). */ - public static final UnitATOMIC_MASS = nonSI(KILOGRAM.times(1e-3 / AVOGADRO_CONSTANT)); + public static final Unit ATOMIC_MASS = nonSI(KILOGRAM.multiply(1e-3 / AVOGADRO_CONSTANT)); /** * A unit of mass equal to the mass of the electron (standard name * me
). */ - public static final UnitELECTRON_MASS = nonSI(KILOGRAM.times(9.10938188e-31)); + public static final Unit ELECTRON_MASS = nonSI(KILOGRAM.multiply(9.10938188e-31)); /** * A unit of mass equal to 453.59237 grams
(avoirdupois pound, * standard namelb
). */ - public static final UnitPOUND = nonSI(KILOGRAM.times( + public static final Unit POUND = nonSI(KILOGRAM.multiply( AVOIRDUPOIS_POUND_DIVIDEND).divide(AVOIRDUPOIS_POUND_DIVISOR)); /** @@ -362,19 +360,19 @@ public static NonSI getInstance() { * A unit of mass equal to 2000 {@link #POUND}
(short ton, standard name *ton_us
). */ - public static final UnitTON_US = nonSI(POUND.times(2000)); + public static final Unit TON_US = nonSI(POUND.multiply(2000)); /** * A unit of mass equal to 2240 {@link #POUND}
(long ton, standard name *ton_uk
). */ - public static final UnitTON_UK = nonSI(POUND.times(2240)); + public static final Unit TON_UK = nonSI(POUND.multiply(2240)); /** * A unit of mass equal to 1000 kg
(metric ton, standard name *t
). */ - public static final UnitMETRIC_TON = nonSI(KILOGRAM.times(1000)); + public static final Unit METRIC_TON = nonSI(KILOGRAM.multiply(1000)); // /////////////////// // Electric charge // @@ -383,20 +381,20 @@ public static NonSI getInstance() { * A unit of electric charge equal to the charge on one electron (standard * name e
). */ - public static final UnitE = nonSI(COULOMB.times(ELEMENTARY_CHARGE)); + public static final Unit E = nonSI(COULOMB.multiply(ELEMENTARY_CHARGE)); /** * A unit of electric charge equal to equal to the product of Avogadro's * number (see {@link SI#MOLE}) and the charge (1 e) on a single electron * (standard name Fd
). */ - public static final UnitFARADAY = nonSI(COULOMB.times(ELEMENTARY_CHARGE * AVOGADRO_CONSTANT)); // e/mol + public static final Unit FARADAY = nonSI(COULOMB.multiply(ELEMENTARY_CHARGE * AVOGADRO_CONSTANT)); // e/mol /** * A unit of electric charge which exerts a force of one dyne on an equal * charge at a distance of one centimeter (standard name Fr
). */ - public static final UnitFRANKLIN = nonSI(COULOMB.times(3.3356e-10)); + public static final Unit FRANKLIN = nonSI(COULOMB.multiply(3.3356e-10)); // /////////////// // Temperature // @@ -405,7 +403,7 @@ public static NonSI getInstance() { * A unit of temperature equal to 5/9 °K
(standard name *°R
). */ - public static final UnitRANKINE = nonSI(KELVIN.times(5).divide(9)); + public static final Unit RANKINE = nonSI(KELVIN.multiply(5).divide(9)); /** * A unit of temperature equal to degree Rankine minus @@ -413,7 +411,7 @@ public static NonSI getInstance() { * * @see #RANKINE */ - public static final Unit FAHRENHEIT = nonSI(RANKINE.plus(459.67)); + public static final Unit FAHRENHEIT = nonSI(RANKINE.add(459.67)); // ///////// // Angle // @@ -422,7 +420,7 @@ public static NonSI getInstance() { * A unit of angle equal to a full circle or 2π * {@link SI#RADIAN}
(standard namerev
). */ - public static final UnitREVOLUTION = nonSI(RADIAN.times(2).times(PI).asType(Angle.class)); + public static final Unit REVOLUTION = nonSI(RADIAN.multiply(2).multiply(PI).asType(Angle.class)); /** * A unit of angle equal to 1/360 {@link #REVOLUTION}
(standard namedeg
). @@ -486,7 +484,7 @@ public static NonSI getInstance() { * A unit of velocity relative to the speed of light (standard name *c
). */ - public static final UnitC = nonSI(METRES_PER_SECOND.times(299792458)); + public static final Unit C = nonSI(METRES_PER_SECOND.multiply(299792458)); // //////////////// // Acceleration // @@ -495,7 +493,7 @@ public static NonSI getInstance() { * A unit of acceleration equal to the gravity at the earth's surface * (standard name grav
). */ - public static final UnitG = nonSI(METRES_PER_SQUARE_SECOND.times(STANDARD_GRAVITY_DIVIDEND).divide(STANDARD_GRAVITY_DIVISOR)); + public static final Unit G = nonSI(METRES_PER_SQUARE_SECOND.multiply(STANDARD_GRAVITY_DIVIDEND).divide(STANDARD_GRAVITY_DIVISOR)); // //////// // Area // @@ -504,12 +502,12 @@ public static NonSI getInstance() { * A unit of area equal to 100 m²
(standard namea
* ). */ - public static final Unit ARE = nonSI(SQUARE_METRE.times(100)); + public static final Unit ARE = nonSI(SQUARE_METRE.multiply(100)); /** * A unit of area equal to100 {@link #ARE}
(standard nameha
). */ - public static final Unit HECTARE = nonSI(ARE.times(100)); // Exact. + public static final Unit HECTARE = nonSI(ARE.multiply(100)); // Exact. // /////////////// // Data Amount // @@ -518,7 +516,7 @@ public static NonSI getInstance() { * A unit of data amount equal to8 {@link SI#BIT}
(BinarY TErm, standard name *byte
). */ - public static final UnitBYTE = nonSI(BIT.times(8)); + public static final Unit BYTE = nonSI(BIT.multiply(8)); /** * Equivalent {@link #BYTE} @@ -533,8 +531,8 @@ public static NonSI getInstance() { * electromagnetic unit of magnetomotive force, equal to 10/4 * πampere-turn
(standard nameGi
). */ - public static final UnitGILBERT = nonSI(SI.AMPERE.times( - 10).divide(4).times(PI).asType(ElectricCurrent.class)); + public static final Unit GILBERT = nonSI(SI.AMPERE.multiply( + 10).divide(4).multiply(PI).asType(ElectricCurrent.class)); // ////////// // Energy // @@ -549,7 +547,7 @@ public static NonSI getInstance() { * A unit of energy equal to one electron-volt (standard name * eV
, also recognizedkeV, MeV, GeV
). */ - public static final UnitELECTRON_VOLT = nonSI(JOULE.times(ELEMENTARY_CHARGE)); + public static final Unit ELECTRON_VOLT = nonSI(JOULE.multiply(ELEMENTARY_CHARGE)); // /////////////// // Illuminance // @@ -558,7 +556,7 @@ public static NonSI getInstance() { * A unit of illuminance equal to 1E4 Lx
(standard name *La
). */ - public static final UnitLAMBERT = nonSI(LUX.times(10000)); + public static final Unit LAMBERT = nonSI(LUX.multiply(10000)); // ///////////////// // Magnetic Flux // @@ -591,13 +589,13 @@ public static NonSI getInstance() { * A unit of force equal to 9.80665 N
(standard name *kgf
). */ - public static final UnitKILOGRAM_FORCE = nonSI(NEWTON.times( + public static final Unit KILOGRAM_FORCE = nonSI(NEWTON.multiply( STANDARD_GRAVITY_DIVIDEND).divide(STANDARD_GRAVITY_DIVISOR)); /** * A unit of force equal to {@link #POUND}·{@link #G}
(standard namelbf
). */ - public static final UnitPOUND_FORCE = nonSI(NEWTON.times( + public static final Unit POUND_FORCE = nonSI(NEWTON.multiply( 1L * AVOIRDUPOIS_POUND_DIVIDEND * STANDARD_GRAVITY_DIVIDEND).divide(1L * AVOIRDUPOIS_POUND_DIVISOR * STANDARD_GRAVITY_DIVISOR)); // ///////// @@ -608,7 +606,7 @@ public static NonSI getInstance() { * kilograms at a velocity of 1 meter per second (metric, standard name * hp
). */ - public static final UnitHORSEPOWER = nonSI(WATT.times(735.499)); + public static final Unit HORSEPOWER = nonSI(WATT.multiply(735.499)); // //////////// // Pressure // @@ -617,26 +615,26 @@ public static NonSI getInstance() { * A unit of pressure equal to the average pressure of the Earth's * atmosphere at sea level (standard name atm
). */ - public static final UnitATMOSPHERE = nonSI(PASCAL.times(101325)); + public static final Unit ATMOSPHERE = nonSI(PASCAL.multiply(101325)); /** * A unit of pressure equal to 100 kPa
(standard name *bar
). */ - public static final UnitBAR = nonSI(PASCAL.times(100000)); + public static final Unit BAR = nonSI(PASCAL.multiply(100000)); /** * A unit of pressure equal to the pressure exerted at the Earth's surface * by a column of mercury 1 millimeter high (standard name mmHg
* ). */ - public static final UnitMILLIMETRE_OF_MERCURY = nonSI(PASCAL.times(133.322)); + public static final Unit MILLIMETRE_OF_MERCURY = nonSI(PASCAL.multiply(133.322)); /** * A unit of pressure equal to the pressure exerted at the Earth's surface * by a column of mercury 1 inch high (standard name inHg
). */ - public static final UnitINCH_OF_MERCURY = nonSI(PASCAL.times(3386.388)); + public static final Unit INCH_OF_MERCURY = nonSI(PASCAL.multiply(3386.388)); // /////////////////////////// // Radiation dose absorbed // @@ -660,13 +658,13 @@ public static NonSI getInstance() { * A unit of radioctive activity equal to the activity of a gram of radium * (standard name Ci
). */ - public static final UnitCURIE = nonSI(BECQUEREL.times(37000000000L)); + public static final Unit CURIE = nonSI(BECQUEREL.multiply(37000000000L)); /** * A unit of radioctive activity equal to 1 million radioactive * disintegrations per second (standard name Rd
). */ - public static final UnitRUTHERFORD = nonSI(SI.BECQUEREL.times(1000000)); + public static final Unit RUTHERFORD = nonSI(SI.BECQUEREL.multiply(1000000)); // /////////////// // Solid angle // @@ -675,7 +673,7 @@ public static NonSI getInstance() { * A unit of solid angle equal to 4 π steradians
* (standard namesphere
). */ - public static final UnitSPHERE = nonSI(STERADIAN.times(4).times(PI).asType(SolidAngle.class)); + public static final Unit SPHERE = nonSI(STERADIAN.multiply(4).multiply(PI).asType(SolidAngle.class)); // ////////// // Volume // @@ -697,7 +695,7 @@ public static NonSI getInstance() { * gallon is based on the Queen Anne or Wine gallon occupying 231 cubic * inches (standard name gal
). */ - public static final UnitGALLON_LIQUID_US = nonSI(CUBIC_INCH.times(231)); + public static final Unit GALLON_LIQUID_US = nonSI(CUBIC_INCH.multiply(231)); /** * A unit of volume equal to 1 / 128 {@link #GALLON_LIQUID_US}
(standard name @@ -709,13 +707,13 @@ public static NonSI getInstance() { * A unit of volume equal to one US dry gallon. (standard name *gallon_dry_us
). */ - public static final UnitGALLON_DRY_US = nonSI(CUBIC_INCH.times( + public static final Unit GALLON_DRY_US = nonSI(CUBIC_INCH.multiply( 2688025).divide(10000)); /** * A unit of volume equal to 4.546 09 {@link #LITRE}
(standard namegal_uk
). */ - public static final UnitGALLON_UK = nonSI(LITRE.times(454609).divide(100000)); + public static final Unit GALLON_UK = nonSI(LITRE.multiply(454609).divide(100000)); /** * A unit of volume equal to 1 / 160 {@link #GALLON_UK}
(standard name @@ -729,7 +727,7 @@ public static NonSI getInstance() { /** * A unit of dynamic viscosity equal to1 g/(cm·s)
(cgs unit). */ - public static final UnitPOISE = nonSI(GRAM.divide(CENTI(METRE).times(SECOND))).asType(DynamicViscosity.class); + public static final Unit POISE = nonSI(GRAM.divide(CENTI(METRE).multiply(SECOND))).asType(DynamicViscosity.class); /** * A unit of kinematic viscosity equal to 1 cm²/s
(cgs unit). @@ -752,7 +750,7 @@ public static NonSI getInstance() { * A unit used to measure the ionizing ability of radiation (standard name *Roentgen
). */ - public static final Unit> ROENTGEN = nonSI(COULOMB.divide(KILOGRAM).times(2.58e-4)); + public static final Unit> ROENTGEN = nonSI(COULOMB.divide(KILOGRAM).multiply(2.58e-4)); // /////////////////// // Collection View // @@ -797,7 +795,7 @@ private BinaryPrefix() { * @returnunit.times(1024)
. */ public staticUnitKIBI(Unitunit) { - return unit.times(1024); + return unit.multiply(1024); } /** @@ -808,7 +806,7 @@ public staticUnitKIBI(Unitunit) { * @returnunit.times(1048576)
. */ public staticUnitMEBI(Unitunit) { - return unit.times(1048576); + return unit.multiply(1048576); } /** @@ -819,7 +817,7 @@ public staticUnitMEBI(Unitunit) { * @returnunit.times(1073741824)
. */ public static finalUnitGIBI(Unitunit) { - return unit.times(1073741824); + return unit.multiply(1073741824); } /** @@ -830,7 +828,7 @@ public static finalUnitGIBI(Unitunit) { * @returnunit.times(1099511627776L)
. */ public staticUnitTEBI(Unitunit) { - return unit.times(1099511627776L); + return unit.multiply(1099511627776L); } /** @@ -841,7 +839,7 @@ public staticUnitTEBI(Unitunit) { * @returnunit.times(1125899906842624L)
. */ public staticUnitPEBI(Unitunit) { - return unit.times(1125899906842624L); + return unit.multiply(1125899906842624L); } /** @@ -852,7 +850,7 @@ public staticUnitPEBI(Unitunit) { * @returnunit.times(1152921504606846976L)
. */ public staticUnitEXBI(Unitunit) { - return unit.times(1152921504606846976L); + return unit.multiply(1152921504606846976L); } } diff --git a/src/main/java/javax/measure/unit/ProductUnit.java b/src/main/java/javax/measure/unit/ProductUnit.java index f7e6dc8..d919a73 100644 --- a/src/main/java/javax/measure/unit/ProductUnit.java +++ b/src/main/java/javax/measure/unit/ProductUnit.java @@ -82,8 +82,6 @@ import java.io.Serializable; -import javax.measure.converter.LinearConverter; -import javax.measure.converter.UnitConverter; import javax.measure.quantity.Quantity; /** @@ -96,7 +94,7 @@ * * @author Jean-Marie Dautelle * @version 1.0, April 15, 2009 - * @see Unit#times(Unit) + * @see Unit#multiply(Unit) * @see Unit#divide(Unit) * @see Unit#pow(int) * @see Unit#root(int) @@ -398,7 +396,7 @@ public UnittoSI() { Unit> unit = _elements[i]._unit.toSI(); unit = unit.pow(_elements[i]._pow); unit = unit.root(_elements[i]._root); - systemUnit = systemUnit.times(unit); + systemUnit = systemUnit.multiply(unit); } return (Unit) systemUnit; } @@ -411,7 +409,7 @@ public final UnitConverter getConverterToSI() { for (int i = 0; i < _elements.length; i++) { Element e = _elements[i]; UnitConverter cvtr = e._unit.getConverterToSI(); - if (!(cvtr instanceof LinearConverter)) + if (!(cvtr.isLinear())) throw new UnsupportedOperationException(e._unit + " is non-linear, cannot convert"); if (e._root != 1) throw new UnsupportedOperationException(e._unit + " holds a base unit with fractional exponent"); @@ -442,7 +440,40 @@ private boolean hasOnlyStandardUnit() { return true; } - /** + @Override + public Dimension getDimension() { + Dimension dimension = Dimension.NONE; + for (int i = 0; i < this.getUnitCount(); i++) { + Unit> unit = this.getUnit(i); + Dimension d = unit.getDimension().pow(this.getUnitPow(i)).root(this.getUnitRoot(i)); + dimension = dimension.multiply(d); + } + return dimension; + } + + @Override + public UnitConverter getDimensionalTransform() { + UnitConverter converter = UnitConverter.IDENTITY; + for (int i = 0; i < this.getUnitCount(); i++) { + Unit> unit = this.getUnit(i); + UnitConverter cvtr = unit.getDimensionalTransform(); + if (!(cvtr.isLinear())) + throw new UnsupportedOperationException(cvtr.getClass() + " is non-linear, cannot convert product unit"); + if (this.getUnitRoot(i) != 1) + throw new UnsupportedOperationException(this + " holds a unit with fractional exponent"); + int pow = this.getUnitPow(i); + if (pow < 0) { // Negative power. + pow = -pow; + cvtr = cvtr.inverse(); + } + for (int j = 0; j < pow; j++) { + converter = converter.concatenate(cvtr); + } + } + return converter; + } + + /** * Returns the greatest common divisor (Euclid's algorithm). * * @param m the first number. @@ -517,7 +548,6 @@ public int getPow() { public int getRoot() { return _root; } - private static final long serialVersionUID = 1L; } diff --git a/src/main/java/javax/measure/unit/SI.java b/src/main/java/javax/measure/unit/SI.java index 75db9ae..889d867 100644 --- a/src/main/java/javax/measure/unit/SI.java +++ b/src/main/java/javax/measure/unit/SI.java @@ -85,7 +85,6 @@ import java.util.HashSet; import java.util.Set; -import javax.measure.converter.RationalConverter; import javax.measure.quantity.*; /** @@ -103,7 +102,7 @@ * * @author Jean-Marie Dautelle * @author Werner Keil - * @version 1.8 ($Revision: 76 $), $Date: 2009-12-03 23:53:52 +0100 (Do, 03 Dez 2009) $ + * @version 1.8 ($Revision: 89 $), $Date: 2010-01-31 23:15:22 +0100 (So, 31 Jän 2010) $ * @see Wikipedia: International System of Units */ public final class SI extends SystemOfUnits { @@ -250,7 +249,7 @@ public static final SI getInstance() { * mathematician and physicist Sir Isaac Newton (1642-1727). */ public static final AlternateUnitNEWTON = si(new AlternateUnit ( - "N", METRE.times(KILOGRAM).divide(SECOND.pow(2)))); + "N", METRE.multiply(KILOGRAM).divide(SECOND.pow(2)))); /** * The derived unit for pressure, stress ( Pa
). @@ -267,7 +266,7 @@ public static final SI getInstance() { * It is named after the English physicist James Prescott Joule (1818-1889). */ public static final AlternateUnitJOULE = si(new AlternateUnit ( - "J", NEWTON.times(METRE))); + "J", NEWTON.multiply(METRE))); /** * The derived unit for power, radiant, flux ( W
). @@ -285,7 +284,7 @@ public static final SI getInstance() { * Charles Augustin de Coulomb (1736-1806). */ public static final AlternateUnitCOULOMB = si(new AlternateUnit ( - "C", SECOND.times(AMPERE))); + "C", SECOND.multiply(AMPERE))); /** * The derived unit for electric potential difference, electromotive force @@ -333,7 +332,7 @@ public static final SI getInstance() { * Wilhelm Eduard Weber (1804-1891). */ public static final AlternateUnit WEBER = si(new AlternateUnit ( - "Wb", VOLT.times(SECOND))); + "Wb", VOLT.multiply(SECOND))); /** * The derived unit for magnetic flux density ( T
). @@ -360,7 +359,7 @@ public static final SI getInstance() { * (at one atmosphere of pressure) is 0 Cel, while the boiling point is * 100 Cel. */ - public static final UnitCELSIUS = si(KELVIN.plus(273.15)); + public static final Unit CELSIUS = si(KELVIN.add(273.15)); /** * The derived unit for luminous flux ( lm
). @@ -368,7 +367,7 @@ public static final SI getInstance() { * by a source of one candela intensity radiating equally in all directions. */ public static final AlternateUnitLUMEN = si(new AlternateUnit ( - "lm", CANDELA.times(STERADIAN))); + "lm", CANDELA.multiply(STERADIAN))); /** * The derived unit for illuminance ( lx
). @@ -432,18 +431,18 @@ public static final SI getInstance() { * The metric unit for area quantities (m2
). */ public static final Unit SQUARE_METRE = si(new ProductUnit( - METRE.times(METRE))); + METRE.multiply(METRE))); /** * The metric unit for volume quantities (m3
). */ public static final UnitCUBIC_METRE = si(new ProductUnit ( - SQUARE_METRE.times(METRE))); + SQUARE_METRE.multiply(METRE))); /** * Equivalent to KILO(METRE)
. */ - public static final UnitKILOMETRE = METRE.times(1000); + public static final Unit KILOMETRE = METRE.multiply(1000); /** * Equivalent to CENTI(METRE)
. diff --git a/src/main/java/javax/measure/unit/SystemOfUnits.java b/src/main/java/javax/measure/unit/SystemOfUnits.java index f2d861d..737586a 100644 --- a/src/main/java/javax/measure/unit/SystemOfUnits.java +++ b/src/main/java/javax/measure/unit/SystemOfUnits.java @@ -80,7 +80,9 @@ */ package javax.measure.unit; +import java.util.HashSet; import java.util.Set; +import javax.measure.quantity.Quantity; /** *This class represents a system of units, it groups units together @@ -90,7 +92,8 @@ * held by {@link NonSI}).
* * @author Jean-Marie Dautelle - * @version 1.0, April 15, 2009 + * @author Werner Keil + * @version 1.0.1, $Date: 2010-01-31 23:15:22 +0100 (So, 31 Jän 2010) $ */ public abstract class SystemOfUnits { @@ -100,4 +103,55 @@ public abstract class SystemOfUnits { * @return the collection of units. */ public abstract Set> getUnits(); -} + + /** + * Returns the the units defined in this system of specified type + * (convenience method). This method returns all the units in this + * system of units having the same standard unit as the one defined + * by the specified quantity class. This method is more selective than + * the {@link #getUnits(javax.measure.unit.Dimension)} since units may + * have the same dimension and still be used to measure quantities + * of different kinds. + * + * @param type the type of the units to be returned. + * @return the collection of units of specified type. + */ + @SuppressWarnings("unchecked") + public Set> getUnits(Class type) { + Set> units = new HashSet(); + Unit standardUnit = null; + try { + standardUnit = (Unit) type.getField("UNIT").get(null); + } catch (Exception e) { + throw new UnsupportedOperationException( + "The quantity class " + type + " does not have a public static field UNIT holding the SI unit " + " for the quantity."); + } + for (Unit> unit : getUnits()) { + if (unit.toSI().equals(standardUnit)) { + units.add((Unit)unit); + } + } + return units; + } + + /** + * Returns the units defined in this system having the specified + * dimension (convenience method). This method returns all the units + * in this system of units having the specified dimension. + * This method is less selective than {@link #getUnits(java.lang.Class)} + * since units may have the same dimension and still be used to measure + * quantities of different kinds. + * + * @param dimension the dimension of the units to be returned. + * @return the collection of units of specified dimension. + */ + public Set> getUnits(Dimension dimension) { + Set > units = new HashSet >(); + for (Unit> unit : getUnits()) { + if (unit.getDimension().equals(dimension)) { + units.add(unit); + } + } + return units; + } +} \ No newline at end of file diff --git a/src/main/java/javax/measure/unit/TransformedUnit.java b/src/main/java/javax/measure/unit/TransformedUnit.java index 94ab454..26eb312 100644 --- a/src/main/java/javax/measure/unit/TransformedUnit.java +++ b/src/main/java/javax/measure/unit/TransformedUnit.java @@ -80,7 +80,6 @@ */ package javax.measure.unit; -import javax.measure.converter.UnitConverter; import javax.measure.quantity.Quantity; /** @@ -94,13 +93,13 @@ * [/code] * * Transformed units have no label. But like any other units, - * they may have labels attached to them (see {@link javax.measure.unit.format.SymbolMap + * they may have labels attached to them (see {@link javax.measure.unit.SymbolMap * SymbolMap}
* *Instances of this class are created through the {@link Unit#transform} method.
* * @author Jean-Marie Dautelle - * @version 1.0.1 ($Revision: 76 $), $Date: 2009-12-03 23:53:52 +0100 (Do, 03 Dez 2009) $ + * @version 1.0.1 ($Revision: 89 $), $Date: 2010-01-31 23:15:22 +0100 (So, 31 Jän 2010) $ */ public final class TransformedUnitextends DerivedUnit{ diff --git a/src/main/java/javax/measure/unit/UCUM.java b/src/main/java/javax/measure/unit/UCUM.java deleted file mode 100644 index e3d653a..0000000 --- a/src/main/java/javax/measure/unit/UCUM.java +++ /dev/null @@ -1,689 +0,0 @@ -/** - * JEAN-MARIE DAUTELLE, WERNER KEIL ARE WILLING TO LICENSE THIS SPECIFICATION TO YOU ONLY UPON THE CONDITION THAT YOU ACCEPT ALL OF THE TERMS CONTAINED IN THIS LICENSE AGREEMENT ("AGREEMENT"). PLEASE READ THE TERMS AND CONDITIONS OF THIS AGREEMENT CAREFULLY. BY DOWNLOADING THIS SPECIFICATION, YOU ACCEPT THE TERMS AND CONDITIONS OF THIS AGREEMENT. IF YOU ARE NOT WILLING TO BE BOUND BY THEM, SELECT THE "DECLINE" BUTTON AT THE BOTTOM OF THIS PAGE AND THE DOWNLOADING PROCESS WILL NOT CONTINUE. - * - * Specification: JSR 275 - Units Specification ("Specification") - * - * Version: 0.9.4 - * Status: Pre-FCS Public Release - * Release: December 4, 2009 - * - * Copyright 2005-2009 Jean-Marie Dautelle, Werner Keil - * All rights reserved. - * - * - * NOTICE - * - * The Specification is protected by copyright and the information described therein may be protected by one or more U.S. patents, foreign patents, or pending applications. Except as provided under the following license, no part of the Specification may be reproduced in any form by any means without the prior written authorization of Jean-Marie Dautelle, Werner Keil and its - * licensors, if any. Any use of the Specification and the information described therein will be governed by the terms and conditions of this Agreement. - * - * - * Subject to the terms and conditions of this license, including your compliance with Paragraphs 1, 2 and 3 below, Jean-Marie Dautelle and Werner Keil hereby grant you a fully-paid, non-exclusive, non-transferable, limited license (without the right to sublicense) under Jean-Marie Dautelle and Werner Keil's intellectual property rights to: - * - * 1. Review the Specification for the purposes of evaluation. This includes: (i) developing implementations of the Specification for your internal, non-commercial use; (ii) discussing the Specification with any third party; and (iii) excerpting brief portions of the Specification in oral or written communications which discuss the Specification provided that such excerpts do not in the aggregate constitute a significant portion of the Specification. - * - * 2. Distribute implementations of the Specification to third parties for their testing and evaluation use, provided that any such implementation: - * - * (i) does not modify, subset, superset or otherwise extend the Licensor Name Space, or include any public or protected packages, classes, Java interfaces, fields or methods within the Licensor Name Space other than those required/authorized by the Specification or Specifications being implemented; - * - * (ii) is clearly and prominently marked with the word "UNTESTED" or "EARLY ACCESS" or "INCOMPATIBLE" or "UNSTABLE" or "BETA" in any list of available builds and in proximity to every link initiating its download, where the list or link is under Licensee's control; and - * - * (iii) includes the following notice: - * "This is an implementation of an early-draft specification developed under the Java Community Process (JCP) and is made available for testing and evaluation purposes only. The code is not compatible with any specification of the JCP." - * - * 3. Distribute applications written to the Specification to third parties for their testing and evaluation use, provided that any such application includes the following notice: - * "This is an application written to interoperate with an early-draft specification developed under the Java Community Process (JCP) and is made available for testing and evaluation purposes only. The code is not compatible with any specification of the JCP." - * - * The grant set forth above concerning your distribution of implementations of the Specification is contingent upon your agreement to terminate development and distribution of your implementation of early draft upon final completion of the Specification. If you fail to do so, the foregoing grant shall be considered null and void. - * - * Other than this limited license, you acquire no right, title or interest in or to the Specification or any other Jean-Marie Dautelle and Werner Keil intellectual property, and the Specification may only be used in accordance with the license terms set forth herein. This license will expire on the earlier of: (a) two (2) years from the date of Release listed above; (b) the date on which the final version of the Specification is publicly released; or (c) the date on which the Java Specification Request (JSR) to which the Specification corresponds is withdrawn. In addition, this license will terminate immediately without notice from Jean-Marie Dautelle, Werner Keil if you fail to comply with any provision of this license. Upon termination, you must cease use of or destroy the Specification. - * - * "Licensor Name Space" means the public class or interface declarations whose names begin with "java", "javax", "org.jscience" or their equivalents in any subsequent naming convention adopted through the Java Community Process, or any recognized successors or replacements thereof - * - * - * TRADEMARKS - * - * No right, title, or interest in or to any trademarks, service marks, or trade names of Jean-Marie Dautelle, Werner Keil or Jean-Marie Dautelle and Werner Keil's licensors is granted hereunder. Java and Java-related logos, marks and names are trademarks or registered trademarks of Sun Microsystems, Inc. in the U.S. and other countries. - * - * - * DISCLAIMER OF WARRANTIES - * - * THE SPECIFICATION IS PROVIDED "AS IS" AND IS EXPERIMENTAL AND MAY CONTAIN DEFECTS OR DEFICIENCIES WHICH CANNOT OR WILL NOT BE CORRECTED BY JEAN-MARIE DAUTELLE, WERNER KEIL. JEAN-MARIE DAUTELLE AND WERNER KEIL MAKE NO REPRESENTATIONS OR WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT THAT THE CONTENTS OF THE SPECIFICATION ARE SUITABLE FOR ANY PURPOSE OR THAT ANY PRACTICE OR IMPLEMENTATION OF SUCH CONTENTS WILL NOT INFRINGE ANY THIRD PARTY PATENTS, COPYRIGHTS, TRADE SECRETS OR OTHER RIGHTS. This document does not represent any commitment to release or implement any portion of the Specification in any product. - * - * THE SPECIFICATION COULD INCLUDE TECHNICAL INACCURACIES OR TYPOGRAPHICAL ERRORS. CHANGES ARE PERIODICALLY ADDED TO THE INFORMATION THEREIN; THESE CHANGES WILL BE INCORPORATED INTO NEW VERSIONS OF THE SPECIFICATION, IF ANY. JEAN-MARIE DAUTELL AND WERNER KEIL MAY MAKE IMPROVEMENTS AND/OR CHANGES TO THE PRODUCT(S) AND/OR THE PROGRAM(S) DESCRIBED IN THE SPECIFICATION AT ANY TIME. Any use of such changes in the Specification will be governed by the then-current license for the applicable version of the Specification. - * - * - * LIMITATION OF LIABILITY - * - * TO THE EXTENT NOT PROHIBITED BY LAW, IN NO EVENT WILL JEAN-MARIE DAUTELLE, WERNER KEIL OR THEIR LICENSORS BE LIABLE FOR ANY DAMAGES, INCLUDING WITHOUT LIMITATION, LOST REVENUE, PROFITS OR DATA, OR FOR SPECIAL, INDIRECT, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF OR RELATED TO ANY FURNISHING, PRACTICING, MODIFYING OR ANY USE OF THE SPECIFICATION, EVEN IF JEAN-MARIE DAUTELLE, WERNER KEIL AND/OR ITS LICENSORS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - * - * You will hold Jean-Marie Dautelle, Werner Keil (and its licensors) harmless from any claims based on your use of the Specification for any purposes other than the limited right of evaluation as described above, and from any claims that later versions or releases of any Specification furnished to you are incompatible with the Specification provided to you under this license. - * - * - * RESTRICTED RIGHTS LEGEND - * - * If this Software is being acquired by or on behalf of the U.S. Government or by a U.S. Government prime contractor or subcontractor (at any tier), then the Government's rights in the Software and accompanying documentation shall be only as set forth in this license; this is in - * accordance with 48 C.F.R. 227.7201 through 227.7202-4 (for Department of Defense (DoD) acquisitions) and with 48 C.F.R. 2.101 and 12.212 (for non-DoD acquisitions). - * - * - * REPORT - * - * You may wish to report any ambiguities, inconsistencies or inaccuracies you may find in connection with your evaluation of the Specification ("Feedback"). To the extent that you provide Jean-Marie Dautelle, Werner Keil with any Feedback, you hereby: (i) agree that such Feedback is provided on a non-proprietary and non-confidential basis, and (ii) grant Jean-Marie Dautelle, Werner Keil a perpetual, non-exclusive, worldwide, fully paid-up, irrevocable license, with the right to sublicense through multiple levels of sublicensees, to incorporate, disclose, and use without limitation the Feedback for any purpose related to the Specification and future versions, implementations, and test suites thereof. - * - * - * GENERAL TERMS - * - * Any action related to this Agreement will be governed by California law and controlling U.S. federal law. The U.N. Convention for the International Sale of Goods and the choice of law rules of any jurisdiction will not apply. - * - * The Specification is subject to U.S. export control laws and may be subject to export or import regulations in other countries. Licensee agrees to comply strictly with all such laws and regulations and acknowledges that it has the responsibility to obtain such licenses to export, re-export or import as may be required after delivery to Licensee. - * - * This Agreement is the parties' entire agreement relating to its subject matter. It supersedes all prior or contemporaneous oral or written communications, proposals, conditions, representations and warranties and prevails over any conflicting or additional terms of any quote, order, acknowledgment, or other communication between the parties relating to its subject matter during the term of this Agreement. No modification to this Agreement will be binding, unless in writing and signed by an authorized representative of each party. - */ -package javax.measure.unit; - -import static javax.measure.unit.SI.MetricPrefix.*; - -import java.util.Collections; -import java.util.HashSet; -import java.util.Set; -import javax.measure.quantity.*; - -/** - *This class contains the units ({@link SI} and {@link NonSI}) as defined - * in the - * Uniform Code for Units of Measure.
- * - *Compatibility with existing {@link javax.measure.unit.SI SI}/ - * {@link javax.measure.unit.NonSI NonSI} units has been given - * priority over strict adherence to the standard. We have attempted to note - * every place where the definitions in this class deviate from the - * UCUM standard, but such notes are likely to be incomplete.
- * - * @author Eric Russell - * @author Werner Keil - * @version 1.4.2, ($Revision: 76 $) $Date: 2009-12-03 23:53:52 +0100 (Do, 03 Dez 2009) $ - * @see UCUM - */ -public final class UCUM extends SystemOfUnits { - - /** Holds collection of all UCUM units. */ - private static HashSet> UNITS = new HashSet >(); - - /** - * Returns the unique instance of this class. - * - * @return the UCUM instance. - */ - public static UCUM getInstance() { - return INSTANCE; - } - private static final UCUM INSTANCE = new UCUM(); - - /** - * Adds a new unit to the collection. - * @param unit the unit being added. - * @return unit
. - */ - private static U ucum(U unit) { - UNITS.add(unit); - return unit; - } - - /** - * Default constructor (prevents this class from being instantiated). - */ - private UCUM() { - } - - /** - * Returns a read only view over the units defined in this class. - * @return the collection of SI units. - */ - public Set> getUnits() { - return Collections.unmodifiableSet(UNITS); - } - ////////////////////////////// - // BASE UNITS: UCUM 4.2 §25 // - ////////////////////////////// - /** As per UCUM standard. */ - public static final BaseUnit METER = ucum(SI.METRE); - /** As per UCUM standard. */ - public static final BaseUnit SECOND = ucum(SI.SECOND); - /** - * We deviate slightly from the standard here, to maintain compatibility - * with the existing SI units. In UCUM, the gram is the base unit of mass, - * rather than the kilogram. This doesn't have much effect on the units - * themselves, but it does make formatting the units a challenge. - */ - public static final Unit GRAM = ucum(SI.GRAM); - /** As per UCUM standard. */ - public static final AlternateUnit RADIAN = ucum(SI.RADIAN); - /** As per UCUM standard. */ - public static final BaseUnit KELVIN = ucum(SI.KELVIN); - /** As per UCUM standard. */ - public static final AlternateUnit COULOMB = ucum(SI.COULOMB); - /** As per UCUM standard. */ - public static final BaseUnit CANDELA = ucum(SI.CANDELA); - /////////////////////////////////////////////// - // DIMENSIONLESS DERIVED UNITS: UCUM 4.3 §26 // - /////////////////////////////////////////////// - /** As per UCUM standard. */ - public static final Unit TRIILLIONS = ucum(Unit.ONE.times(1000000000000L)); - /** As per UCUM standard. */ - public static final Unit BILLIONS = ucum(Unit.ONE.times(1000000000)); - /** As per UCUM standard. */ - public static final Unit MILLIONS = ucum(Unit.ONE.times(1000000)); - /** As per UCUM standard. */ - public static final Unit THOUSANDS = ucum(Unit.ONE.times(1000)); - /** As per UCUM standard. */ - public static final Unit HUNDREDS = ucum(Unit.ONE.times(100)); - /** As per UCUM standard. */ - public static final Unit PI = ucum(Unit.ONE.times(StrictMath.PI)); - /** As per UCUM standard. */ - public static final Unit PERCENT = ucum(Unit.ONE.divide(100)); - /** As per UCUM standard. */ - public static final Unit PER_THOUSAND = ucum(Unit.ONE.divide(1000)); - /** As per UCUM standard. */ - public static final Unit PER_MILLION = ucum(Unit.ONE.divide(1000000)); - /** As per UCUM standard. */ - public static final Unit PER_BILLION = ucum(Unit.ONE.divide(1000000000)); - /** As per UCUM standard. */ - public static final Unit PER_TRILLION = ucum(Unit.ONE.divide(1000000000000L)); - //////////////////////////// - // SI UNITS: UCUM 4.3 §27 // - //////////////////////////// - /** - * We deviate slightly from the standard here, to maintain compatibility - * with the existing SI units. In UCUM, the mole is no longer a base unit, - * but is defined as Unit.ONE.times(6.0221367E23)
. - */ - public static final UnitMOLE = ucum(SI.MOLE); - /** - * We deviate slightly from the standard here, to maintain compatibility - * with the existing SI units. In UCUM, the steradian is defined as - * RADIAN.pow(2)
. - */ - public static final UnitSTERADIAN = ucum(SI.STERADIAN); - /** As per UCUM standard. */ - public static final Unit HERTZ = (Unit ) ucum(SI.HERTZ); - /** As per UCUM standard. */ - public static final Unit NEWTON = ucum(SI.NEWTON); - /** As per UCUM standard. */ - public static final Unit PASCAL = ucum(SI.PASCAL); - /** As per UCUM standard. */ - public static final Unit JOULE = ucum(SI.JOULE); - /** As per UCUM standard. */ - public static final Unit WATT = ucum(SI.WATT); - /** - * We deviate slightly from the standard here, to maintain compatability - * with the existing SI units. In UCUM, the ampere is defined as - * COULOMB.divide(SECOND)
. - */ - public static final UnitAMPERE = ucum(SI.AMPERE); - public static final Unit AMPERE_TURN = ucum(SI.AMPERE_TURN); - /** - * We deviate slightly from the standard here, to maintain compatibility - * with the existing SI units. In UCUM, the volt is defined as - * JOULE.divide(COULOMB)
. - */ - public static final UnitVOLT = ucum(SI.VOLT); - /** As per UCUM standard. */ - public static final Unit FARAD = ucum(SI.FARAD); - /** As per UCUM standard. */ - public static final Unit OHM = ucum(SI.OHM); - /** As per UCUM standard. */ - public static final Unit SIEMENS = ucum(SI.SIEMENS); - /** As per UCUM standard. */ - public static final Unit WEBER = ucum(SI.WEBER); - /** As per UCUM standard. */ - public static final Unit CELSIUS = ucum(SI.CELSIUS); - /** As per UCUM standard. */ - public static final Unit TESLA = ucum(SI.TESLA); - /** As per UCUM standard. */ - public static final Unit HENRY = ucum(SI.HENRY); - /** As per UCUM standard. */ - public static final Unit LUMEN = ucum(SI.LUMEN); - /** As per UCUM standard. */ - public static final Unit LUX = ucum(SI.LUX); - /** As per UCUM standard. */ - public static final Unit BECQUEREL = ucum(SI.BECQUEREL); - /** As per UCUM standard. */ - public static final Unit GRAY = ucum(SI.GRAY); - /** As per UCUM standard. */ - public static final Unit SIEVERT = ucum(SI.SIEVERT); - /////////////////////////////////////////////////////////////////////// - // OTHER UNITS FROM ISO 1000, ISO 2955, AND ANSI X3.50: UCUM 4.3 §28 // - /////////////////////////////////////////////////////////////////////// - // The order of GON and DEGREE has been inverted because GON is defined in terms of DEGREE - /** - * We deviate slightly from the standard here, to maintain compatibility - * with the existing NonSI units. In UCUM, the degree is defined as - * PI.times(RADIAN.divide(180))
. - */ - public static final UnitDEGREE = ucum(NonSI.DEGREE_ANGLE); - /** - * We deviate slightly from the standard here, to maintain compatibility - * with the existing NonSI units. In UCUM, the grade is defined as - * DEGREE.times(0.9)
. - */ - public static final UnitGRADE = ucum(NonSI.GRADE); - /** As per UCUM standard. */ - public static final Unit GON = GRADE; - /** As per UCUM standard. */ - public static final Unit MINUTE_ANGLE = ucum(NonSI.MINUTE_ANGLE); - /** As per UCUM standard. */ - public static final Unit SECOND_ANGLE = ucum(NonSI.SECOND_ANGLE); - /** As per UCUM standard. */ - public static final Unit LITER = ucum(NonSI.LITRE); - /** As per UCUM standard. */ - public static final Unit ARE = ucum(NonSI.ARE); - /** As per UCUM standard. */ - public static final Unit MINUTE = ucum(NonSI.MINUTE); - /** As per UCUM standard. */ - public static final Unit HOUR = ucum(NonSI.HOUR); - /** As per UCUM standard. */ - public static final Unit DAY = ucum(NonSI.DAY); - /** As per UCUM standard. */ - public static final Unit YEAR_TROPICAL = ucum(DAY.times(365.24219)); - /** As per UCUM standard. */ - public static final Unit YEAR_JULIAN = ucum(DAY.times(365.25)); - /** As per UCUM standard. */ - public static final Unit YEAR_GREGORIAN = ucum(DAY.times(365.2425)); - /** As per UCUM standard. */ - public static final Unit YEAR = ucum(DAY.times(365.25)); - /** As per UCUM standard. */ - public static final Unit MONTH_SYNODAL = ucum(DAY.times(29.53059)); - /** As per UCUM standard. */ - public static final Unit MONTH_JULIAN = ucum(YEAR_JULIAN.divide(12)); - /** As per UCUM standard. */ - public static final Unit MONTH_GREGORIAN = ucum(YEAR_GREGORIAN.divide(12)); - /** As per UCUM standard. */ - public static final Unit MONTH = ucum(YEAR_JULIAN.divide(12)); - /** As per UCUM standard. */ - public static final Unit TONNE = ucum(NonSI.METRIC_TON); - /** As per UCUM standard. */ - public static final Unit BAR = ucum(NonSI.BAR); - /** As per UCUM standard. */ - public static final Unit ATOMIC_MASS_UNIT = ucum(NonSI.ATOMIC_MASS); - /** As per UCUM standard. */ - public static final Unit ELECTRON_VOLT = ucum(NonSI.ELECTRON_VOLT); - /** As per UCUM standard. */ - public static final Unit ASTRONOMIC_UNIT = ucum(NonSI.ASTRONOMICAL_UNIT); - /** As per UCUM standard. */ - public static final Unit PARSEC = ucum(NonSI.PARSEC); - ///////////////////////////////// - // NATURAL UNITS: UCUM 4.3 §29 // - ///////////////////////////////// - /** As per UCUM standard. */ - public static final Unit C = ucum(NonSI.C); - /** As per UCUM standard. */ - public static final Unit PLANCK = (Unit ) ucum(JOULE.times(SECOND).times(6.6260755E-24)); - /** As per UCUM standard. */ - public static final Unit BOLTZMAN = (Unit ) ucum(JOULE.divide(KELVIN).times(1.380658E-23)); - /** As per UCUM standard. */ - public static final Unit PERMITTIVITY_OF_VACUUM = (Unit ) ucum(FARAD.divide(METER).times(8.854187817E-12)); - /** As per UCUM standard. */ - public static final Unit PERMEABILITY_OF_VACUUM = (Unit ) ucum(NEWTON.times(4E-7 * StrictMath.PI).divide(AMPERE.pow(2))); - /** As per UCUM standard. */ - public static final Unit ELEMENTARY_CHARGE = ucum(NonSI.E); - /** As per UCUM standard. */ - public static final Unit ELECTRON_MASS = ucum(NonSI.ELECTRON_MASS); - /** As per UCUM standard. */ - public static final Unit PROTON_MASS = ucum(GRAM.times(1.6726231E-24)); - /** As per