[Mulgara-svn] r1182 - in trunk/src/jar: store-stringpool/java/org/mulgara/store/stringpool store-stringpool/java/org/mulgara/store/stringpool/xa store-stringpool-xa/java/org/mulgara/store/stringpool/xa store-stringpool-xa11/java/org/mulgara/store/stringpool/xa11

pag at mulgara.org pag at mulgara.org
Tue Aug 26 20:30:02 UTC 2008


Author: pag
Date: 2008-08-26 13:30:01 -0700 (Tue, 26 Aug 2008)
New Revision: 1182

Modified:
   trunk/src/jar/store-stringpool-xa/java/org/mulgara/store/stringpool/xa/XAStringPoolImpl.java
   trunk/src/jar/store-stringpool-xa11/java/org/mulgara/store/stringpool/xa11/DataAVLComparator.java
   trunk/src/jar/store-stringpool/java/org/mulgara/store/stringpool/AbstractSPStringComparator.java
   trunk/src/jar/store-stringpool/java/org/mulgara/store/stringpool/SPComparator.java
   trunk/src/jar/store-stringpool/java/org/mulgara/store/stringpool/SPLimit.java
   trunk/src/jar/store-stringpool/java/org/mulgara/store/stringpool/xa/SPBase64BinaryImpl.java
   trunk/src/jar/store-stringpool/java/org/mulgara/store/stringpool/xa/SPBase64BinaryUnitTest.java
   trunk/src/jar/store-stringpool/java/org/mulgara/store/stringpool/xa/SPBinaryComparator.java
   trunk/src/jar/store-stringpool/java/org/mulgara/store/stringpool/xa/SPBooleanImpl.java
   trunk/src/jar/store-stringpool/java/org/mulgara/store/stringpool/xa/SPBooleanUnitTest.java
   trunk/src/jar/store-stringpool/java/org/mulgara/store/stringpool/xa/SPCaseInsensitiveStringComparator.java
   trunk/src/jar/store-stringpool/java/org/mulgara/store/stringpool/xa/SPCaseInsensitiveStringComparatorUnitTest.java
   trunk/src/jar/store-stringpool/java/org/mulgara/store/stringpool/xa/SPCaseSensitiveStringComparator.java
   trunk/src/jar/store-stringpool/java/org/mulgara/store/stringpool/xa/SPDateImpl.java
   trunk/src/jar/store-stringpool/java/org/mulgara/store/stringpool/xa/SPDateTimeImpl.java
   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
   trunk/src/jar/store-stringpool/java/org/mulgara/store/stringpool/xa/SPDoubleImpl.java
   trunk/src/jar/store-stringpool/java/org/mulgara/store/stringpool/xa/SPFloatImpl.java
   trunk/src/jar/store-stringpool/java/org/mulgara/store/stringpool/xa/SPGDayImpl.java
   trunk/src/jar/store-stringpool/java/org/mulgara/store/stringpool/xa/SPGDayUnitTest.java
   trunk/src/jar/store-stringpool/java/org/mulgara/store/stringpool/xa/SPGMonthDayImpl.java
   trunk/src/jar/store-stringpool/java/org/mulgara/store/stringpool/xa/SPGMonthDayUnitTest.java
   trunk/src/jar/store-stringpool/java/org/mulgara/store/stringpool/xa/SPGMonthImpl.java
   trunk/src/jar/store-stringpool/java/org/mulgara/store/stringpool/xa/SPGMonthUnitTest.java
   trunk/src/jar/store-stringpool/java/org/mulgara/store/stringpool/xa/SPGYearImpl.java
   trunk/src/jar/store-stringpool/java/org/mulgara/store/stringpool/xa/SPGYearMonthImpl.java
   trunk/src/jar/store-stringpool/java/org/mulgara/store/stringpool/xa/SPGYearMonthUnitTest.java
   trunk/src/jar/store-stringpool/java/org/mulgara/store/stringpool/xa/SPGYearUnitTest.java
   trunk/src/jar/store-stringpool/java/org/mulgara/store/stringpool/xa/SPHexBinaryUnitTest.java
   trunk/src/jar/store-stringpool/java/org/mulgara/store/stringpool/xa/SPXMLLiteralUnitTest.java
   trunk/src/jar/store-stringpool/java/org/mulgara/store/stringpool/xa/UnknownSPTypedLiteralFactory.java
   trunk/src/jar/store-stringpool/java/org/mulgara/store/stringpool/xa/UnknownSPTypedLiteralUnitTest.java
Log:
Updated SPComparator to take the subtype ID when comparing, so that these may be distinguished when being inserted. Only the Decimal objects will use this, as no other types have subtypes, however all implementations of the comparator needed to be updated to deal with this. This should close #137

Modified: trunk/src/jar/store-stringpool/java/org/mulgara/store/stringpool/AbstractSPStringComparator.java
===================================================================
--- trunk/src/jar/store-stringpool/java/org/mulgara/store/stringpool/AbstractSPStringComparator.java	2008-08-26 18:31:13 UTC (rev 1181)
+++ trunk/src/jar/store-stringpool/java/org/mulgara/store/stringpool/AbstractSPStringComparator.java	2008-08-26 20:30:01 UTC (rev 1182)
@@ -83,7 +83,7 @@
     return compare(d1cb, d2cb);
   }
 
-  public final int compare(ByteBuffer d1, ByteBuffer d2) {
+  public final int compare(ByteBuffer d1, int st1, ByteBuffer d2, int st2) {
     return compare(
         AbstractSPObject.CHARSET.decode(d1), AbstractSPObject.CHARSET.decode(d2)
     );

Modified: trunk/src/jar/store-stringpool/java/org/mulgara/store/stringpool/SPComparator.java
===================================================================
--- trunk/src/jar/store-stringpool/java/org/mulgara/store/stringpool/SPComparator.java	2008-08-26 18:31:13 UTC (rev 1181)
+++ trunk/src/jar/store-stringpool/java/org/mulgara/store/stringpool/SPComparator.java	2008-08-26 20:30:01 UTC (rev 1182)
@@ -57,6 +57,6 @@
    */
   public int comparePrefix(ByteBuffer d1, ByteBuffer d2, int d2Size);
 
-  public int compare(ByteBuffer d1, ByteBuffer d2);
+  public int compare(ByteBuffer d1, int subtypeId1, ByteBuffer d2, int subtypeId2);
 
 }

Modified: trunk/src/jar/store-stringpool/java/org/mulgara/store/stringpool/SPLimit.java
===================================================================
--- trunk/src/jar/store-stringpool/java/org/mulgara/store/stringpool/SPLimit.java	2008-08-26 18:31:13 UTC (rev 1181)
+++ trunk/src/jar/store-stringpool/java/org/mulgara/store/stringpool/SPLimit.java	2008-08-26 20:30:01 UTC (rev 1182)
@@ -154,7 +154,7 @@
       return 0;
     }
 
-    public int compare(ByteBuffer d1, ByteBuffer d2) {
+    public int compare(ByteBuffer d1, int st1, ByteBuffer d2, int st2) {
       return 0;
     }
 

Modified: trunk/src/jar/store-stringpool/java/org/mulgara/store/stringpool/xa/SPBase64BinaryImpl.java
===================================================================
--- trunk/src/jar/store-stringpool/java/org/mulgara/store/stringpool/xa/SPBase64BinaryImpl.java	2008-08-26 18:31:13 UTC (rev 1181)
+++ trunk/src/jar/store-stringpool/java/org/mulgara/store/stringpool/xa/SPBase64BinaryImpl.java	2008-08-26 20:30:01 UTC (rev 1182)
@@ -292,7 +292,7 @@
       compare = comparator.comparePrefix(data, objData, data.limit());
       if (compare == 0) {
 
-        compare = comparator.compare(data, objData);
+        compare = comparator.compare(data, 0, objData, 0);
       }
     }
 

Modified: trunk/src/jar/store-stringpool/java/org/mulgara/store/stringpool/xa/SPBase64BinaryUnitTest.java
===================================================================
--- trunk/src/jar/store-stringpool/java/org/mulgara/store/stringpool/xa/SPBase64BinaryUnitTest.java	2008-08-26 18:31:13 UTC (rev 1181)
+++ trunk/src/jar/store-stringpool/java/org/mulgara/store/stringpool/xa/SPBase64BinaryUnitTest.java	2008-08-26 20:30:01 UTC (rev 1182)
@@ -27,11 +27,8 @@
 
 package org.mulgara.store.stringpool.xa;
 
-import java.io.*;
-
 // Third party packages
 import junit.framework.*;
-import java.nio.*;
 import org.mulgara.query.rdf.*;
 import org.mulgara.store.stringpool.*;
 

Modified: trunk/src/jar/store-stringpool/java/org/mulgara/store/stringpool/xa/SPBinaryComparator.java
===================================================================
--- trunk/src/jar/store-stringpool/java/org/mulgara/store/stringpool/xa/SPBinaryComparator.java	2008-08-26 18:31:13 UTC (rev 1181)
+++ trunk/src/jar/store-stringpool/java/org/mulgara/store/stringpool/xa/SPBinaryComparator.java	2008-08-26 20:30:01 UTC (rev 1182)
@@ -69,10 +69,10 @@
     if (d1.limit() > d2.limit()) {
       d1.limit(d2.limit());
     }
