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 2014/11/26 21:22:06 UTC
[1/4] jena git commit: Add a datatype for rdf:langString
Repository: jena
Updated Branches:
refs/heads/master a539ff032 -> 61eb14b95
Add a datatype for rdf:langString
Project: http://git-wip-us.apache.org/repos/asf/jena/repo
Commit: http://git-wip-us.apache.org/repos/asf/jena/commit/6b78e063
Tree: http://git-wip-us.apache.org/repos/asf/jena/tree/6b78e063
Diff: http://git-wip-us.apache.org/repos/asf/jena/diff/6b78e063
Branch: refs/heads/master
Commit: 6b78e063748f13c60534b7cf8cd347edd0540595
Parents: a539ff0
Author: Andy Seaborne <an...@apache.org>
Authored: Wed Nov 26 19:37:27 2014 +0000
Committer: Andy Seaborne <an...@apache.org>
Committed: Wed Nov 26 19:37:27 2014 +0000
----------------------------------------------------------------------
.../com/hp/hpl/jena/sparql/graph/NodeConst.java | 6 +-
.../com/hp/hpl/jena/datatypes/TypeMapper.java | 4 +-
.../jena/datatypes/xsd/impl/RDFLangString.java | 66 ++++++++++++++++++++
.../java/com/hp/hpl/jena/vocabulary/RDF.java | 18 ++++--
.../hpl/jena/graph/test/TestTypedLiterals.java | 11 ++++
5 files changed, 98 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/jena/blob/6b78e063/jena-arq/src/main/java/com/hp/hpl/jena/sparql/graph/NodeConst.java
----------------------------------------------------------------------
diff --git a/jena-arq/src/main/java/com/hp/hpl/jena/sparql/graph/NodeConst.java b/jena-arq/src/main/java/com/hp/hpl/jena/sparql/graph/NodeConst.java
index 37359e6..52e7f0d 100644
--- a/jena-arq/src/main/java/com/hp/hpl/jena/sparql/graph/NodeConst.java
+++ b/jena-arq/src/main/java/com/hp/hpl/jena/sparql/graph/NodeConst.java
@@ -18,6 +18,7 @@
package com.hp.hpl.jena.sparql.graph;
+import com.hp.hpl.jena.datatypes.RDFDatatype ;
import com.hp.hpl.jena.datatypes.xsd.XSDDatatype ;
import com.hp.hpl.jena.graph.Node ;
import com.hp.hpl.jena.graph.NodeFactory ;
@@ -41,6 +42,7 @@ public class NodeConst
public static final Node nodeNil = RDF.Nodes.nil ;
public static final Node nodeANY = Node.ANY ;
- public static final Node nodeOwlSameAs = OWL.sameAs.asNode() ;
- public static final Node rdfLangString = RDF.Nodes.langString ;
+ public static final Node nodeOwlSameAs = OWL.sameAs.asNode() ;
+ public static final Node rdfLangString = RDF.Nodes.langString ;
+ public static final RDFDatatype dtLangString = RDF.dtLangString ;
}
http://git-wip-us.apache.org/repos/asf/jena/blob/6b78e063/jena-core/src/main/java/com/hp/hpl/jena/datatypes/TypeMapper.java
----------------------------------------------------------------------
diff --git a/jena-core/src/main/java/com/hp/hpl/jena/datatypes/TypeMapper.java b/jena-core/src/main/java/com/hp/hpl/jena/datatypes/TypeMapper.java
index 9796b54..beffaff 100644
--- a/jena-core/src/main/java/com/hp/hpl/jena/datatypes/TypeMapper.java
+++ b/jena-core/src/main/java/com/hp/hpl/jena/datatypes/TypeMapper.java
@@ -24,6 +24,7 @@ import java.util.HashMap;
import java.util.Iterator;
import com.hp.hpl.jena.datatypes.xsd.XSDDatatype;
+import com.hp.hpl.jena.datatypes.xsd.impl.RDFLangString ;
import com.hp.hpl.jena.datatypes.xsd.impl.XMLLiteralType;
import com.hp.hpl.jena.shared.impl.JenaParameters;
@@ -67,6 +68,7 @@ public class TypeMapper {
public static void reset() {
theTypeMap = new TypeMapper();
theTypeMap.registerDatatype(XMLLiteralType.theXMLLiteralType);
+ theTypeMap.registerDatatype(RDFLangString.rdfLangString) ;
XSDDatatype.loadXSDSimpleTypes(theTypeMap);
// add primitive types
@@ -120,7 +122,7 @@ public class TypeMapper {
// Plain literal
return null;
} else {
- // Uknown datatype
+ // Unknown datatype
if (JenaParameters.enableSilentAcceptanceOfUnknownDatatypes) {
dtype = new BaseDatatype(uri);
registerDatatype(dtype);
http://git-wip-us.apache.org/repos/asf/jena/blob/6b78e063/jena-core/src/main/java/com/hp/hpl/jena/datatypes/xsd/impl/RDFLangString.java
----------------------------------------------------------------------
diff --git a/jena-core/src/main/java/com/hp/hpl/jena/datatypes/xsd/impl/RDFLangString.java b/jena-core/src/main/java/com/hp/hpl/jena/datatypes/xsd/impl/RDFLangString.java
new file mode 100644
index 0000000..08cc197
--- /dev/null
+++ b/jena-core/src/main/java/com/hp/hpl/jena/datatypes/xsd/impl/RDFLangString.java
@@ -0,0 +1,66 @@
+/**
+ * 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 com.hp.hpl.jena.datatypes.BaseDatatype ;
+import com.hp.hpl.jena.datatypes.RDFDatatype ;
+import com.hp.hpl.jena.graph.impl.LiteralLabel ;
+import com.hp.hpl.jena.vocabulary.RDF ;
+
+/** rdf:langString.
+ * This covers the unusual case of "foo"^^"rdf:langString"
+ * When there is a language tag, there is a lexcial form but it is in two parts lex@lang
+ * This is not rdf:plainLiteral!
+ */
+
+public class RDFLangString extends BaseDatatype implements RDFDatatype {
+ /** Singleton instance */
+ public static final RDFDatatype rdfLangString = new RDFLangString(RDF.getURI() + "langString");
+
+ /**
+ * Private constructor.
+ */
+ private RDFLangString(String uri) {
+ super(uri);
+ }
+
+ /**
+ * Compares two instances of values of the given datatype.
+ */
+ @Override
+ public boolean isEqual(LiteralLabel value1, LiteralLabel value2) {
+ if ( value2 == null )
+ return false ;
+ if ( ! rdfLangString.equals(value2.getDatatype()) )
+ return false ;
+
+ return value1.getLexicalForm().equals(value2.getLexicalForm()) &&
+ value1.language().equalsIgnoreCase(value2.language()) ;
+ }
+
+ // This covers the unusual case of "foo"^^"rdf:langString"
+ // When there is a language tag, there is a lexcial form but it is in two parts lex@lang
+ // This is not rdf:plainLiteral!
+ @Override
+ public Object parse(String lexicalForm) { return lexicalForm ; }
+
+ @Override
+ public String unparse(Object value) { return value.toString(); }
+}
+
http://git-wip-us.apache.org/repos/asf/jena/blob/6b78e063/jena-core/src/main/java/com/hp/hpl/jena/vocabulary/RDF.java
----------------------------------------------------------------------
diff --git a/jena-core/src/main/java/com/hp/hpl/jena/vocabulary/RDF.java b/jena-core/src/main/java/com/hp/hpl/jena/vocabulary/RDF.java
index 2241c91..fe78974 100644
--- a/jena-core/src/main/java/com/hp/hpl/jena/vocabulary/RDF.java
+++ b/jena-core/src/main/java/com/hp/hpl/jena/vocabulary/RDF.java
@@ -18,8 +18,13 @@
package com.hp.hpl.jena.vocabulary;
-import com.hp.hpl.jena.graph.*;
-import com.hp.hpl.jena.rdf.model.*;
+import com.hp.hpl.jena.datatypes.RDFDatatype ;
+import com.hp.hpl.jena.datatypes.xsd.impl.RDFLangString ;
+import com.hp.hpl.jena.datatypes.xsd.impl.XMLLiteralType ;
+import com.hp.hpl.jena.graph.Node ;
+import com.hp.hpl.jena.rdf.model.Property ;
+import com.hp.hpl.jena.rdf.model.Resource ;
+import com.hp.hpl.jena.rdf.model.ResourceFactory ;
/**
The standard RDF vocabulary.
@@ -60,8 +65,13 @@ public class RDF{
public static final Property type = property( "type" );
public static final Property value = property( "value" );
- // RDF 1.1 - the datatype of language strings
- public static final Resource langString = resource("langString") ;
+ // RDF 1.1 - the datatypes of language strings
+ public static final Resource langString = ResourceFactory.createResource(RDFLangString.rdfLangString.getURI()) ;
+ // rdf:XMLLiteral
+ public static final Resource xmlLiteral = ResourceFactory.createResource(XMLLiteralType.theXMLLiteralType.getURI()) ;
+
+ public static final RDFDatatype dtLangString = RDFLangString.rdfLangString ;
+ public static final RDFDatatype dtXMLLiteral = XMLLiteralType.theXMLLiteralType ;
/**
The same items of vocabulary, but at the Node level, parked inside a
http://git-wip-us.apache.org/repos/asf/jena/blob/6b78e063/jena-core/src/test/java/com/hp/hpl/jena/graph/test/TestTypedLiterals.java
----------------------------------------------------------------------
diff --git a/jena-core/src/test/java/com/hp/hpl/jena/graph/test/TestTypedLiterals.java b/jena-core/src/test/java/com/hp/hpl/jena/graph/test/TestTypedLiterals.java
index 9b99d48..9decf37 100644
--- a/jena-core/src/test/java/com/hp/hpl/jena/graph/test/TestTypedLiterals.java
+++ b/jena-core/src/test/java/com/hp/hpl/jena/graph/test/TestTypedLiterals.java
@@ -30,11 +30,13 @@ import junit.framework.TestSuite ;
import org.apache.xerces.impl.dv.util.HexBin ;
import org.junit.Assert ;
+import com.hp.hpl.jena.JenaRuntime ;
import com.hp.hpl.jena.datatypes.BaseDatatype ;
import com.hp.hpl.jena.datatypes.DatatypeFormatException ;
import com.hp.hpl.jena.datatypes.RDFDatatype ;
import com.hp.hpl.jena.datatypes.TypeMapper ;
import com.hp.hpl.jena.datatypes.xsd.* ;
+import com.hp.hpl.jena.datatypes.xsd.impl.RDFLangString ;
import com.hp.hpl.jena.datatypes.xsd.impl.XMLLiteralType ;
import com.hp.hpl.jena.enhanced.EnhNode ;
import com.hp.hpl.jena.graph.* ;
@@ -229,6 +231,15 @@ public class TestTypedLiterals extends TestCase {
}
+ public void testRDFLangString() {
+ // "abc"^^rdf:langString (no language tag)
+ Literal ll1 = m.createTypedLiteral("abc", RDFLangString.rdfLangString) ;
+ if ( JenaRuntime.isRDF11 ) {
+ Literal ll2 = m.createLiteral("xyz", "en") ;
+ assertTrue(ll1.getDatatype() == ll2.getDatatype()) ;
+ }
+ }
+
/**
* Tests basic XSD integer types()
*/
[3/4] jena git commit: rdf:langString registration test.
Posted by an...@apache.org.
rdf:langString registration test.
Project: http://git-wip-us.apache.org/repos/asf/jena/repo
Commit: http://git-wip-us.apache.org/repos/asf/jena/commit/7ea5de7d
Tree: http://git-wip-us.apache.org/repos/asf/jena/tree/7ea5de7d
Diff: http://git-wip-us.apache.org/repos/asf/jena/diff/7ea5de7d
Branch: refs/heads/master
Commit: 7ea5de7d4e290f2efcae4c5e1e23aa0298e0a989
Parents: 4618941
Author: Andy Seaborne <an...@apache.org>
Authored: Wed Nov 26 19:43:40 2014 +0000
Committer: Andy Seaborne <an...@apache.org>
Committed: Wed Nov 26 19:43:40 2014 +0000
----------------------------------------------------------------------
.../hpl/jena/graph/test/TestTypedLiterals.java | 19 +++++++++++++++----
1 file changed, 15 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/jena/blob/7ea5de7d/jena-core/src/test/java/com/hp/hpl/jena/graph/test/TestTypedLiterals.java
----------------------------------------------------------------------
diff --git a/jena-core/src/test/java/com/hp/hpl/jena/graph/test/TestTypedLiterals.java b/jena-core/src/test/java/com/hp/hpl/jena/graph/test/TestTypedLiterals.java
index 9decf37..664241e 100644
--- a/jena-core/src/test/java/com/hp/hpl/jena/graph/test/TestTypedLiterals.java
+++ b/jena-core/src/test/java/com/hp/hpl/jena/graph/test/TestTypedLiterals.java
@@ -44,6 +44,7 @@ import com.hp.hpl.jena.graph.impl.LiteralLabel ;
import com.hp.hpl.jena.graph.impl.LiteralLabelFactory ;
import com.hp.hpl.jena.rdf.model.* ;
import com.hp.hpl.jena.shared.impl.JenaParameters ;
+import com.hp.hpl.jena.vocabulary.RDF ;
import com.hp.hpl.jena.vocabulary.XSD ;
/**
@@ -231,13 +232,23 @@ public class TestTypedLiterals extends TestCase {
}
- public void testRDFLangString() {
+ public void testRDFLangString_1() {
+ // Registration
+ RDFDatatype dt = TypeMapper.getInstance().getTypeByName(RDF.langString.getURI()) ;
+ assertEquals(RDF.dtLangString, dt) ;
+ assertTrue(RDF.dtLangString == dt) ;
+ }
+
+ public void testRDFLangString_2() {
// "abc"^^rdf:langString (no language tag)
Literal ll1 = m.createTypedLiteral("abc", RDFLangString.rdfLangString) ;
- if ( JenaRuntime.isRDF11 ) {
- Literal ll2 = m.createLiteral("xyz", "en") ;
+ assertEquals("", ll1.getLanguage()) ;
+ Literal ll2 = m.createLiteral("xyz", "en") ;
+
+ if ( JenaRuntime.isRDF11 )
assertTrue(ll1.getDatatype() == ll2.getDatatype()) ;
- }
+ else
+ assertTrue(ll1.getDatatype() != ll2.getDatatype()) ;
}
/**
[2/4] jena git commit: JENA-818, JENA-816 : Rewrite sameValueAs.
Posted by an...@apache.org.
JENA-818, JENA-816 : Rewrite sameValueAs.
Project: http://git-wip-us.apache.org/repos/asf/jena/repo
Commit: http://git-wip-us.apache.org/repos/asf/jena/commit/46189416
Tree: http://git-wip-us.apache.org/repos/asf/jena/tree/46189416
Diff: http://git-wip-us.apache.org/repos/asf/jena/diff/46189416
Branch: refs/heads/master
Commit: 46189416954b4422936ffd41fc3c740bb21fa0ea
Parents: 6b78e06
Author: Andy Seaborne <an...@apache.org>
Authored: Wed Nov 26 19:38:20 2014 +0000
Committer: Andy Seaborne <an...@apache.org>
Committed: Wed Nov 26 19:38:20 2014 +0000
----------------------------------------------------------------------
.../hpl/jena/graph/impl/LiteralLabelImpl.java | 85 ++++++++++++++++++--
1 file changed, 78 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/jena/blob/46189416/jena-core/src/main/java/com/hp/hpl/jena/graph/impl/LiteralLabelImpl.java
----------------------------------------------------------------------
diff --git a/jena-core/src/main/java/com/hp/hpl/jena/graph/impl/LiteralLabelImpl.java b/jena-core/src/main/java/com/hp/hpl/jena/graph/impl/LiteralLabelImpl.java
index cb8be15..64362a3 100644
--- a/jena-core/src/main/java/com/hp/hpl/jena/graph/impl/LiteralLabelImpl.java
+++ b/jena-core/src/main/java/com/hp/hpl/jena/graph/impl/LiteralLabelImpl.java
@@ -29,7 +29,9 @@ import com.hp.hpl.jena.datatypes.*;
import com.hp.hpl.jena.datatypes.xsd.*;
import com.hp.hpl.jena.datatypes.xsd.impl.*;
import com.hp.hpl.jena.rdf.model.impl.Util ;
+import com.hp.hpl.jena.shared.JenaException ;
import com.hp.hpl.jena.shared.impl.JenaParameters;
+import com.hp.hpl.jena.vocabulary.RDF ;
/**
* Represents the "contents" of a Node_Literal.
@@ -394,15 +396,84 @@ final /*public*/ class LiteralLabelImpl implements LiteralLabel {
*/
@Override
public boolean sameValueAs( LiteralLabel other ) {
- if (other == null)
- return false;
- if (!wellformed || !other.isWellFormedRaw())
- return areIllFormedLiteralsSameValueAs( other );
- return dtype == null
- ? isPlainLiteralSameValueAsOther( other )
- : isTypedLiteralSameValueAsOther( other );
+
+ return sameValueAs(this, other) ;
+
+// if (other == null)
+// return false;
+// if (!wellformed || !other.isWellFormedRaw())
+// return areIllFormedLiteralsSameValueAs( other );
+// return dtype == null
+// ? isPlainLiteralSameValueAsOther( other )
+// : isTypedLiteralSameValueAsOther( other );
}
+ // -------------
+ private static boolean sameValueAs(LiteralLabel lit1, LiteralLabel lit2) {
+ //return lit1.sameValueAs(lit2) ;
+ if ( lit1 == null )
+ throw new NullPointerException() ;
+ if ( lit2 == null )
+ throw new NullPointerException() ;
+ // Strings.
+ if ( isStringValue(lit1) && isStringValue(lit2) ) {
+ // Complete compatibility mode.
+ if ( JenaParameters.enablePlainLiteralSameAsString )
+ return lit1.getLexicalForm().equals(lit2.getLexicalForm()) ;
+ else
+ return lit1.getLexicalForm().equals(lit2.getLexicalForm()) &&
+ Objects.equals(lit1.getDatatype(), lit2.getDatatype()) ;
+ }
+
+ if ( isStringValue(lit1) ) return false ;
+ if ( isStringValue(lit2) ) return false ;
+
+ // Language tag strings
+ if ( isLangString(lit1) && isLangString(lit2) ) {
+ String lex1 = lit1.getLexicalForm() ;
+ String lex2 = lit2.getLexicalForm() ;
+ return lex1.equals(lex2) && lit1.language().equalsIgnoreCase(lit2.language()) ;
+ }
+ if ( isLangString(lit1) ) return false ;
+ if ( isLangString(lit2) ) return false ;
+
+ // Both not strings, not lang strings.
+ // Datatype set.
+ if ( lit1.isWellFormedRaw() && lit2.isWellFormedRaw() )
+ // Both well-formed.
+ return lit1.getDatatype().isEqual(lit1, lit2) ;
+ if ( ! lit1.isWellFormedRaw() && ! lit2.isWellFormedRaw() )
+ return lit1.equals(lit2) ;
+ // One is well formed, the other is not.
+ return false ;
+ }
+ /** Return true if the literal lable is a string value (RDF 1.0 and RDF 1.1) */
+ private static boolean isStringValue(LiteralLabel lit) {
+ if ( lit.getDatatype() == null )
+ // RDF 1.0
+ return ! isLangString(lit) ;
+ if ( lit.getDatatype().equals(XSDDatatype.XSDstring) )
+ return true;
+ return false ;
+ }
+
+ /** Return true if the literal label is a language string. (RDF 1.0 and RDF 1.1) */
+ public static boolean isLangString(LiteralLabel lit) {
+ String lang = lit.language() ;
+ if ( lang == null )
+ return false ;
+ // Check.
+ if ( lang.equals("") )
+ return false ;
+ // This is an additional check.
+ if ( JenaRuntime.isRDF11 ) {
+ if ( ! Objects.equals(lit.getDatatype(), RDF.dtLangString) )
+ throw new JenaException("Literal with language string which is not rdf:langString: "+lit) ;
+ }
+ return true ;
+ }
+ // -------------
+
/**
Need to support comparison of ill-formed literals in order for the WG
tests on ill formed literals to be testable using isIsomorphic to. "same
[4/4] jena git commit: Correct javadoc. Remove dead code.
Posted by an...@apache.org.
Correct javadoc. Remove dead code.
Project: http://git-wip-us.apache.org/repos/asf/jena/repo
Commit: http://git-wip-us.apache.org/repos/asf/jena/commit/61eb14b9
Tree: http://git-wip-us.apache.org/repos/asf/jena/tree/61eb14b9
Diff: http://git-wip-us.apache.org/repos/asf/jena/diff/61eb14b9
Branch: refs/heads/master
Commit: 61eb14b95634d340d2a37c2803529e397be4e48e
Parents: 7ea5de7
Author: Andy Seaborne <an...@apache.org>
Authored: Wed Nov 26 20:19:33 2014 +0000
Committer: Andy Seaborne <an...@apache.org>
Committed: Wed Nov 26 20:19:33 2014 +0000
----------------------------------------------------------------------
.../hp/hpl/jena/graph/impl/LiteralLabel.java | 4 +-
.../hpl/jena/graph/impl/LiteralLabelImpl.java | 73 +++-----------------
2 files changed, 11 insertions(+), 66 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/jena/blob/61eb14b9/jena-core/src/main/java/com/hp/hpl/jena/graph/impl/LiteralLabel.java
----------------------------------------------------------------------
diff --git a/jena-core/src/main/java/com/hp/hpl/jena/graph/impl/LiteralLabel.java b/jena-core/src/main/java/com/hp/hpl/jena/graph/impl/LiteralLabel.java
index 77429f6..a4e95d9 100644
--- a/jena-core/src/main/java/com/hp/hpl/jena/graph/impl/LiteralLabel.java
+++ b/jena-core/src/main/java/com/hp/hpl/jena/graph/impl/LiteralLabel.java
@@ -90,8 +90,8 @@ public interface LiteralLabel
public boolean equals(Object other) ;
/**
- Answer true iff this literal represents the same (abstract) value as
- the other one.
+ Answer true if this literal represents the same (abstract) value as
+ the other one. Two literals that are .equals are sameValueAs.
*/
public boolean sameValueAs(LiteralLabel other) ;
http://git-wip-us.apache.org/repos/asf/jena/blob/61eb14b9/jena-core/src/main/java/com/hp/hpl/jena/graph/impl/LiteralLabelImpl.java
----------------------------------------------------------------------
diff --git a/jena-core/src/main/java/com/hp/hpl/jena/graph/impl/LiteralLabelImpl.java b/jena-core/src/main/java/com/hp/hpl/jena/graph/impl/LiteralLabelImpl.java
index 64362a3..4cc9219 100644
--- a/jena-core/src/main/java/com/hp/hpl/jena/graph/impl/LiteralLabelImpl.java
+++ b/jena-core/src/main/java/com/hp/hpl/jena/graph/impl/LiteralLabelImpl.java
@@ -396,19 +396,15 @@ final /*public*/ class LiteralLabelImpl implements LiteralLabel {
*/
@Override
public boolean sameValueAs( LiteralLabel other ) {
-
return sameValueAs(this, other) ;
-
-// if (other == null)
-// return false;
-// if (!wellformed || !other.isWellFormedRaw())
-// return areIllFormedLiteralsSameValueAs( other );
-// return dtype == null
-// ? isPlainLiteralSameValueAsOther( other )
-// : isTypedLiteralSameValueAsOther( other );
}
-
- // -------------
+ /**
+ * Two literal labels are the "same value" if they are the same string,
+ * or same language string or same value-by-datatype or .equals (= Same RDF Term)
+ * @param lit1
+ * @param lit2
+ * @return
+ */
private static boolean sameValueAs(LiteralLabel lit1, LiteralLabel lit2) {
//return lit1.sameValueAs(lit2) ;
if ( lit1 == null )
@@ -447,7 +443,8 @@ final /*public*/ class LiteralLabelImpl implements LiteralLabel {
// One is well formed, the other is not.
return false ;
}
- /** Return true if the literal lable is a string value (RDF 1.0 and RDF 1.1) */
+
+ /** Return true if the literal lable is a string value (RDF 1.0 and RDF 1.1) */
private static boolean isStringValue(LiteralLabel lit) {
if ( lit.getDatatype() == null )
// RDF 1.0
@@ -472,58 +469,6 @@ final /*public*/ class LiteralLabelImpl implements LiteralLabel {
}
return true ;
}
- // -------------
-
- /**
- Need to support comparison of ill-formed literals in order for the WG
- tests on ill formed literals to be testable using isIsomorphic to. "same
- value as" on ill-formed literals is defined to mean "same lexical form
- and same [ignoring case] language code".
- <p>
- precondition: at least one of <i>this</i> and <i>other</i> is
- ill-formed.
- */
- private boolean areIllFormedLiteralsSameValueAs( LiteralLabel other )
- { return !other.isWellFormedRaw() && sameByFormAndLanguage( other ); }
-
- /**
- Answer true iff <i>this</i> and <i>other</i> have the same lexical
- form and [ignoring case] language code. [Note: both typed literals
- and plain literals have the empty string as language code.]
- */
- private boolean sameByFormAndLanguage( LiteralLabel other )
- {
- String lex1 = getLexicalForm() ;
- String lex2 = other.getLexicalForm() ;
- return
- lex1.equals( lex2 )
- && lang.equalsIgnoreCase( other.language() );
- }
-
- private boolean isTypedLiteralSameValueAsOther( LiteralLabel other )
- {
- return other.getDatatype() == null
- ? looksLikePlainString( this ) && sameByFormAndLanguage( other )
- : dtype.isEqual( this, other );
- }
-
- private boolean isPlainLiteralSameValueAsOther( LiteralLabel other )
- {
- return other.getDatatype() == null || looksLikePlainString( other )
- ? sameByFormAndLanguage( other )
- : false;
- }
-
- /**
- Answer true iff <i>L</i> has type XSD string and we're treating plain
- literals and xsd string literals as "the same".
- */
- private boolean looksLikePlainString( LiteralLabel L )
- {
- return
- L.getDatatype().equals( XSDDatatype.XSDstring )
- && JenaParameters.enablePlainLiteralSameAsString;
- }
private int hash = 0 ;
/**