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

Commit 08809b1

Browse files
committed
1 parent 41ad346 commit 08809b1

4 files changed

Lines changed: 37 additions & 31 deletions

File tree

README.md

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
jackson-module-unitsofmeasure
22
=============================
33

4-
Contains custom serializers and deserializers for org.unitsofmeasurement classes.
4+
Contains custom serializers and deserializers for JSR 363.
55

6-
This was built with a custom `5.0-opower` version of JScience, which is provided in a local Maven repository, located in the
7-
`/repo` sub-directory of this artifact. It was built from JScience version `r65` (from 2011-10-27), because as of 2013-11-05
8-
there is no publicly released version 5.0 (or greater). It contains fixes to the OSGI and Javolution dependencies, whose Maven
9-
coordinates have changed since the last official JScience release, and corrections to import statements for the
10-
`org.jscience.physics.unit.system.*` classes.
6+
This was built wit version `0.5-SNAPSHOT` of the JSR 363 API and `0.2-SNAPSHOT` of the RI, both provided in a local Maven repository, called `/repository` under this ("unitsofmeasurement") organization.

pom.xml

Lines changed: 25 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -12,27 +12,20 @@
1212
<groupId>com.opower.unitsofmeasure</groupId>
1313
<artifactId>jackson-module-unitsofmeasure</artifactId>
1414
<packaging>jar</packaging>
15-
<version>1.2-uom</version>
15+
<version>1.3-uom-SNAPSHOT</version>
1616

1717
<name>Jackson Unit of Measure Module</name>
1818
<description>Contains custom serializers and deserializers for org.unitsofmeasurement classes.</description>
19-
20-
<repositories>
21-
<repository>
22-
<id>jscience-local-repo</id>
23-
<name>Local repository for the "5.0-opower" JScience version we depend on</name>
24-
<url>https://github.com/opower/jackson-module-unitsofmeasure/raw/master/repo</url>
25-
</repository>
26-
</repositories>
2719

2820
<!-- ======================================================= -->
2921
<!-- Build Settings -->
3022
<!-- ======================================================= -->
3123
<properties>
32-
<project.build.javaVersion>1.7</project.build.javaVersion>
33-
<jdkVersion>1.7</jdkVersion>
24+
<project.build.javaVersion>1.8</project.build.javaVersion>
25+
<jdkVersion>1.8</jdkVersion>
3426
<maven.compile.targetLevel>${jdkVersion}</maven.compile.targetLevel>
3527
<maven.compile.sourceLevel>${jdkVersion}</maven.compile.sourceLevel>
28+
<jsr.version>0.5-SNAPSHOT</jsr.version>
3629
<ri.version>0.2-SNAPSHOT</ri.version>
3730
<lib.version>0.1-SNAPSHOT</lib.version>
3831
<jackson.version>2.2.2</jackson.version>
@@ -44,14 +37,29 @@
4437
<!-- The implementation is provided by JScience -->
4538
<!-- =========================================================================================================== -->
4639
<dependency>
47-
<groupId>org.unitsofmeasurement</groupId>
48-
<artifactId>unit-api</artifactId>
49-
<version>0.6.0</version>
40+
<groupId>javax.measure</groupId>
41+
<artifactId>unit-api-core</artifactId>
42+
<version>${jsr.version}</version>
5043
</dependency>
5144
<dependency>
52-
<groupId>org.jscience</groupId>
53-
<artifactId>jscience-physics</artifactId>
54-
<version>5.0-opower</version>
45+
<groupId>javax.measure</groupId>
46+
<artifactId>unit-api-format</artifactId>
47+
<version>${jsr.version}</version>
48+
</dependency>
49+
<dependency>
50+
<groupId>javax.measure</groupId>
51+
<artifactId>unit-api-quantity</artifactId>
52+
<version>${jsr.version}</version>
53+
</dependency>
54+
<dependency>
55+
<groupId>javax.measure</groupId>
56+
<artifactId>unit-api-util</artifactId>
57+
<version>${jsr.version}</version>
58+
</dependency>
59+
<dependency>
60+
<groupId>org.unitsofmeasurement</groupId>
61+
<artifactId>unit-ri</artifactId>
62+
<version>${ri.version}</version>
5563
</dependency>
5664

5765
<!-- =========================================================================================================== -->

src/main/java/com/opower/unitsofmeasure/UnitJacksonModule.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,10 @@
1313
import com.fasterxml.jackson.databind.module.SimpleModule;
1414
import com.fasterxml.jackson.databind.ser.std.StdScalarSerializer;
1515

16-
import org.jscience.physics.unit.formats.UCUMFormat;
17-
import org.unitsofmeasurement.unit.Unit;
16+
import org.unitsofmeasurement.ri.format.UCUMFormat;
17+
import org.unitsofmeasurement.ri.format.UCUMFormat.Variant;
18+
19+
import javax.measure.Unit;
1820

1921
/**
2022
* Configures Jackson to (de)serialize JScience Unit objects using their UCUM representation, since the actual objects don't
@@ -47,7 +49,7 @@ public void serialize(Unit unit, JsonGenerator jgen, SerializerProvider provider
4749
// Format the unit using the standard UCUM representation.
4850
// The string produced for a given unit is always the same; it is not affected by the locale.
4951
// It can be used as a canonical string representation for exchanging units.
50-
String ucumFormattedUnit = UCUMFormat.getCaseSensitiveInstance().format(unit, new StringBuilder()).toString();
52+
String ucumFormattedUnit = UCUMFormat.getInstance(Variant.CASE_SENSITIVE).format(unit, new StringBuilder()).toString();
5153

5254
jgen.writeString(ucumFormattedUnit);
5355
}
@@ -69,7 +71,7 @@ public Unit deserialize(JsonParser jsonParser, DeserializationContext deserializ
6971
JsonToken currentToken = jsonParser.getCurrentToken();
7072

7173
if (currentToken == JsonToken.VALUE_STRING) {
72-
return UCUMFormat.getCaseInsensitiveInstance().parse(jsonParser.getText(), new ParsePosition(0));
74+
return UCUMFormat.getInstance(Variant.CASE_INSENSITIVE).parse(jsonParser.getText(), new ParsePosition(0));
7375
}
7476
throw deserializationContext.wrongTokenException(jsonParser,
7577
JsonToken.VALUE_STRING,

src/test/java/com/opower/unitsofmeasure/TestUnitJacksonModule.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@
1212
import org.junit.Before;
1313
import org.junit.Test;
1414

15-
import org.jscience.physics.unit.SI;
16-
import org.jscience.physics.unit.UCUM;
17-
import org.unitsofmeasurement.unit.Unit;
15+
import org.unitsofmeasurement.ri.util.SI;
16+
import org.unitsofmeasurement.ri.util.UCUM;
17+
import javax.measure.Unit;
1818

19-
import static org.jscience.physics.unit.SIPrefix.KILO;
19+
import static org.unitsofmeasurement.ri.util.SIPrefix.KILO;
2020
import static org.junit.Assert.*;
2121

2222
/**

0 commit comments

Comments
 (0)