-    return compare(d1, d2);
+    return compare(d1, 0, d2, 0);
   }
 
-  public int compare(ByteBuffer d1, ByteBuffer d2) {
+  public int compare(ByteBuffer d1, int st1, ByteBuffer d2, int st2) {
     while (d1.hasRemaining() && d2.hasRemaining()) {
       int c = (d1.get() & 0xff) - (d2.get() & 0xff);
       if (c != 0) return c;

Modified: trunk/src/jar/store-stringpool/java/org/mulgara/store/stringpool/xa/SPBooleanImpl.java
===================================================================
--- trunk/src/jar/store-stringpool/java/org/mulgara/store/stringpool/xa/SPBooleanImpl.java	2008-08-26 18:31:13 UTC (rev 1181)
+++ trunk/src/jar/store-stringpool/java/org/mulgara/store/stringpool/xa/SPBooleanImpl.java	2008-08-26 20:30:01 UTC (rev 1182)
@@ -287,7 +287,7 @@
      * @param d2 ByteBuffer
      * @return int
      */
-    public int compare(ByteBuffer d1, ByteBuffer d2) {
+    public int compare(ByteBuffer d1, int st1, ByteBuffer d2, int st2) {
 
       //value is stored in the first byte
       return d1.get(0) - d2.get(0);

Modified: trunk/src/jar/store-stringpool/java/org/mulgara/store/stringpool/xa/SPBooleanUnitTest.java
===================================================================
--- trunk/src/jar/store-stringpool/java/org/mulgara/store/stringpool/xa/SPBooleanUnitTest.java	2008-08-26 18:31:13 UTC (rev 1181)
+++ trunk/src/jar/store-stringpool/java/org/mulgara/store/stringpool/xa/SPBooleanUnitTest.java	2008-08-26 20:30:01 UTC (rev 1182)
@@ -27,7 +27,6 @@
 
 package org.mulgara.store.stringpool.xa;
 
-import java.io.*;
 import java.nio.*;
 
 // Third party packages
@@ -265,11 +264,11 @@
     SPComparator comparator = false1.getSPComparator();
     assertTrue("'false' SPBoolean compared to 'true' SPBoolean should return " +
                "a negative number. ",
-               comparator.compare(false1.getData(), true1.getData()) < 0);
+               comparator.compare(false1.getData(), 0, true1.getData(), 0) < 0);
     comparator = true2.getSPComparator();
     assertTrue("'true' SPBoolean compared to 'false' SPBoolean should return " +
                "a positive number.",
-               comparator.compare(true2.getData(), false1.getData()) > 0);
+               comparator.compare(true2.getData(), 0, false1.getData(), 0) > 0);
   }
 
   //set up and tear down

Modified: trunk/src/jar/store-stringpool/java/org/mulgara/store/stringpool/xa/SPCaseInsensitiveStringComparator.java
===================================================================
--- trunk/src/jar/store-stringpool/java/org/mulgara/store/stringpool/xa/SPCaseInsensitiveStringComparator.java	2008-08-26 18:31:13 UTC (rev 1181)
+++ trunk/src/jar/store-stringpool/java/org/mulgara/store/stringpool/xa/SPCaseInsensitiveStringComparator.java	2008-08-26 20:30:01 UTC (rev 1182)
@@ -34,7 +34,6 @@
 
 // Locally written packages
 import org.mulgara.store.stringpool.AbstractSPStringComparator;
-import org.mulgara.store.stringpool.SPComparator;
 
 
 /**

Modified: trunk/src/jar/store-stringpool/java/org/mulgara/store/stringpool/xa/SPCaseInsensitiveStringComparatorUnitTest.java
===================================================================
--- trunk/src/jar/store-stringpool/java/org/mulgara/store/stringpool/xa/SPCaseInsensitiveStringComparatorUnitTest.java	2008-08-26 18:31:13 UTC (rev 1181)
+++ trunk/src/jar/store-stringpool/java/org/mulgara/store/stringpool/xa/SPCaseInsensitiveStringComparatorUnitTest.java	2008-08-26 20:30:01 UTC (rev 1182)
@@ -113,22 +113,22 @@
     // First test the compare() method.
     bb1.clear();
     bb2.clear();
-    assertTrue(spc.compare(bb1, bb2) < 0);
+    assertTrue(spc.compare(bb1, 0, bb2, 0) < 0);
     bb2.clear();
     bb1.clear();
-    assertTrue(spc.compare(bb2, bb1) > 0);
+    assertTrue(spc.compare(bb2, 0, bb1, 0) > 0);
     bb2.clear();
     bb3.clear();
-    assertTrue(spc.compare(bb2, bb3) < 0);
+    assertTrue(spc.compare(bb2, 0, bb3, 0) < 0);
     bb3.clear();
     bb2.clear();
-    assertTrue(spc.compare(bb3, bb2) > 0);
+    assertTrue(spc.compare(bb3, 0, bb2, 0) > 0);
     bb1.clear();
     bb3.clear();
-    assertTrue(spc.compare(bb1, bb3) < 0);
+    assertTrue(spc.compare(bb1, 0, bb3, 0) < 0);
     bb3.clear();
     bb1.clear();
-    assertTrue(spc.compare(bb3, bb1) > 0);
+    assertTrue(spc.compare(bb3, 0, bb1, 0) > 0);
 
     // The comparePrefix() method should return 0 in all these cases.
     bb1.clear();

Modified: trunk/src/jar/store-stringpool/java/org/mulgara/store/stringpool/xa/SPCaseSensitiveStringComparator.java
===================================================================
--- trunk/src/jar/store-stringpool/java/org/mulgara/store/stringpool/xa/SPCaseSensitiveStringComparator.java	2008-08-26 18:31:13 UTC (rev 1181)
+++ trunk/src/jar/store-stringpool/java/org/mulgara/store/stringpool/xa/SPCaseSensitiveStringComparator.java	2008-08-26 20:30:01 UTC (rev 1182)
@@ -34,7 +34,6 @@
 
 // Locally written packages
 import org.mulgara.store.stringpool.AbstractSPStringComparator;
-import org.mulgara.store.stringpool.SPComparator;
 
 
 /**

Modified: trunk/src/jar/store-stringpool/java/org/mulgara/store/stringpool/xa/SPDateImpl.java
===================================================================
--- trunk/src/jar/store-stringpool/java/org/mulgara/store/stringpool/xa/SPDateImpl.java	2008-08-26 18:31:13 UTC (rev 1181)
+++ trunk/src/jar/store-stringpool/java/org/mulgara/store/stringpool/xa/SPDateImpl.java	2008-08-26 20:30:01 UTC (rev 1182)
@@ -224,14 +224,10 @@
       return 0;
     }
 
-    public int compare(ByteBuffer d1, ByteBuffer d2) {
-      return compare(d1.getLong(), d2.getLong());
+    public int compare(ByteBuffer d1, int st1, ByteBuffer d2, int st2) {
+      return AbstractSPObject.compare(d1.getLong(), d2.getLong());
     }
 
-    private static int compare(long a, long b) {
-      return a == b ? 0 : (a < b ? -1 : 1);
-    }
-
   }
 
 }

Modified: trunk/src/jar/store-stringpool/java/org/mulgara/store/stringpool/xa/SPDateTimeImpl.java
===================================================================
--- trunk/src/jar/store-stringpool/java/org/mulgara/store/stringpool/xa/SPDateTimeImpl.java	2008-08-26 18:31:13 UTC (rev 1181)
+++ trunk/src/jar/store-stringpool/java/org/mulgara/store/stringpool/xa/SPDateTimeImpl.java	2008-08-26 20:30:01 UTC (rev 1182)
@@ -193,14 +193,10 @@
       return 0;
     }
 
-    public int compare(ByteBuffer d1, ByteBuffer d2) {
-      return compare(d1.getLong(), d2.getLong());
+    public int compare(ByteBuffer d1, int st1, ByteBuffer d2, int st2) {
+      return AbstractSPObject.compare(d1.getLong(), d2.getLong());
     }
 
-    private static int compare(long a, long b) {
-      return a == b ? 0 : (a < b ? -1 : 1);
-    }
-
   }
 
 }

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-08-26 18:31:13 UTC (rev 1181)
+++ trunk/src/jar/store-stringpool/java/org/mulgara/store/stringpool/xa/SPDecimalImpl.java	2008-08-26 20:30:01 UTC (rev 1182)
@@ -41,6 +41,9 @@
 
 /**
  * An SPTypedLiteral that represents xsd:decimal literals.
+ * Data is encoded as a string or a long. If the data is the length of a long, then
+ * it is a long. If it is one more, then it could be a normal string, or a string
+ * that was padded to not look like a long.
  *
  * @created 2004-10-05
  * @author David Makepeace
@@ -76,13 +79,16 @@
    */
   static BigDecimal decode(ByteBuffer bb) {
     ByteBuffer number = bb;
-    if (bb.limit() == END_IDX + 1) {
-      byte type = bb.get(END_IDX);
-      if (type == SPDecimalExtImpl.END_BYTE) {
-        return BigDecimal.valueOf(bb.getLong());
+    int limit = bb.limit();
+    if (limit == Constants.SIZEOF_LONG) return BigDecimal.valueOf(bb.getLong());
+    if (limit == END_IDX + 1) {
+      // is this buffer padded?
+      byte terminator = bb.get(END_IDX);
+      if (terminator == SPDecimalBaseImpl.END_BYTE) {
+        // remove the padding
+        bb.limit(END_IDX);
+        number = bb.slice();
       }
-      bb.limit(END_IDX);
-      number = bb.slice();
     }
     return new BigDecimal(CHARSET.decode(number).toString());
   }
@@ -143,11 +149,13 @@
    */
   SPDecimalBaseImpl(int subtypeId, URI typeURI, ByteBuffer data) {
     super(subtypeId, typeURI);
+    if (data.limit() == Constants.SIZEOF_LONG) throw new IllegalArgumentException("Buffer does not hold a decimal.");
     ByteBuffer number = data;
     if (data.limit() == END_IDX + 1) {
-      assert data.get(END_IDX) == END_BYTE;
-      data.limit(END_IDX);
-      number = data.slice();
+      if (data.get(END_IDX) == END_BYTE) {
+        data.limit(END_IDX);
+        number = data.slice();
+      }
     }
     lexical = CHARSET.decode(number).toString();
     val = new BigDecimal(lexical);
@@ -170,10 +178,12 @@
   /** @see org.mulgara.store.stringpool.SPObject#getData() */
   public ByteBuffer getData() {
     ByteBuffer data = CHARSET.encode(lexical);
+    // if this is the same size as a long, expand it and pad it
     if (data.limit() == END_IDX) {
       ByteBuffer newData = ByteBuffer.allocate(END_IDX + 1);
       newData.put(data);
       newData.put(END_IDX, END_BYTE);
+      newData.rewind();
       data = newData;
     }
     return data;
@@ -253,8 +263,10 @@
      * @see org.mulgara.store.stringpool.SPComparator#compare(java.nio.ByteBuffer, java.nio.ByteBuffer)
      * This comparator WILL compare between xsd:decimal and the extending types
      */
-    public int compare(ByteBuffer d1, ByteBuffer d2) {
-      return decode(d1).compareTo(decode(d2));
+    public int compare(ByteBuffer d1, int subtypeId1, ByteBuffer d2, int subtypeId2) {
+      int c = decode(d1).compareTo(decode(d2));
+      if (c == 0) c = AbstractSPObject.compare(subtypeId1, subtypeId2);
+      return c;
     }
 
   }
@@ -269,9 +281,6 @@
  */
 class SPDecimalExtImpl extends SPDecimalImpl {
 
-  /** The terminating byte, to distinguish the data types from SPDecimalBaseImpl */
-  static final byte END_BYTE = 0;
-
   /** The long value containing the number. */
   final Long l;
 
@@ -295,9 +304,7 @@
    */
   SPDecimalExtImpl(int subtypeId, URI typeURI, ByteBuffer data) {
     super(subtypeId, typeURI);
-    assert data.limit() == Constants.SIZEOF_LONG + 1;
-    int end = data.limit() - 1;
-    assert data.get(end) == END_BYTE;
+    assert isLong(data);
     l = data.getLong();
   }
 
@@ -316,9 +323,8 @@
 
   /** @see org.mulgara.store.stringpool.SPObject#getData() */
   public ByteBuffer getData() {
-    ByteBuffer data = ByteBuffer.allocate(Constants.SIZEOF_LONG + 1);
+    ByteBuffer data = ByteBuffer.allocate(Constants.SIZEOF_LONG);
     data.putLong(l);
-    data.put((byte)END_BYTE);
     data.flip();
     return data;
   }
@@ -375,16 +381,15 @@
 
 
   /**
-   * Utility for comparing long values.
-   * @param l1 The first long.
-   * @param l2 The second long.
-   * @return +1 if l1 > l2, -1 if l1 < l2, and 0 if l1 == l2
+   * Tests a buffer to see if if contains a long value. It must be the correct length
+   * and it must have the correct byte in the last place.
+   * @param d The buffer to test.
+   * @return <code>true</code> if the buffer contains a long value.
    */
-  public static int compare(long l1, long l2) {
-    return l1 < l2 ? -1 : (l1 > l2 ? 1 : 0);
+  static final boolean isLong(ByteBuffer d) {
+    return d.limit() == Constants.SIZEOF_LONG;
   }
 
-
   /** Compares the binary representations of two SPDecimalExtImpl objects. */
   public static class SPDecimalExtComparator implements SPComparator {
 
@@ -408,11 +413,15 @@
      * @see org.mulgara.store.stringpool.SPComparator#compare(java.nio.ByteBuffer, java.nio.ByteBuffer)
      * This comparator WILL compare between xsd:decimal and the extending types
      */
-    public int compare(ByteBuffer d1, ByteBuffer d2) {
-      if (d1.get(END_IDX) == END_BYTE && d2.get(END_IDX) == END_BYTE) {
-        return SPDecimalExtImpl.compare(d1.getLong(), d2.getLong());
+    public int compare(ByteBuffer d1, int subtypeId1, ByteBuffer d2, int subtypeId2) {
+      int c;
+      if (isLong(d1) && isLong(d2)) {
+        c = SPDecimalExtImpl.compare(d1.getLong(), d2.getLong());
+      } else {
+        c = decode(d1).compareTo(decode(d2));
       }
-      return SPDecimalExtImpl.compare(d1.getLong(), d2.getLong());
+      if (c == 0) c = AbstractSPObject.compare(subtypeId1, subtypeId2);
+      return c;
     }
 
   }

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-08-26 18:31:13 UTC (rev 1181)
+++ trunk/src/jar/store-stringpool/java/org/mulgara/store/stringpool/xa/SPDecimalUnitTest.java	2008-08-26 20:30:01 UTC (rev 1182)
@@ -121,12 +121,11 @@
     assertEquals(VALID_XSD_DECIMAL1, Long.toString(dLong));
 
     // Byte buffer to hold our decimal information
-    ByteBuffer buffer = ByteBuffer.wrap(new byte[Constants.SIZEOF_LONG + 1]);
+    ByteBuffer buffer = ByteBuffer.wrap(new byte[Constants.SIZEOF_LONG]);
 
     // If the previous step passed then we know the long value is what we want,
     // so store it in our buffer
     buffer.putLong(dLong);
-    buffer.put((byte)0);
 
     // Reset the buffer for reading
     buffer.flip();

Modified: trunk/src/jar/store-stringpool/java/org/mulgara/store/stringpool/xa/SPDoubleImpl.java
===================================================================
--- trunk/src/jar/store-stringpool/java/org/mulgara/store/stringpool/xa/SPDoubleImpl.java	2008-08-26 18:31:13 UTC (rev 1181)
+++ trunk/src/jar/store-stringpool/java/org/mulgara/store/stringpool/xa/SPDoubleImpl.java	2008-08-26 20:30:01 UTC (rev 1182)
@@ -160,7 +160,7 @@
       return 0;
     }
 
-    public int compare(ByteBuffer d1, ByteBuffer d2) {
+    public int compare(ByteBuffer d1, int st1, ByteBuffer d2, int st2) {
       return Double.compare(d1.getDouble(), d2.getDouble());
     }
 

Modified: trunk/src/jar/store-stringpool/java/org/mulgara/store/stringpool/xa/SPFloatImpl.java
===================================================================
--- trunk/src/jar/store-stringpool/java/org/mulgara/store/stringpool/xa/SPFloatImpl.java	2008-08-26 18:31:13 UTC (rev 1181)
+++ trunk/src/jar/store-stringpool/java/org/mulgara/store/stringpool/xa/SPFloatImpl.java	2008-08-26 20:30:01 UTC (rev 1182)
@@ -152,7 +152,7 @@
       return 0;
     }
 
-    public int compare(ByteBuffer f1, ByteBuffer f2) {
+    public int compare(ByteBuffer f1, int st1, ByteBuffer f2, int st2) {
       return Float.compare(f1.getFloat(), f2.getFloat());
     }
 

Modified: trunk/src/jar/store-stringpool/java/org/mulgara/store/stringpool/xa/SPGDayImpl.java
===================================================================
--- trunk/src/jar/store-stringpool/java/org/mulgara/store/stringpool/xa/SPGDayImpl.java	2008-08-26 18:31:13 UTC (rev 1181)
+++ trunk/src/jar/store-stringpool/java/org/mulgara/store/stringpool/xa/SPGDayImpl.java	2008-08-26 20:30:01 UTC (rev 1182)
@@ -381,22 +381,9 @@
      * @return Whether the first buffer's content is greater than (> 0), less
      *         than (< 0), or equal to (0) the other
      */
-    public int compare(ByteBuffer d1, ByteBuffer d2) {
-      return compare(d1.getLong(), d2.getLong());
+    public int compare(ByteBuffer d1, int st1, ByteBuffer d2, int st2) {
+      return AbstractSPObject.compare(d1.getLong(), d2.getLong());
     }
 
-    /**
-     * Compares two longs and returns whether the first is equal to (0), greater
-     * than (> 0), or less than (< 0) the second.
-     *
-     * @param a The first long
-     * @param b The second long
-     * @return Whether the first is equal to (0), greater than (> 0), or less
-     *         than (< 0) the second
-     */
-    private static int compare(long a, long b) {
-
-      return a == b ? 0 : (a < b ? -1 : 1);
-    }
   }
 }

Modified: trunk/src/jar/store-stringpool/java/org/mulgara/store/stringpool/xa/SPGDayUnitTest.java
===================================================================
--- trunk/src/jar/store-stringpool/java/org/mulgara/store/stringpool/xa/SPGDayUnitTest.java	2008-08-26 18:31:13 UTC (rev 1181)
+++ trunk/src/jar/store-stringpool/java/org/mulgara/store/stringpool/xa/SPGDayUnitTest.java	2008-08-26 20:30:01 UTC (rev 1182)
@@ -354,6 +354,7 @@
     SPGDayFactory factory = new SPGDayFactory();
 
     // Container for our gDay object
+    @SuppressWarnings("unused")
     SPGDayImpl gDay = null;
 
     // Indicator of whether an exception occurred or not.  Assumed false.
@@ -362,8 +363,7 @@
     try {
 
       // Create a gDay object by lexical string
-      gDay = (SPGDayImpl) factory.newSPTypedLiteral(XSD.GDAY_URI,
-          INVALID_DATE_1);
+      gDay = (SPGDayImpl) factory.newSPTypedLiteral(XSD.GDAY_URI, INVALID_DATE_1);
     } catch (IllegalArgumentException illegalArgumentException) {
 
       // We are expecting an exception so indicate it with the flag
@@ -496,12 +496,12 @@
 
     // Test that two same objects will compare equally by comparator
     assertTrue("Same object did not compare equally by comparator.",
-               comparator.compare(gDay.getData(), gDay.getData()) == 0);
+               comparator.compare(gDay.getData(), 0, gDay.getData(), 0) == 0);
 
     // Test that two different objects will compare inequally by comparator
     assertTrue(
         "Different object was unexpectedly found to compare inequally by comparator.",
-        comparator.compare(gDay.getData(), gDay2.getData()) != 0);
+        comparator.compare(gDay.getData(), 0, gDay2.getData(), 0) != 0);
 
   }
 

Modified: trunk/src/jar/store-stringpool/java/org/mulgara/store/stringpool/xa/SPGMonthDayImpl.java
===================================================================
--- trunk/src/jar/store-stringpool/java/org/mulgara/store/stringpool/xa/SPGMonthDayImpl.java	2008-08-26 18:31:13 UTC (rev 1181)
+++ trunk/src/jar/store-stringpool/java/org/mulgara/store/stringpool/xa/SPGMonthDayImpl.java	2008-08-26 20:30:01 UTC (rev 1182)
@@ -389,22 +389,9 @@
      * @return Whether the first buffer's content is greater than (> 0), less
      *         than (< 0), or equal to (0) the other
      */
-    public int compare(ByteBuffer d1, ByteBuffer d2) {
-      return compare(d1.getLong(), d2.getLong());
+    public int compare(ByteBuffer d1, int st1, ByteBuffer d2, int st2) {
+      return AbstractSPObject.compare(d1.getLong(), d2.getLong());
     }
 
-    /**
-     * Compares two longs and returns whether the first is equal to (0), greater
-     * than (> 0), or less than (< 0) the second.
-     *
-     * @param a The first long
-     * @param b The second long
-     * @return Whether the first is equal to (0), greater than (> 0), or less
-     *         than (< 0) the second
-     */
-    private static int compare(long a, long b) {
-
-      return a == b ? 0 : (a < b ? -1 : 1);
-    }
   }
 }

Modified: trunk/src/jar/store-stringpool/java/org/mulgara/store/stringpool/xa/SPGMonthDayUnitTest.java
===================================================================
--- trunk/src/jar/store-stringpool/java/org/mulgara/store/stringpool/xa/SPGMonthDayUnitTest.java	2008-08-26 18:31:13 UTC (rev 1181)
+++ trunk/src/jar/store-stringpool/java/org/mulgara/store/stringpool/xa/SPGMonthDayUnitTest.java	2008-08-26 20:30:01 UTC (rev 1182)
@@ -27,18 +27,15 @@
 
 package org.mulgara.store.stringpool.xa;
 
-import java.io.*;
 import java.util.Date;
 import java.util.TimeZone;
 import java.text.SimpleDateFormat;
-import java.text.ParseException;
 import java.net.URL;
 import java.net.MalformedURLException;
 import java.nio.ByteBuffer;
 
 // Third party packages
 import junit.framework.*;
-import java.nio.*;
 import org.apache.log4j.*;
 import org.apache.log4j.xml.*;
 
@@ -325,6 +322,7 @@
     SPGMonthDayFactory factory = new SPGMonthDayFactory();
 
     // Container for our gMonthDay object
+    @SuppressWarnings("unused")
     SPGMonthDayImpl gMonthDay = null;
 
     // Indicator of whether an exception occurred or not.  Assumed false.
@@ -333,8 +331,7 @@
     try {
 
       // Create a gMonthDay object by lexical string
-      gMonthDay = (SPGMonthDayImpl) factory.newSPTypedLiteral(XSD.GMONTHDAY_URI,
-          INVALID_DATE_1);
+      gMonthDay = (SPGMonthDayImpl)factory.newSPTypedLiteral(XSD.GMONTHDAY_URI, INVALID_DATE_1);
     } catch (IllegalArgumentException illegalArgumentException) {
 
       // We are expecting an exception so indicate it with the flag
@@ -342,8 +339,7 @@
     }
 
     // Test that we failed to create the object
-    assertTrue("Unexpectedly created a gMonthDay with non-numeric month value.",
-               failed);
+    assertTrue("Unexpectedly created a gMonthDay with non-numeric month value.", failed);
 
     // Reset the failure flag
     failed = false;
@@ -351,8 +347,7 @@
     try {
 
       // Create a gMonthDay object by lexical string
-      gMonthDay = (SPGMonthDayImpl) factory.newSPTypedLiteral(XSD.GMONTHDAY_URI,
-          INVALID_DATE_2);
+      gMonthDay = (SPGMonthDayImpl)factory.newSPTypedLiteral(XSD.GMONTHDAY_URI, INVALID_DATE_2);
     } catch (IllegalArgumentException illegalArgumentException) {
 
       // We are expecting an exception so indicate it with the flag
@@ -360,8 +355,7 @@
     }
 
     // Test that we failed to create the object
-    assertTrue("Unexpectedly created a gMonthDay with invalid lexical format.",
-               failed);
+    assertTrue("Unexpectedly created a gMonthDay with invalid lexical format.", failed);
 
     // Reset the failure flag
     failed = false;
@@ -369,7 +363,7 @@
     try {
 
       // Create a gMonthDay object by lexical string
-      gMonthDay = (SPGMonthDayImpl) factory.newSPTypedLiteral(XSD.GMONTHDAY_URI,
+      gMonthDay = (SPGMonthDayImpl)factory.newSPTypedLiteral(XSD.GMONTHDAY_URI,
           INVALID_DATE_3);
     } catch (IllegalArgumentException illegalArgumentException) {
 
@@ -378,8 +372,7 @@
     }
 
     // Test that we failed to create the object
-    assertTrue("Unexpectedly created a gMonthDay with invalid timezone format.",
-               failed);
+    assertTrue("Unexpectedly created a gMonthDay with invalid timezone format.", failed);
 
     // Reset the failure flag
     failed = false;
@@ -387,8 +380,7 @@
     try {
 
       // Create a gMonthDay object by lexical string
-      gMonthDay = (SPGMonthDayImpl) factory.newSPTypedLiteral(XSD.GMONTHDAY_URI,
-          INVALID_DATE_4);
+      gMonthDay = (SPGMonthDayImpl)factory.newSPTypedLiteral(XSD.GMONTHDAY_URI, INVALID_DATE_4);
     } catch (IllegalArgumentException illegalArgumentException) {
 
       // We are expecting an exception so indicate it with the flag
@@ -396,8 +388,7 @@
     }
 
     // Test that we failed to create the object
-    assertTrue("Unexpectedly created a gMonthDay with invalid month value.",
-               failed);
+    assertTrue("Unexpectedly created a gMonthDay with invalid month value.", failed);
 
     // Reset the failure flag
     failed = false;
@@ -414,8 +405,7 @@
     }
 
     // Test that we failed to create the object
-    assertTrue("Unexpectedly created a gMonthDay with preceding '-'.",
-               failed);
+    assertTrue("Unexpectedly created a gMonthDay with preceding '-'.", failed);
 
     // Reset the failure flag
     failed = false;
@@ -432,8 +422,7 @@
     }
 
     // Test that we failed to create the object
-    assertTrue("Unexpectedly created a gMonthDay with non-numeric day.",
-               failed);
+    assertTrue("Unexpectedly created a gMonthDay with non-numeric day.", failed);
 
     // Reset the failure flag
     failed = false;
@@ -441,7 +430,7 @@
     try {
 
       // Create a gMonthDay object by lexical string
-      gMonthDay = (SPGMonthDayImpl) factory.newSPTypedLiteral(XSD.GMONTHDAY_URI,
+      gMonthDay = (SPGMonthDayImpl)factory.newSPTypedLiteral(XSD.GMONTHDAY_URI,
           INVALID_DATE_7);
     } catch (IllegalArgumentException illegalArgumentException) {
 
@@ -450,8 +439,7 @@
     }
 
     // Test that we failed to create the object
-    assertTrue("Unexpectedly created a gMonthDay with invalid day value.",
-               failed);
+    assertTrue("Unexpectedly created a gMonthDay with invalid day value.", failed);
 
     // Reset the failure flag
     failed = false;
@@ -459,8 +447,7 @@
     try {
 
       // Create a gMonthDay object by lexical string
-      gMonthDay = (SPGMonthDayImpl) factory.newSPTypedLiteral(XSD.GMONTHDAY_URI,
-          INVALID_DATE_8);
+      gMonthDay = (SPGMonthDayImpl)factory.newSPTypedLiteral(XSD.GMONTHDAY_URI, INVALID_DATE_8);
     } catch (IllegalArgumentException illegalArgumentException) {
 
       // We are expecting an exception so indicate it with the flag
@@ -468,8 +455,7 @@
     }
 
     // Test that we failed to create the object
-    assertTrue("Unexpectedly created a gMonthDay with invalid day lexical value.",
-               failed);
+    assertTrue("Unexpectedly created a gMonthDay with invalid day lexical value.", failed);
 
     // Reset the failure flag
     failed = false;
@@ -477,8 +463,7 @@
     try {
 
       // Create a gMonthDay object by lexical string
-      gMonthDay = (SPGMonthDayImpl) factory.newSPTypedLiteral(XSD.GMONTHDAY_URI,
-          INVALID_DATE_9);
+      gMonthDay = (SPGMonthDayImpl) factory.newSPTypedLiteral(XSD.GMONTHDAY_URI, INVALID_DATE_9);
     } catch (IllegalArgumentException illegalArgumentException) {
 
       // We are expecting an exception so indicate it with the flag
@@ -504,8 +489,7 @@
 
     // Create a gMonthDay object that is different
     SPGMonthDayImpl gMonthDay2 = (SPGMonthDayImpl) factory.newSPTypedLiteral(
-        XSD.
-        GMONTHDAY_URI, "--06-01");
+        XSD.GMONTHDAY_URI, "--06-01");
 
     // Test that two same objects will be equal
     assertTrue("Same object did not register as equal.",
@@ -541,13 +525,12 @@
 
     // Test that two same objects will compare equally by comparator
     assertTrue("Same object did not compare equally by comparator.",
-               comparator.compare(gMonthDay.getData(), gMonthDay.getData()) ==
-               0);
+               comparator.compare(gMonthDay.getData(), 0, gMonthDay.getData(), 0) == 0);
 
     // Test that two different objects will compare inequally by comparator
     assertTrue(
         "Different object was unexpectedly found to compare inequally by comparator.",
-        comparator.compare(gMonthDay.getData(), gMonthDay2.getData()) != 0);
+        comparator.compare(gMonthDay.getData(), 0, gMonthDay2.getData(), 0) != 0);
 
   }
 

Modified: trunk/src/jar/store-stringpool/java/org/mulgara/store/stringpool/xa/SPGMonthImpl.java
===================================================================
--- trunk/src/jar/store-stringpool/java/org/mulgara/store/stringpool/xa/SPGMonthImpl.java	2008-08-26 18:31:13 UTC (rev 1181)
+++ trunk/src/jar/store-stringpool/java/org/mulgara/store/stringpool/xa/SPGMonthImpl.java	2008-08-26 20:30:01 UTC (rev 1182)
@@ -377,22 +377,9 @@
      * @return Whether the first buffer's content is greater than (> 0), less
      *         than (< 0), or equal to (0) the other
      */
-    public int compare(ByteBuffer d1, ByteBuffer d2) {
-      return compare(d1.getLong(), d2.getLong());
+    public int compare(ByteBuffer d1, int st1, ByteBuffer d2, int st2) {
+      return AbstractSPObject.compare(d1.getLong(), d2.getLong());
     }
 
-    /**
-     * Compares two longs and returns whether the first is equal to (0), greater
-     * than (> 0), or less than (< 0) the second.
-     *
-     * @param a The first long
-     * @param b The second long
-     * @return Whether the first is equal to (0), greater than (> 0), or less
-     *         than (< 0) the second
-     */
-    private static int compare(long a, long b) {
-
-      return a == b ? 0 : (a < b ? -1 : 1);
-    }
   }
 }

Modified: trunk/src/jar/store-stringpool/java/org/mulgara/store/stringpool/xa/SPGMonthUnitTest.java
===================================================================
--- trunk/src/jar/store-stringpool/java/org/mulgara/store/stringpool/xa/SPGMonthUnitTest.java	2008-08-26 18:31:13 UTC (rev 1181)
+++ trunk/src/jar/store-stringpool/java/org/mulgara/store/stringpool/xa/SPGMonthUnitTest.java	2008-08-26 20:30:01 UTC (rev 1182)
@@ -27,17 +27,14 @@
 
 package org.mulgara.store.stringpool.xa;
 
-import java.io.*;
 import java.util.Date;
 import java.text.SimpleDateFormat;
-import java.text.ParseException;
 import java.net.URL;
 import java.net.MalformedURLException;
 import java.nio.ByteBuffer;
 
 // Third party packages
 import junit.framework.*;
-import java.nio.*;
 import org.apache.log4j.*;
 import org.apache.log4j.xml.*;
 
@@ -235,8 +232,7 @@
                ("" + month).equals(VALID_DATE));
 
     // Create a gMonth object by lexical string (testing range acceptance)
-    gMonth = (SPGMonthImpl) factory.newSPTypedLiteral(XSD.GMONTH_URI,
-        VALID_DATE2);
+    gMonth = (SPGMonthImpl) factory.newSPTypedLiteral(XSD.GMONTH_URI, VALID_DATE2);
 
     // Test that the lexical form of the date is correct
     assertTrue("GMonth lexical form was not " + VALID_DATE3 +
@@ -323,6 +319,7 @@
     SPGMonthFactory factory = new SPGMonthFactory();
 
     // Container for our gMonth object
+    @SuppressWarnings("unused")
     SPGMonthImpl gMonth = null;
 
     // Indicator of whether an exception occurred or not.  Assumed false.
@@ -331,8 +328,7 @@
     try {
 
       // Create a gMonth object by lexical string
-      gMonth = (SPGMonthImpl) factory.newSPTypedLiteral(XSD.GMONTH_URI,
-          INVALID_DATE_1);
+      gMonth = (SPGMonthImpl) factory.newSPTypedLiteral(XSD.GMONTH_URI, INVALID_DATE_1);
     } catch (IllegalArgumentException illegalArgumentException) {
 
       // We are expecting an exception so indicate it with the flag
@@ -340,8 +336,7 @@
     }
 
     // Test that we failed to create the object
-    assertTrue("Unexpectedly created a gMonth with non-numeric characters",
-               failed);
+    assertTrue("Unexpectedly created a gMonth with non-numeric characters", failed);
 
     // Reset the failure flag
     failed = false;
@@ -349,8 +344,7 @@
     try {
 
       // Create a gMonth object by lexical string
-      gMonth = (SPGMonthImpl) factory.newSPTypedLiteral(XSD.GMONTH_URI,
-          INVALID_DATE_2);
+      gMonth = (SPGMonthImpl) factory.newSPTypedLiteral(XSD.GMONTH_URI, INVALID_DATE_2);
     } catch (IllegalArgumentException illegalArgumentException) {
 
       // We are expecting an exception so indicate it with the flag
@@ -358,8 +352,7 @@
     }
 
     // Test that we failed to create the object
-    assertTrue("Unexpectedly created a gMonth with invalid lexical format.",
-               failed);
+    assertTrue("Unexpectedly created a gMonth with invalid lexical format.", failed);
 
     // Reset the failure flag
     failed = false;
@@ -367,8 +360,7 @@
     try {
 
       // Create a gMonth object by lexical string
-      gMonth = (SPGMonthImpl) factory.newSPTypedLiteral(XSD.GMONTH_URI,
-          INVALID_DATE_3);
+      gMonth = (SPGMonthImpl) factory.newSPTypedLiteral(XSD.GMONTH_URI, INVALID_DATE_3);
     } catch (IllegalArgumentException illegalArgumentException) {
 
       // We are expecting an exception so indicate it with the flag
@@ -376,8 +368,7 @@
     }
 
     // Test that we failed to create the object
-    assertTrue("Unexpectedly created a gMonth with invalid timezone format.",
-               failed);
+    assertTrue("Unexpectedly created a gMonth with invalid timezone format.", failed);
 
     // Reset the failure flag
     failed = false;
@@ -385,8 +376,7 @@
     try {
 
       // Create a gMonth object by lexical string
-      gMonth = (SPGMonthImpl) factory.newSPTypedLiteral(XSD.GMONTH_URI,
-          INVALID_DATE_4);
+      gMonth = (SPGMonthImpl) factory.newSPTypedLiteral(XSD.GMONTH_URI, INVALID_DATE_4);
     } catch (IllegalArgumentException illegalArgumentException) {
 
       // We are expecting an exception so indicate it with the flag
@@ -394,8 +384,7 @@
     }
 
     // Test that we failed to create the object
-    assertTrue("Unexpectedly created a gMonth with invalid date value.",
-               failed);
+    assertTrue("Unexpectedly created a gMonth with invalid date value.", failed);
 
     // Reset the failure flag
     failed = false;
@@ -403,8 +392,7 @@
     try {
 
       // Create a gMonth object by lexical string
-      gMonth = (SPGMonthImpl) factory.newSPTypedLiteral(XSD.GMONTH_URI,
-          INVALID_DATE_5);
+      gMonth = (SPGMonthImpl) factory.newSPTypedLiteral(XSD.GMONTH_URI, INVALID_DATE_5);
     } catch (IllegalArgumentException illegalArgumentException) {
 
       // We are expecting an exception so indicate it with the flag
@@ -412,8 +400,7 @@
     }
 
     // Test that we failed to create the object
-    assertTrue("Unexpectedly created a gMonth with preceding '-'.",
-               failed);
+    assertTrue("Unexpectedly created a gMonth with preceding '-'.", failed);
   }
 
   /**
@@ -425,12 +412,10 @@
     SPGMonthFactory factory = new SPGMonthFactory();
 
     // Create a gMonth object by lexical string
-    SPGMonthImpl gMonth = (SPGMonthImpl) factory.newSPTypedLiteral(XSD.
-        GMONTH_URI, VALID_DATE);
+    SPGMonthImpl gMonth = (SPGMonthImpl) factory.newSPTypedLiteral(XSD.GMONTH_URI, VALID_DATE);
 
     // Create a gMonth object that is different
-    SPGMonthImpl gMonth2 = (SPGMonthImpl) factory.newSPTypedLiteral(XSD.
-        GMONTH_URI,"--06");
+    SPGMonthImpl gMonth2 = (SPGMonthImpl) factory.newSPTypedLiteral(XSD.GMONTH_URI,"--06");
 
     // Test that two same objects will be equal
     assertTrue("Same object did not register as equal.", gMonth.equals(gMonth));
@@ -465,12 +450,12 @@
 
     // Test that two same objects will compare equally by comparator
     assertTrue("Same object did not compare equally by comparator.",
-               comparator.compare(gMonth.getData(), gMonth.getData()) == 0);
+               comparator.compare(gMonth.getData(), 0, gMonth.getData(), 0) == 0);
 
     // Test that two different objects will compare inequally by comparator
     assertTrue(
         "Different object was unexpectedly found to compare inequally by comparator.",
-        comparator.compare(gMonth.getData(), gMonth2.getData()) != 0);
+        comparator.compare(gMonth.getData(), 0, gMonth2.getData(), 0) != 0);
 
   }
 
@@ -502,8 +487,7 @@
     } catch (Exception exception) {
 
       // Fail the test if we cannot tear down
-      fail("Failed to tear down members after testing. " +
-           exception.getMessage());
+      fail("Failed to tear down members after testing. " + exception.getMessage());
     }
   }
 }

Modified: trunk/src/jar/store-stringpool/java/org/mulgara/store/stringpool/xa/SPGYearImpl.java
===================================================================
--- trunk/src/jar/store-stringpool/java/org/mulgara/store/stringpool/xa/SPGYearImpl.java	2008-08-26 18:31:13 UTC (rev 1181)
+++ trunk/src/jar/store-stringpool/java/org/mulgara/store/stringpool/xa/SPGYearImpl.java	2008-08-26 20:30:01 UTC (rev 1182)
@@ -344,22 +344,9 @@
      * @return Whether the first buffer's content is greater than (> 0), less
      *         than (< 0), or equal to (0) the other
      */
-    public int compare(ByteBuffer d1, ByteBuffer d2) {
-      return compare(d1.getLong(), d2.getLong());
+    public int compare(ByteBuffer d1, int st1, ByteBuffer d2, int st2) {
+      return AbstractSPObject.compare(d1.getLong(), d2.getLong());
     }
 
-    /**
-     * Compares two longs and returns whether the first is equal to (0), greater
-     * than (> 0), or less than (< 0) the second.
-     *
-     * @param a The first long
-     * @param b The second long
-     * @return Whether the first is equal to (0), greater than (> 0), or less
-     *         than (< 0) the second
-     */
-    private static int compare(long a, long b) {
-
-      return a == b ? 0 : (a < b ? -1 : 1);
-    }
   }
 }

Modified: trunk/src/jar/store-stringpool/java/org/mulgara/store/stringpool/xa/SPGYearMonthImpl.java
===================================================================
--- trunk/src/jar/store-stringpool/java/org/mulgara/store/stringpool/xa/SPGYearMonthImpl.java	2008-08-26 18:31:13 UTC (rev 1181)
+++ trunk/src/jar/store-stringpool/java/org/mulgara/store/stringpool/xa/SPGYearMonthImpl.java	2008-08-26 20:30:01 UTC (rev 1182)
@@ -370,22 +370,9 @@
      * @return Whether the first buffer's content is greater than (> 0), less
      *         than (< 0), or equal to (0) the other
      */
-    public int compare(ByteBuffer d1, ByteBuffer d2) {
-      return compare(d1.getLong(), d2.getLong());
+    public int compare(ByteBuffer d1, int st1, ByteBuffer d2, int st2) {
+      return AbstractSPObject.compare(d1.getLong(), d2.getLong());
     }
 
-    /**
-     * Compares two longs and returns whether the first is equal to (0), greater
-     * than (> 0), or less than (< 0) the second.
-     *
-     * @param a The first long
-     * @param b The second long
-     * @return Whether the first is equal to (0), greater than (> 0), or less
-     *         than (< 0) the second
-     */
-    private static int compare(long a, long b) {
-
-      return a == b ? 0 : (a < b ? -1 : 1);
-    }
   }
 }

