Skip to content
This repository has been archived by the owner on Sep 21, 2020. It is now read-only.

Commit

Permalink
Import PR1
Browse files Browse the repository at this point in the history
  • Loading branch information
keilw committed Aug 25, 2016
1 parent d1a31bb commit 9b71aea
Show file tree
Hide file tree
Showing 63 changed files with 475 additions and 12,183 deletions.
12 changes: 0 additions & 12 deletions .gitignore

This file was deleted.

19 changes: 13 additions & 6 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
https://kenai.com/projects/jsr-275
======================================================================= -->

<!-- $Id: pom.xml 76 2009-12-03 22:53:52Z keilw $ -->
<!-- $Id: pom.xml 87 2010-01-31 21:44:57Z keilw $ -->
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
Expand All @@ -24,8 +24,7 @@
<!-- ==================================================== -->
<groupId>javax.measure</groupId>
<artifactId>jsr-275</artifactId>
<packaging>jar</packaging>
<version>0.9.4</version>
<version>0.9.5-SNAPSHOT</version>
<name>JSR-275</name>
<url>https://kenai.com/projects/jsr-275</url>

Expand Down Expand Up @@ -61,6 +60,10 @@
<system>JIRA</system>
<url>http://kenai.com/jira/browse/JSR_275</url>
</issueManagement>
<ciManagement>
<system>Hudson</system>
<url>http://hudson.geomatys.com/job/JSR-275/</url>
</ciManagement>

<mailingLists>
<mailingList>
Expand All @@ -84,8 +87,8 @@
<timezone>+1</timezone>
<roles>
<role>Spec Lead</role>
<role>Java Developer</role>
<role>Architect</role>
<role>Java Developer</role>
</roles>
</developer>
<developer>
Expand Down Expand Up @@ -337,12 +340,16 @@
<version>2.2</version>
<configuration>
<archive>
<compress>true</compress>
<manifestEntries>
<Implementation-Title>${project.name}</Implementation-Title>
<Bundle-Version>${project.version}</Bundle-Version>
<Bundle-Name>${project.name}</Bundle-Name>
<Bundle-Vendor>${project.organization.name}</Bundle-Vendor>
<Implementation-Title>${project.organization.name}</Implementation-Title>
<Implementation-Version>${project.version}</Implementation-Version>
<!-- mode>development</mode> TODO call it stage?
<SCM-Revision>${buildNumber}</SCM-Revision-->
<SCM-Revision>$Revision: 76 $</SCM-Revision>
<SCM-Revision>$Revision: 87 $</SCM-Revision>
</manifestEntries>
<manifestFile>src/main/java/META-INF/MANIFEST.MF</manifestFile>
</archive>
Expand Down
17 changes: 9 additions & 8 deletions src/main/java/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
Manifest-Version: 1.0
Export-Package: javax.measure;uses:="javax.measure.unit,junit.framework",
javax.measure.quantity,
javax.measure.unit;uses:="junit.framework"
Bundle-Version: 0.9.5
Tool: Bundlor 1.0.0.BUILD-20091207202403
Bundle-Name: Units of Measure
Bundle-ManifestVersion: 2
Bundle-Vendor: JScience
Bundle-SymbolicName: javax.measure
Bundle-Name: Measures and Units
Bundle-Version: 0.9.3
Export-Package: javax.measure,
javax.measure.converter,
javax.measure.quantity,
javax.measure.unit,
javax.measure.unit.format
Import-Package: junit.framework
Provide-Package: javax.measure,javax.measure.quantity,javax.measure.un
it

