You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@clerezza.apache.org by ha...@apache.org on 2011/01/14 03:37:44 UTC

svn commit: r1058842 - in /incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.sesame.parser: ./ src/ src/main/ src/main/java/ src/main/java/org/ src/main/java/org/apache/ src/main/java/org/apache/clerezza/ src/main/java/org/apa...

Author: hasan
Date: Fri Jan 14 02:37:43 2011
New Revision: 1058842

URL: http://svn.apache.org/viewvc?rev=1058842&view=rev
Log:
CLEREZZA-392: initial version

Added:
    incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.sesame.parser/   (with props)
    incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.sesame.parser/pom.xml
    incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.sesame.parser/src/   (with props)
    incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.sesame.parser/src/main/
    incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.sesame.parser/src/main/java/
    incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.sesame.parser/src/main/java/org/
    incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.sesame.parser/src/main/java/org/apache/
    incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.sesame.parser/src/main/java/org/apache/clerezza/
    incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.sesame.parser/src/main/java/org/apache/clerezza/rdf/
    incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.sesame.parser/src/main/java/org/apache/clerezza/rdf/sesame/
    incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.sesame.parser/src/main/java/org/apache/clerezza/rdf/sesame/parser/
    incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.sesame.parser/src/main/java/org/apache/clerezza/rdf/sesame/parser/ParserFactory.java
    incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.sesame.parser/src/main/java/org/apache/clerezza/rdf/sesame/parser/SesameParserProvider.java
    incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.sesame.parser/src/main/java/org/apache/clerezza/rdf/sesame/parser/SesameRdfHandler.java
    incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.sesame.parser/src/main/java/org/apache/clerezza/rdf/sesame/parser/SesameScbConverter.java
    incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.sesame.parser/src/test/
    incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.sesame.parser/src/test/java/
    incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.sesame.parser/src/test/java/org/
    incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.sesame.parser/src/test/java/org/apache/
    incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.sesame.parser/src/test/java/org/apache/clerezza/
    incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.sesame.parser/src/test/java/org/apache/clerezza/rdf/
    incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.sesame.parser/src/test/java/org/apache/clerezza/rdf/sesame/
    incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.sesame.parser/src/test/java/org/apache/clerezza/rdf/sesame/parser/
    incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.sesame.parser/src/test/java/org/apache/clerezza/rdf/sesame/parser/SesameParserProviderTest.java
    incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.sesame.parser/src/test/resources/
    incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.sesame.parser/src/test/resources/org/
    incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.sesame.parser/src/test/resources/org/apache/
    incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.sesame.parser/src/test/resources/org/apache/clerezza/
    incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.sesame.parser/src/test/resources/org/apache/clerezza/rdf/
    incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.sesame.parser/src/test/resources/org/apache/clerezza/rdf/sesame/
    incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.sesame.parser/src/test/resources/org/apache/clerezza/rdf/sesame/parser/
    incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.sesame.parser/src/test/resources/org/apache/clerezza/rdf/sesame/parser/test-04.nt
    incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.sesame.parser/src/test/resources/org/apache/clerezza/rdf/sesame/parser/test-04.rdf
    incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.sesame.parser/src/test/resources/org/apache/clerezza/rdf/sesame/parser/test-04.ttl

Propchange: incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.sesame.parser/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Fri Jan 14 02:37:43 2011
@@ -0,0 +1,4 @@
+.classpath
+.settings
+target
+.project