Modified: trunk/src/jar/store-stringpool/java/org/mulgara/store/stringpool/xa/SPGYearMonthUnitTest.java
===================================================================
--- trunk/src/jar/store-stringpool/java/org/mulgara/store/stringpool/xa/SPGYearMonthUnitTest.java	2008-08-26 18:31:13 UTC (rev 1181)
+++ trunk/src/jar/store-stringpool/java/org/mulgara/store/stringpool/xa/SPGYearMonthUnitTest.java	2008-08-26 20:30:01 UTC (rev 1182)
@@ -27,17 +27,14 @@
 
 package org.mulgara.store.stringpool.xa;
 
-import java.io.*;
 import java.util.Date;
 import java.text.SimpleDateFormat;
-import java.text.ParseException;
 import java.net.URL;
 import java.net.MalformedURLException;
 import java.nio.ByteBuffer;
 
 // Third party packages
 import junit.framework.*;
-import java.nio.*;
 import org.apache.log4j.*;
 import org.apache.log4j.xml.*;
 
@@ -330,6 +327,7 @@
     SPGYearMonthFactory factory = new SPGYearMonthFactory();
 
     // Container for our gYearMonth object
+    @SuppressWarnings("unused")
     SPGYearMonthImpl gYearMonth = null;
 
     // Indicator of whether an exception occurred or not.  Assumed false.
