You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jena.apache.org by an...@apache.org on 2012/10/22 13:57:15 UTC

svn commit: r1400849 - in /jena/trunk/jena-core/src: main/java/com/hp/hpl/jena/datatypes/xsd/ test/java/com/hp/hpl/jena/graph/test/

Author: andy
Date: Mon Oct 22 11:57:15 2012
New Revision: 1400849

URL: http://svn.apache.org/viewvc?rev=1400849&view=rev
Log:
JENA-335 : Make XSDbase64binary as registered handler for byte[] (this is the original behaviour, pre JENA-335).  Do not register XSDhexBinary.

Modified:
    jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/datatypes/xsd/XSDbase64Binary.java
    jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/datatypes/xsd/XSDbinary.java
    jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/datatypes/xsd/XSDhexBinary.java
    jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/graph/test/TestTypedLiterals.java

Modified: jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/datatypes/xsd/XSDbase64Binary.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/datatypes/xsd/XSDbase64Binary.java?rev=1400849&r1=1400848&r2=1400849&view=diff
==============================================================================
--- jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/datatypes/xsd/XSDbase64Binary.java (original)
+++ jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/datatypes/xsd/XSDbase64Binary.java Mon Oct 22 11:57:15 2012
@@ -29,7 +29,7 @@ import com.hp.hpl.jena.datatypes.Datatyp
 public class XSDbase64Binary extends XSDbinary {
     
     public XSDbase64Binary(String typeName) {
-        super(typeName);
+        super(typeName, true);
     }
 
     /**

Modified: jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/datatypes/xsd/XSDbinary.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/datatypes/xsd/XSDbinary.java?rev=1400849&r1=1400848&r2=1400849&view=diff
==============================================================================
--- jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/datatypes/xsd/XSDbinary.java (original)
+++ jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/datatypes/xsd/XSDbinary.java Mon Oct 22 11:57:15 2012
@@ -31,8 +31,8 @@ public abstract class XSDbinary extends 
      * @param typeName the name of the XSD type to be instantiated, this is 
      * used to lookup a type definition from the Xerces schema factory.
      */
-    public XSDbinary(String typeName) {
-        super(typeName, byte[].class);
+    protected XSDbinary(String typeName,  boolean register) {
+        super(typeName, register ? byte[].class : null );
     }
          
     /**

Modified: jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/datatypes/xsd/XSDhexBinary.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/datatypes/xsd/XSDhexBinary.java?rev=1400849&r1=1400848&r2=1400849&view=diff
==============================================================================
--- jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/datatypes/xsd/XSDhexBinary.java (original)
+++ jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/datatypes/xsd/XSDhexBinary.java Mon Oct 22 11:57:15 2012
@@ -29,7 +29,7 @@ import com.hp.hpl.jena.datatypes.Datatyp
 public class XSDhexBinary extends XSDbinary {
     
     public XSDhexBinary(String typeName) {
-        super(typeName);
+        super(typeName, false);
     }
 
     /**

Modified: jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/graph/test/TestTypedLiterals.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/graph/test/TestTypedLiterals.java?rev=1400849&r1=1400848&r2=1400849&view=diff
==============================================================================
--- jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/graph/test/TestTypedLiterals.java (original)
+++ jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/graph/test/TestTypedLiterals.java Mon Oct 22 11:57:15 2012
@@ -907,23 +907,22 @@ public class TestTypedLiterals extends T
     }
     
     private static byte[] data = new byte[]{12, 42, 99};
+    
     /**
      * Test binary types base64 and hexbinary
      */
     public void testBinary1() {
-        // Check byte[] maps onto a binary type
+        // Check byte[] maps onto a binary typex
         byte[] data = new byte[]{12, 42, 99};
         Literal l = m.createTypedLiteral(data);
         LiteralLabel ll = l.asNode().getLiteral();
         
         assertTrue("binary test 1", ll.getDatatype() instanceof XSDbinary);
         
-        if ( ll.getDatatype() instanceof XSDhexBinary)
-            assertEquals("binary test 2a", "0C2A63", ll.getLexicalForm());
-        else if ( ll.getDatatype() instanceof XSDbase64Binary)
-            assertEquals("binary test 2b", "DCpj", ll.getLexicalForm());
-        else
-            fail("Unrecognized binary datatype") ;
+        // base64 is registered for byte[] 
+        // hexBinary is not registered as a type for byte[] 
+        assertTrue("binary test 1a", ll.getDatatype() instanceof XSDbase64Binary) ;
+        assertEquals("binary test 1b", "DCpj", ll.getLexicalForm());
     }
     
     public void testBinary2() {