You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@clerezza.apache.org by re...@apache.org on 2015/05/26 10:44:23 UTC
[2/2] clerezza git commit: CLEREZZA-966:moved rdfjson to be a child
of rdf
CLEREZZA-966:moved rdfjson to be a child of rdf
Project: http://git-wip-us.apache.org/repos/asf/clerezza/repo
Commit: http://git-wip-us.apache.org/repos/asf/clerezza/commit/c8293374
Tree: http://git-wip-us.apache.org/repos/asf/clerezza/tree/c8293374
Diff: http://git-wip-us.apache.org/repos/asf/clerezza/diff/c8293374
Branch: refs/heads/master
Commit: c8293374efb8e89a2846118654c62df3f08a977c
Parents: 9794006
Author: Reto Gmür <re...@apache.org>
Authored: Tue May 26 10:43:45 2015 +0200
Committer: Reto Gmür <re...@apache.org>
Committed: Tue May 26 10:43:45 2015 +0200
----------------------------------------------------------------------
pom.xml | 1 -
rdf.rdfjson/LICENSE | 201 --------------
rdf.rdfjson/README.md | 4 -
rdf.rdfjson/pom.xml | 79 ------
.../rdfjson/parser/RdfJsonParsingProvider.java | 144 ----------
.../serializer/RdfJsonSerializingProvider.java | 217 ---------------
...ezza.rdf.core.serializedform.ParsingProvider | 1 -
....rdf.core.serializedform.SerializingProvider | 1 -
.../parser/RdfJsonParserProviderTest.java | 87 ------
.../RdfJsonSerializerProviderTest.java | 277 -------------------
.../rdf/rdfjson/parser/test-object-bnode.json | 5 -
.../rdf/rdfjson/parser/test-subject-bnode.json | 10 -
.../clerezza/rdf/rdfjson/parser/test.json | 16 --
rdf/pom.xml | 1 +
rdf/rdfjson/LICENSE | 201 ++++++++++++++
rdf/rdfjson/README.md | 4 +
rdf/rdfjson/pom.xml | 79 ++++++
.../rdfjson/parser/RdfJsonParsingProvider.java | 144 ++++++++++
.../serializer/RdfJsonSerializingProvider.java | 217 +++++++++++++++
...ezza.rdf.core.serializedform.ParsingProvider | 1 +
....rdf.core.serializedform.SerializingProvider | 1 +
.../parser/RdfJsonParserProviderTest.java | 87 ++++++
.../RdfJsonSerializerProviderTest.java | 277 +++++++++++++++++++
.../rdf/rdfjson/parser/test-object-bnode.json | 5 +
.../rdf/rdfjson/parser/test-subject-bnode.json | 10 +
.../clerezza/rdf/rdfjson/parser/test.json | 16 ++
26 files changed, 1043 insertions(+), 1043 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/clerezza/blob/c8293374/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 2897792..fc39996 100644
--- a/pom.xml
+++ b/pom.xml
@@ -72,7 +72,6 @@
<module>rdf.cris</module>
<module>rdf.enrichment</module>
<module>rdf.locking</module>
- <module>rdf.rdfjson</module>
<module>shell</module>
<module>shell.felixshellcommand</module>
<module>bundledevtool</module>
http://git-wip-us.apache.org/repos/asf/clerezza/blob/c8293374/rdf.rdfjson/LICENSE
----------------------------------------------------------------------
diff --git a/rdf.rdfjson/LICENSE b/rdf.rdfjson/LICENSE
deleted file mode 100644
index 261eeb9..0000000
--- a/rdf.rdfjson/LICENSE
+++ /dev/null
@@ -1,201 +0,0 @@
- Apache License
- Version 2.0, January 2004
- http://www.apache.org/licenses/
-
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-
- 1. Definitions.
-
- "License" shall mean the terms and conditions for use, reproduction,
- and distribution as defined by Sections 1 through 9 of this document.
-
- "Licensor" shall mean the copyright owner or entity authorized by
- the copyright owner that is granting the License.
-
- "Legal Entity" shall mean the union of the acting entity and all
- other entities that control, are controlled by, or are under common
- control with that entity. For the purposes of this definition,
- "control" means (i) the power, direct or indirect, to cause the
- direction or management of such entity, whether by contract or
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
- outstanding shares, or (iii) beneficial ownership of such entity.
-
- "You" (or "Your") shall mean an individual or Legal Entity
- exercising permissions granted by this License.
-
- "Source" form shall mean the preferred form for making modifications,
- including but not limited to software source code, documentation
- source, and configuration files.
-
- "Object" form shall mean any form resulting from mechanical
- transformation or translation of a Source form, including but
- not limited to compiled object code, generated documentation,
- and conversions to other media types.
-
- "Work" shall mean the work of authorship, whether in Source or
- Object form, made available under the License, as indicated by a
- copyright notice that is included in or attached to the work
- (an example is provided in the Appendix below).
-
- "Derivative Works" shall mean any work, whether in Source or Object
- form, that is based on (or derived from) the Work and for which the
- editorial revisions, annotations, elaborations, or other modifications
- represent, as a whole, an original work of authorship. For the purposes
- of this License, Derivative Works shall not include works that remain
- separable from, or merely link (or bind by name) to the interfaces of,
- the Work and Derivative Works thereof.
-
- "Contribution" shall mean any work of authorship, including
- the original version of the Work and any modifications or additions
- to that Work or Derivative Works thereof, that is intentionally
- submitted to Licensor for inclusion in the Work by the copyright owner
- or by an individual or Legal Entity authorized to submit on behalf of
- the copyright owner. For the purposes of this definition, "submitted"
- means any form of electronic, verbal, or written communication sent
- to the Licensor or its representatives, including but not limited to
- communication on electronic mailing lists, source code control systems,
- and issue tracking systems that are managed by, or on behalf of, the
- Licensor for the purpose of discussing and improving the Work, but
- excluding communication that is conspicuously marked or otherwise
- designated in writing by the copyright owner as "Not a Contribution."
-
- "Contributor" shall mean Licensor and any individual or Legal Entity
- on behalf of whom a Contribution has been received by Licensor and
- subsequently incorporated within the Work.
-
- 2. Grant of Copyright License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- copyright license to reproduce, prepare Derivative Works of,
- publicly display, publicly perform, sublicense, and distribute the
- Work and such Derivative Works in Source or Object form.
-
- 3. Grant of Patent License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- (except as stated in this section) patent license to make, have made,
- use, offer to sell, sell, import, and otherwise transfer the Work,
- where such license applies only to those patent claims licensable
- by such Contributor that are necessarily infringed by their
- Contribution(s) alone or by combination of their Contribution(s)
- with the Work to which such Contribution(s) was submitted. If You
- institute patent litigation against any entity (including a
- cross-claim or counterclaim in a lawsuit) alleging that the Work
- or a Contribution incorporated within the Work constitutes direct
- or contributory patent infringement, then any patent licenses
- granted to You under this License for that Work shall terminate
- as of the date such litigation is filed.
-
- 4. Redistribution. You may reproduce and distribute copies of the
- Work or Derivative Works thereof in any medium, with or without
- modifications, and in Source or Object form, provided that You
- meet the following conditions:
-
- (a) You must give any other recipients of the Work or
- Derivative Works a copy of this License; and
-
- (b) You must cause any modified files to carry prominent notices
- stating that You changed the files; and
-
- (c) You must retain, in the Source form of any Derivative Works
- that You distribute, all copyright, patent, trademark, and
- attribution notices from the Source form of the Work,
- excluding those notices that do not pertain to any part of
- the Derivative Works; and
-
- (d) If the Work includes a "NOTICE" text file as part of its
- distribution, then any Derivative Works that You distribute must
- include a readable copy of the attribution notices contained
- within such NOTICE file, excluding those notices that do not
- pertain to any part of the Derivative Works, in at least one
- of the following places: within a NOTICE text file distributed
- as part of the Derivative Works; within the Source form or
- documentation, if provided along with the Derivative Works; or,
- within a display generated by the Derivative Works, if and
- wherever such third-party notices normally appear. The contents
- of the NOTICE file are for informational purposes only and
- do not modify the License. You may add Your own attribution
- notices within Derivative Works that You distribute, alongside
- or as an addendum to the NOTICE text from the Work, provided
- that such additional attribution notices cannot be construed
- as modifying the License.
-
- You may add Your own copyright statement to Your modifications and
- may provide additional or different license terms and conditions
- for use, reproduction, or distribution of Your modifications, or
- for any such Derivative Works as a whole, provided Your use,
- reproduction, and distribution of the Work otherwise complies with
- the conditions stated in this License.
-
- 5. Submission of Contributions. Unless You explicitly state otherwise,
- any Contribution intentionally submitted for inclusion in the Work
- by You to the Licensor shall be under the terms and conditions of
- this License, without any additional terms or conditions.
- Notwithstanding the above, nothing herein shall supersede or modify
- the terms of any separate license agreement you may have executed
- with Licensor regarding such Contributions.
-
- 6. Trademarks. This License does not grant permission to use the trade
- names, trademarks, service marks, or product names of the Licensor,
- except as required for reasonable and customary use in describing the
- origin of the Work and reproducing the content of the NOTICE file.
-
- 7. Disclaimer of Warranty. Unless required by applicable law or
- agreed to in writing, Licensor provides the Work (and each
- Contributor provides its Contributions) on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- implied, including, without limitation, any warranties or conditions
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
- PARTICULAR PURPOSE. You are solely responsible for determining the
- appropriateness of using or redistributing the Work and assume any
- risks associated with Your exercise of permissions under this License.
-
- 8. Limitation of Liability. In no event and under no legal theory,
- whether in tort (including negligence), contract, or otherwise,
- unless required by applicable law (such as deliberate and grossly
- negligent acts) or agreed to in writing, shall any Contributor be
- liable to You for damages, including any direct, indirect, special,
- incidental, or consequential damages of any character arising as a
- result of this License or out of the use or inability to use the
- Work (including but not limited to damages for loss of goodwill,
- work stoppage, computer failure or malfunction, or any and all
- other commercial damages or losses), even if such Contributor
- has been advised of the possibility of such damages.
-
- 9. Accepting Warranty or Additional Liability. While redistributing
- the Work or Derivative Works thereof, You may choose to offer,
- and charge a fee for, acceptance of support, warranty, indemnity,
- or other liability obligations and/or rights consistent with this
- License. However, in accepting such obligations, You may act only
- on Your own behalf and on Your sole responsibility, not on behalf
- of any other Contributor, and only if You agree to indemnify,
- defend, and hold each Contributor harmless for any liability
- incurred by, or claims asserted against, such Contributor by reason
- of your accepting any such warranty or additional liability.
-
- END OF TERMS AND CONDITIONS
-
- APPENDIX: How to apply the Apache License to your work.
-
- To apply the Apache License to your work, attach the following
- boilerplate notice, with the fields enclosed by brackets "[]"
- replaced with your own identifying information. (Don't include
- the brackets!) The text should be enclosed in the appropriate
- comment syntax for the file format. We also recommend that a
- file or class name and description of purpose be included on the
- same "printed page" as the copyright notice for easier
- identification within third-party archives.
-
- Copyright [yyyy] [name of copyright owner]
-
- Licensed 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.
http://git-wip-us.apache.org/repos/asf/clerezza/blob/c8293374/rdf.rdfjson/README.md
----------------------------------------------------------------------
diff --git a/rdf.rdfjson/README.md b/rdf.rdfjson/README.md
deleted file mode 100644
index e3ace1c..0000000
--- a/rdf.rdfjson/README.md
+++ /dev/null
@@ -1,4 +0,0 @@
-# Apache Clerezza rdf/json Parser and Serializer
-
-This provides support for the RDF 1.1 JSON Alternate Serialization (RDF/JSON),
-see: http://www.w3.org/TR/rdf-json/
http://git-wip-us.apache.org/repos/asf/clerezza/blob/c8293374/rdf.rdfjson/pom.xml
----------------------------------------------------------------------
diff --git a/rdf.rdfjson/pom.xml b/rdf.rdfjson/pom.xml
deleted file mode 100644
index 280b682..0000000
--- a/rdf.rdfjson/pom.xml
+++ /dev/null
@@ -1,79 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" standalone="no"?><project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
-<!--
-
- 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.
-
- -->
-
- <modelVersion>4.0.0</modelVersion>
- <parent>
- <artifactId>clerezza</artifactId>
- <groupId>org.apache.clerezza</groupId>
- <version>7</version>
- <relativePath>../parent</relativePath>
- </parent>
- <groupId>org.apache.clerezza</groupId>
- <artifactId>rdf.rdfjson</artifactId>
- <packaging>bundle</packaging>
- <version>1.0.0-SNAPSHOT</version>
- <name>Clerezza - SCB rdf/json Parser and Serializer</name>
- <description>A rdf/json Parser- and SerializerProvider</description>
- <dependencies>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.clerezza</groupId>
- <artifactId>rdf.ontologies</artifactId>
- <scope>test</scope>
- <version>1.0.0</version>
- </dependency>
- <dependency>
- <groupId>org.apache.clerezza</groupId>
- <artifactId>rdf.core</artifactId>
- <version>1.0.0</version>
- </dependency>
- <dependency>
- <groupId>org.apache.clerezza.ext</groupId>
- <artifactId>org.json.simple</artifactId>
- <version>0.4</version>
- </dependency>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.scr.annotations</artifactId>
- </dependency>
- </dependencies>
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <extensions>true</extensions>
- <configuration>
- <instructions>
- <Include-Resource>
- {maven-resources}
- </Include-Resource>
- </instructions>
- </configuration>
- </plugin>
- </plugins>
- </build>
-</project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/clerezza/blob/c8293374/rdf.rdfjson/src/main/java/org/apache/clerezza/rdf/rdfjson/parser/RdfJsonParsingProvider.java
----------------------------------------------------------------------
diff --git a/rdf.rdfjson/src/main/java/org/apache/clerezza/rdf/rdfjson/parser/RdfJsonParsingProvider.java b/rdf.rdfjson/src/main/java/org/apache/clerezza/rdf/rdfjson/parser/RdfJsonParsingProvider.java
deleted file mode 100644
index 9ad302c..0000000
--- a/rdf.rdfjson/src/main/java/org/apache/clerezza/rdf/rdfjson/parser/RdfJsonParsingProvider.java
+++ /dev/null
@@ -1,144 +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.clerezza.rdf.rdfjson.parser;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.UnsupportedEncodingException;
-import java.util.HashMap;
-import java.util.Map;
-import org.json.simple.JSONArray;
-import org.json.simple.JSONObject;
-import org.json.simple.parser.JSONParser;
-import org.json.simple.parser.ParseException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.apache.clerezza.commons.rdf.BlankNode;
-import org.apache.clerezza.commons.rdf.Language;
-import org.apache.clerezza.commons.rdf.Graph;
-import org.apache.clerezza.commons.rdf.BlankNodeOrIRI;
-import org.apache.clerezza.commons.rdf.IRI;
-import org.apache.clerezza.commons.rdf.impl.utils.LiteralImpl;
-import org.apache.clerezza.commons.rdf.impl.utils.PlainLiteralImpl;
-import org.apache.clerezza.commons.rdf.impl.utils.TripleImpl;
-import org.apache.clerezza.commons.rdf.impl.utils.TypedLiteralImpl;
-import org.apache.clerezza.rdf.core.serializedform.ParsingProvider;
-import org.apache.clerezza.rdf.core.serializedform.SupportedFormat;
-import org.apache.felix.scr.annotations.Component;
-import org.apache.felix.scr.annotations.Service;
-
-/**
- * A {@link org.apache.clerezza.rdf.core.serializedform.ParsingProvider} for
- * rdf/json
- *
- * @author tio, hasan
- *
- */
-@Component(immediate = true)
-@Service(ParsingProvider.class)
-@SupportedFormat(SupportedFormat.RDF_JSON)
-public class RdfJsonParsingProvider implements ParsingProvider {
-
- private final Logger logger = LoggerFactory.getLogger(getClass());
- private static final IRI XSD_STRING = new IRI("http://www.w3.org/2001/XMLSchema#string");
-
- @Override
- public void parse(Graph target, InputStream serializedGraph, String formatIdentifier, IRI baseUri) {
-
- BlankNodeManager bNodeMgr = new BlankNodeManager();
-
- JSONParser parser = new JSONParser();
- InputStreamReader reader;
- try {
- reader = new InputStreamReader(serializedGraph, "UTF-8");
- } catch (UnsupportedEncodingException e) {
- String msg = "Encoding 'UTF-8' is not supported by this System";
- logger.error("{} (message: {})", msg, e.getMessage());
- throw new IllegalStateException(msg, e);
- }
-
- try {
- JSONObject root = (JSONObject) parser.parse(reader);
-
- BlankNodeOrIRI nonLiteral = null;
- for (Object key : root.keySet()) {
- String keyString = (String) key;
- if (keyString.startsWith("_:")) {
- nonLiteral = bNodeMgr.getBlankNode(keyString);
- } else {
- nonLiteral = new IRI(keyString);
- }
- JSONObject predicates = (JSONObject) root.get(keyString);
- addTriplesToGraph(nonLiteral, bNodeMgr, predicates, target);
- }
- } catch (IOException ioe) {
- logger.error(ioe.getMessage());
- throw new RuntimeException(ioe.getMessage());
- } catch (ParseException pe) {
- logger.error(pe.getMessage());
- throw new RuntimeException(pe.getMessage());
- }
- }
-
- private class BlankNodeManager {
-
- private Map<String, BlankNode> bNodeMap = new HashMap<String, BlankNode>();
-
- public BlankNode getBlankNode(String id) {
- BlankNode bNode = bNodeMap.get(id);
- if (bNode == null) {
- bNode = new BlankNode();
- bNodeMap.put(id, bNode);
- }
- return bNode;
- }
- }
-
- private void addTriplesToGraph(BlankNodeOrIRI subject, BlankNodeManager bNodeMgr, JSONObject predicates, Graph mGraph) {
- for (Object predicate : predicates.keySet()) {
- JSONArray objects = (JSONArray) predicates.get(predicate);
- for (Object object : objects) {
- JSONObject values = (JSONObject) object;
- String value = (String) values.get("value");
- if (values.get("type").equals("literal")) {
- IRI dataType;
- Object dataTypeValue = values.get("datatype");
- if (dataTypeValue == null
- || dataTypeValue.toString().isEmpty()) {
- dataType = XSD_STRING;
- } else {
- dataType = new IRI(dataTypeValue.toString());
- }
- Language language = null;
- if (values.containsKey("lang")
- && !values.get("lang").equals("")
- && values.get("lang") != null) {
- language = new Language((String) values.get("lang"));
- }
- mGraph.add(new TripleImpl(subject, new IRI((String) predicate),
- new LiteralImpl(value.toString(), dataType, language)));
- } else if (values.get("type").equals("uri")) {
- mGraph.add(new TripleImpl(subject, new IRI((String) predicate), new IRI(value)));
- } else if (values.get("type").equals("bnode")) {
- BlankNodeOrIRI bNode = bNodeMgr.getBlankNode(value);
- mGraph.add(new TripleImpl(subject, new IRI((String) predicate), bNode));
- }
- }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/clerezza/blob/c8293374/rdf.rdfjson/src/main/java/org/apache/clerezza/rdf/rdfjson/serializer/RdfJsonSerializingProvider.java
----------------------------------------------------------------------
diff --git a/rdf.rdfjson/src/main/java/org/apache/clerezza/rdf/rdfjson/serializer/RdfJsonSerializingProvider.java b/rdf.rdfjson/src/main/java/org/apache/clerezza/rdf/rdfjson/serializer/RdfJsonSerializingProvider.java
deleted file mode 100644
index b0b8991..0000000
--- a/rdf.rdfjson/src/main/java/org/apache/clerezza/rdf/rdfjson/serializer/RdfJsonSerializingProvider.java
+++ /dev/null
@@ -1,217 +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.clerezza.rdf.rdfjson.serializer;
-
-import java.io.BufferedWriter;
-import java.io.IOException;
-import java.io.OutputStream;
-import java.io.OutputStreamWriter;
-import java.io.UnsupportedEncodingException;
-import java.util.Arrays;
-import java.util.Comparator;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Map.Entry;
-
-import org.apache.clerezza.commons.rdf.BlankNode;
-import org.apache.clerezza.commons.rdf.BlankNodeOrIRI;
-import org.apache.clerezza.commons.rdf.RDFTerm;
-import org.apache.clerezza.commons.rdf.Triple;
-import org.apache.clerezza.commons.rdf.Graph;
-import org.apache.clerezza.commons.rdf.IRI;
-import org.apache.clerezza.commons.rdf.Literal;
-import org.apache.clerezza.rdf.core.serializedform.SerializingProvider;
-import org.apache.clerezza.rdf.core.serializedform.SupportedFormat;
-import org.apache.felix.scr.annotations.Component;
-import org.apache.felix.scr.annotations.Service;
-import org.json.simple.JSONArray;
-import org.json.simple.JSONObject;
-
-/**
- * A {@link org.apache.clerezza.rdf.core.serializedform.SerializingProvider} for
- * rdf/json.
- *
- * This implementation is based on first sorting the triples within the parsed
- * {@link Graph} based on the {@link #SUBJECT_COMPARATOR subject}.
- * <p>
- * The serialization is done on a subject scope. Meaning that all triples for a
- * subject are serialized and instantly written to the provided
- * {@link OutputStream}.
- * <p>
- * 'UFT-8' is used as encoding to write the data.
- *
- * @author tio, hasan, rwesten
- */
-@Component(immediate = true)
-@Service(SerializingProvider.class)
-@SupportedFormat(SupportedFormat.RDF_JSON)
-public class RdfJsonSerializingProvider implements SerializingProvider {
-
- @SuppressWarnings("unchecked")
- @Override
- public void serialize(OutputStream serializedGraph, Graph tc,
- String formatIdentifier) {
- if (tc.isEmpty()) { // ensure writing an empty element in case of an
- // empty collection
- try {
- serializedGraph.write(new JSONObject().toJSONString().getBytes(
- "UTF-8"));
- } catch (IOException e) {
- throw new IllegalStateException(
- "Exception while writing to parsed OutputStream", e);
- }
- return;
- }
- BlankNodeManager bNodeMgr = new BlankNodeManager();
- BufferedWriter out;
- try {
- out = new BufferedWriter(new OutputStreamWriter(serializedGraph,
- "UTF-8"));
- } catch (UnsupportedEncodingException e) {
- throw new IllegalStateException(
- "Encoding 'UTF-8' is not supported by this System", e);
- }
- Triple[] sortedTriples = tc.toArray(new Triple[tc.size()]);
- Arrays.sort(sortedTriples, SUBJECT_COMPARATOR);
- Triple triple;
- BlankNodeOrIRI subject = null;
- String subjectStr = null;
- IRI predicate = null;
- Map<IRI, JSONArray> predicateValues = new HashMap<IRI, JSONArray>();
- JSONObject jSubject = new JSONObject();
- try {
- out.write("{"); // start the root object
- for (int i = 0; i < sortedTriples.length; i++) {
- triple = sortedTriples[i];
- boolean subjectChange = !triple.getSubject().equals(subject);
- if (subjectChange) {
- if (subject != null) {
- // write the predicate values
- for (Entry<IRI, JSONArray> predicates : predicateValues
- .entrySet()) {
- jSubject.put(
- predicates.getKey().getUnicodeString(),
- predicates.getValue());
- }
- // write subject
- out.write(JSONObject.toString(subjectStr, jSubject));
- out.write(",");
- jSubject.clear(); // just clear
- predicateValues.clear();
- }
- // init next subject
- subject = triple.getSubject();
- if (subject instanceof BlankNode) {
- subjectStr = bNodeMgr.getBlankNodeId((BlankNode) subject);
- } else { // if (subject instanceof IRI)
- subjectStr = ((IRI) subject).getUnicodeString();
- }
- }
- predicate = triple.getPredicate();
- JSONArray values = predicateValues.get(predicate);
- if (values == null) {
- values = new JSONArray();
- predicateValues.put(predicate, values);
- }
- values.add(writeObject(bNodeMgr, triple.getObject()));
- }
- if (subjectStr != null) {
- for (Entry<IRI, JSONArray> predicates : predicateValues
- .entrySet()) {
- jSubject.put(predicates.getKey().getUnicodeString(),
- predicates.getValue());
- }
- out.write(JSONObject.toString(subjectStr, jSubject));
- }
- out.write("}");// end the root object
- out.flush();
- } catch (IOException e) {
- throw new IllegalStateException(
- "Exception while writing on the parsed OutputStream", e);
- }
- }
-
- private class BlankNodeManager {
- private Map<BlankNode, String> bNodeMap = new HashMap<BlankNode, String>();
- private int counter = 0;
-
- public String getBlankNodeId(BlankNode node) {
- String bNodeId = bNodeMap.get(node);
- if (bNodeId == null) {
- bNodeId = "_:b" + ++counter;
- bNodeMap.put((BlankNode) node, bNodeId);
- }
- return bNodeId;
- }
- }
-
- /**
- * Converts the {@link RDFTerm object} of an triple to JSON
- *
- * @param bNodeMgr
- * used to lookup {@link BlankNode} instances
- * @param object
- * the object of the triple
- * @return the JSON representation of parsed object
- */
- @SuppressWarnings("unchecked")
- private JSONObject writeObject(BlankNodeManager bNodeMgr, RDFTerm object) {
- JSONObject jObject = new JSONObject();
- if (object instanceof Literal) {
- Literal literal = (Literal) object;
- jObject.put("value", literal.getLexicalForm());
- jObject.put("type", "literal");
- jObject.put("datatype", literal.getDataType().getUnicodeString());
- if (literal.getLanguage() != null) {
- jObject.put("lang", literal.getLanguage().toString());
- }
- } else if (object instanceof IRI) {
- IRI uriRef = (IRI) object;
- jObject.put("value", uriRef.getUnicodeString());
- jObject.put("type", "uri");
- } else if (object instanceof BlankNode) {
- String bNodeId = bNodeMgr.getBlankNodeId((BlankNode) object);
- jObject.put("value", bNodeId);
- jObject.put("type", "bnode");
- }
- return jObject;
- }
-
- /**
- * Compares only the subjects of the triples. If they are equals
- * <code>0</code> is returned. This will ensure that all triples with the
- * same subjects are sorted correctly. However it does not sort predicates
- * and objects!
- */
- public static final Comparator<Triple> SUBJECT_COMPARATOR = new Comparator<Triple>() {
-
- @Override
- public int compare(Triple a, Triple b) {
- return compare(a.getSubject(), b.getSubject());
- }
-
- private int compare(BlankNodeOrIRI a, BlankNodeOrIRI b) {
- int hashA = a.hashCode();
- int hashB = b.hashCode();
- if (hashA != hashB) {
- return hashA > hashB ? 1 : -1;
- }
- return a.toString().compareTo(b.toString());
- }
-
- };
-}
http://git-wip-us.apache.org/repos/asf/clerezza/blob/c8293374/rdf.rdfjson/src/main/resources/META-INF/services/org.apache.clerezza.rdf.core.serializedform.ParsingProvider
----------------------------------------------------------------------
diff --git a/rdf.rdfjson/src/main/resources/META-INF/services/org.apache.clerezza.rdf.core.serializedform.ParsingProvider b/rdf.rdfjson/src/main/resources/META-INF/services/org.apache.clerezza.rdf.core.serializedform.ParsingProvider
deleted file mode 100644
index 2599bc3..0000000
--- a/rdf.rdfjson/src/main/resources/META-INF/services/org.apache.clerezza.rdf.core.serializedform.ParsingProvider
+++ /dev/null
@@ -1 +0,0 @@
-org.apache.clerezza.rdf.rdfjson.parser.RdfJsonParsingProvider
http://git-wip-us.apache.org/repos/asf/clerezza/blob/c8293374/rdf.rdfjson/src/main/resources/META-INF/services/org.apache.clerezza.rdf.core.serializedform.SerializingProvider
----------------------------------------------------------------------
diff --git a/rdf.rdfjson/src/main/resources/META-INF/services/org.apache.clerezza.rdf.core.serializedform.SerializingProvider b/rdf.rdfjson/src/main/resources/META-INF/services/org.apache.clerezza.rdf.core.serializedform.SerializingProvider
deleted file mode 100644
index c0c6766..0000000
--- a/rdf.rdfjson/src/main/resources/META-INF/services/org.apache.clerezza.rdf.core.serializedform.SerializingProvider
+++ /dev/null
@@ -1 +0,0 @@
-org.apache.clerezza.rdf.rdfjson.serializer.RdfJsonSerializingProvider
http://git-wip-us.apache.org/repos/asf/clerezza/blob/c8293374/rdf.rdfjson/src/test/java/org/apache/clerezza/rdf/rdfjson/parser/RdfJsonParserProviderTest.java
----------------------------------------------------------------------
diff --git a/rdf.rdfjson/src/test/java/org/apache/clerezza/rdf/rdfjson/parser/RdfJsonParserProviderTest.java b/rdf.rdfjson/src/test/java/org/apache/clerezza/rdf/rdfjson/parser/RdfJsonParserProviderTest.java
deleted file mode 100644
index 200a253..0000000
--- a/rdf.rdfjson/src/test/java/org/apache/clerezza/rdf/rdfjson/parser/RdfJsonParserProviderTest.java
+++ /dev/null
@@ -1,87 +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.clerezza.rdf.rdfjson.parser;
-
-import java.io.InputStream;
-import java.util.Iterator;
-import org.apache.clerezza.commons.rdf.BlankNode;
-
-import org.junit.Assert;
-import org.junit.Test;
-import org.apache.clerezza.commons.rdf.Graph;
-import org.apache.clerezza.commons.rdf.BlankNodeOrIRI;
-import org.apache.clerezza.commons.rdf.Triple;
-import org.apache.clerezza.commons.rdf.IRI;
-import org.apache.clerezza.commons.rdf.impl.utils.simple.SimpleGraph;
-import org.apache.clerezza.rdf.core.serializedform.ParsingProvider;
-
-/**
- * @author tio, hasan
- */
-public class RdfJsonParserProviderTest {
-
- @Test
- public void testParsingOfObjectBlankNode() {
- ParsingProvider provider = new RdfJsonParsingProvider();
- InputStream jsonIn = getClass().getResourceAsStream("test-object-bnode.json");
- Graph parsedGraph = new SimpleGraph();
- provider.parse(parsedGraph, jsonIn, "application/rdf+json", null);
- Assert.assertEquals(parsedGraph.size(), 1);
- Iterator<Triple> triples = parsedGraph.filter(new IRI("http://example.org/node1"),
- new IRI("http://example.org/prop1"), null);
- Assert.assertTrue(triples.hasNext());
- Assert.assertTrue(triples.next().getObject() instanceof BlankNode);
- }
-
- @Test
- public void testParsingOfSubjectBlankNode() {
- ParsingProvider provider = new RdfJsonParsingProvider();
- InputStream jsonIn = getClass().getResourceAsStream("test-subject-bnode.json");
- Graph parsedGraph = new SimpleGraph();
- provider.parse(parsedGraph, jsonIn, "application/rdf+json", null);
- Assert.assertEquals(3, parsedGraph.size());
- Iterator<Triple> triples = parsedGraph.filter(null, new IRI("http://example.org/prop1"),
- new IRI("http://example.org/node1"));
- Assert.assertTrue(triples.hasNext());
- BlankNodeOrIRI subject = triples.next().getSubject();
- Assert.assertTrue(subject instanceof BlankNode);
-
- triples = parsedGraph.filter(null, new IRI("http://example.org/prop2"),
- new IRI("http://example.org/node2"));
- Assert.assertTrue(triples.hasNext());
- Assert.assertTrue(subject.equals(triples.next().getSubject()));
-
- triples = parsedGraph.filter(null, new IRI("http://example.org/prop3"),
- new IRI("http://example.org/node3"));
- Assert.assertTrue(triples.hasNext());
- Assert.assertFalse(subject.equals(triples.next().getSubject()));
- }
-
- @Test
- public void testParser() {
- ParsingProvider provider = new RdfJsonParsingProvider();
- InputStream jsonIn = getClass().getResourceAsStream("test.json");
- Graph deserializedGraph = new SimpleGraph();
- provider.parse(deserializedGraph, jsonIn, "application/rdf+json", null);
- Assert.assertEquals(deserializedGraph.size(), 6);
- Iterator<Triple> triples = deserializedGraph.filter(new IRI("http://base/child1"), null, null);
- while (triples.hasNext()) {
- IRI uri = triples.next().getPredicate();
- Assert.assertEquals(uri.getUnicodeString(), "http://base/propertyB");
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/clerezza/blob/c8293374/rdf.rdfjson/src/test/java/org/apache/clerezza/rdf/rdfjson/serializer/RdfJsonSerializerProviderTest.java
----------------------------------------------------------------------
diff --git a/rdf.rdfjson/src/test/java/org/apache/clerezza/rdf/rdfjson/serializer/RdfJsonSerializerProviderTest.java b/rdf.rdfjson/src/test/java/org/apache/clerezza/rdf/rdfjson/serializer/RdfJsonSerializerProviderTest.java
deleted file mode 100644
index f997e97..0000000
--- a/rdf.rdfjson/src/test/java/org/apache/clerezza/rdf/rdfjson/serializer/RdfJsonSerializerProviderTest.java
+++ /dev/null
@@ -1,277 +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.clerezza.rdf.rdfjson.serializer;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-
-import java.util.Set;
-import org.junit.Assert;
-import org.junit.Test;
-import org.apache.clerezza.commons.rdf.BlankNode;
-import org.apache.clerezza.commons.rdf.Language;
-import org.apache.clerezza.commons.rdf.Graph;
-import org.apache.clerezza.commons.rdf.BlankNodeOrIRI;
-import org.apache.clerezza.commons.rdf.Triple;
-import org.apache.clerezza.commons.rdf.IRI;
-import org.apache.clerezza.commons.rdf.Literal;
-import org.apache.clerezza.commons.rdf.impl.utils.PlainLiteralImpl;
-import org.apache.clerezza.commons.rdf.impl.utils.simple.SimpleGraph;
-import org.apache.clerezza.commons.rdf.impl.utils.TripleImpl;
-import org.apache.clerezza.rdf.core.LiteralFactory;
-import org.apache.clerezza.rdf.core.serializedform.ParsingProvider;
-import org.apache.clerezza.rdf.core.serializedform.SerializingProvider;
-import org.apache.clerezza.rdf.ontologies.FOAF;
-import org.apache.clerezza.rdf.ontologies.RDF;
-import org.apache.clerezza.rdf.ontologies.RDFS;
-import org.apache.clerezza.rdf.rdfjson.parser.RdfJsonParsingProvider;
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
-
-/**
- *
- * @author tio, hasan
- */
-public class RdfJsonSerializerProviderTest {
-
- private final static LiteralFactory lf = LiteralFactory.getInstance();
- private final static IRI RDF_NIL = new IRI("http://www.w3.org/1999/02/22-rdf-syntax-ns#nil");
- private final static IRI node1 = new IRI("http://example.org/node1");
- private final static IRI node2 = new IRI("http://example.org/node2");
- private final static IRI prop1 = new IRI("http://example.org/prop1");
- private final static IRI prop2 = new IRI("http://example.org/prop2");
- private final static IRI prop3 = new IRI("http://example.org/prop3");
- private final static IRI prop4 = new IRI("http://example.org/prop4");
- private final static IRI prop5 = new IRI("http://example.org/prop5");
- private final static IRI prop6 = new IRI("http://example.org/prop6");
- private final static BlankNode blank1 = new BlankNode();
- private final static BlankNode blank2 = new BlankNode();
- private final static PlainLiteralImpl plainLiteralA = new PlainLiteralImpl("A");
- private final static PlainLiteralImpl plainLiteralB = new PlainLiteralImpl("B");
- private final static PlainLiteralImpl plainLiteralC = new PlainLiteralImpl("C");
- private final static Literal typedLiteralA = lf.createTypedLiteral("A");
-
- private Graph mGraph;
-
- @BeforeClass
- public static void setUpClass() throws Exception {
- }
-
- @AfterClass
- public static void tearDownClass() throws Exception {
- }
-
- @Before
- public void setUp() {
- mGraph = new SimpleGraph();
- }
-
- @After
- public void tearDown() {
- }
-
- @Test
- public void testSerializationOfBlankNode() {
- mGraph.add(new TripleImpl(node1, prop1, blank1));
- SerializingProvider provider = new RdfJsonSerializingProvider();
- ByteArrayOutputStream serializedGraph = new ByteArrayOutputStream();
- provider.serialize(serializedGraph, mGraph, "application/rdf+json");
- Assert.assertTrue(serializedGraph.toString().contains("_:"));
- }
-
- @Test
- public void testSerializationOfRdfList() {
- mGraph.add(new TripleImpl(blank1, RDF.first, blank2));
- mGraph.add(new TripleImpl(blank1, RDF.rest, RDF_NIL));
- mGraph.add(new TripleImpl(blank2, prop1, node1));
-
-// System.out.println(mGraph);
-
- SerializingProvider provider = new RdfJsonSerializingProvider();
- ByteArrayOutputStream serializedGraph = new ByteArrayOutputStream();
- provider.serialize(serializedGraph, mGraph, "application/rdf+json");
-
-// System.out.println(serializedGraph.toString());
-
- ParsingProvider parsingProvider = new RdfJsonParsingProvider();
- ByteArrayInputStream jsonIn = new ByteArrayInputStream(serializedGraph.toByteArray());
- Graph parsedGraph = new SimpleGraph();
- parsingProvider.parse(parsedGraph, jsonIn, "application/rdf+json", null);
-
- Assert.assertEquals(mGraph.getImmutableGraph(), parsedGraph.getImmutableGraph());
- }
-
- /*
- * serializes a graph and parse it back.
- */
- @Test
- public void testSerializer() {
- mGraph.add(new TripleImpl(node1, prop1, plainLiteralA));
- mGraph.add(new TripleImpl(node1, prop2, node2));
- mGraph.add(new TripleImpl(node2, prop3, plainLiteralB));
- mGraph.add(new TripleImpl(blank1, prop4, plainLiteralC));
- mGraph.add(new TripleImpl(blank1, prop5, typedLiteralA));
- mGraph.add(new TripleImpl(node1, prop6, blank1));
- serializeDeserialize(mGraph);
- }
-
- @Test
- public void literalWithLanguage() {
- Literal l = new PlainLiteralImpl("Ein deutsches Literal.",
- new Language("de"));
- mGraph.add(new TripleImpl(blank1, RDF.first, l));
- serializeDeserialize(mGraph);
- }
-
- /**
- * For local performance testing
- */
- @Test
- public void testBigGraph() throws Exception {
- //reduced ImmutableGraph size to 5000 to allow equals test between the
- //serialised and parsed RDF graphs. Equals tests on bigger graphs
- //would take to much time
- int NUM_TRIPLES = 5000;
- //randoms are in the range [0..3]
- double l = 1.0; //literal
- double i = l / 3; //int
- double d = l * 2 / 3;//double
- double b = 2.0;//bNode
- double nb = b - (l * 2 / 3); //create new bNode
- double random;
- BlankNodeOrIRI subject = null;
- IRI predicate = null;
- List<IRI> predicateList = new ArrayList<IRI>();
- predicateList.add(RDF.first);
- predicateList.add(RDF.rest);
- predicateList.add(RDF.type);
- predicateList.add(RDFS.label);
- predicateList.add(RDFS.comment);
- predicateList.add(RDFS.range);
- predicateList.add(RDFS.domain);
- predicateList.add(FOAF.name);
- predicateList.add(FOAF.nick);
- predicateList.add(FOAF.homepage);
- predicateList.add(FOAF.age);
- predicateList.add(FOAF.depiction);
- String URI_PREFIX = "http://www.test.org/bigGraph/ref";
- Language DE = new Language("de");
- Language EN = new Language("en");
- Iterator<IRI> predicates = predicateList.iterator();
- List<BlankNode> bNodes = new ArrayList<BlankNode>();
- bNodes.add(new BlankNode());
- for (int count = 0; mGraph.size() < NUM_TRIPLES; count++) {
- random = Math.random() * 3;
- if (random >= 2.5 || count == 0) {
- if (random <= 2.75) {
- subject = new IRI(URI_PREFIX + count);
- } else {
- int rndIndex = (int) ((random - 2.75) * bNodes.size() / (3.0 - 2.75));
- subject = bNodes.get(rndIndex);
- }
- }
- if (random > 2.0 || count == 0) {
- if (!predicates.hasNext()) {
- Collections.shuffle(predicateList);
- predicates = predicateList.iterator();
- }
- predicate = predicates.next();
- }
- if (random <= l) { //literal
- if (random <= i) {
- mGraph.add(new TripleImpl(subject, predicate, lf.createTypedLiteral(count)));
- } else if (random <= d) {
- mGraph.add(new TripleImpl(subject, predicate, lf.createTypedLiteral(random)));
- } else {
- Literal text;
- if (random <= i) {
- text = new PlainLiteralImpl("Literal for " + count);
- } else if (random <= d) {
- text = new PlainLiteralImpl("An English literal for " + count, EN);
- } else {
- text = new PlainLiteralImpl("Ein Dutsches Literal für " + count, DE);
- }
- mGraph.add(new TripleImpl(subject, predicate, text));
- }
- } else if (random <= b) { //bnode
- BlankNode bnode;
- if (random <= nb) {
- bnode = new BlankNode();
- bNodes.add(bnode);
- } else { //>nb <b
- int rndIndex = (int) ((random - nb) * bNodes.size() / (b - nb));
- bnode = bNodes.get(rndIndex);
- }
- mGraph.add(new TripleImpl(subject, predicate, bnode));
- } else { //IRI
- mGraph.add(new TripleImpl(subject, predicate,
- new IRI(URI_PREFIX + (int) count * random)));
- }
- }
- //Asserts the correct sorting of the triples in the graph by the
- //Comparator used by the JSON serializer
- Set<BlankNodeOrIRI> subjects = new HashSet<BlankNodeOrIRI>();
- Triple[] sortedTriples = mGraph.toArray(new Triple[mGraph.size()]);
- Arrays.sort(sortedTriples, RdfJsonSerializingProvider.SUBJECT_COMPARATOR);
- BlankNodeOrIRI current = sortedTriples[0].getSubject();
- for(Triple triple : sortedTriples){
- if(!triple.getSubject().equals(current)){
- subjects.add(current);
- current = triple.getSubject();
- Assert.assertFalse(subjects.contains(current));
- }
- }
- sortedTriples = null;
- subjects = null;
-
- int originalSize = mGraph.size();
-
- SerializingProvider provider = new RdfJsonSerializingProvider();
- ByteArrayOutputStream serializedGraph = new ByteArrayOutputStream();
- long start = System.currentTimeMillis();
- provider.serialize(serializedGraph, mGraph, "application/rdf+json");
- System.out.println("Serialized " + mGraph.size() + " Triples in " + (System.currentTimeMillis() - start) + " ms");
- ParsingProvider parsingProvider = new RdfJsonParsingProvider();
- ByteArrayInputStream jsonIn = new ByteArrayInputStream(serializedGraph.toByteArray());
- Graph parsedGraph = new SimpleGraph();
- parsingProvider.parse(parsedGraph, jsonIn, "application/rdf+json", null);
- Assert.assertEquals(originalSize, parsedGraph.size());
- sortedTriples = parsedGraph.toArray(new Triple[parsedGraph.size()]);
- Arrays.sort(sortedTriples, RdfJsonSerializingProvider.SUBJECT_COMPARATOR);
- Assert.assertEquals(mGraph.getImmutableGraph(), parsedGraph.getImmutableGraph());
- }
-
- private void serializeDeserialize(Graph mGraph) {
- SerializingProvider provider = new RdfJsonSerializingProvider();
- ByteArrayOutputStream serializedGraph = new ByteArrayOutputStream();
- provider.serialize(serializedGraph, mGraph, "application/rdf+json");
- ParsingProvider parsingProvider = new RdfJsonParsingProvider();
- ByteArrayInputStream jsonIn = new ByteArrayInputStream(serializedGraph.toByteArray());
- Graph parsedGraph = new SimpleGraph();
- parsingProvider.parse(parsedGraph, jsonIn, "application/rdf+json", null);
- Assert.assertEquals(mGraph.size(), parsedGraph.size());
- Assert.assertEquals(mGraph.getImmutableGraph(), parsedGraph.getImmutableGraph());
- }
-}
http://git-wip-us.apache.org/repos/asf/clerezza/blob/c8293374/rdf.rdfjson/src/test/resources/org/apache/clerezza/rdf/rdfjson/parser/test-object-bnode.json
----------------------------------------------------------------------
diff --git a/rdf.rdfjson/src/test/resources/org/apache/clerezza/rdf/rdfjson/parser/test-object-bnode.json b/rdf.rdfjson/src/test/resources/org/apache/clerezza/rdf/rdfjson/parser/test-object-bnode.json
deleted file mode 100644
index 40d2882..0000000
--- a/rdf.rdfjson/src/test/resources/org/apache/clerezza/rdf/rdfjson/parser/test-object-bnode.json
+++ /dev/null
@@ -1,5 +0,0 @@
-{
- "http://example.org/node1": {
- "http://example.org/prop1": [{"value":"_:bnode1","type":"bnode"}]
- }
-}
http://git-wip-us.apache.org/repos/asf/clerezza/blob/c8293374/rdf.rdfjson/src/test/resources/org/apache/clerezza/rdf/rdfjson/parser/test-subject-bnode.json
----------------------------------------------------------------------
diff --git a/rdf.rdfjson/src/test/resources/org/apache/clerezza/rdf/rdfjson/parser/test-subject-bnode.json b/rdf.rdfjson/src/test/resources/org/apache/clerezza/rdf/rdfjson/parser/test-subject-bnode.json
deleted file mode 100644
index bf856fe..0000000
--- a/rdf.rdfjson/src/test/resources/org/apache/clerezza/rdf/rdfjson/parser/test-subject-bnode.json
+++ /dev/null
@@ -1,10 +0,0 @@
-{
- "_:bnode1": {
- "http://example.org/prop1": [{"value":"http://example.org/node1","type":"uri"}],
- "http://example.org/prop2": [{"value":"http://example.org/node2","type":"uri"}]
- },
-
- "_:bnode2": {
- "http://example.org/prop3": [{"value":"http://example.org/node3","type":"uri"}]
- }
-}
http://git-wip-us.apache.org/repos/asf/clerezza/blob/c8293374/rdf.rdfjson/src/test/resources/org/apache/clerezza/rdf/rdfjson/parser/test.json
----------------------------------------------------------------------
diff --git a/rdf.rdfjson/src/test/resources/org/apache/clerezza/rdf/rdfjson/parser/test.json b/rdf.rdfjson/src/test/resources/org/apache/clerezza/rdf/rdfjson/parser/test.json
deleted file mode 100644
index 150ab90..0000000
--- a/rdf.rdfjson/src/test/resources/org/apache/clerezza/rdf/rdfjson/parser/test.json
+++ /dev/null
@@ -1,16 +0,0 @@
-{
- "http://base/child1": {
- "http://base/propertyB":[{"value":"B","type":"literal"}]
- },
-
- "_:b1": {
- "http://base/propertyC":[{"value":"C","type":"literal","lang":"en"}],
- "http://base/propertyE":[{"value":"E","type":"literal","datatype":"http://www.w3.org/2001/XMLSchema#string"}]
- },
-
- "http://base/root": {
- "http://base/propertyA":[{"value":"A","type":"literal"}],
- "http://base/resourcePropertyB":[{"value":"http://base/child1","type":"uri"}],
- "http://base/resourcePropertyD":[{"value":"_:b1","type":"bnode"}]
- }
-}
http://git-wip-us.apache.org/repos/asf/clerezza/blob/c8293374/rdf/pom.xml
----------------------------------------------------------------------
diff --git a/rdf/pom.xml b/rdf/pom.xml
index 9495747..e807216 100644
--- a/rdf/pom.xml
+++ b/rdf/pom.xml
@@ -52,6 +52,7 @@
<module>schemagen/maven-plugin</module>
<module>ontologies</module>
<module>rdfa</module>
+ <module>rdfjson</module>
<module>simple.storage</module>
<module>stable.serializer</module>
<module>storage.web</module>
http://git-wip-us.apache.org/repos/asf/clerezza/blob/c8293374/rdf/rdfjson/LICENSE
----------------------------------------------------------------------
diff --git a/rdf/rdfjson/LICENSE b/rdf/rdfjson/LICENSE
new file mode 100644
index 0000000..261eeb9
--- /dev/null
+++ b/rdf/rdfjson/LICENSE
@@ -0,0 +1,201 @@
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed 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.
http://git-wip-us.apache.org/repos/asf/clerezza/blob/c8293374/rdf/rdfjson/README.md
----------------------------------------------------------------------
diff --git a/rdf/rdfjson/README.md b/rdf/rdfjson/README.md
new file mode 100644
index 0000000..e3ace1c
--- /dev/null
+++ b/rdf/rdfjson/README.md
@@ -0,0 +1,4 @@
+# Apache Clerezza rdf/json Parser and Serializer
+
+This provides support for the RDF 1.1 JSON Alternate Serialization (RDF/JSON),
+see: http://www.w3.org/TR/rdf-json/
http://git-wip-us.apache.org/repos/asf/clerezza/blob/c8293374/rdf/rdfjson/pom.xml
----------------------------------------------------------------------
diff --git a/rdf/rdfjson/pom.xml b/rdf/rdfjson/pom.xml
new file mode 100644
index 0000000..52e6f55
--- /dev/null
+++ b/rdf/rdfjson/pom.xml
@@ -0,0 +1,79 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?><project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+<!--
+
+ 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.
+
+ -->
+
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <artifactId>clerezza</artifactId>
+ <groupId>org.apache.clerezza</groupId>
+ <version>7</version>
+ <relativePath>../../parent</relativePath>
+ </parent>
+ <groupId>org.apache.clerezza</groupId>
+ <artifactId>rdf.rdfjson</artifactId>
+ <packaging>bundle</packaging>
+ <version>1.0.0-SNAPSHOT</version>
+ <name>Clerezza - SCB rdf/json Parser and Serializer</name>
+ <description>A rdf/json Parser- and SerializerProvider</description>
+ <dependencies>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.clerezza</groupId>
+ <artifactId>rdf.ontologies</artifactId>
+ <scope>test</scope>
+ <version>1.0.0</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.clerezza</groupId>
+ <artifactId>rdf.core</artifactId>
+ <version>1.0.0</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.clerezza.ext</groupId>
+ <artifactId>org.json.simple</artifactId>
+ <version>0.4</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>org.apache.felix.scr.annotations</artifactId>
+ </dependency>
+ </dependencies>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <extensions>true</extensions>
+ <configuration>
+ <instructions>
+ <Include-Resource>
+ {maven-resources}
+ </Include-Resource>
+ </instructions>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/clerezza/blob/c8293374/rdf/rdfjson/src/main/java/org/apache/clerezza/rdf/rdfjson/parser/RdfJsonParsingProvider.java
----------------------------------------------------------------------
diff --git a/rdf/rdfjson/src/main/java/org/apache/clerezza/rdf/rdfjson/parser/RdfJsonParsingProvider.java b/rdf/rdfjson/src/main/java/org/apache/clerezza/rdf/rdfjson/parser/RdfJsonParsingProvider.java
new file mode 100644
index 0000000..9ad302c
--- /dev/null
+++ b/rdf/rdfjson/src/main/java/org/apache/clerezza/rdf/rdfjson/parser/RdfJsonParsingProvider.java
@@ -0,0 +1,144 @@
+/*
+ * 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.clerezza.rdf.rdfjson.parser;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.UnsupportedEncodingException;
+import java.util.HashMap;
+import java.util.Map;
+import org.json.simple.JSONArray;
+import org.json.simple.JSONObject;
+import org.json.simple.parser.JSONParser;
+import org.json.simple.parser.ParseException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.apache.clerezza.commons.rdf.BlankNode;
+import org.apache.clerezza.commons.rdf.Language;
+import org.apache.clerezza.commons.rdf.Graph;
+import org.apache.clerezza.commons.rdf.BlankNodeOrIRI;
+import org.apache.clerezza.commons.rdf.IRI;
+import org.apache.clerezza.commons.rdf.impl.utils.LiteralImpl;
+import org.apache.clerezza.commons.rdf.impl.utils.PlainLiteralImpl;
+import org.apache.clerezza.commons.rdf.impl.utils.TripleImpl;
+import org.apache.clerezza.commons.rdf.impl.utils.TypedLiteralImpl;
+import org.apache.clerezza.rdf.core.serializedform.ParsingProvider;
+import org.apache.clerezza.rdf.core.serializedform.SupportedFormat;
+import org.apache.felix.scr.annotations.Component;
+import org.apache.felix.scr.annotations.Service;
+
+/**
+ * A {@link org.apache.clerezza.rdf.core.serializedform.ParsingProvider} for
+ * rdf/json
+ *
+ * @author tio, hasan
+ *
+ */
+@Component(immediate = true)
+@Service(ParsingProvider.class)
+@SupportedFormat(SupportedFormat.RDF_JSON)
+public class RdfJsonParsingProvider implements ParsingProvider {
+
+ private final Logger logger = LoggerFactory.getLogger(getClass());
+ private static final IRI XSD_STRING = new IRI("http://www.w3.org/2001/XMLSchema#string");
+
+ @Override
+ public void parse(Graph target, InputStream serializedGraph, String formatIdentifier, IRI baseUri) {
+
+ BlankNodeManager bNodeMgr = new BlankNodeManager();
+
+ JSONParser parser = new JSONParser();
+ InputStreamReader reader;
+ try {
+ reader = new InputStreamReader(serializedGraph, "UTF-8");
+ } catch (UnsupportedEncodingException e) {
+ String msg = "Encoding 'UTF-8' is not supported by this System";
+ logger.error("{} (message: {})", msg, e.getMessage());
+ throw new IllegalStateException(msg, e);
+ }
+
+ try {
+ JSONObject root = (JSONObject) parser.parse(reader);
+
+ BlankNodeOrIRI nonLiteral = null;
+ for (Object key : root.keySet()) {
+ String keyString = (String) key;
+ if (keyString.startsWith("_:")) {
+ nonLiteral = bNodeMgr.getBlankNode(keyString);
+ } else {
+ nonLiteral = new IRI(keyString);
+ }
+ JSONObject predicates = (JSONObject) root.get(keyString);
+ addTriplesToGraph(nonLiteral, bNodeMgr, predicates, target);
+ }
+ } catch (IOException ioe) {
+ logger.error(ioe.getMessage());
+ throw new RuntimeException(ioe.getMessage());
+ } catch (ParseException pe) {
+ logger.error(pe.getMessage());
+ throw new RuntimeException(pe.getMessage());
+ }
+ }
+
+ private class BlankNodeManager {
+
+ private Map<String, BlankNode> bNodeMap = new HashMap<String, BlankNode>();
+
+ public BlankNode getBlankNode(String id) {
+ BlankNode bNode = bNodeMap.get(id);
+ if (bNode == null) {
+ bNode = new BlankNode();
+ bNodeMap.put(id, bNode);
+ }
+ return bNode;
+ }
+ }
+
+ private void addTriplesToGraph(BlankNodeOrIRI subject, BlankNodeManager bNodeMgr, JSONObject predicates, Graph mGraph) {
+ for (Object predicate : predicates.keySet()) {
+ JSONArray objects = (JSONArray) predicates.get(predicate);
+ for (Object object : objects) {
+ JSONObject values = (JSONObject) object;
+ String value = (String) values.get("value");
+ if (values.get("type").equals("literal")) {
+ IRI dataType;
+ Object dataTypeValue = values.get("datatype");
+ if (dataTypeValue == null
+ || dataTypeValue.toString().isEmpty()) {
+ dataType = XSD_STRING;
+ } else {
+ dataType = new IRI(dataTypeValue.toString());
+ }
+ Language language = null;
+ if (values.containsKey("lang")
+ && !values.get("lang").equals("")
+ && values.get("lang") != null) {
+ language = new Language((String) values.get("lang"));
+ }
+ mGraph.add(new TripleImpl(subject, new IRI((String) predicate),
+ new LiteralImpl(value.toString(), dataType, language)));
+ } else if (values.get("type").equals("uri")) {
+ mGraph.add(new TripleImpl(subject, new IRI((String) predicate), new IRI(value)));
+ } else if (values.get("type").equals("bnode")) {
+ BlankNodeOrIRI bNode = bNodeMgr.getBlankNode(value);
+ mGraph.add(new TripleImpl(subject, new IRI((String) predicate), bNode));
+ }
+ }
+ }
+ }
+}