@@ -498,13 +496,12 @@
 
     // Test that two same objects will compare equally by comparator
     assertTrue("Same object did not compare equally by comparator.",
-               comparator.compare(gYearMonth.getData(), gYearMonth.getData()) ==
-               0);
+               comparator.compare(gYearMonth.getData(), 0, gYearMonth.getData(), 0) == 0);
 
     // Test that two different objects will compare inequally by comparator
     assertTrue(
         "Different object was unexpectedly found to compare inequally by comparator.",
-        comparator.compare(gYearMonth.getData(), gYearMonth2.getData()) != 0);
+        comparator.compare(gYearMonth.getData(), 0, gYearMonth2.getData(), 0) != 0);
 
   }
 

Modified: trunk/src/jar/store-stringpool/java/org/mulgara/store/stringpool/xa/SPGYearUnitTest.java
===================================================================
--- trunk/src/jar/store-stringpool/java/org/mulgara/store/stringpool/xa/SPGYearUnitTest.java	2008-08-26 18:31:13 UTC (rev 1181)
+++ trunk/src/jar/store-stringpool/java/org/mulgara/store/stringpool/xa/SPGYearUnitTest.java	2008-08-26 20:30:01 UTC (rev 1182)
@@ -27,17 +27,14 @@
 
 package org.mulgara.store.stringpool.xa;
 