Added: incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.sesame.parser/pom.xml
URL: http://svn.apache.org/viewvc/incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.sesame.parser/pom.xml?rev=1058842&view=auto
==============================================================================
--- incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.sesame.parser/pom.xml (added)
+++ incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.sesame.parser/pom.xml Fri Jan 14 02:37:43 2011
@@ -0,0 +1,38 @@
+<?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">
+	<modelVersion>4.0.0</modelVersion>
+	<parent>
+		<groupId>org.apache.clerezza</groupId>
+		<artifactId>org.apache.clerezza.parent</artifactId>
+		<version>0.2-incubating-SNAPSHOT</version>
+	</parent>
+	<groupId>org.apache.clerezza</groupId>
+	<artifactId>org.apache.clerezza.rdf.sesame.parser</artifactId>
+	<version>0.1-incubating-SNAPSHOT</version>
+	<packaging>bundle</packaging>
+	<name>Clerezza - SCB Sesame-based Parser</name>
+	<description>An RDF parser based on Sesame</description>
+	<dependencies>
+		<dependency>
+			<groupId>junit</groupId>
+			<artifactId>junit</artifactId>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>org.osgi</groupId>
+			<artifactId>org.osgi.core</artifactId>
+		</dependency>
+		<dependency>
+			<groupId>org.osgi</groupId>
+			<artifactId>org.osgi.compendium</artifactId>
+		</dependency>
+		<dependency>
+			<groupId>org.apache.clerezza</groupId>
+			<artifactId>org.apache.clerezza.rdf.core</artifactId>
+		</dependency>
+		<dependency>
+			<groupId>org.apache.clerezza.ext</groupId>
+			<artifactId>org.openrdf.sesame</artifactId>
+		</dependency>
+	</dependencies>
+</project>

Propchange: incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.sesame.parser/src/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Fri Jan 14 02:37:43 2011
@@ -0,0 +1 @@
+pom.xml

Added: incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.sesame.parser/src/main/java/org/apache/clerezza/rdf/sesame/parser/ParserFactory.java
URL: http://svn.apache.org/viewvc/incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.sesame.parser/src/main/java/org/apache/clerezza/rdf/sesame/parser/ParserFactory.java?rev=1058842&view=auto
==============================================================================
--- incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.sesame.parser/src/main/java/org/apache/clerezza/rdf/sesame/parser/ParserFactory.java (added)
+++ incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.sesame.parser/src/main/java/org/apache/clerezza/rdf/sesame/parser/ParserFactory.java Fri Jan 14 02:37:43 2011
@@ -0,0 +1,59 @@
+/*
+ * 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.sesame.parser;
+
+import java.util.HashMap;
+import java.util.Map;
+import org.apache.clerezza.rdf.core.serializedform.SupportedFormat;
+import org.openrdf.rio.RDFParser;
+import org.openrdf.rio.RDFParserFactory;
+import org.openrdf.rio.n3.N3ParserFactory;
+import org.openrdf.rio.ntriples.NTriplesParserFactory;
+import org.openrdf.rio.rdfxml.RDFXMLParserFactory;
+import org.openrdf.rio.turtle.TurtleParserFactory;
+
+/**
+ *
+ * @author hasan
+ */
+public class ParserFactory {
+	private static final Map<String, RDFParserFactory> factories = new HashMap<String, RDFParserFactory>();
+	static {
+		factories.put(SupportedFormat.RDF_XML, new RDFXMLParserFactory());
+		factories.put(SupportedFormat.N_TRIPLE, new NTriplesParserFactory());
+		factories.put(SupportedFormat.X_TURTLE, new TurtleParserFactory());
+		factories.put(SupportedFormat.TURTLE, new TurtleParserFactory());
+		factories.put(SupportedFormat.N3, new N3ParserFactory());
+		// other parser factories can be added in future if needed:
+		// TriXParserFactory, TriGParserFactory, and RDFaHtmlParserFactory
+	}
+
+	private ParserFactory() {
+	}
+
+	public static RDFParser createRdfParser(String format) {
+		RDFParserFactory factory = factories.get(format);
+		if (factory == null) {
+			return null;
+		}
+		return factory.getParser();
+	}
+}