4 changes: 2 additions & 2 deletions src/main/java/javax/measure/Measurable.java
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,9 @@
*
* @author <a href="mailto:[email protected]">Jean-Marie Dautelle</a>
* @author <a href="mailto:[email protected]">Werner Keil</a>
* @version 1.0.3 ($Revision: 76 $), $Date: 2009-12-03 23:53:52 +0100 (Do, 03 Dez 2009) $
* @version 1.0.4 ($Revision: 96 $), $Date: 2010-02-03 19:21:17 +0100 (Mi, 03 Feb 2010) $
*/
public interface Measurable<Q extends Quantity> extends Comparable<Measurable<Q>> {
interface Measurable<Q extends Quantity> extends Comparable<Measurable<Q>> {

/**
* Returns the integral <code>int</code> value of this measurable when
Expand Down
68 changes: 48 additions & 20 deletions src/main/java/javax/measure/Measure.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand Down Expand Up @@ -143,10 +142,9 @@
*
* @author <a href="mailto:[email protected]">Jean-Marie Dautelle</a>
* @author <a href="mailto:[email protected]">Werner Keil</a>
* @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<Q extends Quantity> implements Measurable<Q>,
Serializable {
public abstract class Measure<Q extends Quantity> extends Number implements Measurable<Q> {

/**
*
Expand Down Expand Up @@ -193,7 +191,7 @@ public long round(Unit<Q> unit) {
* @throws ArithmeticException if the result is inexact and the quotient
* has a non-terminating decimal expansion.
*/
public Measure<Q> toSI() {
public Measure<Q> toSI() { // TODO needed?
return to(this.getUnit().toSI());
}

Expand Down Expand Up @@ -312,20 +310,32 @@ public int hashCode() {
}

/**
* Returns the <code>String</code> representation of this measure. The
* string produced for a given measure is always the same; it is not
* Returns the standard <code>String</code> 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 <code>UnitFormat.getInternational().format(this)</code>
* @return <code>UnitFormat.getStandard().format(this)</code>
*/
@Override
public String toString() {
return MeasureFormat.getStandard().format(this);
}

/**
* Returns the locale <code>String</code> 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 <code>UnitFormat.getInstance().format(this)</code>
*/
// public String toStringLocale() {
// return MeasureFormat.getInstance().format(this);
// }

// Implements Measurable
public final int intValue(Unit<Q> unit) throws ArithmeticException {
long longValue = longValue(unit);
Expand All @@ -343,12 +353,20 @@ public long longValue(Unit<Q> unit) throws ArithmeticException {
}
return (long) result;
}

public long longValue() {
return longValue(getUnit());
}

// Implements Measurable
public final float floatValue(Unit<Q> 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
* <code>ClassCastException</code> if the dimension of the specified
Expand All @@ -369,7 +387,7 @@ public final float floatValue(Unit<Q> unit) {
@SuppressWarnings("unchecked")
public <T extends Quantity> Measure<T> asType(Class<T> type)
throws ClassCastException {
this.getUnit().asType(type); // Raises ClassCastException is dimension
this.getUnit().asType(type); // Raises ClassCastException if dimension
// mismatches.
return (Measure<T>) this;
}
Expand Down Expand Up @@ -414,35 +432,35 @@ private static class IntegerMeasure<T extends Quantity> extends Measure<T> {
*/
private static final long serialVersionUID = 5355395476874521709L;

int _value;
int value;

Unit<T> _unit;
Unit<T> unit;

public IntegerMeasure(int value, Unit<T> unit) {
_value = value;
_unit = unit;
this.value = value;
this.unit = unit;
}

@Override
public Integer getValue() {
return _value;
return value;
}

@Override
public Unit<T> getUnit() {
return _unit;
return unit;
}

// Implements Measurable
public double doubleValue(Unit<T> unit) {
return (_unit.equals(unit)) ? _value : _unit.getConverterTo(unit).convert(_value);
return (this.unit.equals(unit)) ? value : this.unit.getConverterTo(unit).convert(value);
}

// Implements Measurable
public BigDecimal decimalValue(Unit<T> unit, MathContext ctx)
throws ArithmeticException {
BigDecimal decimal = BigDecimal.valueOf(_value);
return (_unit.equals(unit)) ? decimal : _unit.getConverterTo(unit).convert(decimal, ctx);
BigDecimal decimal = BigDecimal.valueOf(value);
return (this.unit.equals(unit)) ? decimal : this.unit.getConverterTo(unit).convert(decimal, ctx);
}
}

Expand Down Expand Up @@ -646,7 +664,7 @@ public Unit<T> getUnit() {
return unit;
}

// Implements Measurable

public double doubleValue(Unit<T> unit) {
return (this.unit.equals(unit)) ? value.doubleValue() : this.unit.getConverterTo(unit).convert(value.doubleValue());
}
Expand All @@ -657,4 +675,14 @@ public BigDecimal decimalValue(Unit<T> unit, MathContext ctx)
return (this.unit.equals(unit)) ? value : this.unit.getConverterTo(unit).convert(value, ctx);
}
}

@Override
public double doubleValue() {
return doubleValue(getUnit());
}

@Override
public int intValue() {
return intValue(getUnit());
}
}
6 changes: 3 additions & 3 deletions src/main/java/javax/measure/MeasureFormat.java
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@
*
* @author <a href="mailto:[email protected]">Jean-Marie Dautelle</a>
* @author <a href="mailto:[email protected]">Werner Keil</a>
* @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 abstract class MeasureFormat extends Format {

Expand Down Expand Up @@ -348,7 +348,7 @@ public Appendable format(Measure measure, Appendable dest)
if (measure.getUnit().equals(Unit.ONE))
return dest;
dest.append(' ');
return UnitFormat.getStandard().format(unit, dest);
return UnitFormat.getInstance().format(unit, dest);
}
}

Expand All @@ -369,7 +369,7 @@ public Measure<?> parse(CharSequence csq, ParsePosition cursor)
BigDecimal decimal = new BigDecimal(csq.subSequence(startDecimal,
endDecimal).toString());
cursor.setIndex(endDecimal + 1);
Unit unit = UnitFormat.getStandard().parse(csq, cursor);
Unit unit = UnitFormat.getInstance().parse(csq, cursor);
return Measure.valueOf(decimal, unit);
}
}
Expand Down
Loading

0 comments on commit 9b71aea

Please sign in to comment.