-import java.io.*;
 import java.util.Date;
 import java.text.SimpleDateFormat;
-import java.text.ParseException;
 import java.net.URL;
 import java.net.MalformedURLException;
 import java.nio.ByteBuffer;
 
 // Third party packages
 import junit.framework.*;
-import java.nio.*;
 import org.apache.log4j.*;
 import org.apache.log4j.xml.*;
 
@@ -314,6 +311,7 @@
     SPGYearFactory factory = new SPGYearFactory();
 
     // Container for our gYear object
+    @SuppressWarnings("unused")
     SPGYearImpl gYear = null;
 
     // Indicator of whether an exception occurred or not.  Assumed false.
@@ -322,8 +320,7 @@
     try {
 
       // Create a gYear object by lexical string
-      gYear = (SPGYearImpl) factory.newSPTypedLiteral(XSD.GYEAR_URI,
-          INVALID_DATE_1);
+      gYear = (SPGYearImpl) factory.newSPTypedLiteral(XSD.GYEAR_URI, INVALID_DATE_1);
     } catch (IllegalArgumentException illegalArgumentException) {
 
       // We are expecting an exception so indicate it with the flag
@@ -331,8 +328,7 @@
     }
 
     // Test that we failed to create the object
-    assertTrue("Unexpectedly created a gYear with non-numeric characters",
-               failed);
+    assertTrue("Unexpectedly created a gYear with non-numeric characters", failed);
 
     // Reset the failure flag
     failed = false;
