Return-Path: X-Original-To: apmail-jena-commits-archive@www.apache.org Delivered-To: apmail-jena-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 0DDF310510 for ; Mon, 1 Dec 2014 21:37:40 +0000 (UTC) Received: (qmail 34705 invoked by uid 500); 1 Dec 2014 21:37:39 -0000 Delivered-To: apmail-jena-commits-archive@jena.apache.org Received: (qmail 34651 invoked by uid 500); 1 Dec 2014 21:37:39 -0000 Mailing-List: contact commits-help@jena.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@jena.apache.org Delivered-To: mailing list commits@jena.apache.org Received: (qmail 34629 invoked by uid 99); 1 Dec 2014 21:37:39 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 01 Dec 2014 21:37:39 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 9D2B29B4734; Mon, 1 Dec 2014 21:37:39 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: andy@apache.org To: commits@jena.apache.org Date: Mon, 01 Dec 2014 21:37:40 -0000 Message-Id: <85cf7ae496be4dd3bdda99923465f3b0@git.apache.org> In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [2/4] jena git commit: Remove very fragile helper. Put code in RDFJSONWriter itself. 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 Authored: Mon Dec 1 20:51:08 2014 +0000 Committer: Andy Seaborne 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>>> { - - 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>> 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> predicates = item.getRight() ; - for (Node p : predicates.keySet() ) { - out.key(p.getURI()) ; - out.startArray() ; - Set 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); - } - } - -}