Added: incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.sesame.parser/src/main/java/org/apache/clerezza/rdf/sesame/parser/SesameParserProvider.java
URL: http://svn.apache.org/viewvc/incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.sesame.parser/src/main/java/org/apache/clerezza/rdf/sesame/parser/SesameParserProvider.java?rev=1058842&view=auto
==============================================================================
--- incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.sesame.parser/src/main/java/org/apache/clerezza/rdf/sesame/parser/SesameParserProvider.java (added)
+++ incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.sesame.parser/src/main/java/org/apache/clerezza/rdf/sesame/parser/SesameParserProvider.java Fri Jan 14 02:37:43 2011
@@ -0,0 +1,73 @@
+/*
+ * 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.sesame.parser;
+
+import java.io.IOException;
+import java.io.InputStream;
+import org.apache.clerezza.rdf.core.MGraph;
+import org.apache.clerezza.rdf.core.serializedform.ParsingProvider;
+import org.apache.clerezza.rdf.core.serializedform.SupportedFormat;
+import org.apache.clerezza.rdf.core.UriRef;
+import org.apache.felix.scr.annotations.Component;
+import org.apache.felix.scr.annotations.Property;
+import org.apache.felix.scr.annotations.Service;
+import org.apache.clerezza.rdf.core.serializedform.UnsupportedParsingFormatException;
+import org.openrdf.rio.RDFHandlerException;
+import org.openrdf.rio.RDFParseException;
+import org.openrdf.rio.RDFParser;
+
+/**
+ * A {@link org.apache.clerezza.rdf.core.serializedform.ParsingProvider} based on Sesame
+ *
+ * @author hasan
+ */
+
+@Component(immediate=true)
+@Service(ParsingProvider.class)
+@Property(name="supportedFormat", value={SupportedFormat.RDF_XML,
+	SupportedFormat.TURTLE,	SupportedFormat.X_TURTLE,
+	SupportedFormat.N_TRIPLE, SupportedFormat.N3})
+@SupportedFormat({SupportedFormat.RDF_XML,
+	SupportedFormat.TURTLE,	SupportedFormat.X_TURTLE,
+	SupportedFormat.N_TRIPLE, SupportedFormat.N3})
+public class SesameParserProvider implements ParsingProvider {
+
+	@Override
+	public void parse(MGraph target, InputStream serializedGraph, String formatIdentifier, UriRef baseUri) {
+
+		RDFParser rdfParser = ParserFactory.createRdfParser(formatIdentifier);
+		if (rdfParser == null) {
+			throw new UnsupportedParsingFormatException(formatIdentifier);
+		}
+		SesameRdfHandler sesameRdfHandler = new SesameRdfHandler(target);
+		rdfParser.setRDFHandler(sesameRdfHandler);
+		String base = (baseUri == null) ? "http://relative-uri.fake/" : baseUri.getUnicodeString();
+		try {
+			rdfParser.parse(serializedGraph, base);
+		} catch (IOException ex) {
+			throw new RuntimeException(ex);
+		} catch (RDFParseException ex) {
+			throw new RuntimeException(ex);
+		} catch (RDFHandlerException ex) {
+			throw new RuntimeException(ex);
+		}
+	}
+}