@@ -340,8 +336,7 @@
     try {
 
       // Create a gYear object by lexical string
-      gYear = (SPGYearImpl) factory.newSPTypedLiteral(XSD.GYEAR_URI,
-          INVALID_DATE_2);
+      gYear = (SPGYearImpl) factory.newSPTypedLiteral(XSD.GYEAR_URI, INVALID_DATE_2);
     } catch (IllegalArgumentException illegalArgumentException) {
 
       // We are expecting an exception so indicate it with the flag
@@ -349,8 +344,7 @@
     }
 
     // Test that we failed to create the object
-    assertTrue("Unexpectedly created a gYear with invalid lexical format.",
-               failed);
+    assertTrue("Unexpectedly created a gYear with invalid lexical format.", failed);
 
     // Reset the failure flag
     failed = false;
@@ -358,8 +352,7 @@
     try {
 
       // Create a gYear object by lexical string
-      gYear = (SPGYearImpl) factory.newSPTypedLiteral(XSD.GYEAR_URI,
-          INVALID_DATE_3);
+      gYear = (SPGYearImpl) factory.newSPTypedLiteral(XSD.GYEAR_URI, INVALID_DATE_3);
     } catch (IllegalArgumentException illegalArgumentException) {
 
       // We are expecting an exception so indicate it with the flag
@@ -367,8 +360,7 @@
     }
 
     // Test that we failed to create the object
