jena-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rve...@apache.org
Subject [30/48] jena git commit: JENA-816 : Recode to be RDF 1.0/1.1 neutral.
Date Tue, 25 Nov 2014 16:26:52 GMT
JENA-816 : Recode to be RDF 1.0/1.1 neutral.

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

Branch: refs/heads/hadoop-rdf
Commit: 8864bd0609831cd67edff27e6b5e39d4d2d2ee22
Parents: c3843a3
Author: Andy Seaborne <andy@apache.org>
Authored: Sat Nov 22 15:17:15 2014 +0000
Committer: Andy Seaborne <andy@apache.org>
Committed: Sat Nov 22 15:17:15 2014 +0000

----------------------------------------------------------------------
 .../process/normalize/CanonicalizeLiteral.java  | 27 ++++++++++----------
 1 file changed, 13 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/jena/blob/8864bd06/jena-arq/src/main/java/org/apache/jena/riot/process/normalize/CanonicalizeLiteral.java
----------------------------------------------------------------------
diff --git a/jena-arq/src/main/java/org/apache/jena/riot/process/normalize/CanonicalizeLiteral.java
b/jena-arq/src/main/java/org/apache/jena/riot/process/normalize/CanonicalizeLiteral.java
index a745b29..d30eee6 100644
--- a/jena-arq/src/main/java/org/apache/jena/riot/process/normalize/CanonicalizeLiteral.java
+++ b/jena-arq/src/main/java/org/apache/jena/riot/process/normalize/CanonicalizeLiteral.java
@@ -23,12 +23,12 @@ import java.util.Map ;
 
 import org.apache.jena.riot.web.LangTag ;
 
-
 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 ;
 import com.hp.hpl.jena.sparql.graph.NodeTransform ;
+import com.hp.hpl.jena.sparql.util.NodeUtils ;
 import com.hp.hpl.jena.vocabulary.RDF ;
 
 public class CanonicalizeLiteral implements NodeTransform    
@@ -40,42 +40,41 @@ public class CanonicalizeLiteral implements NodeTransform
     private CanonicalizeLiteral() {}
     
     @Override
-    public Node convert(Node node)
-    {
+    public Node convert(Node node) {
         if ( ! node.isLiteral() )
             return node ;
             
         RDFDatatype dt = node.getLiteralDatatype() ;
         Node n2 ;
-        if ( dt == null )
-        {
+        if ( NodeUtils.isLangString(node) ) {
+            // RDF 1.0, no datatype ; RDF 1.1 : datatype is rdf:langString 
             if ( node.getLiteralLanguage().equals("") )
                 //n2 = NormalizeValue.dtSimpleLiteral.handle(node, node.getLiteralLexicalForm(),
null) ;
                 return node ;
             else
-                n2 = canonicalLangtag(node, node.getLiteralLexicalForm(), node.getLiteralLanguage())
; 
-        }
-        else
-        {
-            // Valid?  Yes - assumes checking has been done.
-            // May integrate later
+                n2 = canonicalLangtag(node.getLiteralLexicalForm(), node.getLiteralLanguage())
; 
+        } else if ( dt == null ) {
+            // RDF 1.0 / no lang.
+            n2 = NormalizeValue.dtSimpleLiteral.handle(node, node.getLiteralLexicalForm(),
null) ;
+        } else {
+            // Dataype, not rdf:langString (RDF 1.1). 
             DatatypeHandler handler = dispatch.get(dt) ;
             if ( handler == null )
                 return node ;
-    
             n2 = handler.handle(node, node.getLiteralLexicalForm(), dt) ;
         }
+        
         if ( n2 == null )
             return node ;
         return n2 ;
     }
     
-    private static Node canonicalLangtag(Node node, String lexicalForm, String langTag)
+    private static Node canonicalLangtag(String lexicalForm, String langTag)
     {
         String langTag2 = LangTag.canonical(langTag) ;
         if ( langTag2.equals(langTag) )
             return null ;
-        return NodeFactory.createLiteral(lexicalForm, langTag2, null) ;
+        return NodeFactory.createLiteral(lexicalForm, langTag2) ;
     }
     
     private static final RDFDatatype dtPlainLiteral = NodeFactory.getType(RDF.getURI()+"PlainLiteral")
;


Mime
View raw message