Added: incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.sesame.parser/src/main/java/org/apache/clerezza/rdf/sesame/parser/SesameRdfHandler.java
URL: http://svn.apache.org/viewvc/incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.sesame.parser/src/main/java/org/apache/clerezza/rdf/sesame/parser/SesameRdfHandler.java?rev=1058842&view=auto
==============================================================================
--- incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.sesame.parser/src/main/java/org/apache/clerezza/rdf/sesame/parser/SesameRdfHandler.java (added)
+++ incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.sesame.parser/src/main/java/org/apache/clerezza/rdf/sesame/parser/SesameRdfHandler.java Fri Jan 14 02:37:43 2011
@@ -0,0 +1,63 @@
+/*
+ * 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.sesame.parser;
+
+import org.apache.clerezza.rdf.core.TripleCollection;
+import org.openrdf.model.Statement;
+import org.openrdf.rio.RDFHandler;
+import org.openrdf.rio.RDFHandlerException;
+
+/**
+ *
+ * @author hasan
+ */
+public class SesameRdfHandler implements RDFHandler {
+
+	final TripleCollection tc;
+	private SesameScbConverter sesameScbConverter;
+
+	public SesameRdfHandler(TripleCollection tc) {
+		this.tc = tc;
+	}
+
+	@Override
+	public void startRDF() throws RDFHandlerException {
+		sesameScbConverter = new SesameScbConverter();
+	}
+
+	@Override
+	public void endRDF() throws RDFHandlerException {
+		sesameScbConverter = null;
+	}
+
+	@Override
+	public void handleNamespace(String string, String string1) throws RDFHandlerException {
+	}
+
+	@Override
+	public void handleStatement(Statement stmnt) throws RDFHandlerException {
+		tc.add(sesameScbConverter.createTriple(stmnt));
+	}
+
+	@Override
+	public void handleComment(String string) throws RDFHandlerException {
+	}
+}

Added: incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.sesame.parser/src/main/java/org/apache/clerezza/rdf/sesame/parser/SesameScbConverter.java
URL: http://svn.apache.org/viewvc/incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.sesame.parser/src/main/java/org/apache/clerezza/rdf/sesame/parser/SesameScbConverter.java?rev=1058842&view=auto
==============================================================================
--- incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.sesame.parser/src/main/java/org/apache/clerezza/rdf/sesame/parser/SesameScbConverter.java (added)
+++ incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.sesame.parser/src/main/java/org/apache/clerezza/rdf/sesame/parser/SesameScbConverter.java Fri Jan 14 02:37:43 2011
@@ -0,0 +1,124 @@
+/*
+ * 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.sesame.parser;
+
+import java.util.HashMap;
+import java.util.Map;
+import org.apache.clerezza.rdf.core.BNode;
+import org.apache.clerezza.rdf.core.Language;
+import org.apache.clerezza.rdf.core.Literal;
+import org.apache.clerezza.rdf.core.NonLiteral;
+import org.apache.clerezza.rdf.core.Resource;
+import org.apache.clerezza.rdf.core.Triple;
+import org.apache.clerezza.rdf.core.UriRef;
+import org.apache.clerezza.rdf.core.impl.PlainLiteralImpl;
+import org.apache.clerezza.rdf.core.impl.TripleImpl;
+import org.apache.clerezza.rdf.core.impl.TypedLiteralImpl;
+import org.openrdf.model.Statement;
+
+/**
+ *
+ * @author hasan
+ */
+public class SesameScbConverter {
+
+	private final Map<org.openrdf.model.BNode, BNode> bNodesMap = new HashMap<org.openrdf.model.BNode, BNode>();
+
+	/**
+	 * Create a {@link org.apache.clerezza.rdf.core.Triple} instance from a {@link org.openrdf.model.Statement}
+	 *
+	 * @param statement
+	 * @return a new TripleImpl instance
+	 */
+	public Triple createTriple(Statement statement) {
+		NonLiteral subject = createNonLiteral(statement.getSubject());
+		UriRef predicate = createUriRef(statement.getPredicate());
+		Resource resource = createResource(statement.getObject());
+		return new TripleImpl(subject, predicate, resource);
+	}
+
+	/**
+	 * Create a {@link org.apache.clerezza.rdf.core.NonLiteral} instance from a {@link org.openrdf.model.Resource}
+	 * 
+	 * @param resource
+	 * @return a new UriRef or a BNode instance. The BNode instance is new if it does not exist before
+	 */
+	public NonLiteral createNonLiteral(org.openrdf.model.Resource resource) {
+		if (resource instanceof org.openrdf.model.BNode) {
+			org.openrdf.model.BNode sesameBNode = (org.openrdf.model.BNode) resource;
+			return getOrCreateBNode(sesameBNode);
+		} else {
+			org.openrdf.model.URI uri = (org.openrdf.model.URI) resource;
+			return createUriRef(uri);
+		}
+	}
+
+	private org.apache.clerezza.rdf.core.BNode getOrCreateBNode(org.openrdf.model.BNode sesameBNode) {
+		BNode result = bNodesMap.get(sesameBNode);
+
+		if (result == null) {
+			result = new BNode();
+			bNodesMap.put(sesameBNode, result);
+		}
+		return result;
+	}
+
+	/**
+	 * Create a {@link org.apache.clerezza.rdf.core.UriRef} instance from a {@link org.openrdf.model.URI}
+	 *
+	 * @param uri
+	 * @return a new UriRef instance
+	 */
+	public UriRef createUriRef(org.openrdf.model.URI uri) {
+		return new UriRef(uri.stringValue());
+	}
+
+	/**
+	 * Create a {@link org.apache.clerezza.rdf.core.Resource} instance from a {@link org.openrdf.model.Value}
+	 *
+	 * @param value
+	 * @return a new PlainLiteralImpl, a new TypedLiteralImpl, a new UriRef, or a BNode instance
+	 */
+	public Resource createResource(org.openrdf.model.Value value) {
+		if (value instanceof org.openrdf.model.Literal) {
+			return createLiteral((org.openrdf.model.Literal) value);
+		} else {
+			return createNonLiteral((org.openrdf.model.Resource) value);
+		}
+	}
+
+	/**
+	 * Create a {@link org.apache.clerezza.rdf.core.Literal} instance from a {@link org.openrdf.model.Literal}
+	 *
+	 * @param literal
+	 * @return a new PlainLiteralImpl or TypedLiteralImpl instance
+	 */
+	public Literal createLiteral(org.openrdf.model.Literal literal) {
+		org.openrdf.model.URI dataType = literal.getDatatype();
+		if (dataType == null) {
+			String languageString = literal.getLanguage();
+			Language language = languageString == null ? null : new Language(languageString);
+			return new PlainLiteralImpl(literal.getLabel(), language);
+		} else {
+			return new TypedLiteralImpl(literal.getLabel(), createUriRef(dataType));
+		}
+	}
+}