-    assertTrue("Unexpectedly created a gYear with invalid timezone format.",
-               failed);
+    assertTrue("Unexpectedly created a gYear with invalid timezone format.", failed);
 
   }
 
@@ -381,23 +373,19 @@
     SPGYearFactory factory = new SPGYearFactory();
 
     // Create a gYear object by lexical string
-    SPGYearImpl gYear = (SPGYearImpl) factory.newSPTypedLiteral(XSD.GYEAR_URI,
-        VALID_DATE);
+    SPGYearImpl gYear = (SPGYearImpl) factory.newSPTypedLiteral(XSD.GYEAR_URI, VALID_DATE);
 
     // Create a gYear object that is different
-    SPGYearImpl gYear2 = (SPGYearImpl) factory.newSPTypedLiteral(XSD.GYEAR_URI,
-        VALID_DATE2);
+    SPGYearImpl gYear2 = (SPGYearImpl) factory.newSPTypedLiteral(XSD.GYEAR_URI, VALID_DATE2);
 
     // Test that two same objects will be equal
     assertTrue("Same object did not register as equal.", gYear.equals(gYear));
 
     // Test that two different objects will be inequal
-    assertTrue("Different object was unexpectedly found to be equal.",
-               !gYear.equals(gYear2));
+    assertTrue("Different object was unexpectedly found to be equal.", !gYear.equals(gYear2));
 
     // Test that two same objects will compare equally
-    assertTrue("Same object did not compare equally.",
-               gYear.compareTo(gYear) == 0);
+    assertTrue("Same object did not compare equally.", gYear.compareTo(gYear) == 0);
 
     // Test that two different objects will compare inequally
     assertTrue("Different object was unexpectedly found to compare equally.",
@@ -421,12 +409,12 @@
 
     // Test that two same objects will compare equally by comparator
     assertTrue("Same object did not compare equally by comparator.",
-               comparator.compare(gYear.getData(), gYear.getData()) == 0);
+               comparator.compare(gYear.getData(), 0, gYear.getData(), 0) == 0);
 
     // Test that two different objects will compare inequally by comparator
     assertTrue(
         "Different object was unexpectedly found to compare inequally by comparator.",
-        comparator.compare(gYear.getData(), gYear2.getData()) != 0);
+        comparator.compare(gYear.getData(), 0, gYear2.getData(), 0) != 0);
 
   }
 
@@ -458,8 +446,7 @@
     } catch (Exception exception) {
 
       // Fail the test if we cannot tear down
-      fail("Failed to tear down members after testing. " +
-           exception.getMessage());
+      fail("Failed to tear down members after testing. " + exception.getMessage());
     }
   }
 }

Modified: trunk/src/jar/store-stringpool/java/org/mulgara/store/stringpool/xa/SPHexBinaryUnitTest.java
===================================================================
--- trunk/src/jar/store-stringpool/java/org/mulgara/store/stringpool/xa/SPHexBinaryUnitTest.java	2008-08-26 18:31:13 UTC (rev 1181)
+++ trunk/src/jar/store-stringpool/java/org/mulgara/store/stringpool/xa/SPHexBinaryUnitTest.java	2008-08-26 20:30:01 UTC (rev 1182)
@@ -27,11 +27,8 @@
 
 package org.mulgara.store.stringpool.xa;
 
-import java.io.*;
-
 // Third party packages
 import junit.framework.*;
-import java.nio.*;
 import org.mulgara.query.rdf.*;
 import org.mulgara.store.stringpool.*;
 

Modified: trunk/src/jar/store-stringpool/java/org/mulgara/store/stringpool/xa/SPXMLLiteralUnitTest.java
===================================================================
--- trunk/src/jar/store-stringpool/java/org/mulgara/store/stringpool/xa/SPXMLLiteralUnitTest.java	2008-08-26 18:31:13 UTC (rev 1181)
+++ trunk/src/jar/store-stringpool/java/org/mulgara/store/stringpool/xa/SPXMLLiteralUnitTest.java	2008-08-26 20:30:01 UTC (rev 1182)
@@ -27,18 +27,12 @@
 
 package org.mulgara.store.stringpool.xa;
 
-import java.io.*;
-import java.nio.*;
-
 // JRDF
 import org.jrdf.vocabulary.RDF;
 
 // Third party packages
 import junit.framework.*;
 
