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/01 22:37:39 UTC
[1/4] jena git commit: Remove old,
deprecated writer and its very fragile helper.
Repository: jena
Updated Branches:
refs/heads/master b9b49abf3 -> f11ebe2a4
Remove old, deprecated writer and its very fragile helper.
Project: http://git-wip-us.apache.org/repos/asf/jena/repo
Commit: http://git-wip-us.apache.org/repos/asf/jena/commit/b20d07ca
Tree: http://git-wip-us.apache.org/repos/asf/jena/tree/b20d07ca
Diff: http://git-wip-us.apache.org/repos/asf/jena/diff/b20d07ca
Branch: refs/heads/master
Commit: b20d07caa4483e410c5f295ca9a16a3566dc15b9
Parents: b9b49ab
Author: Andy Seaborne <an...@apache.org>
Authored: Mon Dec 1 20:50:35 2014 +0000
Committer: Andy Seaborne <an...@apache.org>
Committed: Mon Dec 1 20:50:35 2014 +0000
----------------------------------------------------------------------
.../org/apache/jena/riot/out/RDFJSONWriter.java | 54 -------
.../apache/jena/riot/out/SinkEntityOutput.java | 147 -------------------
2 files changed, 201 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/jena/blob/b20d07ca/jena-arq/src/main/java/org/apache/jena/riot/out/RDFJSONWriter.java
----------------------------------------------------------------------
diff --git a/jena-arq/src/main/java/org/apache/jena/riot/out/RDFJSONWriter.java b/jena-arq/src/main/java/org/apache/jena/riot/out/RDFJSONWriter.java
deleted file mode 100644
index 1468552..0000000
--- a/jena-arq/src/main/java/org/apache/jena/riot/out/RDFJSONWriter.java
+++ /dev/null
@@ -1,54 +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 org.apache.jena.riot.out;
-
-import java.io.OutputStream ;
-import java.io.Writer ;
-
-import org.apache.jena.riot.Lang ;
-import org.apache.jena.riot.RDFDataMgr ;
-
-import com.hp.hpl.jena.graph.Graph ;
-
-/** @deprecated
- * Use {@link RDFDataMgr#write(OutputStream, Graph, Lang)} with {@code Lang.RDFJSON}
- */
-@Deprecated
-public class RDFJSONWriter {
-
- //public RDFJSONWriter() {}
-
- /** @deprecated
- * Use {@link RDFDataMgr#write(OutputStream, Graph, Lang)}
- * with {@code Lang.RDFJSON}
- */
- @Deprecated
- public static void write (OutputStream out, Graph graph) {
- RDFDataMgr.write(out, graph, Lang.RDFJSON) ;
- }
-
- /** @deprecated
- * Use {@link RDFDataMgr#write(OutputStream, Graph, Lang)}
- * with {@code Lang.RDFJSON}
- */
- @Deprecated
- public static void write (Writer out, Graph graph) {
- RDFDataMgr.write(out, graph, Lang.RDFJSON) ;
- }
-}
http://git-wip-us.apache.org/repos/asf/jena/blob/b20d07ca/jena-arq/src/main/java/org/apache/jena/riot/out/SinkEntityOutput.java
----------------------------------------------------------------------
diff --git a/jena-arq/src/main/java/org/apache/jena/riot/out/SinkEntityOutput.java b/jena-arq/src/main/java/org/apache/jena/riot/out/SinkEntityOutput.java
deleted file mode 100644
index 12df828..0000000
--- a/jena-arq/src/main/java/org/apache/jena/riot/out/SinkEntityOutput.java
+++ /dev/null
@@ -1,147 +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 org.apache.jena.riot.out;
-
-import java.io.OutputStream ;
-import java.io.Writer ;
-import java.util.Map ;
-import java.util.Set ;
-
-import org.apache.jena.atlas.io.IndentedWriter ;
-import org.apache.jena.atlas.json.io.JSWriter ;
-import org.apache.jena.atlas.lib.Pair ;
-import org.apache.jena.atlas.lib.Sink ;
-import org.apache.jena.riot.RiotException ;
-import org.apache.jena.riot.system.Prologue ;
-import org.apache.jena.riot.system.SyntaxLabels ;
-
-import com.hp.hpl.jena.graph.Node;
-
-public class SinkEntityOutput implements Sink<Pair<Node, Map<Node, Set<Node>>>> {
-
- private Prologue prologue = null ;
- private NodeToLabel labelPolicy = null ;
- private JSWriter out ;
-
- public SinkEntityOutput(OutputStream outs)
- {
- this(outs, null, SyntaxLabels.createNodeToLabel()) ;
- }
-
- public SinkEntityOutput(OutputStream outs, Prologue prologue, NodeToLabel labels)
- {
- init(new JSWriter(outs), prologue, labels) ;
- }
-
- public SinkEntityOutput(Writer outs)
- {
- this(outs, null, SyntaxLabels.createNodeToLabel()) ;
- }
-
- public SinkEntityOutput(Writer outs, Prologue prologue, NodeToLabel labels)
- {
- init(new JSWriter(new IndentedWriterEx(outs)), prologue, labels) ;
- }
-
- private void init (JSWriter out, Prologue prologue, NodeToLabel labels)
- {
- this.out = out ;
- setPrologue(prologue) ;
- setLabelPolicy(labels) ;
- out.startOutput() ;
- out.startObject() ;
- }
-
- public void setPrologue(Prologue prologue)
- {
- this.prologue = prologue ;
- }
-
- public void setLabelPolicy(NodeToLabel labels)
- {
- this.labelPolicy = labels ;
- }
-
- @Override
- public void send(Pair<Node, Map<Node, Set<Node>>> item) {
- Node s = item.getLeft() ;
- if ( s.isBlank() ) {
- out.key("_:" + s.getBlankNodeLabel()) ;
- } else if ( s.isURI() ) {
- out.key(s.getURI()) ;
- } else {
- throw new RiotException ("Only URIs or blank nodes are legal subjects.") ;
- }
- out.startObject() ;
- // out.pair(key, value) ;
- Map<Node, Set<Node>> predicates = item.getRight() ;
- for (Node p : predicates.keySet() ) {
- out.key(p.getURI()) ;
- out.startArray() ;
- Set<Node> objects = predicates.get(p) ;
- int i = 0;
- for ( Node o : objects ) {
- out.startObject() ;
- if ( o.isBlank() ) {
- out.pair("type", "bnode") ;
- out.pair("value", "_:" + o.getBlankNodeLabel()) ;
- } else if ( o.isURI() ) {
- out.pair("type", "uri") ;
- out.pair("value", o.getURI()) ;
- } else if ( o.isLiteral() ) {
- String dt = o.getLiteralDatatypeURI() ;
- String lang = o.getLiteralLanguage() ;
- String lex = o.getLiteralLexicalForm() ;
- out.pair("type", "literal") ;
- out.pair("value", lex) ;
- if ( dt != null )
- out.pair("datatype", dt) ;
- if ( ( lang != null ) && ( lang != "" ) )
- out.pair("lang", lang) ;
- }
- out.finishObject() ;
- if (i < objects.size() - 1)
- {
- out.arraySep();
- }
- i++;
- }
- out.finishArray() ;
- }
- out.finishObject() ;
- }
-
- @Override
- public void flush() {
- out.finishObject() ;
- out.finishOutput();
- }
-
- @Override
- public void close() {
- flush() ;
- }
-
- private class IndentedWriterEx extends IndentedWriter {
- public IndentedWriterEx(Writer writer) {
- super(writer);
- }
- }
-
-}
[4/4] jena git commit: Add more dev files to RAT exclusions
Posted by an...@apache.org.
Add more dev files to RAT exclusions
Project: http://git-wip-us.apache.org/repos/asf/jena/repo
Commit: http://git-wip-us.apache.org/repos/asf/jena/commit/f11ebe2a
Tree: http://git-wip-us.apache.org/repos/asf/jena/tree/f11ebe2a
Diff: http://git-wip-us.apache.org/repos/asf/jena/diff/f11ebe2a
Branch: refs/heads/master
Commit: f11ebe2a43c29fbdda4ae08385a02ecbb930164a
Parents: fdc666e
Author: Andy Seaborne <an...@apache.org>
Authored: Mon Dec 1 21:37:28 2014 +0000
Committer: Andy Seaborne <an...@apache.org>
Committed: Mon Dec 1 21:37:28 2014 +0000
----------------------------------------------------------------------
jena-parent/pom.xml | 4 ++++
1 file changed, 4 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/jena/blob/f11ebe2a/jena-parent/pom.xml
----------------------------------------------------------------------
diff --git a/jena-parent/pom.xml b/jena-parent/pom.xml
index 2a3d2a3..81ccd61 100644
--- a/jena-parent/pom.xml
+++ b/jena-parent/pom.xml
@@ -397,6 +397,10 @@
<exclude>**/DB/**/*</exclude>
<!-- TDB config files JSON - no comments allowed -->
<exclude>**/tdb*.cfg</exclude>
+ <!-- Fuseki2 server "run" area -->
+ <exclude>**/run/**/*</exclude>
+ <!-- Cached classpath for commands - autogenerated -->
+ <exclude>**/*.classpath</exclude>
</excludes>
</configuration>
</plugin>
[3/4] jena git commit: JENA-816 : Adapt for RDF 1.0/RDF 1.1.
Posted by an...@apache.org.
JENA-816 : Adapt for RDF 1.0/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/fdc666e0
Tree: http://git-wip-us.apache.org/repos/asf/jena/tree/fdc666e0
Diff: http://git-wip-us.apache.org/repos/asf/jena/diff/fdc666e0
Branch: refs/heads/master
Commit: fdc666e031095786f47ae29264bac8e860cf54a6
Parents: 0189468
Author: Andy Seaborne <an...@apache.org>
Authored: Mon Dec 1 20:51:39 2014 +0000
Committer: Andy Seaborne <an...@apache.org>
Committed: Mon Dec 1 20:51:39 2014 +0000
----------------------------------------------------------------------
.../apache/jena/riot/writer/RDFJSONWriter.java | 114 ++++++++++++++-----
1 file changed, 87 insertions(+), 27 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/jena/blob/fdc666e0/jena-arq/src/main/java/org/apache/jena/riot/writer/RDFJSONWriter.java
----------------------------------------------------------------------
diff --git a/jena-arq/src/main/java/org/apache/jena/riot/writer/RDFJSONWriter.java b/jena-arq/src/main/java/org/apache/jena/riot/writer/RDFJSONWriter.java
index dc62df0..400fcbe 100644
--- a/jena-arq/src/main/java/org/apache/jena/riot/writer/RDFJSONWriter.java
+++ b/jena-arq/src/main/java/org/apache/jena/riot/writer/RDFJSONWriter.java
@@ -25,18 +25,19 @@ import java.util.HashSet ;
import java.util.Map ;
import java.util.Set ;
+import org.apache.jena.atlas.io.IndentedWriter ;
+import org.apache.jena.atlas.json.io.JSWriter ;
import org.apache.jena.atlas.lib.Pair ;
-import org.apache.jena.atlas.lib.Sink ;
import org.apache.jena.riot.Lang ;
+import org.apache.jena.riot.RiotException ;
import org.apache.jena.riot.system.PrefixMap ;
-import org.apache.jena.riot.system.Prologue ;
-import org.apache.jena.riot.system.SyntaxLabels ;
import com.hp.hpl.jena.graph.Graph ;
import com.hp.hpl.jena.graph.GraphUtil ;
import com.hp.hpl.jena.graph.Node ;
import com.hp.hpl.jena.graph.Triple ;
import com.hp.hpl.jena.sparql.util.Context ;
+import com.hp.hpl.jena.sparql.util.NodeUtils ;
import com.hp.hpl.jena.util.iterator.ExtendedIterator ;
public class RDFJSONWriter extends WriterGraphRIOTBase
@@ -44,18 +45,35 @@ public class RDFJSONWriter extends WriterGraphRIOTBase
public RDFJSONWriter() {}
public static void output(OutputStream out, Graph graph) {
- Prologue prologue = Prologue.create(null, null) ; // (null, graph.getPrefixMapping()) ;
- Sink<Pair<Node, Map<Node, Set<Node>>>> sink = new SinkEntityOutput(out, prologue, SyntaxLabels.createNodeToLabel()) ;
- output( sink, graph ) ;
+ output(new JSWriter(out), graph ) ;
}
public static void output(Writer out, Graph graph) {
- Prologue prologue = Prologue.create(null, null) ; // (null, graph.getPrefixMapping()) ;
- Sink<Pair<Node, Map<Node, Set<Node>>>> sink = new SinkEntityOutput(out, prologue, SyntaxLabels.createNodeToLabel()) ;
- output( sink, graph ) ;
+ output(new JSWriter(new IndentedWriterEx(out)), graph ) ;
}
- private static void output(Sink<Pair<Node, Map<Node, Set<Node>>>> sink, Graph graph) {
+ @Override
+ public Lang getLang()
+ {
+ return Lang.RDFJSON ;
+ }
+
+ @Override
+ public void write(Writer out, Graph graph, PrefixMap prefixMap, String baseURI, Context context)
+ {
+ output(out, graph) ;
+ }
+
+ @Override
+ public void write(OutputStream out, Graph graph, PrefixMap prefixMap, String baseURI, Context context)
+ {
+ output(out, graph) ;
+ }
+
+ private static void output(JSWriter out, Graph graph) {
+ out.startOutput() ;
+ out.startObject();
+
ExtendedIterator<Node> subjects = GraphUtil.listSubjects(graph, Node.ANY, Node.ANY) ;
try {
Map<Node, Set<Node>> predicates = new HashMap<>() ;
@@ -77,31 +95,73 @@ public class RDFJSONWriter extends WriterGraphRIOTBase
} finally {
if ( triples != null ) triples.close() ;
}
- sink.send(new Pair<>(subject, predicates)) ;
+ send(out, new Pair<>(subject, predicates)) ;
predicates.clear() ;
}
} finally {
if ( subjects != null ) subjects.close() ;
- sink.close() ;
+ out.finishObject();
+ out.finishOutput() ;
}
}
- @Override
- public Lang getLang()
- {
- return Lang.RDFJSON ;
- }
-
- @Override
- public void write(Writer out, Graph graph, PrefixMap prefixMap, String baseURI, Context context)
- {
- output(out, graph) ;
- }
+ private static void send(JSWriter out, Pair<Node, Map<Node, Set<Node>>> item) {
+ Node s = item.getLeft() ;
+ if ( s.isBlank() ) {
+ out.key("_:" + s.getBlankNodeLabel()) ;
+ } else if ( s.isURI() ) {
+ out.key(s.getURI()) ;
+ } else {
+ throw new RiotException ("Only URIs or blank nodes are legal subjects.") ;
+ }
- @Override
- public void write(OutputStream out, Graph graph, PrefixMap prefixMap, String baseURI, Context context)
- {
- output(out, graph) ;
+ out.startObject() ;
+ // out.pair(key, value) ;
+ Map<Node, Set<Node>> predicates = item.getRight() ;
+ for (Node p : predicates.keySet() ) {
+ out.key(p.getURI()) ;
+ out.startArray() ;
+ Set<Node> objects = predicates.get(p) ;
+ int i = 0;
+ for ( Node o : objects ) {
+ out.startObject() ;
+ if ( o.isBlank() ) {
+ out.pair("type", "bnode") ;
+ out.pair("value", "_:" + o.getBlankNodeLabel()) ;
+ } else if ( o.isURI() ) {
+ out.pair("type", "uri") ;
+ out.pair("value", o.getURI()) ;
+ } else if ( o.isLiteral() ) {
+ String lex = o.getLiteralLexicalForm() ;
+ out.pair("type", "literal") ;
+ out.pair("value", lex) ;
+
+ if ( NodeUtils.isSimpleString(o) ) {
+ // No-op.
+ } else if ( NodeUtils.isLangString(o) ) {
+ String lang = o.getLiteralLanguage() ;
+ out.pair("lang", lang) ;
+ } else {
+ // Datatype, nothing special.
+ String dt = o.getLiteralDatatypeURI() ;
+ out.pair("datatype", dt) ;
+ }
+ }
+ out.finishObject() ;
+ if (i < objects.size() - 1)
+ {
+ out.arraySep();
+ }
+ i++;
+ }
+ out.finishArray() ;
+ }
+ out.finishObject() ;
}
+ private static class IndentedWriterEx extends IndentedWriter {
+ public IndentedWriterEx(Writer writer) {
+ super(writer);
+ }
+ }
}
[2/4] jena git commit: Remove very fragile helper. Put code in
RDFJSONWriter itself.
Posted by an...@apache.org.
Remove very fragile helper. Put code in RDFJSONWriter itself.
Project: http://git-wip-us.apache.org/repos/asf/jena/repo
Commit: http://git-wip-us.apache.org/repos/asf/jena/commit/0189468c
Tree: http://git-wip-us.apache.org/repos/asf/jena/tree/0189468c
Diff: http://git-wip-us.apache.org/repos/asf/jena/diff/0189468c
Branch: refs/heads/master
Commit: 0189468c6daa15ab4ac58d9672dcc2b55f684804
Parents: b20d07c
Author: Andy Seaborne <an...@apache.org>
Authored: Mon Dec 1 20:51:08 2014 +0000
Committer: Andy Seaborne <an...@apache.org>
Committed: Mon Dec 1 20:51:08 2014 +0000
----------------------------------------------------------------------
.../jena/riot/writer/SinkEntityOutput.java | 148 -------------------
1 file changed, 148 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/jena/blob/0189468c/jena-arq/src/main/java/org/apache/jena/riot/writer/SinkEntityOutput.java
----------------------------------------------------------------------
diff --git a/jena-arq/src/main/java/org/apache/jena/riot/writer/SinkEntityOutput.java b/jena-arq/src/main/java/org/apache/jena/riot/writer/SinkEntityOutput.java
deleted file mode 100644
index 8e4e6b1..0000000
--- a/jena-arq/src/main/java/org/apache/jena/riot/writer/SinkEntityOutput.java
+++ /dev/null
@@ -1,148 +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 org.apache.jena.riot.writer;
-
-import java.io.OutputStream ;
-import java.io.Writer ;
-import java.util.Map ;
-import java.util.Set ;
-
-import org.apache.jena.atlas.io.IndentedWriter ;
-import org.apache.jena.atlas.json.io.JSWriter ;
-import org.apache.jena.atlas.lib.Pair ;
-import org.apache.jena.atlas.lib.Sink ;
-import org.apache.jena.riot.RiotException ;
-import org.apache.jena.riot.out.NodeToLabel ;
-import org.apache.jena.riot.system.Prologue ;
-import org.apache.jena.riot.system.SyntaxLabels ;
-
-import com.hp.hpl.jena.graph.Node ;
-
-public class SinkEntityOutput implements Sink<Pair<Node, Map<Node, Set<Node>>>> {
-
- private Prologue prologue = null ;
- private NodeToLabel labelPolicy = null ;
- private JSWriter out ;
-
- public SinkEntityOutput(OutputStream outs)
- {
- this(outs, null, SyntaxLabels.createNodeToLabel()) ;
- }
-
- public SinkEntityOutput(OutputStream outs, Prologue prologue, NodeToLabel labels)
- {
- init(new JSWriter(outs), prologue, labels) ;
- }
-
- public SinkEntityOutput(Writer outs)
- {
- this(outs, null, SyntaxLabels.createNodeToLabel()) ;
- }
-
- public SinkEntityOutput(Writer outs, Prologue prologue, NodeToLabel labels)
- {
- init(new JSWriter(new IndentedWriterEx(outs)), prologue, labels) ;
- }
-
- private void init (JSWriter out, Prologue prologue, NodeToLabel labels)
- {
- this.out = out ;
- setPrologue(prologue) ;
- setLabelPolicy(labels) ;
- out.startOutput() ;
- out.startObject() ;
- }
-
- public void setPrologue(Prologue prologue)
- {
- this.prologue = prologue ;
- }
-
- public void setLabelPolicy(NodeToLabel labels)
- {
- this.labelPolicy = labels ;
- }
-
- @Override
- public void send(Pair<Node, Map<Node, Set<Node>>> item) {
- Node s = item.getLeft() ;
- if ( s.isBlank() ) {
- out.key("_:" + s.getBlankNodeLabel()) ;
- } else if ( s.isURI() ) {
- out.key(s.getURI()) ;
- } else {
- throw new RiotException ("Only URIs or blank nodes are legal subjects.") ;
- }
- out.startObject() ;
- // out.pair(key, value) ;
- Map<Node, Set<Node>> predicates = item.getRight() ;
- for (Node p : predicates.keySet() ) {
- out.key(p.getURI()) ;
- out.startArray() ;
- Set<Node> objects = predicates.get(p) ;
- int i = 0;
- for ( Node o : objects ) {
- out.startObject() ;
- if ( o.isBlank() ) {
- out.pair("type", "bnode") ;
- out.pair("value", "_:" + o.getBlankNodeLabel()) ;
- } else if ( o.isURI() ) {
- out.pair("type", "uri") ;
- out.pair("value", o.getURI()) ;
- } else if ( o.isLiteral() ) {
- String dt = o.getLiteralDatatypeURI() ;
- String lang = o.getLiteralLanguage() ;
- String lex = o.getLiteralLexicalForm() ;
- out.pair("type", "literal") ;
- out.pair("value", lex) ;
- if ( dt != null )
- out.pair("datatype", dt) ;
- if ( ( lang != null ) && ( lang != "" ) )
- out.pair("lang", lang) ;
- }
- out.finishObject() ;
- if (i < objects.size() - 1)
- {
- out.arraySep();
- }
- i++;
- }
- out.finishArray() ;
- }
- out.finishObject() ;
- }
-
- @Override
- public void flush() {
- out.finishObject() ;
- out.finishOutput();
- }
-
- @Override
- public void close() {
- flush() ;
- }
-
- private class IndentedWriterEx extends IndentedWriter {
- public IndentedWriterEx(Writer writer) {
- super(writer);
- }
- }
-
-}