Added: incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.sesame.parser/src/test/java/org/apache/clerezza/rdf/sesame/parser/SesameParserProviderTest.java
URL: http://svn.apache.org/viewvc/incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.sesame.parser/src/test/java/org/apache/clerezza/rdf/sesame/parser/SesameParserProviderTest.java?rev=1058842&view=auto
==============================================================================
--- incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.sesame.parser/src/test/java/org/apache/clerezza/rdf/sesame/parser/SesameParserProviderTest.java (added)
+++ incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.sesame.parser/src/test/java/org/apache/clerezza/rdf/sesame/parser/SesameParserProviderTest.java Fri Jan 14 02:37:43 2011
@@ -0,0 +1,72 @@
+/*
+ * 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.sesame.parser;
+
+import java.io.InputStream;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.apache.clerezza.rdf.core.Graph;
+import org.apache.clerezza.rdf.core.MGraph;
+import org.apache.clerezza.rdf.core.UriRef;
+import org.apache.clerezza.rdf.core.impl.SimpleMGraph;
+import org.apache.clerezza.rdf.core.serializedform.ParsingProvider;
+import org.apache.clerezza.rdf.core.serializedform.SupportedFormat;
+
+/**
+ * Tests taken from http://www.w3.org/2001/sw/DataAccess/df1/tests/
+ *
+ * @author hasan
+ */
+public class SesameParserProviderTest {
+
+	/*
+	 * comparing result from nt and turtle parsing,
+	 */
+	@Test
+	public void testTurtleParser() {
+		ParsingProvider provider = new SesameParserProvider();
+		InputStream nTriplesIn = getClass().getResourceAsStream("test-04.nt");
+		InputStream turtleIn = getClass().getResourceAsStream("test-04.ttl");
+		Graph graphFromNTriples = parse(provider, nTriplesIn, SupportedFormat.N_TRIPLE, null);
+		Graph graphFromTurtle = parse(provider, turtleIn, SupportedFormat.TURTLE, null);
+		Assert.assertEquals(graphFromNTriples, graphFromTurtle);
+	}
+
+	/*
+	 * comparing result from nt and rdf/xml parsing,
+	 */
+	@Test
+	public void testRdfXmlParser() {
+		ParsingProvider provider = new SesameParserProvider();
+		InputStream nTriplesIn = getClass().getResourceAsStream("test-04.nt");
+		InputStream rdfXmlIn = getClass().getResourceAsStream("test-04.rdf");
+		Graph graphFromNTriples = parse(provider, nTriplesIn, SupportedFormat.N_TRIPLE, null);
+		Graph graphFromRdfXml = parse(provider, rdfXmlIn, SupportedFormat.RDF_XML, null);
+		Assert.assertEquals(graphFromNTriples, graphFromRdfXml);
+	}
+
+	private Graph parse(ParsingProvider parsingProvider, InputStream in, String type, UriRef base) {
+		MGraph simpleMGraph = new SimpleMGraph();
+		parsingProvider.parse(simpleMGraph, in, type, base);
+		return simpleMGraph.getGraph();
+	}
+}