-import org.mulgara.query.rdf.XSD;
-import org.mulgara.store.stringpool.*;
-
 /**
  * Unit test for {@link SPXMLLiteralImpl}
  *
@@ -174,25 +168,23 @@
   public void testInvalid() throws Exception {
 
     SPXMLLiteralFactory factory = new SPXMLLiteralFactory();
+
+    @SuppressWarnings("unused")
     SPXMLLiteralImpl text;
 
     // Test with a tag.
     try {
-      text = (SPXMLLiteralImpl) factory.newSPTypedLiteral(
-          RDF.XML_LITERAL, "<foo>Hello there</bar>");
+      text = (SPXMLLiteralImpl) factory.newSPTypedLiteral(RDF.XML_LITERAL, "<foo>Hello there</bar>");
       fail("Should be invalid");
+    } catch (IllegalArgumentException iae) {
     }
-    catch (IllegalArgumentException iae) {
-    }
 
     // Test nested tags
     try {
-      text = (SPXMLLiteralImpl) factory.newSPTypedLiteral(
-          RDF.XML_LITERAL, "<bar><foo>Hello there</bar></foo>");
+      text = (SPXMLLiteralImpl) factory.newSPTypedLiteral(RDF.XML_LITERAL, "<bar><foo>Hello there</bar></foo>");
       fail("Should be invalid");
+    } catch (IllegalArgumentException iae) {
     }
-    catch (IllegalArgumentException iae) {
-    }
   }
 
   //set up and tear down

Modified: trunk/src/jar/store-stringpool/java/org/mulgara/store/stringpool/xa/UnknownSPTypedLiteralFactory.java
===================================================================
--- trunk/src/jar/store-stringpool/java/org/mulgara/store/stringpool/xa/UnknownSPTypedLiteralFactory.java	2008-08-26 18:31:13 UTC (rev 1181)
+++ trunk/src/jar/store-stringpool/java/org/mulgara/store/stringpool/xa/UnknownSPTypedLiteralFactory.java	2008-08-26 20:30:01 UTC (rev 1182)
@@ -59,6 +59,7 @@
 public final class UnknownSPTypedLiteralFactory
   implements SPTypedLiteralFactory
 {
+  @SuppressWarnings("unused")
   private final static Logger logger =
       Logger.getLogger(UnknownSPTypedLiteralFactory.class.getName());
 
@@ -66,7 +67,7 @@
     return UnknownSPTypedLiteralImpl.TYPE_ID;
   }
 
-  public Set getTypeURIs() {
+  public Set<URI> getTypeURIs() {
     throw new UnsupportedOperationException("Unknown types");
   }
 

Modified: trunk/src/jar/store-stringpool/java/org/mulgara/store/stringpool/xa/UnknownSPTypedLiteralUnitTest.java
===================================================================
--- trunk/src/jar/store-stringpool/java/org/mulgara/store/stringpool/xa/UnknownSPTypedLiteralUnitTest.java	2008-08-26 18:31:13 UTC (rev 1181)
+++ trunk/src/jar/store-stringpool/java/org/mulgara/store/stringpool/xa/UnknownSPTypedLiteralUnitTest.java	2008-08-26 20:30:01 UTC (rev 1182)
@@ -29,7 +29,6 @@
 
 // Java 2 standard packages
 import java.net.URI;
-import java.nio.ByteBuffer;
 import java.nio.charset.Charset;
 
 // Third party packages

Modified: trunk/src/jar/store-stringpool-xa/java/org/mulgara/store/stringpool/xa/XAStringPoolImpl.java
===================================================================
--- trunk/src/jar/store-stringpool-xa/java/org/mulgara/store/stringpool/xa/XAStringPoolImpl.java	2008-08-26 18:31:13 UTC (rev 1181)
+++ trunk/src/jar/store-stringpool-xa/java/org/mulgara/store/stringpool/xa/XAStringPoolImpl.java	2008-08-26 20:30:01 UTC (rev 1182)
@@ -1398,7 +1398,7 @@
         }
         ByteBuffer data = spObject.getData();
         SPComparator spComparator = spObject.getSPComparator();
-        AVLComparator avlComparator = new SPAVLComparator(spComparator, typeCategory, typeId, data);
+        AVLComparator avlComparator = new SPAVLComparator(spComparator, typeCategory, typeId, subtypeId, data);
 
         // Find the adjacent nodes.
         findResult = avlFilePhase.find(avlComparator, null);
@@ -1625,12 +1625,18 @@
         }
 
         SPObject.TypeCategory typeCategory = spObject.getTypeCategory();
-        int typeId = typeCategory == SPObject.TypeCategory.TYPED_LITERAL ?
-            ((SPTypedLiteral)spObject).getTypeId() :
-            SPObjectFactory.INVALID_TYPE_ID;
+        int typeId;
+        int subtypeId;
+        if (typeCategory == SPObject.TypeCategory.TYPED_LITERAL) {
+          typeId = ((SPTypedLiteral)spObject).getTypeId();
+          subtypeId = ((SPTypedLiteral)spObject).getSubtypeId();
+        } else {
+          typeId = SPObjectFactory.INVALID_TYPE_ID;
+          subtypeId = 0;
+        }
         ByteBuffer data = spObject.getData();
         SPComparator spComparator = spObject.getSPComparator();
-        AVLComparator avlComparator = new SPAVLComparator(spComparator, typeCategory, typeId, data);
+        AVLComparator avlComparator = new SPAVLComparator(spComparator, typeCategory, typeId, subtypeId, data);
 
         // Find the SPObject.
         AVLNode[] findResult = avlFilePhase.find(avlComparator, null);
@@ -1700,7 +1706,7 @@
           }
           ByteBuffer data = spObject.getData();
           SPComparator spComparator = spObject.getSPComparator();
-          AVLComparator avlComparator = new SPAVLComparator(spComparator, typeCategory, typeId, data);
+          AVLComparator avlComparator = new SPAVLComparator(spComparator, typeCategory, typeId, subtypeId, data);
 
           // Find the SPObject.
           findResult = avlFilePhase.find(avlComparator, null);
@@ -1854,6 +1860,7 @@
     ) throws StringPoolException {
       SPObject.TypeCategory typeCategory;
       int typeId;
+      int subtypeId;
       AVLNode lowAVLNode;
       long highAVLNodeId;
 
@@ -1861,6 +1868,7 @@
         // Return all nodes in the index.
         typeCategory = null;
         typeId = SPObjectFactory.INVALID_TYPE_ID;
+        subtypeId = 0;
         lowAVLNode = avlFilePhase.getRootNode();
         if (lowAVLNode != null) lowAVLNode = lowAVLNode.getMinNode_R();
         highAVLNodeId = Block.INVALID_BLOCK_ID;
@@ -1868,8 +1876,13 @@
         // Get the type category.
         SPObject typeValue = lowValue != null ? lowValue : highValue;
         typeCategory = typeValue.getTypeCategory();
-        typeId = typeCategory == SPObject.TypeCategory.TYPED_LITERAL ?
-                 ((SPTypedLiteral)typeValue).getTypeId() : SPObjectFactory.INVALID_TYPE_ID;
+        if (typeCategory == SPObject.TypeCategory.TYPED_LITERAL) {
+          typeId = ((SPTypedLiteral)typeValue).getTypeId();
+          subtypeId = ((SPTypedLiteral)typeValue).getSubtypeId();
+        } else {
+          typeId = SPObjectFactory.INVALID_TYPE_ID;
+          subtypeId = 0;
+        }
 
         // Check that the two SPObjects are of the same type.
         if (lowValue != null && highValue != null) {
@@ -1903,7 +1916,7 @@
         if (lowValue != null) {
           ByteBuffer data = lowValue.getData();
           SPComparator spComparator = lowValue.getSPComparator();
-          lowComparator = new SPAVLComparator(spComparator, typeCategory, typeId, data);
+          lowComparator = new SPAVLComparator(spComparator, typeCategory, typeId, subtypeId, data);
         } else {
           // Select the first node with the current type.
           if (typeCategory == SPObject.TypeCategory.TYPED_LITERAL) {
@@ -1918,7 +1931,7 @@
         if (highValue != null) {
           ByteBuffer data = highValue.getData();
           SPComparator spComparator = highValue.getSPComparator();
-          highComparator = new SPAVLComparator(spComparator, typeCategory, typeId, data);
+          highComparator = new SPAVLComparator(spComparator, typeCategory, typeId, subtypeId, data);
         } else {
           // Select the first node past the last one that has the current type.
           if (typeCategory == SPObject.TypeCategory.TYPED_LITERAL) {
@@ -2691,12 +2704,14 @@
       private final SPComparator spComparator;
       private final SPObject.TypeCategory typeCategory;
       private final int typeId;
+      private final int subtypeId;
       private final ByteBuffer data;
 
-      SPAVLComparator(SPComparator spComparator, SPObject.TypeCategory typeCategory, int typeId, ByteBuffer data) {
+      SPAVLComparator(SPComparator spComparator, SPObject.TypeCategory typeCategory, int typeId, int subtypeId, ByteBuffer data) {
         this.spComparator = spComparator;
         this.typeCategory = typeCategory;
         this.typeId = typeId;
+        this.subtypeId = subtypeId;
         this.data = data;
       }
 
@@ -2712,6 +2727,8 @@
         int nodeTypeId = avlNode.getPayloadByte(IDX_TYPE_ID_B);
         if (typeId != nodeTypeId) return typeId < nodeTypeId ? -1 : 1;
 
+        int nodeSubtypeId = avlNode.getPayloadByte(IDX_SUBTYPE_ID_B);
+
         // Finally, defer to the SPComparator.
         int dataSize = avlNode.getPayloadInt(IDX_DATA_SIZE_I);
 
@@ -2760,7 +2777,7 @@
 
         data.rewind();
         nodeData.rewind();
-        return spComparator.compare(data, nodeData);
+        return spComparator.compare(data, subtypeId, nodeData, nodeSubtypeId);
       }
 
     }

Modified: trunk/src/jar/store-stringpool-xa11/java/org/mulgara/store/stringpool/xa11/DataAVLComparator.java
===================================================================
--- trunk/src/jar/store-stringpool-xa11/java/org/mulgara/store/stringpool/xa11/DataAVLComparator.java	2008-08-26 18:31:13 UTC (rev 1181)
+++ trunk/src/jar/store-stringpool-xa11/java/org/mulgara/store/stringpool/xa11/DataAVLComparator.java	2008-08-26 20:30:01 UTC (rev 1182)
@@ -34,13 +34,15 @@
   private final SPComparator spComparator;
   private final int typeCategoryId;
   private final int typeId;
+  private final int subtypeId;
   private final ByteBuffer data;
   private final RandomAccessFile readOnlyFlatFile;
 
-  DataAVLComparator(SPComparator spComparator, SPObject.TypeCategory typeCategory, int typeId, ByteBuffer data, RandomAccessFile flatFile) {
+  DataAVLComparator(SPComparator spComparator, SPObject.TypeCategory typeCategory, int typeId, int subtypeId, ByteBuffer data, RandomAccessFile flatFile) {
     this.spComparator = spComparator;
     this.typeCategoryId = typeCategory.ID;
     this.typeId = typeId;
+    this.subtypeId = subtypeId;
     this.data = data;
     this.readOnlyFlatFile = flatFile;
   }
@@ -49,6 +51,7 @@
     this.spComparator = spComparator;
     this.typeCategoryId = dataStruct.getTypeCategoryId();
     this.typeId = dataStruct.getTypeId();
+    this.subtypeId = dataStruct.getSubtypeId();
     this.data = dataStruct.getData();
     this.readOnlyFlatFile = readOnlyFlatFile;
   }
@@ -68,6 +71,8 @@
     int nodeTypeId = DataStruct.getTypeId(avlNode);
     if (typeId != nodeTypeId) return typeId < nodeTypeId ? -1 : 1;
 
+    int nodeSubtypeId = DataStruct.getSubtypeId(avlNode);
+
     // Finally, defer to the SPComparator.
     int dataSize = DataStruct.getDataSize(avlNode);
 
@@ -100,7 +105,7 @@
 
     data.rewind();
     nodeData.rewind();
-    return spComparator.compare(data, nodeData);
+    return spComparator.compare(data, subtypeId, nodeData, nodeSubtypeId);
   }
 
 }




More information about the Mulgara-svn mailing list