[Mulgara-svn] r1090 - trunk/src/jar/store-stringpool/java/org/mulgara/store/stringpool/xa
pag at mulgara.org
pag at mulgara.org
Thu Jul 17 17:13:09 UTC 2008
Author: pag
Date: 2008-07-17 10:13:08 -0700 (Thu, 17 Jul 2008)
New Revision: 1090
Modified:
trunk/src/jar/store-stringpool/java/org/mulgara/store/stringpool/xa/SPDecimalImpl.java
trunk/src/jar/store-stringpool/java/org/mulgara/store/stringpool/xa/SPDecimalUnitTest.java
Log:
Added support for decimals to start with a '+' character
Modified: trunk/src/jar/store-stringpool/java/org/mulgara/store/stringpool/xa/SPDecimalImpl.java
===================================================================
--- trunk/src/jar/store-stringpool/java/org/mulgara/store/stringpool/xa/SPDecimalImpl.java 2008-07-17 16:17:57 UTC (rev 1089)
+++ trunk/src/jar/store-stringpool/java/org/mulgara/store/stringpool/xa/SPDecimalImpl.java 2008-07-17 17:13:08 UTC (rev 1090)
@@ -67,7 +67,7 @@
@SuppressWarnings("unused")
private final static Logger logger = Logger.getLogger(SPDecimalImpl.class);
- private Long l;
+ private long l;
static final int TYPE_ID = 2; // Unique ID
@@ -86,6 +86,7 @@
SPDecimalImpl(int subtypeId, URI typeURI, String lexicalForm) {
super(TYPE_ID, subtypeId, typeURI);
+ if (lexicalForm.charAt(0) == '+') lexicalForm = lexicalForm.substring(1);
int decPos = lexicalForm.indexOf('.');
if (decPos < 0) {
l = Long.valueOf(lexicalForm);
@@ -114,7 +115,7 @@
public String getLexicalForm() {
- return l.toString();
+ return Long.toString(l);
}
@@ -127,7 +128,7 @@
// Compare the longs.
SPDecimalImpl di = (SPDecimalImpl)o;
- return compare(l.longValue(), di.l.longValue());
+ return compare(l, di.l);
}
@@ -144,7 +145,7 @@
try {
SPDecimalImpl di = (SPDecimalImpl)obj;
- return l.equals(di.l);
+ return l == di.l;
} catch (ClassCastException ex) {
// obj was not an SPDecimalImpl.
return false;
Modified: trunk/src/jar/store-stringpool/java/org/mulgara/store/stringpool/xa/SPDecimalUnitTest.java
===================================================================
--- trunk/src/jar/store-stringpool/java/org/mulgara/store/stringpool/xa/SPDecimalUnitTest.java 2008-07-17 16:17:57 UTC (rev 1089)
+++ trunk/src/jar/store-stringpool/java/org/mulgara/store/stringpool/xa/SPDecimalUnitTest.java 2008-07-17 17:13:08 UTC (rev 1090)
@@ -55,6 +55,8 @@
private static final String VALID_XSD_DECIMAL5 = "0";
+ private static final String VALID_XSD_DECIMAL6 = "+101";
+
private static final String INVALID_XSD_DECIMAL = "x";
private static final String INVALID_XSD_DECIMAL2 = "0x";
private static final String INVALID_XSD_DECIMAL3 = "10.10";
@@ -104,6 +106,7 @@
validTest(VALID_XSD_DECIMAL3, factory);
validTest(VALID_XSD_DECIMAL4, factory);
validTest(VALID_XSD_DECIMAL5, factory);
+ validTest(VALID_XSD_DECIMAL6, factory);
SPDecimalImpl dec = (SPDecimalImpl)factory.newSPTypedLiteral(XSD.DECIMAL_URI, VALID_XSD_DECIMAL1);
@@ -137,6 +140,7 @@
SPDecimalImpl d = (SPDecimalImpl)factory.newSPTypedLiteral(XSD.DECIMAL_URI, number);
if (number.contains(".")) number = number.substring(0, number.indexOf('.'));
+ if (number.charAt(0) == '+') number = number.substring(1);
// Test that the lexical form of the decimal is correct
assertEquals(number, d.getLexicalForm());
More information about the Mulgara-svn
mailing list