Added: incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.sesame.parser/src/test/resources/org/apache/clerezza/rdf/sesame/parser/test-04.nt
URL: http://svn.apache.org/viewvc/incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.sesame.parser/src/test/resources/org/apache/clerezza/rdf/sesame/parser/test-04.nt?rev=1058842&view=auto
==============================================================================
--- incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.sesame.parser/src/test/resources/org/apache/clerezza/rdf/sesame/parser/test-04.nt (added)
+++ incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.sesame.parser/src/test/resources/org/apache/clerezza/rdf/sesame/parser/test-04.nt Fri Jan 14 02:37:43 2011
@@ -0,0 +1,2 @@
+_:genid1 <http://example.org/base#a> <http://example.org/base#b> .
+<http://example.org/base#c> <http://example.org/base#d> _:genid2 .

Added: incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.sesame.parser/src/test/resources/org/apache/clerezza/rdf/sesame/parser/test-04.rdf
URL: http://svn.apache.org/viewvc/incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.sesame.parser/src/test/resources/org/apache/clerezza/rdf/sesame/parser/test-04.rdf?rev=1058842&view=auto
==============================================================================
--- incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.sesame.parser/src/test/resources/org/apache/clerezza/rdf/sesame/parser/test-04.rdf (added)
+++ incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.sesame.parser/src/test/resources/org/apache/clerezza/rdf/sesame/parser/test-04.rdf Fri Jan 14 02:37:43 2011
@@ -0,0 +1,10 @@
+<rdf:RDF
+    xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+    xmlns:j.0="http://example.org/base#" > 
+  <rdf:Description rdf:about="http://example.org/base#c">
+    <j.0:d rdf:nodeID="A0"/>
+  </rdf:Description>
+  <rdf:Description rdf:nodeID="A1">
+    <j.0:a rdf:resource="http://example.org/base#b"/>
+  </rdf:Description>
+</rdf:RDF>
\ No newline at end of file

Added: incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.sesame.parser/src/test/resources/org/apache/clerezza/rdf/sesame/parser/test-04.ttl
URL: http://svn.apache.org/viewvc/incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.sesame.parser/src/test/resources/org/apache/clerezza/rdf/sesame/parser/test-04.ttl?rev=1058842&view=auto
==============================================================================
--- incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.sesame.parser/src/test/resources/org/apache/clerezza/rdf/sesame/parser/test-04.ttl (added)
+++ incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.sesame.parser/src/test/resources/org/apache/clerezza/rdf/sesame/parser/test-04.ttl Fri Jan 14 02:37:43 2011
@@ -0,0 +1,4 @@
+# Test empty [] operator; not allowed as predicate
+@prefix : <http://example.org/base#> .
+[] :a :b .
+:c :d [] .