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 2015/02/19 12:22:25 UTC

[1/3] jena git commit: Use Arrays.hashCode Fix comment copied from elsewhere.

Repository: jena
Updated Branches:
  refs/heads/master 2cf50f370 -> 1072c02f0


Use Arrays.hashCode
Fix comment copied from elsewhere.

Project: http://git-wip-us.apache.org/repos/asf/jena/repo
Commit: http://git-wip-us.apache.org/repos/asf/jena/commit/3ca21248
Tree: http://git-wip-us.apache.org/repos/asf/jena/tree/3ca21248
Diff: http://git-wip-us.apache.org/repos/asf/jena/diff/3ca21248

Branch: refs/heads/master
Commit: 3ca212486ed795c7a18ee897191ccb24378b2ffb
Parents: 2cf50f3
Author: Andy Seaborne <an...@apache.org>
Authored: Thu Feb 19 11:17:30 2015 +0000
Committer: Andy Seaborne <an...@apache.org>
Committed: Thu Feb 19 11:17:30 2015 +0000

----------------------------------------------------------------------
 .../src/main/java/com/hp/hpl/jena/datatypes/xsd/XSDbinary.java | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/jena/blob/3ca21248/jena-core/src/main/java/com/hp/hpl/jena/datatypes/xsd/XSDbinary.java
