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/12/14 18:01:35 UTC
[1/3] jena git commit: JENA-828 : Sorting of literals for RDF 1.1
Repository: jena
Updated Branches:
refs/heads/master 508ac678d -> bb185e3b8
JENA-828 : Sorting of literals for RDF 1.1
Project: http://git-wip-us.apache.org/repos/asf/jena/repo
Commit: http://git-wip-us.apache.org/repos/asf/jena/commit/932528b1
Tree: http://git-wip-us.apache.org/repos/asf/jena/tree/932528b1
Diff: http://git-wip-us.apache.org/repos/asf/jena/diff/932528b1
Branch: refs/heads/master
Commit: 932528b1ebb2cfb93dbc9046b179c6993743fc80
Parents: 508ac67
Author: Andy Seaborne <an...@apache.org>
Authored: Sun Dec 14 16:53:18 2014 +0000
Committer: Andy Seaborne <an...@apache.org>
Committed: Sun Dec 14 16:53:18 2014 +0000
----------------------------------------------------------------------
.../com/hp/hpl/jena/sparql/util/NodeUtils.java | 252 +++++++++----------
1 file changed, 114 insertions(+), 138 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/jena/blob/932528b1/jena-arq/src/main/java/com/hp/hpl/jena/sparql/util/NodeUtils.java
----------------------------------------------------------------------
diff --git a/jena-arq/src/main/java/com/hp/hpl/jena/sparql/util/NodeUtils.java b/jena-arq/src/main/java/com/hp/hpl/jena/sparql/util/NodeUtils.java
index f8ae6f7..b3e01e8 100644
--- a/jena-arq/src/main/java/com/hp/hpl/jena/sparql/util/NodeUtils.java
+++ b/jena-arq/src/main/java/com/hp/hpl/jena/sparql/util/NodeUtils.java
@@ -41,113 +41,110 @@ import com.hp.hpl.jena.util.iterator.MapFilter ;
import com.hp.hpl.jena.util.iterator.MapFilterIterator ;
import com.hp.hpl.jena.util.iterator.WrappedIterator ;
-
/** Node utilities */
-
-
public class NodeUtils
{
- public interface EqualityTest { boolean equal(Node n1, Node n2) ; }
+ public interface EqualityTest {
+ boolean equal(Node n1, Node n2) ;
+ }
- public static Node asNode(IRI iri) { return NodeFactory.createURI(iri.toString()) ; }
- public static Node asNode(String iri) { return NodeFactory.createURI(iri) ; }
-
- public static boolean isStringLiteral(Node literal)
- {
- if ( ! literal.isLiteral() )
+ public static Node asNode(IRI iri) {
+ return NodeFactory.createURI(iri.toString()) ;
+ }
+
+ public static Node asNode(String iri) {
+ return NodeFactory.createURI(iri) ;
+ }
+
+ public static boolean isStringLiteral(Node literal) {
+ if ( !literal.isLiteral() )
return false ;
- RDFDatatype dType = literal.getLiteralDatatype() ;
+ RDFDatatype dType = literal.getLiteralDatatype() ;
String langTag = literal.getLiteralLanguage() ;
-
+
// Language?
- if ( langTag == null || ! langTag.equals("") ) return false ;
-
+ if ( langTag == null || !langTag.equals("") )
+ return false ;
+
// Datatype
- if ( dType != null && ! dType.equals(XSDDatatype.XSDstring) )
+ if ( dType != null && !dType.equals(XSDDatatype.XSDstring) )
return false ;
-
+
return true ;
}
-
- public static boolean hasLang(Node node)
- {
- if ( ! node.isLiteral() ) return false ;
+
+ public static boolean hasLang(Node node) {
+ if ( !node.isLiteral() )
+ return false ;
String x = node.getLiteralLanguage() ;
- if ( x == null ) return false ;
- if ( x.equals("") ) return false ;
+ if ( x == null )
+ return false ;
+ if ( x.equals("") )
+ return false ;
return true ;
}
-
- // Get the string value of plain literal or XSD string.
-
- public static String stringLiteral(Node literal)
- {
- if ( ! isStringLiteral(literal) ) return null ;
- return literal.getLiteralLexicalForm() ;
+
+ // Get the string value of plain literal or XSD string.
+
+ public static String stringLiteral(Node literal) {
+ if ( !isStringLiteral(literal) )
+ return null ;
+ return literal.getLiteralLexicalForm() ;
}
-
- public static Iterator<String> nodesToURIs(Iterator<Node> iter)
- {
- MapFilter<Node, String> mapper = new MapFilter<Node, String>(){
+
+ public static Iterator<String> nodesToURIs(Iterator<Node> iter) {
+ MapFilter<Node, String> mapper = new MapFilter<Node, String>() {
@Override
- public String accept(Node x)
- {
- return x.getURI() ;
- }} ;
-
+ public String accept(Node x) {
+ return x.getURI() ;
+ }
+ } ;
+
ExtendedIterator<Node> eIter = WrappedIterator.create(iter) ;
Iterator<String> conv = new MapFilterIterator<>(mapper, eIter) ;
return conv ;
}
-
- public static Set<Node> convertToNodes(Collection<String> uris)
- {
+
+ public static Set<Node> convertToNodes(Collection<String> uris) {
Set<Node> nodes = new HashSet<>() ;
for ( String x : uris )
nodes.add(NodeFactory.createURI(x)) ;
return nodes ;
}
-
-
+
/** Compare two Nodes, based on their RDF terms forms, not value */
- public static int compareRDFTerms(Node node1, Node node2)
- {
- if ( node1 == null )
- {
+ public static int compareRDFTerms(Node node1, Node node2) {
+ if ( node1 == null ) {
if ( node2 == null )
return Expr.CMP_EQUAL ;
return Expr.CMP_LESS ;
}
-
+
if ( node2 == null )
return Expr.CMP_GREATER ;
-
+
// No nulls.
if ( node1.isLiteral() && node2.isLiteral() )
return compareLiteralsBySyntax(node1, node2) ;
-
+
// One or both not literals
// Variables < Blank nodes < URIs < Literals
-
- if ( node1.isVariable() )
- {
- if ( node2.isVariable() )
- {
+
+ if ( node1.isVariable() ) {
+ if ( node2.isVariable() ) {
return StrUtils.strCompare(node1.getName(), node2.getName()) ;
}
// Variables before anything else
- return Expr.CMP_LESS;
+ return Expr.CMP_LESS ;
}
-
+
if ( node2.isVariable() ) {
// node1 not variable
return Expr.CMP_GREATER ;
}
-
- if ( node1.isBlank() )
- {
- if ( node2.isBlank() )
- {
+
+ if ( node1.isBlank() ) {
+ if ( node2.isBlank() ) {
String s1 = node1.getBlankNodeId().getLabelString() ;
String s2 = node2.getBlankNodeId().getLabelString() ;
return StrUtils.strCompare(s1, s2) ;
@@ -155,24 +152,22 @@ public class NodeUtils
// bNodes before anything but variables
return Expr.CMP_LESS ;
}
-
+
if ( node2.isBlank() )
// node1 not blank.
- return Expr.CMP_GREATER ;
-
- // Not blanks. 2 URI or one URI and one literal
-
- if ( node1.isURI() )
- {
- if ( node2.isURI() )
- {
+ return Expr.CMP_GREATER ;
+
+ // Not blanks. 2 URI or one URI and one literal
+
+ if ( node1.isURI() ) {
+ if ( node2.isURI() ) {
String s1 = node1.getURI() ;
String s2 = node2.getURI() ;
- return StrUtils.strCompare(s1, s2) ;
+ return StrUtils.strCompare(s1, s2) ;
}
return Expr.CMP_LESS ;
}
-
+
if ( node2.isURI() )
return Expr.CMP_GREATER ;
@@ -180,92 +175,73 @@ public class NodeUtils
// And a pair of literals was filterd out first.
// Should not happen.
- throw new ARQInternalErrorException("Compare: "+node1+" "+node2) ;
+ throw new ARQInternalErrorException("Compare: " + node1 + " " + node2) ;
}
- // Compare literals by kind - not by value.
- // public for testing - otherwise call compareRDFTerms
- // Ordering:
- // 1/ By lexical form
- // 2/ For same lexical form:
- // simple literal < literal by lang < literal with type
- // 3/ Lang by sorting on language tag (first case insensistive then case sensitive)
- // 4/ Datatypes by URI
+ /** Compare literals by kind - not by value.
+ * Gives a determinitics, stable, arbitrary ordering between unrelated literals.
+ *
+ * Ordering:
+ * <ol>
+ * <li>By lexical form</li>
+ * <li> For same lexical form:
+ * <ul>
+ * <li> RDF 1.0 : simple literal < literal by lang < literal with type
+ * <li> RDF 1.1 : xsd:string < rdf:langString < other dataypes.<br/>
+ * This is the closest to SPARQL 1.1: treat xsd:string as a simple literal</ul></li>
+ * <li> Lang by sorting on language tag (first case insensistive then case sensitive)
+ * <li> Datatypes by URI
+ * </ol>
+ */
- private static int compareLiteralsBySyntax(Node node1, Node node2)
- {
- if ( node1 == null || ! node1.isLiteral() ||
- node2 == null || ! node2.isLiteral() )
- throw new ARQInternalErrorException("compareLiteralsBySyntax called with non-literal: ("+node1+","+node2+")") ;
+ private static int compareLiteralsBySyntax(Node node1, Node node2) {
+ if ( node1 == null || !node1.isLiteral() || node2 == null || !node2.isLiteral() )
+ throw new ARQInternalErrorException("compareLiteralsBySyntax called with non-literal: (" + node1 + "," + node2 + ")") ;
if ( node1.equals(node2) )
return Expr.CMP_EQUAL ;
String lex1 = node1.getLiteralLexicalForm() ;
String lex2 = node2.getLiteralLexicalForm() ;
-
+
int x = StrUtils.strCompare(lex1, lex2) ;
if ( x != Expr.CMP_EQUAL )
return x ;
-
- // Same lexical form. Not .equals()
-
- String lang1 = node1.getLiteralLanguage() ;
- String lang2 = node2.getLiteralLanguage() ;
-
- String dt1 = node1.getLiteralDatatypeURI() ;
- String dt2 = node2.getLiteralDatatypeURI() ;
- if ( lang1 == null )
- throw new ARQInternalErrorException("Language tag is null: "+node1) ;
- if ( lang2 == null )
- throw new ARQInternalErrorException("Language tag is null: "+node2) ;
-
- if ( simpleLiteral(node1) )
- // Node 2 can't be simple because they'd be the same
+ // Same lexical form. Not .equals()
+ if ( isSimpleString(node1) ) // node2 not a simple string because they
+ // would be .equals
return Expr.CMP_LESS ;
-
- if ( simpleLiteral(node2) )
+ if ( isSimpleString(node2) )
return Expr.CMP_GREATER ;
-
- // Neither simple.
-
- // Language before datatypes.
- // Can't both be no lang, no datatype
- // because they are already same lexcial form
- // so they'd be same simple literal.
-
- if ( ! lang1.equals("") && dt2 != null )
+ // Neither simple string / xsd:string(RDF 1.1)
+
+ // Both language strings?
+ if ( isLangString(node1) && isLangString(node2) ) {
+ String lang1 = node1.getLiteralLanguage() ;
+ String lang2 = node2.getLiteralLanguage() ;
+ x = StrUtils.strCompareIgnoreCase(lang1, lang2) ;
+ if ( x != Expr.CMP_EQUAL )
+ return x ;
+ x = StrUtils.strCompare(lang1, lang2) ;
+ if ( x != Expr.CMP_EQUAL )
+ return x ;
+ throw new ARQInternalErrorException("compareLiteralsBySyntax: lexical form and languages tags identical on non.equals literals") ;
+ }
+
+ // One a language string?
+ if ( isLangString(node1) )
return Expr.CMP_LESS ;
-
- if ( dt1 != null && ! lang2.equals("") )
+ if ( isLangString(node2) )
return Expr.CMP_GREATER ;
-
- // Both language tags, or both datatypes
-
- if ( dt1 == null && dt2 == null )
- {
- // Syntactic - lang tags case considered
- // case sensitive if necessary
- x = StrUtils.strCompareIgnoreCase(lang1, lang2) ;
- if ( x != Expr.CMP_EQUAL )
- return x ;
- x = StrUtils.strCompare(lang1, lang2) ;
- if ( x != Expr.CMP_EQUAL )
- return x ;
- throw new ARQInternalErrorException("compareLiteralsBySyntax: lexical form and languages tags identical on non.equals literals");
- }
-
+
+ // Both have other datatypes. Neither simple nor language tagged.
+ String dt1 = node1.getLiteralDatatypeURI() ;
+ String dt2 = node2.getLiteralDatatypeURI() ;
// Two datatypes.
return StrUtils.strCompare(dt1, dt2) ;
}
- private static boolean simpleLiteral(Node node)
- {
- return node.getLiteralDatatypeURI() == null &&
- node.getLiteralLanguage().equals("") ;
- }
-
/**
* A Node is a simple string if:
* <li>(RDF 1.0) No datatype and no language tag
[2/3] jena git commit: Tidy
Posted by an...@apache.org.
Tidy
Project: http://git-wip-us.apache.org/repos/asf/jena/repo
Commit: http://git-wip-us.apache.org/repos/asf/jena/commit/92652425
Tree: http://git-wip-us.apache.org/repos/asf/jena/tree/92652425
Diff: http://git-wip-us.apache.org/repos/asf/jena/diff/92652425
Branch: refs/heads/master
Commit: 92652425319b4404b4a67548f1ecfed3778a1274
Parents: 932528b
Author: Andy Seaborne <an...@apache.org>
Authored: Sun Dec 14 16:53:51 2014 +0000
Committer: Andy Seaborne <an...@apache.org>
Committed: Sun Dec 14 16:53:51 2014 +0000
----------------------------------------------------------------------
.../org/apache/jena/fuseki/server/ShiroEnvironmentLoader.java | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/jena/blob/92652425/jena-fuseki2/src/main/java/org/apache/jena/fuseki/server/ShiroEnvironmentLoader.java
----------------------------------------------------------------------
diff --git a/jena-fuseki2/src/main/java/org/apache/jena/fuseki/server/ShiroEnvironmentLoader.java b/jena-fuseki2/src/main/java/org/apache/jena/fuseki/server/ShiroEnvironmentLoader.java
index 29a633a..c7f679c 100644
--- a/jena-fuseki2/src/main/java/org/apache/jena/fuseki/server/ShiroEnvironmentLoader.java
+++ b/jena-fuseki2/src/main/java/org/apache/jena/fuseki/server/ShiroEnvironmentLoader.java
@@ -44,6 +44,9 @@ import com.hp.hpl.jena.util.FileUtils ;
public class ShiroEnvironmentLoader extends EnvironmentLoader implements ServletContextListener {
private static Logger confLog = Fuseki.configLog ;
private ServletContext servletContext ;
+
+ public ShiroEnvironmentLoader() {}
+
@Override
public void contextInitialized(ServletContextEvent sce) {
FusekiServer.init() ;
@@ -56,7 +59,6 @@ public class ShiroEnvironmentLoader extends EnvironmentLoader implements Servlet
// Exit?
throw ex ;
}
-
}
@Override
[3/3] jena git commit: Remove mistaken dev code
Posted by an...@apache.org.
Remove mistaken dev code
Project: http://git-wip-us.apache.org/repos/asf/jena/repo
Commit: http://git-wip-us.apache.org/repos/asf/jena/commit/bb185e3b
Tree: http://git-wip-us.apache.org/repos/asf/jena/tree/bb185e3b
Diff: http://git-wip-us.apache.org/repos/asf/jena/diff/bb185e3b
Branch: refs/heads/master
Commit: bb185e3b8e5ad47ca99a1bef7ed810e502a53e0c
Parents: 9265242
Author: Andy Seaborne <an...@apache.org>
Authored: Sun Dec 14 17:01:15 2014 +0000
Committer: Andy Seaborne <an...@apache.org>
Committed: Sun Dec 14 17:01:15 2014 +0000
----------------------------------------------------------------------
jena-fuseki2/src/main/webapp/js/app/views/dataset-management.js | 1 -
1 file changed, 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/jena/blob/bb185e3b/jena-fuseki2/src/main/webapp/js/app/views/dataset-management.js
----------------------------------------------------------------------
diff --git a/jena-fuseki2/src/main/webapp/js/app/views/dataset-management.js b/jena-fuseki2/src/main/webapp/js/app/views/dataset-management.js
index 7f65982..7f5e7d8 100644
--- a/jena-fuseki2/src/main/webapp/js/app/views/dataset-management.js
+++ b/jena-fuseki2/src/main/webapp/js/app/views/dataset-management.js
@@ -104,7 +104,6 @@ define(
onDatasetRemoveSuccess: function( data, dsId ) {
console.log( "deleted dataset" );
- window.location.reload() ;
},
/** Removing the dataset did not work: notify the user */