----------------------------------------------------------------------
diff --git a/jena-core/src/main/java/com/hp/hpl/jena/datatypes/xsd/XSDbinary.java b/jena-core/src/main/java/com/hp/hpl/jena/datatypes/xsd/XSDbinary.java
index e0c8018..ec545db 100644
--- a/jena-core/src/main/java/com/hp/hpl/jena/datatypes/xsd/XSDbinary.java
+++ b/jena-core/src/main/java/com/hp/hpl/jena/datatypes/xsd/XSDbinary.java
@@ -46,8 +46,6 @@ public abstract class XSDbinary extends XSDDatatype {
     
     /**
      * Compares two instances of values of the given datatype.
-     * This ignores lang tags and just uses the java.lang.Number 
-     * equality.
      */
     @Override
     public boolean isEqual(LiteralLabel value1, LiteralLabel value2) {
@@ -59,10 +57,8 @@ public abstract class XSDbinary extends XSDDatatype {
     @Override
     public int getHashCode( LiteralLabel lit )
     {
-        // Can't use super.getHashCode as that does "value.hashCode"
-        // Java arrays are not equal by value and their hash code of the sameValue array are different. 
         if ( lit.isWellFormed() )
-            return getHashCode( (byte []) lit.getValue() );
+            return Arrays.hashCode((byte []) lit.getValue()) ;
         else
             return lit.getLexicalForm().hashCode() ;
     }


[3/3] jena git commit: JENA-878 : Hide stuff from OSGi.

Posted by an...@apache.org.
JENA-878 : Hide stuff from OSGi.

Remove getHashCode (use Arrays.hashCode directly)
Tidy code.

This closes #31
This closes #30


Project: http://git-wip-us.apache.org/repos/asf/jena/repo
Commit: http://git-wip-us.apache.org/repos/asf/jena/commit/1072c02f
Tree: http://git-wip-us.apache.org/repos/asf/jena/tree/1072c02f
Diff: http://git-wip-us.apache.org/repos/asf/jena/diff/1072c02f

Branch: refs/heads/master
Commit: 1072c02f0c31032cee9dbec8c07522925f3d210b
Parents: 79db86b
Author: Andy Seaborne <an...@apache.org>
Authored: Thu Feb 19 11:19:27 2015 +0000
Committer: Andy Seaborne <an...@apache.org>
Committed: Thu Feb 19 11:19:27 2015 +0000

----------------------------------------------------------------------
 .../hp/hpl/jena/datatypes/xsd/XSDDatatype.java  | 69 +++++++++++---------
 .../jena/datatypes/xsd/impl/XSDGenericType.java | 66 -------------------
 2 files changed, 38 insertions(+), 97 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/jena/blob/1072c02f/jena-core/src/main/java/com/hp/hpl/jena/datatypes/xsd/XSDDatatype.java
----------------------------------------------------------------------
diff --git a/jena-core/src/main/java/com/hp/hpl/jena/datatypes/xsd/XSDDatatype.java b/jena-core/src/main/java/com/hp/hpl/jena/datatypes/xsd/XSDDatatype.java
index 21d9839..aee2bcf 100644
--- a/jena-core/src/main/java/com/hp/hpl/jena/datatypes/xsd/XSDDatatype.java
+++ b/jena-core/src/main/java/com/hp/hpl/jena/datatypes/xsd/XSDDatatype.java
@@ -21,7 +21,7 @@ package com.hp.hpl.jena.datatypes.xsd;
 import java.io.Reader ;
 import java.math.BigDecimal ;
 import java.math.BigInteger ;
-import java.net.URI;
+import java.net.URI ;
 import java.util.ArrayList ;
 import java.util.List ;
 
@@ -209,7 +209,7 @@ public class XSDDatatype extends BaseDatatype {
 // local variables
 
     /** the Xerces internal type declaration */
-    protected XSSimpleType typeDeclaration;
+    XSSimpleType typeDeclaration;
 
     /** the corresponding java primitive class, if any */
     protected Class<?> javaClass = null;
@@ -244,14 +244,12 @@ public class XSDDatatype extends BaseDatatype {
     }
 
     /**
-     * Constructor used when loading in external user defined XSD types -
-     * should only be used by the internals but public scope because
-     * the internals spread across multiple packages.
-     *
+     * Constructor used when loading in external user defined XSD types via 
+     * 
      * @param xstype the XSSimpleType definition to be wrapped
      * @param namespace the namespace for the type (used because the grammar loading doesn't seem to keep that)
      */
-    public XSDDatatype(XSSimpleType xstype, String namespace) {
+    protected XSDDatatype(XSSimpleType xstype, String namespace) {
         super("");
         typeDeclaration = xstype;
         this.uri = namespace + "#" + typeDeclaration.getName();
@@ -284,8 +282,6 @@ public class XSDDatatype extends BaseDatatype {
 
     /**
      * Compares two instances of values of the given datatype.
-     * This ignores lang tags and defers to the equality function
-     * defined by the Xerces package.
      */
     @Override
     public boolean isEqual(LiteralLabel value1, LiteralLabel value2) {
@@ -392,7 +388,7 @@ public class XSDDatatype extends BaseDatatype {
      * @param validatedInfo a fully populated Xerces data validation context
      * @return the appropriate java wrapper type
      */
-    public Object convertValidatedDataValue(ValidatedInfo validatedInfo) throws DatatypeFormatException {
+    Object convertValidatedDataValue(ValidatedInfo validatedInfo) throws DatatypeFormatException {
         switch (validatedInfo.actualValueType) {
             case XSConstants.BASE64BINARY_DT:
                 byte[] decoded = Base64.decode(validatedInfo.normalizedValue);
@@ -601,33 +597,44 @@ public class XSDDatatype extends BaseDatatype {
 //        tm.registerDatatype(XSDNMTOKENS);
     }
 
-    // Temporary - used bootstrap the above initialization code
+    /**
+     * Generic XML Schema datatype (outside the xsd: namespace)
+     * <p>
+     * Datatype template that adapts any response back from Xerces type parsing
+     * to an appropriate java representation. This is primarily used in creating
+     * user defined types - the built in types have a fixed mapping.
+     */
+    public static class XSDGenericType extends XSDDatatype {
+
+        /**
+         * Hidden constructor used when loading in external user defined XSD
+         * types
+         * 
+         * @param xstype
+         *            the XSSimpleType definition to be wrapped
+         * @param namespace
+         *            the namespace for the type (used because the grammar
+         *            loading doesn't seem to keep that)
+         */
+        XSDGenericType(XSSimpleType xstype, String namespace) {
+            super(xstype, namespace);
+        }
+    }
+
+    
+    // Used to bootstrap the above initialization code
     public static void main(String[] args) {
         SymbolHash types = SchemaDVFactory.getInstance().getBuiltInTypes();
         int len = types.getLength();
         Object[] values = new Object[len];
         types.getValues(values, 0);
-        for ( Object value : values )
-        {
-            if ( value instanceof XSSimpleTypeDecl )
-            {
-                XSSimpleTypeDecl decl = (XSSimpleTypeDecl) value;
-                System.out.println( "tm.registerDatatype(new XSDDatatype(\"" + decl.getName() + "\"));" );
-            }
-            else
-            {
-                System.out.println( " - " + value );
+        for ( Object value : values ) {
+            if ( value instanceof XSSimpleTypeDecl ) {
+                XSSimpleTypeDecl decl = (XSSimpleTypeDecl)value ;
+                System.out.println("tm.registerDatatype(new XSDDatatype(\"" + decl.getName() + "\"));") ;
+            } else {
+                System.out.println(" - " + value) ;
             }
         }
     }
-
-    public int getHashCode( byte [] bytes )
-        {
-        int length = bytes.length;
-        return length == 0
-            ? 0
-            : (bytes[0] << 12) ^ (bytes[length / 2] << 6) ^ (bytes[length - 1]) ^ length
-            ;
-        }
-
 }

http://git-wip-us.apache.org/repos/asf/jena/blob/1072c02f/jena-core/src/main/java/com/hp/hpl/jena/datatypes/xsd/impl/XSDGenericType.java
----------------------------------------------------------------------
diff --git a/jena-core/src/main/java/com/hp/hpl/jena/datatypes/xsd/impl/XSDGenericType.java b/jena-core/src/main/java/com/hp/hpl/jena/datatypes/xsd/impl/XSDGenericType.java
deleted file mode 100644
index 543c064..0000000
--- a/jena-core/src/main/java/com/hp/hpl/jena/datatypes/xsd/impl/XSDGenericType.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.hp.hpl.jena.datatypes.xsd.impl;
-
-import org.apache.xerces.impl.dv.XSSimpleType;
-
-import com.hp.hpl.jena.datatypes.xsd.*;
-
-/**
- * Datatype template that adapts any response back from Xerces type parsing
- * to an appropriate java representation. This is primarily used in creating
- * user defined types - the built in types have a fixed mapping.
- * <p>
- * This class is probably now redundant in that XSDDatatype can support
- * run time conversion of union results. Left in for now during restructuring and
- * in case any existing user code expects this type - very unlikely.
- * </p>
- */
-public class XSDGenericType extends XSDDatatype {
-
-    /**
-     * Hidden constructor used when loading in external user defined XSD types
-     * @param xstype the XSSimpleType definition to be wrapped
-     * @param namespace the namespace for the type (used because the grammar loading doesn't seem to keep that)
-     */
-    public XSDGenericType(XSSimpleType xstype, String namespace) {
-        super(xstype, namespace);
-    }
-
-
-//  No longer need to perform any special case processing of union types since we
-//  now do runtime type coercion - is that right?
-
-//    /**
-//     * Parse a lexical form of this datatype to a value
-//     * @throws DatatypeFormatException if the lexical form is not legal
-//     */
-//    public Object parse(String lexicalForm) throws DatatypeFormatException {
-//        try {
-//            ValidationContext context = new ValidationState();
-//            ValidatedInfo resultInfo = new ValidatedInfo();
-//            Object result = typeDeclaration.validate(lexicalForm, context, resultInfo);
-//            return convertValidatedDataValue(resultInfo);
-//        } catch (InvalidDatatypeValueException e) { 
-//            throw new DatatypeFormatException(lexicalForm, this, "during parse -" + e);
-//        } 
-//    }
-    
- 
-}


[2/3] jena git commit: Fix comment copied from elsewhere.

Posted by an...@apache.org.
Fix comment copied from elsewhere.

Project: http://git-wip-us.apache.org/repos/asf/jena/repo
Commit: http://git-wip-us.apache.org/repos/asf/jena/commit/79db86bd
Tree: http://git-wip-us.apache.org/repos/asf/jena/tree/79db86bd
Diff: http://git-wip-us.apache.org/repos/asf/jena/diff/79db86bd

Branch: refs/heads/master
Commit: 79db86bd7e8ea91236f3d5208c4a7d8b329dba96
Parents: 3ca2124
Author: Andy Seaborne <an...@apache.org>
Authored: Thu Feb 19 11:18:57 2015 +0000
Committer: Andy Seaborne <an...@apache.org>
Committed: Thu Feb 19 11:18:57 2015 +0000

----------------------------------------------------------------------
 .../com/hp/hpl/jena/datatypes/xsd/impl/XSDBaseNumericType.java     | 2 --
 1 file changed, 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/jena/blob/79db86bd/jena-core/src/main/java/com/hp/hpl/jena/datatypes/xsd/impl/XSDBaseNumericType.java
----------------------------------------------------------------------
diff --git a/jena-core/src/main/java/com/hp/hpl/jena/datatypes/xsd/impl/XSDBaseNumericType.java b/jena-core/src/main/java/com/hp/hpl/jena/datatypes/xsd/impl/XSDBaseNumericType.java
index 7fdee8a..22fb417 100644
--- a/jena-core/src/main/java/com/hp/hpl/jena/datatypes/xsd/impl/XSDBaseNumericType.java
+++ b/jena-core/src/main/java/com/hp/hpl/jena/datatypes/xsd/impl/XSDBaseNumericType.java
@@ -176,8 +176,6 @@ public class XSDBaseNumericType extends XSDDatatype {
     
     /**
      * Compares two instances of values of the given datatype.
-     * This ignores lang tags and just uses the java.lang.Number 
-     * equality.
      */
     @Override
     public boolean isEqual(LiteralLabel value1, LiteralLabel value2) {