You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@any23.apache.org by an...@apache.org on 2013/04/19 06:10:46 UTC

[01/19] git commit: remove aduna repository, as sesame-2.7 is going to be deployed to sonatype and maven central

Updated Branches:
  refs/heads/ANY23-141 [created] ced48a39f


remove aduna repository, as sesame-2.7 is going to be deployed to sonatype and maven central


Project: http://git-wip-us.apache.org/repos/asf/any23/repo
Commit: http://git-wip-us.apache.org/repos/asf/any23/commit/681fa9e5
Tree: http://git-wip-us.apache.org/repos/asf/any23/tree/681fa9e5
Diff: http://git-wip-us.apache.org/repos/asf/any23/diff/681fa9e5

Branch: refs/heads/ANY23-141
Commit: 681fa9e5eb25f4a9fdf3d532cd8ee2afe5202efe
Parents: 914510c
Author: Peter Ansell <p_...@yahoo.com>
Authored: Fri Dec 7 09:50:14 2012 +1000
Committer: Peter Ansell <p_...@yahoo.com>
Committed: Fri Apr 19 13:21:44 2013 +1000

----------------------------------------------------------------------
 pom.xml |    7 -------
 1 files changed, 0 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/any23/blob/681fa9e5/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 172c7b9..7eac9be 100644
--- a/pom.xml
+++ b/pom.xml
@@ -511,13 +511,6 @@
       <id>any23-repository-external</id>
       <url>http://svn.apache.org/repos/asf/any23/repo-ext/</url>
     </repository>
-    <!-- Specific repository for Aduna / Sesame related dependencies. -->
-    <repository>
-      <id>aduna-software-release-repo</id>
-      <name>Aduna SW Release Repository</name>
-      <url>http://repo.aduna-software.org/maven2/releases</url>
-      <layout>default</layout>
-    </repository>
   </repositories>
 
   <build>


[16/19] git commit: fix test that attempted to parse an nquads file with no newlines in it, against the specification

Posted by an...@apache.org.
fix test that attempted to parse an nquads file with no newlines in it, against the specification


Project: http://git-wip-us.apache.org/repos/asf/any23/repo
Commit: http://git-wip-us.apache.org/repos/asf/any23/commit/86846dc6
Tree: http://git-wip-us.apache.org/repos/asf/any23/tree/86846dc6
Diff: http://git-wip-us.apache.org/repos/asf/any23/diff/86846dc6

Branch: refs/heads/ANY23-141
Commit: 86846dc699dd6ae58257fa74df8a95dae13929d8
Parents: 0b69595
Author: Peter Ansell <p_...@yahoo.com>
Authored: Wed Oct 24 14:47:19 2012 +1000
Committer: Peter Ansell <p_...@yahoo.com>
Committed: Fri Apr 19 13:35:47 2013 +1000

----------------------------------------------------------------------
 .../java/org/apache/any23/cli/CrawlerTest.java     |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/any23/blob/86846dc6/plugins/basic-crawler/src/test/java/org/apache/any23/cli/CrawlerTest.java
----------------------------------------------------------------------
diff --git a/plugins/basic-crawler/src/test/java/org/apache/any23/cli/CrawlerTest.java b/plugins/basic-crawler/src/test/java/org/apache/any23/cli/CrawlerTest.java
index 6a776e7..fa4cbc0 100644
--- a/plugins/basic-crawler/src/test/java/org/apache/any23/cli/CrawlerTest.java
+++ b/plugins/basic-crawler/src/test/java/org/apache/any23/cli/CrawlerTest.java
@@ -87,6 +87,7 @@ public class CrawlerTest extends Any23OnlineTestBase {
         final StringBuilder allLinesExceptLast = new StringBuilder();
         for (int i = 0; i < lines.length - 1; i++) {
             allLinesExceptLast.append(lines[i]);
+            allLinesExceptLast.append("\n");
         }
 
         final Statement[] statements = RDFUtils.parseRDF(RDFFormat.NQUADS, allLinesExceptLast.toString());


[10/19] git commit: add log4j properties file to nquads module

Posted by an...@apache.org.
add log4j properties file to nquads module


Project: http://git-wip-us.apache.org/repos/asf/any23/repo
Commit: http://git-wip-us.apache.org/repos/asf/any23/commit/0227cc0c
Tree: http://git-wip-us.apache.org/repos/asf/any23/tree/0227cc0c
Diff: http://git-wip-us.apache.org/repos/asf/any23/diff/0227cc0c

Branch: refs/heads/ANY23-141
Commit: 0227cc0cb394474c41e05ddd4f0f14675438121f
Parents: d083560
Author: Peter Ansell <p_...@yahoo.com>
Authored: Wed Oct 24 13:52:22 2012 +1000
Committer: Peter Ansell <p_...@yahoo.com>
Committed: Fri Apr 19 13:33:27 2013 +1000

----------------------------------------------------------------------
 nquads/src/test/resources/log4j.properties |   23 +++++++++++++++++++++++
 1 files changed, 23 insertions(+), 0 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/any23/blob/0227cc0c/nquads/src/test/resources/log4j.properties
----------------------------------------------------------------------
diff --git a/nquads/src/test/resources/log4j.properties b/nquads/src/test/resources/log4j.properties
new file mode 100644
index 0000000..d715976
--- /dev/null
+++ b/nquads/src/test/resources/log4j.properties
@@ -0,0 +1,23 @@
+# 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.
+
+log4j.rootCategory=INFO, stdout
+
+log4j.appender.stdout.Threshold=INFO
+
+log4j.appender.stdout=org.apache.log4j.ConsoleAppender
+log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
+
+log4j.appender.stdout.layout.ConversionPattern=%5p [%t] %m%n


[12/19] git commit: fix test that relies on the NQuadsWriter expanding namespaces, when this is never necessary with the Sesame API, as namespaces are always expanded automatically inside of the org.openrdf.model.URI interface, and in addition, N-Quads h

Posted by an...@apache.org.
fix test that relies on the NQuadsWriter expanding namespaces, when this is never necessary with the Sesame API, as namespaces are always expanded automatically inside of the org.openrdf.model.URI interface, and in addition, N-Quads has never, and will never have, any support for namespaces. If that happens it will be as an extension to Turtle, which will be separate from N-Quads as N-Quads is by design a very thin wrapper over N-Triples, which will also never have namespace/prefixes


Project: http://git-wip-us.apache.org/repos/asf/any23/repo
Commit: http://git-wip-us.apache.org/repos/asf/any23/commit/c7562f9e
Tree: http://git-wip-us.apache.org/repos/asf/any23/tree/c7562f9e
Diff: http://git-wip-us.apache.org/repos/asf/any23/diff/c7562f9e

Branch: refs/heads/ANY23-141
Commit: c7562f9e20f2604f273ffd8af83445d024762e24
Parents: bc291c0
Author: Peter Ansell <p_...@yahoo.com>
Authored: Wed Oct 24 13:55:18 2012 +1000
Committer: Peter Ansell <p_...@yahoo.com>
Committed: Fri Apr 19 13:34:55 2013 +1000

----------------------------------------------------------------------
 .../apache/any23/io/nquads/NQuadsWriterTest.java   |   23 ++++++++-------
 1 files changed, 12 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/any23/blob/c7562f9e/nquads/src/test/java/org/apache/any23/io/nquads/NQuadsWriterTest.java
----------------------------------------------------------------------
diff --git a/nquads/src/test/java/org/apache/any23/io/nquads/NQuadsWriterTest.java b/nquads/src/test/java/org/apache/any23/io/nquads/NQuadsWriterTest.java
index 368e876..1fe92c6 100644
--- a/nquads/src/test/java/org/apache/any23/io/nquads/NQuadsWriterTest.java
+++ b/nquads/src/test/java/org/apache/any23/io/nquads/NQuadsWriterTest.java
@@ -97,12 +97,12 @@ public class NQuadsWriterTest {
                 literal("12345", uri("http://www.w3.org/2001/XMLSchema#integer")),
                 uri("http://gra2")
         );
-        Statement s6 = quad(
-                uri("p1:sub"),
-                uri("p1:pre"),
-                uri("p1:obj"),
-                uri("p1:gra2")
-        );
+//        Statement s6 = quad(
+//                uri("p1:sub"),
+//                uri("p1:pre"),
+//                uri("p1:obj"),
+//                uri("p1:gra2")
+//        );
         Statement s7 = quad(
                 uri("http://sub"),
                 uri("http://pre"),
@@ -112,29 +112,30 @@ public class NQuadsWriterTest {
 
         // Sending events.
         writer.startRDF();
-        writer.handleNamespace("p1", "http://test.com/");
+        //writer.handleNamespace("p1", "http://test.com/");
         writer.handleStatement(s1);
         writer.handleStatement(s2);
         writer.handleStatement(s3);
         writer.handleStatement(s4);
         writer.handleStatement(s5);
-        writer.handleStatement(s6);
+        //writer.handleStatement(s6);
         writer.handleStatement(s7);
         writer.endRDF();
 
         // Checking content.
         String content = baos.toString();
+        logger.info("output={}", content);
         String[] lines = content.split("\n");
-        Assert.assertEquals("Unexpected number of lines.", 7, lines.length);
+        Assert.assertEquals("Unexpected number of lines.", 6, lines.length);
         Assert.assertTrue( lines[0].matches("<.*> <.*> <.*> <.*> \\.") );
         Assert.assertTrue( lines[1].matches("_:.* <.*> _:.* <.*> \\.") );
         Assert.assertTrue( lines[2].matches("_:.* <.*> \".*\" <.*> \\.") );
         Assert.assertTrue( lines[3].matches("_:.* <.*> \".*\"@en <.*> \\.") );
         Assert.assertTrue( lines[4].matches("_:.* <.*> \".*\"\\^\\^<.*> <.*> \\.") );
-        Assert.assertTrue( lines[5].matches("<http://.*> <http://.*> <http://.*> <http://.*> \\.") );
+        //Assert.assertTrue( lines[5].matches("<http://.*> <http://.*> <http://.*> <http://.*> \\.") );
         Assert.assertEquals(
                 "<http://sub> <http://pre> \"This is line 1.\\nThis is line 2.\\n\" <http://gra3> .",
-                lines[6]
+                lines[5]
         );
     }
 


[08/19] git commit: add changes since beta2

Posted by an...@apache.org.
add changes since beta2


Project: http://git-wip-us.apache.org/repos/asf/any23/repo
Commit: http://git-wip-us.apache.org/repos/asf/any23/commit/972faab5
Tree: http://git-wip-us.apache.org/repos/asf/any23/tree/972faab5
Diff: http://git-wip-us.apache.org/repos/asf/any23/diff/972faab5

Branch: refs/heads/ANY23-141
Commit: 972faab5506e9f07e676a7cce1b744be0c3c86ab
Parents: 9cb8985
Author: Peter Ansell <p_...@yahoo.com>
Authored: Fri Apr 19 13:31:50 2013 +1000
Committer: Peter Ansell <p_...@yahoo.com>
Committed: Fri Apr 19 13:31:50 2013 +1000

----------------------------------------------------------------------
 .../apache/any23/rdf/Any23ValueFactoryWrapper.java |    5 ---
 .../org/apache/any23/io/nquads/NQuadsParser.java   |    7 +++--
 .../org/apache/any23/io/nquads/NQuadsWriter.java   |   20 ++++++++++++++-
 pom.xml                                            |    4 +-
 4 files changed, 25 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/any23/blob/972faab5/core/src/main/java/org/apache/any23/rdf/Any23ValueFactoryWrapper.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/any23/rdf/Any23ValueFactoryWrapper.java b/core/src/main/java/org/apache/any23/rdf/Any23ValueFactoryWrapper.java
index 4db8629..d601d68 100644
--- a/core/src/main/java/org/apache/any23/rdf/Any23ValueFactoryWrapper.java
+++ b/core/src/main/java/org/apache/any23/rdf/Any23ValueFactoryWrapper.java
@@ -149,11 +149,6 @@ public class Any23ValueFactoryWrapper implements ValueFactory {
         return wrappedFactory.createLiteral(date);
     }
 
-    @Override
-    public Literal createLiteral(Object object) {
-        return wrappedFactory.createLiteral(object);
-    }
-
     public Statement createStatement(Resource sub, URI pre, Value obj) {
         if (sub == null || pre == null || obj == null) {
             return null;

http://git-wip-us.apache.org/repos/asf/any23/blob/972faab5/nquads/src/main/java/org/apache/any23/io/nquads/NQuadsParser.java
----------------------------------------------------------------------
diff --git a/nquads/src/main/java/org/apache/any23/io/nquads/NQuadsParser.java b/nquads/src/main/java/org/apache/any23/io/nquads/NQuadsParser.java
index ba484ba..485d5cb 100644
--- a/nquads/src/main/java/org/apache/any23/io/nquads/NQuadsParser.java
+++ b/nquads/src/main/java/org/apache/any23/io/nquads/NQuadsParser.java
@@ -29,6 +29,7 @@ import org.openrdf.rio.RDFFormat;
 import org.openrdf.rio.RDFHandler;
 import org.openrdf.rio.RDFHandlerException;
 import org.openrdf.rio.RDFParseException;
+import org.openrdf.rio.helpers.NTriplesParserSettings;
 import org.openrdf.rio.helpers.RDFParserBase;
 import org.openrdf.rio.ntriples.NTriplesUtil;
 
@@ -170,7 +171,7 @@ public class NQuadsParser extends RDFParserBase {
         try {
             return (char) Integer.parseInt(unicodeCharStr, 16);
         } catch (NumberFormatException nfe) {
-            reportError("Error while converting unicode char '\\u" + unicodeCharStr + "'", row, col);
+            reportError("Error while converting unicode char '\\u" + unicodeCharStr + "'", row, col, NTriplesParserSettings.IGNORE_NTRIPLES_INVALID_LINES);
             throw new IllegalStateException();
         }
     }
@@ -280,7 +281,7 @@ public class NQuadsParser extends RDFParserBase {
                     throw new RDFParseException(e, row, col);
             } else { // Remove rest of broken line and report error.
                 consumeBrokenLine(br);
-                reportError(e.getMessage(), row, col);
+                reportError(e.getMessage(), row, col, NTriplesParserSettings.IGNORE_NTRIPLES_INVALID_LINES);
                 return true;
             }
         }
@@ -636,7 +637,7 @@ public class NQuadsParser extends RDFParserBase {
             try {
                 literalType = new URIImpl(lt.value);
             } catch (Exception e) {
-                reportError( String.format("Error while parsing literal type '%s'", lt.value), row, col );
+                reportError( String.format("Error while parsing literal type '%s'", lt.value), row, col , NTriplesParserSettings.IGNORE_NTRIPLES_INVALID_LINES);
             }
             return createLiteral(
                     validateAndNormalizeLiteral(value, literalType),

http://git-wip-us.apache.org/repos/asf/any23/blob/972faab5/nquads/src/main/java/org/apache/any23/io/nquads/NQuadsWriter.java
----------------------------------------------------------------------
diff --git a/nquads/src/main/java/org/apache/any23/io/nquads/NQuadsWriter.java b/nquads/src/main/java/org/apache/any23/io/nquads/NQuadsWriter.java
index 6f7abaf..6da59d4 100644
--- a/nquads/src/main/java/org/apache/any23/io/nquads/NQuadsWriter.java
+++ b/nquads/src/main/java/org/apache/any23/io/nquads/NQuadsWriter.java
@@ -26,14 +26,21 @@ import org.openrdf.model.Value;
 import org.openrdf.rio.RDFFormat;
 import org.openrdf.rio.RDFHandlerException;
 import org.openrdf.rio.RDFWriter;
+import org.openrdf.rio.RioSetting;
+import org.openrdf.rio.WriterConfig;
+import org.openrdf.rio.helpers.NTriplesParserSettings;
+import org.openrdf.rio.helpers.RDFWriterBase;
 import org.openrdf.rio.ntriples.NTriplesUtil;
 
 import java.io.IOException;
 import java.io.OutputStream;
 import java.io.OutputStreamWriter;
 import java.io.Writer;
+import java.util.Collection;
 import java.util.HashMap;
+import java.util.HashSet;
 import java.util.Map;
+import java.util.Set;
 
 /**
  * <i>N-Quads</i> implementation of an {@link org.openrdf.rio.RDFWriter}.
@@ -41,7 +48,7 @@ import java.util.Map;
  *
  * @author Michele Mostarda (mostarda@fbk.eu)
  */
-public class NQuadsWriter implements RDFWriter {
+public class NQuadsWriter extends RDFWriterBase implements RDFWriter {
 
     /**
      * The table maintaining namespaces.
@@ -58,6 +65,8 @@ public class NQuadsWriter implements RDFWriter {
      */
     private boolean started = false;
 
+    private WriterConfig writerConfig;
+
     public NQuadsWriter(OutputStream os) {
         this( new OutputStreamWriter(os) );
     }
@@ -270,4 +279,13 @@ public class NQuadsWriter implements RDFWriter {
         }
     }
 
+    @Override
+    public Collection<RioSetting<?>> getSupportedSettings() {
+        Set<RioSetting<?>> results = new HashSet<RioSetting<?>>(super.getSupportedSettings());
+        
+        results.add(NTriplesParserSettings.IGNORE_NTRIPLES_INVALID_LINES);
+        
+        return results;
+    }
+
 }

http://git-wip-us.apache.org/repos/asf/any23/blob/972faab5/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 68bad57..64d8add 100644
--- a/pom.xml
+++ b/pom.xml
@@ -226,8 +226,8 @@
     <maven.build.timestamp.format>yyyy-MM-dd HH:mm:ssZ</maven.build.timestamp.format>
     <implementation.build>${scmBranch}@r${buildNumber}</implementation.build>
     <implementation.build.tstamp>${implementation.build}; ${maven.build.timestamp}</implementation.build.tstamp>
-    <slf4j.logger.version>1.7.2</slf4j.logger.version>
-    <sesame.version>2.7.0-beta2-SNAPSHOT</sesame.version>
+    <slf4j.logger.version>1.7.5</slf4j.logger.version>
+    <sesame.version>2.7.0</sesame.version>
     <latest.stable.released>0.7.0-incubating</latest.stable.released>
 
     <!-- Maven Plugin Versions -->


[05/19] git commit: modify N3 mimetype to match current W3C team submission

Posted by an...@apache.org.
modify N3 mimetype to match current W3C team submission


Project: http://git-wip-us.apache.org/repos/asf/any23/repo
Commit: http://git-wip-us.apache.org/repos/asf/any23/commit/9cb89856
Tree: http://git-wip-us.apache.org/repos/asf/any23/tree/9cb89856
Diff: http://git-wip-us.apache.org/repos/asf/any23/diff/9cb89856

Branch: refs/heads/ANY23-141
Commit: 9cb8985691ce8a3e37ec8b780c4a9eb5465726d2
Parents: 9d2c180
Author: Peter Ansell <p_...@yahoo.com>
Authored: Mon Jan 21 09:54:16 2013 +1000
Committer: Peter Ansell <p_...@yahoo.com>
Committed: Fri Apr 19 13:21:45 2013 +1000

----------------------------------------------------------------------
 .../resources/org/apache/any23/mime/mimetypes.xml  |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/any23/blob/9cb89856/mime/src/main/resources/org/apache/any23/mime/mimetypes.xml
----------------------------------------------------------------------
diff --git a/mime/src/main/resources/org/apache/any23/mime/mimetypes.xml b/mime/src/main/resources/org/apache/any23/mime/mimetypes.xml
index 0ef6e0c..f2e8457 100644
--- a/mime/src/main/resources/org/apache/any23/mime/mimetypes.xml
+++ b/mime/src/main/resources/org/apache/any23/mime/mimetypes.xml
@@ -25,8 +25,8 @@
 	<!-- BEGIN: Any23 Semantic Web document mime types. -->
 
 	<!-- N3 -->
-	<mime-type type="text/rdf+n3">
-		<alias type="text/n3" />
+	<mime-type type="text/n3">
+		<alias type="text/rdf+n3" />
 		<alias type="application/n3" />
 		<glob pattern="*.n3" />
 		<magic priority="50">


[19/19] git commit: Switch off verification for now as otherwise DBPedia will be inaccessible

Posted by an...@apache.org.
Switch off verification for now as otherwise DBPedia will be
inaccessible

Project: http://git-wip-us.apache.org/repos/asf/any23/repo
Commit: http://git-wip-us.apache.org/repos/asf/any23/commit/ced48a39
Tree: http://git-wip-us.apache.org/repos/asf/any23/tree/ced48a39
Diff: http://git-wip-us.apache.org/repos/asf/any23/diff/ced48a39

Branch: refs/heads/ANY23-141
Commit: ced48a39f2a3f149541366958f2c3de93da21b25
Parents: d5cedee
Author: Peter Ansell <p_...@yahoo.com>
Authored: Fri Apr 19 14:07:25 2013 +1000
Committer: Peter Ansell <p_...@yahoo.com>
Committed: Fri Apr 19 14:07:25 2013 +1000

----------------------------------------------------------------------
 .../any23/extractor/rdf/BaseRDFExtractor.java      |   13 +++++++++++++
 1 files changed, 13 insertions(+), 0 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/any23/blob/ced48a39/core/src/main/java/org/apache/any23/extractor/rdf/BaseRDFExtractor.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/any23/extractor/rdf/BaseRDFExtractor.java b/core/src/main/java/org/apache/any23/extractor/rdf/BaseRDFExtractor.java
index d0797dd..c079841 100644
--- a/core/src/main/java/org/apache/any23/extractor/rdf/BaseRDFExtractor.java
+++ b/core/src/main/java/org/apache/any23/extractor/rdf/BaseRDFExtractor.java
@@ -26,10 +26,13 @@ import org.apache.any23.extractor.ExtractorDescription;
 import org.openrdf.rio.RDFHandlerException;
 import org.openrdf.rio.RDFParseException;
 import org.openrdf.rio.RDFParser;
+import org.openrdf.rio.RioSetting;
+import org.openrdf.rio.helpers.BasicParserSettings;
 import org.openrdf.rio.helpers.RDFParserBase;
 
 import java.io.IOException;
 import java.io.InputStream;
+import java.util.HashSet;
 
 /**
  * Base class for a generic <i>RDF</i>
@@ -90,6 +93,16 @@ public abstract class BaseRDFExtractor implements Extractor.ContentExtractor {
     ) throws IOException, ExtractionException {
         try {
             final RDFParser parser = getParser(extractionContext, extractionResult);
+            parser.getParserConfig().setNonFatalErrors(new HashSet<RioSetting<?>>());
+
+            // Disable verification to ensure that DBPedia is accessible, given it uses so many custom datatypes
+            parser.getParserConfig().set(BasicParserSettings.FAIL_ON_UNKNOWN_DATATYPES, false);                
+            parser.getParserConfig().addNonFatalError(BasicParserSettings.FAIL_ON_UNKNOWN_DATATYPES);
+            parser.getParserConfig().set(BasicParserSettings.VERIFY_DATATYPE_VALUES, false);                
+            parser.getParserConfig().addNonFatalError(BasicParserSettings.VERIFY_DATATYPE_VALUES);
+            parser.getParserConfig().set(BasicParserSettings.NORMALIZE_DATATYPE_VALUES, false);                
+            parser.getParserConfig().addNonFatalError(BasicParserSettings.NORMALIZE_DATATYPE_VALUES);
+            
             parser.parse(in, extractionContext.getDocumentURI().stringValue());
         } catch (RDFHandlerException ex) {
             throw new IllegalStateException("Unexpected exception.", ex);


[15/19] git commit: convert NQuadsParser to override sesame-rio-nquads parser with UTF-8 support for InputStreamReader constructor

Posted by an...@apache.org.
convert NQuadsParser to override sesame-rio-nquads parser with UTF-8 support for InputStreamReader constructor


Project: http://git-wip-us.apache.org/repos/asf/any23/repo
Commit: http://git-wip-us.apache.org/repos/asf/any23/commit/34cee606
Tree: http://git-wip-us.apache.org/repos/asf/any23/tree/34cee606
Diff: http://git-wip-us.apache.org/repos/asf/any23/diff/34cee606

Branch: refs/heads/ANY23-141
Commit: 34cee606fee6f2bcc0b319976af04c6369ca956b
Parents: 384944f
Author: Peter Ansell <p_...@yahoo.com>
Authored: Wed Oct 24 14:16:34 2012 +1000
Committer: Peter Ansell <p_...@yahoo.com>
Committed: Fri Apr 19 13:35:45 2013 +1000

----------------------------------------------------------------------
 .../org/apache/any23/io/nquads/NQuadsParser.java   |  694 +--------------
 1 files changed, 1 insertions(+), 693 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/any23/blob/34cee606/nquads/src/main/java/org/apache/any23/io/nquads/NQuadsParser.java
----------------------------------------------------------------------
diff --git a/nquads/src/main/java/org/apache/any23/io/nquads/NQuadsParser.java b/nquads/src/main/java/org/apache/any23/io/nquads/NQuadsParser.java
index 7ca4fe9..3f5b5d2 100644
--- a/nquads/src/main/java/org/apache/any23/io/nquads/NQuadsParser.java
+++ b/nquads/src/main/java/org/apache/any23/io/nquads/NQuadsParser.java
@@ -17,27 +17,12 @@
 
 package org.apache.any23.io.nquads;
 
-import org.openrdf.model.BNode;
-import org.openrdf.model.Resource;
-import org.openrdf.model.Statement;
-import org.openrdf.model.URI;
-import org.openrdf.model.Value;
-import org.openrdf.model.datatypes.XMLDatatypeUtil;
-import org.openrdf.model.impl.URIImpl;
-import org.openrdf.rio.ParseLocationListener;
-import org.openrdf.rio.RDFFormat;
-import org.openrdf.rio.RDFHandler;
 import org.openrdf.rio.RDFHandlerException;
 import org.openrdf.rio.RDFParseException;
-import org.openrdf.rio.helpers.NTriplesParserSettings;
-import org.openrdf.rio.helpers.RDFParserBase;
-import org.openrdf.rio.ntriples.NTriplesUtil;
 
-import java.io.BufferedReader;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.InputStreamReader;
-import java.io.Reader;
 import java.nio.charset.Charset;
 
 /**
@@ -48,61 +33,7 @@ import java.nio.charset.Charset;
  * @author Michele Mostarda (mostarda@fbk.eu)
  * @see org.openrdf.rio.RDFParser
  */
-public class NQuadsParser extends RDFParserBase {
-
-    /**
-     * Location listener acquired when parsing started.
-     */
-    private ParseLocationListener locationListener;
-
-    /**
-     * RDF handler acquired when parsing started.
-     */
-    private RDFHandler rdfHandler;
-
-    /**
-     * Current row, col and marker trackers.
-     */
-    private int row, col, mark;
-
-    public NQuadsParser() {}
-
-    public RDFFormat getRDFFormat() {
-        return RDFFormat.NQUADS;
-    }
-
-    public void parse(Reader reader, String baseURI)
-    throws IOException, RDFParseException, RDFHandlerException {
-        if(reader == null) {
-            throw new NullPointerException("reader cannot be null.");
-        }
-        if(baseURI == null) {
-            throw new NullPointerException("baseURI cannot be null.");
-        }
-        
-        try {
-            row = col = 1;
-
-            locationListener = getParseLocationListener();
-            rdfHandler = getRDFHandler();
-
-            setBaseURI(baseURI);
-
-            final BufferedReader br = new BufferedReader( reader );
-            if( rdfHandler != null ) {
-                rdfHandler.startRDF();
-            }
-            while( parseLine(br) ) {
-                nextRow();
-            }
-        } finally {
-            if(rdfHandler != null) {
-                rdfHandler.endRDF();
-            }
-            clear();
-            clearBNodeIDMap();
-        }
-    }
+public class NQuadsParser extends org.openrdf.rio.nquads.NQuadsParser {
 
     public synchronized void parse(InputStream is, String baseURI)
     throws IOException, RDFParseException, RDFHandlerException {
@@ -117,627 +48,4 @@ public class NQuadsParser extends RDFParserBase {
         this.parse(new InputStreamReader(is, Charset.forName("UTF-8")), baseURI);
     }
 
-    /**
-     * Moves to the next row, resets the column.
-     */
-    private void nextRow() {
-        col = 1;
-        row++;
-        if(locationListener != null) {
-            locationListener.parseLocationUpdate(row, col);
-        }
-    }
-
-    /**
-     * Moves to the next column.
-     */
-    private void nextCol() {
-        col++;
-        if(locationListener != null) {
-            locationListener.parseLocationUpdate(row, col);
-        }
-    }
-
-    /**
-     * Reads the next char.
-     *
-     * @param br
-     * @return the next read char.
-     * @throws IOException
-     */
-    private char readChar(BufferedReader br) throws IOException {
-        final int c = br.read();
-        if(c == -1) {
-            throw new EOS();
-        }
-        nextCol();
-        return (char) c;
-    }
-
-    /**
-     * Reads an unicode char with pattern <code>\\uABCD</code>.
-     *
-     * @param br input reader.
-     * @return read char.
-     * @throws IOException
-     * @throws RDFParseException
-     */
-    private char readUnicode(BufferedReader br) throws IOException, RDFParseException {
-        final char[] unicodeSequence = new char[4];
-        for(int i = 0; i < unicodeSequence.length; i++) {
-            unicodeSequence[i] = readChar(br);
-        }
-        final String unicodeCharStr = new String(unicodeSequence);
-        try {
-            return (char) Integer.parseInt(unicodeCharStr, 16);
-        } catch (NumberFormatException nfe) {
-            reportError("Error while converting unicode char '\\u" + unicodeCharStr + "'", row, col, NTriplesParserSettings.IGNORE_NTRIPLES_INVALID_LINES);
-            throw new IllegalStateException();
-        }
-    }
-
-    /**
-     * Marks the buffered input stream with the current location.
-     *
-     * @param br
-     */
-    private void mark(BufferedReader br) throws IOException {
-        mark = col;
-        br.mark(5);
-    }
-
-    /**
-     * Resets the buffered input stream and update the new location.
-     *
-     * @param br
-     * @throws IOException
-     */
-    private void reset(BufferedReader br) throws IOException {
-        col = mark;
-        br.reset();
-        if(locationListener != null) {
-            locationListener.parseLocationUpdate(row, col);
-        }
-    }
-
-    /**
-     * Asserts to read a specific char.
-     *
-     * @param br
-     * @param c
-     * @throws IOException
-     */
-    private void assertChar(BufferedReader br, char c) throws IOException, RDFParseException {
-        final char read = readChar(br);
-        if(read != c) {
-            throw new RDFParseException(
-                    String.format("Unexpected char '%s', expected '%s'", read, c),
-                    row, col
-            );
-        }
-    }
-
-    /**
-     * Consumes the reader until the next carriage return.
-     *
-     * @param br
-     * @throws IOException
-     */
-    private void consumeBrokenLine(BufferedReader br) throws IOException {
-        char c;
-        while (true) {
-            mark(br);
-            c = readChar(br);
-            if (c == '\n') {
-                return;
-            }
-        }
-    }
-
-    /**
-     * Parsers an <i>NQuads</i> line.
-     *
-     * @param br input stream reader containing NQuads.
-     * @return <code>false</code> if the parsing completed, <code>true</code> otherwise.
-     * @throws IOException
-     * @throws RDFParseException
-     * @throws RDFHandlerException
-     */
-    private boolean parseLine(BufferedReader br)
-    throws IOException, RDFParseException, RDFHandlerException {
-
-        if(!consumeSpacesAndNotEOS(br)) {
-            return false;
-        }
-
-        // Consumes empty line or line comment.
-        try {
-            if(consumeEmptyLine(br)) return true;
-            if( consumeComment(br) ) return true;
-        } catch (EOS eos) {
-            return false;
-        }
-
-        final Resource sub;
-        final URI      pred;
-        final Value    obj;
-        final URI      context;
-        try {
-            sub = parseSubject(br);
-            consumeSpaces(br);
-            pred = parsePredicate(br);
-            consumeSpaces(br);
-            obj = parseObject(br);
-            consumeSpaces(br);
-            context = parseContextAndOrDot(br);
-        } catch (EOS eos) {
-            reportFatalError("Unexpected end of stream.", row, col);
-            throw new IllegalStateException();
-        } catch (Exception e) { // FIXME: We should not be catching IOException here as that is used to indicate a failure of the stream/writer
-            if(super.stopAtFirstError()) {
-                if(e instanceof RDFParseException)
-                    throw (RDFParseException) e;
-                else
-                    throw new RDFParseException(e, row, col);
-            } else { // Remove rest of broken line and report error.
-                consumeBrokenLine(br);
-                reportError(e.getMessage(), row, col, NTriplesParserSettings.IGNORE_NTRIPLES_INVALID_LINES);
-                return true;
-            }
-        }
-
-        assert sub  != null : "Subject cannot be null.";
-        assert pred != null : "Predicate cannot be null.";
-        assert obj  != null : "Object cannot be null.";
-        notifyStatement(sub, pred, obj, context);
-
-        if(!consumeSpacesAndNotEOS(br)) {
-            return false;
-        }
-        return readChar(br) == '\n';
-    }
-
-    /**
-     * Consumes the line if empty (contains just a carriage return).
-     *
-     * @param br input NQuads stream.
-     * @return <code>true</code> if the line is empty.
-     * @throws IOException if an error occurs while consuming stream.
-     */
-    private boolean consumeEmptyLine(BufferedReader br) throws IOException {
-        char c;
-        mark(br);
-        c = readChar(br);
-        if (c == '\n') {
-            return true;
-        } else {
-            reset(br);
-            return false;
-        }
-    }
-
-    /**
-     * Consumes all subsequent spaces and returns true, if End Of Stream is reached instead returns false.
-     * @param br input NQuads stream reader.
-     * @return <code>true</code> if there are other chars to be consumed.
-     * @throws IOException if an error occurs while consuming stream.
-     */
-    private boolean consumeSpacesAndNotEOS(BufferedReader br) throws IOException {
-        try {
-            consumeSpaces(br);
-            return true;
-        } catch (EOS eos) {
-            return false;
-        }
-    }
-
-    /**
-     * Consumes a comment if any.
-     *
-     * @param br input NQuads stream reader.
-     * @return <code>true</code> if comment has been consumed, false otherwise.
-     * @throws IOException
-     */
-    private boolean consumeComment(BufferedReader br) throws IOException {
-        char c;
-        mark(br);
-        c = readChar(br);
-        if (c == '#') {
-            mark(br);
-            while (readChar(br) != '\n');
-            mark(br);
-            return true;
-        } else {
-            reset(br);
-            return false;
-        }
-    }
-
-    /**
-     * Notifies the parsed statement to the {@link RDFHandler}.
-     *
-     * @param sub
-     * @param pred
-     * @param obj
-     * @param context
-     * @throws RDFParseException
-     * @throws RDFHandlerException
-     */
-    private void notifyStatement(Resource sub, URI pred, Value obj, URI context)
-    throws RDFParseException, RDFHandlerException {
-        Statement statement = super.createStatement(sub, pred, obj, context);
-        if (rdfHandler != null) {
-            try {
-                rdfHandler.handleStatement(statement);
-            } catch (RDFHandlerException rdfhe) {
-                reportFatalError(rdfhe);
-                throw rdfhe;
-            }
-        }
-    }
-
-    /**
-     * Consumes spaces until a non space char is detected.
-     *
-     * @param br input stream reader from which consume spaces.
-     * @throws IOException
-     */
-    private void consumeSpaces(BufferedReader br) throws IOException {
-        char c;
-        while(true) {
-            mark(br);
-            c = readChar(br);
-            if(c == ' ' || c == '\r' || c == '\f' || c == '\t') {
-                mark(br);
-            } else {
-                break;
-            }
-        }
-        reset(br);
-    }
-
-    /**
-     * Consumes the dot at the end of NQuads line.
-     *
-     * @param br
-     * @throws IOException
-     */
-    private void parseDot(BufferedReader br) throws IOException, RDFParseException {
-        assertChar(br, '.');
-    }
-
-    /**
-     * Parses a URI enclosed within &lt; and &gt; brackets.
-     * @param br
-     * @return the parsed URI.
-     * @throws IOException
-     * @throws RDFParseException
-     */
-    private URI parseURI(BufferedReader br) throws IOException, RDFParseException {
-        assertChar(br, '<');
-
-        StringBuilder sb = new StringBuilder();
-        char c;
-        while(true) {
-            c = readChar(br);
-            if(c != '>') {
-                sb.append(c);
-            } else {
-                break;
-            }
-        }
-        mark(br);
-
-        try {
-            // TODO - LOW: used to unescape \\uXXXX unicode chars. Unify with #printEscaped().
-            String uriStr = NTriplesUtil.unescapeString( sb.toString() );
-            URI uri;
-            if(uriStr.charAt(0) == '#') {
-                uri = super.resolveURI(uriStr);
-            } else {
-                uri = super.createURI(uriStr);
-            }
-            return uri;
-        } catch (RDFParseException rdfpe) {
-            reportFatalError(rdfpe, row, col);
-            throw rdfpe;
-        }
-    }
-
-    /**
-     * Parses a BNode.
-     *
-     * @param br the buffered input stream.
-     * @return the generated bnode.
-     * @throws IOException
-     * @throws RDFParseException
-     */
-    private BNode parseBNode(BufferedReader br) throws IOException, RDFParseException {
-        assertChar(br, '_');
-        assertChar(br, ':');
-
-        char c;
-        StringBuilder sb = new StringBuilder();
-        while(true) {
-            c = readChar(br);
-            if(c != ' ' && c != '<') {
-                sb.append(c);
-                mark(br);
-            } else {
-                break;
-            }
-        }
-        reset(br);
-
-        try {
-            return createBNode( sb.toString() );
-        } catch (RDFParseException rdfpe) {
-            reportFatalError(rdfpe, row, col);
-            throw rdfpe;
-        }
-    }
-
-    /**
-     * Parses a literal attribute that can be either the language or the data type.
-     *
-     * @param br
-     * @return the literal attribute.
-     * @throws IOException
-     */
-    private LiteralAttribute parseLiteralAttribute(BufferedReader br) throws IOException, RDFParseException {
-        char c = readChar(br);
-        if(c != '^' && c != '@') {
-            reset(br);
-            return null;
-        }
-
-        boolean isLang = true;
-        if(c == '^') {
-            isLang = false;
-            assertChar(br, '^');
-        }
-
-        final String attribute;
-        if (isLang) { // Read until space or context begin.
-            final StringBuilder sb = new StringBuilder();
-            while (true) {
-                c = readChar(br);
-                if (c != ' ' && c != '<') {
-                    mark(br);
-                    sb.append(c);
-                } else {
-                    reset(br);
-                    break;
-                }
-            }
-            attribute = sb.toString();
-        }  else {
-            attribute = parseURI(br).stringValue();
-        }
-
-        return new LiteralAttribute(isLang, attribute);
-    }
-
-    /**
-     * Validates and normalize the value of a literal on the basis of the datat ype handling policy and
-     * the associated data type.
-     *
-     * @param value
-     * @param datatype
-     * @return the normalized data type. It depends on the data type handling policy and the specified data type.
-     * @throws RDFParseException
-     */
-    private String validateAndNormalizeLiteral(String value, URI datatype) throws RDFParseException {
-        DatatypeHandling dh = datatypeHandling();
-        if(dh.equals( DatatypeHandling.IGNORE )) {
-            return value;
-        }
-
-        if ( dh.equals(DatatypeHandling.VERIFY) ) {
-            if( ! XMLDatatypeUtil.isBuiltInDatatype(datatype)){
-                return value;
-            }
-            if( ! XMLDatatypeUtil.isValidValue(value, datatype) ) {
-                throw new RDFParseException(
-                        String.format("Illegal literal value '%s' with datatype %s", value, datatype.stringValue() ),
-                        row, col
-                );
-            }
-            return value;
-        } else if( dh.equals(DatatypeHandling.NORMALIZE) ) {
-            return XMLDatatypeUtil.normalize(value, datatype);
-        } else {
-            throw new IllegalArgumentException( String.format("Unsupported datatype handling: %s", dh) );
-        }
-    }
-
-    /**
-     * Prints the escaped version of the given char c.
-     *
-     * @param c escaped char.
-     * @param sb output string builder.
-     */
-    private void printEscaped(char c, StringBuilder sb) {
-        if(c == 'b') {
-            sb.append('\b');
-            return;
-        }
-        if(c == 'f') {
-            sb.append('\f');
-            return;
-        }
-        if(c == 'n') {
-            sb.append('\n');
-            return;
-        }
-        if(c == 'r') {
-            sb.append('\r');
-            return;
-        }
-        if(c == 't') {
-            sb.append('\t');
-            return;
-        }
-    }
-
-    /**
-     * Parses a literal.
-     *
-     * @param br
-     * @return the parsed literal.
-     * @throws IOException
-     * @throws RDFParseException
-     */
-    private Value parseLiteral(BufferedReader br) throws IOException, RDFParseException {
-        assertChar(br, '"');
-
-        char c;
-        boolean escaped = false;
-        StringBuilder sb = new StringBuilder();
-        while(true) {
-            c = readChar(br);
-            if( c == '\\' ) {
-                if(escaped) {
-                    escaped = false;
-                    sb.append(c);
-                } else {
-                    escaped = true;
-                }
-                continue;
-            } else if(c == '"' && !escaped) {
-                break;
-            }
-            if(escaped) {
-                if(c == 'u') {
-                    char unicodeChar = readUnicode(br);
-                    sb.append(unicodeChar);
-                } else {
-                    printEscaped(c, sb);
-                }
-                escaped = false;
-            } else {
-                sb.append(c);
-            }
-        }
-        mark(br);
-
-        LiteralAttribute lt = parseLiteralAttribute(br);
-
-        final String value = sb.toString();
-        if(lt == null) {
-            return createLiteral(value, null, null);
-        }else if(lt.isLang) {
-            return createLiteral(
-                    value,
-                    lt.value,
-                    null
-            );
-        } else {
-            URI literalType = null;
-            try {
-                literalType = new URIImpl(lt.value);
-            } catch (Exception e) {
-                reportError( String.format("Error while parsing literal type '%s'", lt.value), row, col , NTriplesParserSettings.IGNORE_NTRIPLES_INVALID_LINES);
-            }
-            return createLiteral(
-                    validateAndNormalizeLiteral(value, literalType),
-                    null,
-                    literalType
-            );
-        }
-    }
-
-    /**
-     * Parses the subject sequence.
-     *
-     * @param br
-     * @return the corresponding URI object.
-     * @throws IOException
-     * @throws RDFParseException
-     */
-    private Resource parseSubject(BufferedReader br) throws IOException, RDFParseException {
-        mark(br);
-        char c = readChar(br);
-        reset(br);
-        if( c == '<' ) {
-            return parseURI(br);
-        } else {
-            return parseBNode(br);
-        }
-    }
-
-    /**
-     * Parses the predicate URI.
-     *
-     * @param br
-     * @return the corresponding URI object.
-     * @throws IOException
-     * @throws RDFParseException
-     */
-    private URI parsePredicate(BufferedReader br) throws IOException, RDFParseException {
-        return parseURI(br);
-    }
-
-    /**
-     * Parses the the object sequence.
-     *
-     * @param br
-     * @return the corresponding URI object.
-     * @throws IOException
-     * @throws RDFParseException
-     */
-    private Value parseObject(BufferedReader br) throws IOException, RDFParseException {
-        mark(br);
-        char c = readChar(br);
-        reset(br);
-        if( c == '<' ) {
-            return parseURI(br);
-        } else if( c == '_') {
-            return parseBNode(br);
-        } else {
-            return parseLiteral(br);
-        }
-    }
-
-    /**
-     * Represents a literal with its attribute value that can be either a language or a data type.
-     */
-    class LiteralAttribute {
-        final boolean isLang;
-        final String value;
-
-        LiteralAttribute(boolean lang, String value) {
-            isLang = lang;
-            this.value = value;
-        }
-    }
-
-    /**
-     * Parses the context if any.
-     *
-     * @param br
-     * @return the context URI or null if not found.
-     * @throws IOException
-     * @throws RDFParseException
-     */
-    private URI parseContextAndOrDot(BufferedReader br) throws IOException, RDFParseException {
-        mark(br);
-        final char c = readChar(br);
-        reset(br);
-        if(c == '<') {
-            final URI context = parseURI(br);
-            consumeSpaces(br);
-            parseDot(br);
-            return context;
-        } else {
-            parseDot(br);
-            return null;
-        }
-    }
-
-    /**
-     * Defines the End Of Stream exception.
-     */
-    class EOS extends IOException {}
-
 }


[03/19] git commit: add new ValueFactory methods to Any23ValueFactoryWrapper

Posted by an...@apache.org.
add new ValueFactory methods to Any23ValueFactoryWrapper


Project: http://git-wip-us.apache.org/repos/asf/any23/repo
Commit: http://git-wip-us.apache.org/repos/asf/any23/commit/9d2c1803
Tree: http://git-wip-us.apache.org/repos/asf/any23/tree/9d2c1803
Diff: http://git-wip-us.apache.org/repos/asf/any23/diff/9d2c1803

Branch: refs/heads/ANY23-141
Commit: 9d2c18033cf0306b86a4e886d09b0ff163ad5c5c
Parents: 454d0ae
Author: Peter Ansell <p_...@yahoo.com>
Authored: Thu Jan 17 12:19:18 2013 +1000
Committer: Peter Ansell <p_...@yahoo.com>
Committed: Fri Apr 19 13:21:45 2013 +1000

----------------------------------------------------------------------
 .../apache/any23/rdf/Any23ValueFactoryWrapper.java |   13 +++++++++++++
 1 files changed, 13 insertions(+), 0 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/any23/blob/9d2c1803/core/src/main/java/org/apache/any23/rdf/Any23ValueFactoryWrapper.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/any23/rdf/Any23ValueFactoryWrapper.java b/core/src/main/java/org/apache/any23/rdf/Any23ValueFactoryWrapper.java
index bbde7b0..4db8629 100644
--- a/core/src/main/java/org/apache/any23/rdf/Any23ValueFactoryWrapper.java
+++ b/core/src/main/java/org/apache/any23/rdf/Any23ValueFactoryWrapper.java
@@ -17,6 +17,8 @@
 
 package org.apache.any23.rdf;
 
+import java.util.Date;
+
 import org.apache.any23.extractor.IssueReport;
 import org.openrdf.model.BNode;
 import org.openrdf.model.Literal;
@@ -25,6 +27,7 @@ import org.openrdf.model.Statement;
 import org.openrdf.model.URI;
 import org.openrdf.model.Value;
 import org.openrdf.model.ValueFactory;
+import org.openrdf.model.impl.ValueFactoryBase;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -141,6 +144,16 @@ public class Any23ValueFactoryWrapper implements ValueFactory {
         return wrappedFactory.createLiteral(pref, value);
     }
 
+    @Override
+    public Literal createLiteral(Date date) {
+        return wrappedFactory.createLiteral(date);
+    }
+
+    @Override
+    public Literal createLiteral(Object object) {
+        return wrappedFactory.createLiteral(object);
+    }
+
     public Statement createStatement(Resource sub, URI pre, Value obj) {
         if (sub == null || pre == null || obj == null) {
             return null;


[11/19] git commit: replace NQuadsWriter as a thin wrapper over sesame-rio-nquads writer

Posted by an...@apache.org.
replace NQuadsWriter as a thin wrapper over sesame-rio-nquads writer


Project: http://git-wip-us.apache.org/repos/asf/any23/repo
Commit: http://git-wip-us.apache.org/repos/asf/any23/commit/bc291c02
Tree: http://git-wip-us.apache.org/repos/asf/any23/tree/bc291c02
Diff: http://git-wip-us.apache.org/repos/asf/any23/diff/bc291c02

Branch: refs/heads/ANY23-141
Commit: bc291c02b09954bb8e154ce8dc1543e5bd7cb8b3
Parents: 0227cc0
Author: Peter Ansell <p_...@yahoo.com>
Authored: Wed Oct 24 13:53:14 2012 +1000
Committer: Peter Ansell <p_...@yahoo.com>
Committed: Fri Apr 19 13:34:53 2013 +1000

----------------------------------------------------------------------
 .../org/apache/any23/io/nquads/NQuadsWriter.java   |  263 +--------------
 1 files changed, 6 insertions(+), 257 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/any23/blob/bc291c02/nquads/src/main/java/org/apache/any23/io/nquads/NQuadsWriter.java
----------------------------------------------------------------------
diff --git a/nquads/src/main/java/org/apache/any23/io/nquads/NQuadsWriter.java b/nquads/src/main/java/org/apache/any23/io/nquads/NQuadsWriter.java
index 6da59d4..6adb3a4 100644
--- a/nquads/src/main/java/org/apache/any23/io/nquads/NQuadsWriter.java
+++ b/nquads/src/main/java/org/apache/any23/io/nquads/NQuadsWriter.java
@@ -17,275 +17,24 @@
 
 package org.apache.any23.io.nquads;
 
-import org.openrdf.model.BNode;
-import org.openrdf.model.Literal;
-import org.openrdf.model.Resource;
-import org.openrdf.model.Statement;
-import org.openrdf.model.URI;
-import org.openrdf.model.Value;
-import org.openrdf.rio.RDFFormat;
-import org.openrdf.rio.RDFHandlerException;
-import org.openrdf.rio.RDFWriter;
-import org.openrdf.rio.RioSetting;
-import org.openrdf.rio.WriterConfig;
-import org.openrdf.rio.helpers.NTriplesParserSettings;
-import org.openrdf.rio.helpers.RDFWriterBase;
-import org.openrdf.rio.ntriples.NTriplesUtil;
-
-import java.io.IOException;
 import java.io.OutputStream;
 import java.io.OutputStreamWriter;
 import java.io.Writer;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
+import java.nio.charset.Charset;
 
 /**
- * <i>N-Quads</i> implementation of an {@link org.openrdf.rio.RDFWriter}.
+ * A UTF-8 aware <i>N-Quads</i> implementation of an {@link org.openrdf.rio.RDFWriter}.
  * See the format specification <a href="http://sw.deri.org/2008/07/n-quads/">here</a>.
  *
  * @author Michele Mostarda (mostarda@fbk.eu)
  */
-public class NQuadsWriter extends RDFWriterBase implements RDFWriter {
-
-    /**
-     * The table maintaining namespaces.
-     */
-    private Map<String,String> namespaceTable;
-
-    /**
-     * The output writer.
-     */
-    private Writer writer;
-
-    /**
-     * Maintain the started status.
-     */
-    private boolean started = false;
-
-    private WriterConfig writerConfig;
+public class NQuadsWriter extends org.openrdf.rio.nquads.NQuadsWriter {
 
     public NQuadsWriter(OutputStream os) {
-        this( new OutputStreamWriter(os) );
-    }
-
-    public NQuadsWriter(Writer w) {
-        if(w == null) {
-            throw new NullPointerException("the writer cannot be null.");
-        }
-        writer = w;
-    }
-
-    public RDFFormat getRDFFormat() {
-        return RDFFormat.NQUADS;
-    }
-
-    public void startRDF() throws RDFHandlerException {
-        if(started) {
-            throw new IllegalStateException("Parsing already started.");
-        }
-        started = true;
-    }
-
-    public void endRDF() throws RDFHandlerException {
-        if(!started) {
-            throw new IllegalStateException("Parsing never started.");
-        }
-
-        try {
-            writer.flush();
-        } catch (IOException ioe) {
-            throw new RDFHandlerException("Error while flushing writer.", ioe);
-        } finally {
-            started = false;
-            if(namespaceTable != null) {
-                namespaceTable.clear();
-            }
-        }
-    }
-
-    public void handleNamespace(String ns, String uri) throws RDFHandlerException {
-        if(!started) {
-            throw new IllegalStateException("Parsing never started.");
-        }
-
-        if(namespaceTable == null) {
-            namespaceTable = new HashMap<String, String>();
-        }
-        namespaceTable.put(ns, NTriplesUtil.escapeString(uri) );
-    }
-
-    public void handleStatement(Statement statement) throws RDFHandlerException {
-        if(!started) {
-            throw new IllegalStateException("Cannot handle statement without start parsing first.");
-        }
-
-        try {
-            printSubject(statement);
-            printSpace();
-            printPredicate(statement);
-            printSpace();
-            printObject(statement);
-            printSpace();
-            printGraph(statement);
-            printCloseStatement();
-        } catch (IOException ioe) {
-            throw new RDFHandlerException("An error occurred while printing statement.", ioe);
-        }
-    }
-
-    public void handleComment(String comment) throws RDFHandlerException {
-        try {
-            writer.write("# ");
-            writer.write(comment);
-            writer.append('\n');
-        } catch (IOException ioe) {
-            throw new RDFHandlerException("An error occurred while printing comment.", ioe);
-        }
+        super( new OutputStreamWriter(os, Charset.forName("UTF-8")) );
     }
 
-    /**
-     * Prints out a space.
-     *
-     * @throws IOException
-     */
-    private void printSpace() throws IOException {
-        writer.append(' ');
+    public NQuadsWriter(Writer writer) {
+        super( writer );
     }
-
-    /**
-     * Prints out the close statement.
-     * 
-     * @throws IOException
-     */
-    private void printCloseStatement() throws IOException {
-        writer.append(" .\n");
-    }
-
-    /**
-     * Prints out a URI string, replacing the existing prefix if found.
-     * 
-     * @param uri the URI to print.
-     * @throws IOException
-     */
-    private void printURI(URI uri) throws IOException {
-        final String uriString = uri.stringValue();
-        int splitIdx = 0;
-        String namespace = null;
-        if(namespaceTable != null) {
-            splitIdx = uriString.indexOf(':');
-            if (splitIdx > 0) {
-                String prefix = uriString.substring(0, splitIdx);
-                namespace = namespaceTable.get(prefix);
-            }
-        }
-
-        if (namespace != null) {
-            writer.append('<');
-            writer.append(namespace);
-            writer.append( NTriplesUtil.escapeString(uriString.substring(splitIdx)) );
-            writer.append('>');
-        } else {
-            writer.append('<');
-            writer.append( NTriplesUtil.escapeString(uriString) );
-            writer.append('>');
-        }
-    }
-
-    /**
-     * Prints out the bnode.
-     *
-     * @param b bnode value.
-     * @throws IOException
-     */
-    private void printBNode(BNode b) throws IOException {
-        writer.append( NTriplesUtil.toNTriplesString(b) );
-    }
-
-    /**
-     * Prints out the resource.
-     *
-     * @param r resource value.
-     * @throws java.io.IOException
-     */
-    private void printResource(Resource r) throws IOException {
-        if(r instanceof BNode) {
-            printBNode((BNode) r);
-        } else if(r instanceof URI) {
-            printURI((URI) r);
-        } else {
-            throw new IllegalStateException();
-        }
-    }
-
-    /**
-     * Prints out a literal value.
-     *
-     * @param l literal value.
-     * @throws java.io.IOException
-     */
-    private void printLiteral(Literal l) throws IOException {
-        writer.append( NTriplesUtil.toNTriplesString(l) );
-    }
-
-    /**
-     * Prints out the subject.
-     * 
-     * @param s
-     * @throws IOException
-     */
-    private void printSubject(Statement s) throws IOException {
-        printResource( s.getSubject() );
-    }
-
-    /**
-     * Prints out the predicate.
-     *
-     * @param s
-     * @throws IOException
-     */
-    private void printPredicate(Statement s) throws IOException {
-        printURI( s.getPredicate() );
-    }
-
-    /**
-     * Prints out the object, handling all the logic to manage
-     * the literal data type / language attribute.
-     *
-     * @param s
-     * @throws IOException
-     */
-    private void printObject(Statement s) throws IOException {
-        Value v = s.getObject();
-        if(v instanceof Resource) {
-            printResource((Resource) v);
-            return;
-        }
-        printLiteral( (Literal) v );
-    }
-
-    /**
-     * Prints out the graph.
-     *
-     * @param s
-     * @throws IOException
-     */
-    private void printGraph(Statement s) throws IOException {
-        Resource graph = s.getContext();
-        if(graph != null) {
-            printResource( s.getContext() );
-        }
-    }
-
-    @Override
-    public Collection<RioSetting<?>> getSupportedSettings() {
-        Set<RioSetting<?>> results = new HashSet<RioSetting<?>>(super.getSupportedSettings());
-        
-        results.add(NTriplesParserSettings.IGNORE_NTRIPLES_INVALID_LINES);
-        
-        return results;
-    }
-
 }


[14/19] git commit: fix use of relative URLs in test1.nq that is designed to only test cases from the NQuads grammar

Posted by an...@apache.org.
fix use of relative URLs in test1.nq that is designed to only test cases from the NQuads grammar


Project: http://git-wip-us.apache.org/repos/asf/any23/repo
Commit: http://git-wip-us.apache.org/repos/asf/any23/commit/384944fd
Tree: http://git-wip-us.apache.org/repos/asf/any23/tree/384944fd
Diff: http://git-wip-us.apache.org/repos/asf/any23/diff/384944fd

Branch: refs/heads/ANY23-141
Commit: 384944fd953ad211d70ff569730f1245e6534deb
Parents: 0c9f476
Author: Peter Ansell <p_...@yahoo.com>
Authored: Wed Oct 24 14:15:52 2012 +1000
Committer: Peter Ansell <p_...@yahoo.com>
Committed: Fri Apr 19 13:34:55 2013 +1000

----------------------------------------------------------------------
 .../src/test/resources/application/nquads/test1.nq |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/any23/blob/384944fd/test-resources/src/test/resources/application/nquads/test1.nq
----------------------------------------------------------------------
diff --git a/test-resources/src/test/resources/application/nquads/test1.nq b/test-resources/src/test/resources/application/nquads/test1.nq
index bcc6108..df6263a 100644
--- a/test-resources/src/test/resources/application/nquads/test1.nq
+++ b/test-resources/src/test/resources/application/nquads/test1.nq
@@ -4,5 +4,5 @@ _:bnode2 <http://xmlns.com/foaf/0.1/Friend> _:bnode3 <http://example.org/alice/f
 
 
 _:bnode3 <http://xmlns.com/foaf/0.1/Friend> "This literal is \"really\" useful"@it <http://example.org/alice/foaf4.rdf> .
-_:bnode1 <#like> "12345"^^<http://www.w3.org/2001/XMLSchema#integer> <http://example.org/alice/foaf5.rdf> .
-_:bnode4 <#type> "triple"^^<http://www.w3.org/2001/XMLSchema#String> .
\ No newline at end of file
+_:bnode1 <http://example.org/#like> "12345"^^<http://www.w3.org/2001/XMLSchema#integer> <http://example.org/alice/foaf5.rdf> .
+_:bnode4 <http://example.org/#type> "triple"^^<http://www.w3.org/2001/XMLSchema#String> .
\ No newline at end of file


[18/19] git commit: migrate NQuadsParserTest to make it use strict datatype handling

Posted by an...@apache.org.
migrate NQuadsParserTest to make it use strict datatype handling

apparently previously a test with a non-XSD datatype that should have
been failing was not failing

if non-XSD datatypes need to be supported now, when datatype
validation/verification is enabled, they need to have custom
org.openrdf.rio.DatatypeHandler implementations

Project: http://git-wip-us.apache.org/repos/asf/any23/repo
Commit: http://git-wip-us.apache.org/repos/asf/any23/commit/d5cedee7
Tree: http://git-wip-us.apache.org/repos/asf/any23/tree/d5cedee7
Diff: http://git-wip-us.apache.org/repos/asf/any23/diff/d5cedee7

Branch: refs/heads/ANY23-141
Commit: d5cedee775e1cab51372c7a343735fe3cea0a85c
Parents: 86846dc
Author: Peter Ansell <p_...@yahoo.com>
Authored: Fri Apr 19 13:46:04 2013 +1000
Committer: Peter Ansell <p_...@yahoo.com>
Committed: Fri Apr 19 13:46:04 2013 +1000

----------------------------------------------------------------------
 .../apache/any23/io/nquads/NQuadsParserTest.java   |   30 ++++++++++++--
 1 files changed, 25 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/any23/blob/d5cedee7/nquads/src/test/java/org/apache/any23/io/nquads/NQuadsParserTest.java
----------------------------------------------------------------------
diff --git a/nquads/src/test/java/org/apache/any23/io/nquads/NQuadsParserTest.java b/nquads/src/test/java/org/apache/any23/io/nquads/NQuadsParserTest.java
index 1e7d545..8d25e02 100644
--- a/nquads/src/test/java/org/apache/any23/io/nquads/NQuadsParserTest.java
+++ b/nquads/src/test/java/org/apache/any23/io/nquads/NQuadsParserTest.java
@@ -33,6 +33,8 @@ import org.openrdf.rio.RDFHandler;
 import org.openrdf.rio.RDFHandlerException;
 import org.openrdf.rio.RDFParseException;
 import org.openrdf.rio.RDFParser;
+import org.openrdf.rio.RioSetting;
+import org.openrdf.rio.helpers.BasicParserSettings;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -41,7 +43,9 @@ import java.io.ByteArrayInputStream;
 import java.io.IOException;
 import java.io.InputStreamReader;
 import java.util.ArrayList;
+import java.util.HashSet;
 import java.util.List;
+import java.util.Set;
 
 import static org.hamcrest.core.Is.is;
 
@@ -63,9 +67,15 @@ public class NQuadsParserTest {
         parser = new NQuadsParser();
         rdfHandler = new TestRDFHandler();
         parser.setRDFHandler(rdfHandler);
-        parser.setVerifyData(true);
-        parser.setDatatypeHandling(RDFParser.DatatypeHandling.VERIFY);
-        parser.setStopAtFirstError(true);
+        Set<RioSetting<?>> nonFatalErrors = new HashSet<RioSetting<?>>();
+        parser.getParserConfig().setNonFatalErrors(nonFatalErrors);
+        parser.getParserConfig().set(BasicParserSettings.FAIL_ON_UNKNOWN_DATATYPES, false);
+        parser.getParserConfig().addNonFatalError(BasicParserSettings.FAIL_ON_UNKNOWN_DATATYPES);
+        parser.getParserConfig().set(BasicParserSettings.VERIFY_DATATYPE_VALUES, false);
+        parser.getParserConfig().addNonFatalError(BasicParserSettings.VERIFY_DATATYPE_VALUES);
+        parser.getParserConfig().set(BasicParserSettings.NORMALIZE_DATATYPE_VALUES, false);
+        parser.getParserConfig().addNonFatalError(BasicParserSettings.NORMALIZE_DATATYPE_VALUES);
+        
     }
 
     @After
@@ -443,7 +453,7 @@ public class NQuadsParserTest {
         verifyStatementWithInvalidDatatype(RDFParser.DatatypeHandling.IGNORE);
     }
 
-    @Test
+    @Test(expected = RDFParseException.class)
     public void testStatementWithInvalidDatatypeAndVerifyValidation()
     throws RDFHandlerException, IOException, RDFParseException {
         verifyStatementWithInvalidDatatype(RDFParser.DatatypeHandling.VERIFY);
@@ -529,7 +539,12 @@ public class NQuadsParserTest {
                 "<http://it.wikipedia.org/wiki/Camillo_Benso,_conte_di_Cavour#absolute-line=20> ."
                 ).getBytes()
         );
-        parser.setDatatypeHandling(datatypeHandling);
+        if(datatypeHandling == RDFParser.DatatypeHandling.VERIFY) {
+            parser.getParserConfig().setNonFatalErrors(new HashSet<RioSetting<?>>());
+            parser.getParserConfig().set(BasicParserSettings.FAIL_ON_UNKNOWN_DATATYPES, true);
+            parser.getParserConfig().set(BasicParserSettings.VERIFY_DATATYPE_VALUES, true);
+        }
+        //parser.setDatatypeHandling(datatypeHandling);
         parser.parse(bais, "http://base-uri");
     }
 
@@ -544,6 +559,11 @@ public class NQuadsParserTest {
                         "<http://it.wikipedia.org/wiki/Camillo_Benso,_conte_di_Cavour#absolute-line=20> ."
                 ).getBytes()
         );
+        if(datatypeHandling == RDFParser.DatatypeHandling.VERIFY) {
+            parser.getParserConfig().setNonFatalErrors(new HashSet<RioSetting<?>>());
+            parser.getParserConfig().set(BasicParserSettings.FAIL_ON_UNKNOWN_DATATYPES, true);
+            parser.getParserConfig().set(BasicParserSettings.VERIFY_DATATYPE_VALUES, true);
+        }
         parser.parse(bais, "http://base-uri");
         rdfHandler.assertHandler(1);
     }


[09/19] git commit: import sesame-rio-nquads package into nquads module

Posted by an...@apache.org.
import sesame-rio-nquads package into nquads module


Project: http://git-wip-us.apache.org/repos/asf/any23/repo
Commit: http://git-wip-us.apache.org/repos/asf/any23/commit/d0835607
Tree: http://git-wip-us.apache.org/repos/asf/any23/tree/d0835607
Diff: http://git-wip-us.apache.org/repos/asf/any23/diff/d0835607

Branch: refs/heads/ANY23-141
Commit: d08356077e6fa4a8a2741da233feb8b88a0b831a
Parents: 972faab
Author: Peter Ansell <p_...@yahoo.com>
Authored: Wed Oct 24 13:51:57 2012 +1000
Committer: Peter Ansell <p_...@yahoo.com>
Committed: Fri Apr 19 13:33:26 2013 +1000

----------------------------------------------------------------------
 nquads/pom.xml |    9 +++++++++
 pom.xml        |    5 +++++
 2 files changed, 14 insertions(+), 0 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/any23/blob/d0835607/nquads/pom.xml
----------------------------------------------------------------------
diff --git a/nquads/pom.xml b/nquads/pom.xml
index 7c8e57f..b92c018 100644
--- a/nquads/pom.xml
+++ b/nquads/pom.xml
@@ -52,6 +52,10 @@
       <artifactId>sesame-rio-ntriples</artifactId>
     </dependency>
     <dependency>
+      <groupId>org.openrdf.sesame</groupId>
+      <artifactId>sesame-rio-nquads</artifactId>
+    </dependency>
+    <dependency>
       <groupId>org.kohsuke.metainf-services</groupId>
       <artifactId>metainf-services</artifactId>
       <scope>compile</scope>
@@ -62,6 +66,11 @@
       <artifactId>junit</artifactId>
       <scope>test</scope>
     </dependency>
+    <dependency>
+      <groupId>org.slf4j</groupId>
+      <artifactId>slf4j-log4j12</artifactId>
+      <scope>test</scope>
+    </dependency>
   </dependencies>
 
   <build>

http://git-wip-us.apache.org/repos/asf/any23/blob/d0835607/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 64d8add..737e187 100644
--- a/pom.xml
+++ b/pom.xml
@@ -357,6 +357,11 @@
       </dependency>
       <dependency>
         <groupId>org.openrdf.sesame</groupId>
+        <artifactId>sesame-rio-nquads</artifactId>
+        <version>${sesame.version}</version>
+      </dependency>
+      <dependency>
+        <groupId>org.openrdf.sesame</groupId>
         <artifactId>sesame-rio-n3</artifactId>
         <version>${sesame.version}</version>
       </dependency>


[02/19] git commit: bump sesame and slf4j versions

Posted by an...@apache.org.
bump sesame and slf4j versions


Project: http://git-wip-us.apache.org/repos/asf/any23/repo
Commit: http://git-wip-us.apache.org/repos/asf/any23/commit/914510c0
Tree: http://git-wip-us.apache.org/repos/asf/any23/tree/914510c0
Diff: http://git-wip-us.apache.org/repos/asf/any23/diff/914510c0

Branch: refs/heads/ANY23-141
Commit: 914510c0832f96aa5aa9f2a6209bee3d797c3627
Parents: 0ec3e91
Author: Peter Ansell <p_...@yahoo.com>
Authored: Fri Dec 7 09:41:15 2012 +1000
Committer: Peter Ansell <p_...@yahoo.com>
Committed: Fri Apr 19 13:21:44 2013 +1000

----------------------------------------------------------------------
 pom.xml |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/any23/blob/914510c0/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index ea1b39c..172c7b9 100644
--- a/pom.xml
+++ b/pom.xml
@@ -226,8 +226,8 @@
     <maven.build.timestamp.format>yyyy-MM-dd HH:mm:ssZ</maven.build.timestamp.format>
     <implementation.build>${scmBranch}@r${buildNumber}</implementation.build>
     <implementation.build.tstamp>${implementation.build}; ${maven.build.timestamp}</implementation.build.tstamp>
-    <slf4j.logger.version>1.6.6</slf4j.logger.version>
-    <sesame.version>2.6.9</sesame.version>
+    <slf4j.logger.version>1.7.2</slf4j.logger.version>
+    <sesame.version>2.7-SNAPSHOT</sesame.version>
     <latest.stable.released>0.7.0-incubating</latest.stable.released>
 
     <!-- Maven Plugin Versions -->


[07/19] git commit: add sonatype snapshot repository to fetch sesame-2.7-SNAPSHOT artifacts

Posted by an...@apache.org.
add sonatype snapshot repository to fetch sesame-2.7-SNAPSHOT artifacts


Project: http://git-wip-us.apache.org/repos/asf/any23/repo
Commit: http://git-wip-us.apache.org/repos/asf/any23/commit/2cd26b1c
Tree: http://git-wip-us.apache.org/repos/asf/any23/tree/2cd26b1c
Diff: http://git-wip-us.apache.org/repos/asf/any23/diff/2cd26b1c

Branch: refs/heads/ANY23-141
Commit: 2cd26b1c2fe1d75a01d826542305deef4e7a6b56
Parents: 681fa9e
Author: Peter Ansell <p_...@yahoo.com>
Authored: Fri Dec 7 09:55:05 2012 +1000
Committer: Peter Ansell <p_...@yahoo.com>
Committed: Fri Apr 19 13:21:45 2013 +1000

----------------------------------------------------------------------
 pom.xml |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/any23/blob/2cd26b1c/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 7eac9be..1e0a188 100644
--- a/pom.xml
+++ b/pom.xml
@@ -511,6 +511,12 @@
       <id>any23-repository-external</id>
       <url>http://svn.apache.org/repos/asf/any23/repo-ext/</url>
     </repository>
+    <repository>
+      <id>sonatype-snapshots</id>
+      <url>https://oss.sonatype.org/content/repositories/snapshots/</url>
+      <releases><enabled>false</enabled></releases>
+      <snapshots><enabled>true</enabled></snapshots>
+    </repository>
   </repositories>
 
   <build>


[04/19] git commit: bump to sesame-2.7.0-beta2-SNAPSHOT

Posted by an...@apache.org.
bump to sesame-2.7.0-beta2-SNAPSHOT


Project: http://git-wip-us.apache.org/repos/asf/any23/repo
Commit: http://git-wip-us.apache.org/repos/asf/any23/commit/454d0ae8
Tree: http://git-wip-us.apache.org/repos/asf/any23/tree/454d0ae8
Diff: http://git-wip-us.apache.org/repos/asf/any23/diff/454d0ae8

Branch: refs/heads/ANY23-141
Commit: 454d0ae83499f774134d10153ffa3fe5659140c7
Parents: 78c2cdc
Author: Peter Ansell <p_...@yahoo.com>
Authored: Thu Jan 17 12:17:13 2013 +1000
Committer: Peter Ansell <p_...@yahoo.com>
Committed: Fri Apr 19 13:21:45 2013 +1000

----------------------------------------------------------------------
 pom.xml |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/any23/blob/454d0ae8/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index a0f1100..68bad57 100644
--- a/pom.xml
+++ b/pom.xml
@@ -227,7 +227,7 @@
     <implementation.build>${scmBranch}@r${buildNumber}</implementation.build>
     <implementation.build.tstamp>${implementation.build}; ${maven.build.timestamp}</implementation.build.tstamp>
     <slf4j.logger.version>1.7.2</slf4j.logger.version>
-    <sesame.version>2.7-SNAPSHOT</sesame.version>
+    <sesame.version>2.7.0-beta2-SNAPSHOT</sesame.version>
     <latest.stable.released>0.7.0-incubating</latest.stable.released>
 
     <!-- Maven Plugin Versions -->


[13/19] git commit: add FIXME note about N-Quads parser catching all Exceptions

Posted by an...@apache.org.
add FIXME note about N-Quads parser catching all Exceptions


Project: http://git-wip-us.apache.org/repos/asf/any23/repo
Commit: http://git-wip-us.apache.org/repos/asf/any23/commit/0c9f4762
Tree: http://git-wip-us.apache.org/repos/asf/any23/tree/0c9f4762
Diff: http://git-wip-us.apache.org/repos/asf/any23/diff/0c9f4762

Branch: refs/heads/ANY23-141
Commit: 0c9f476210152a6c8e91427a0c527af06492f121
Parents: c7562f9
Author: Peter Ansell <p_...@yahoo.com>
Authored: Wed Oct 24 13:57:50 2012 +1000
Committer: Peter Ansell <p_...@yahoo.com>
Committed: Fri Apr 19 13:34:55 2013 +1000

----------------------------------------------------------------------
 .../org/apache/any23/io/nquads/NQuadsParser.java   |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/any23/blob/0c9f4762/nquads/src/main/java/org/apache/any23/io/nquads/NQuadsParser.java
----------------------------------------------------------------------
diff --git a/nquads/src/main/java/org/apache/any23/io/nquads/NQuadsParser.java b/nquads/src/main/java/org/apache/any23/io/nquads/NQuadsParser.java
index 485d5cb..7ca4fe9 100644
--- a/nquads/src/main/java/org/apache/any23/io/nquads/NQuadsParser.java
+++ b/nquads/src/main/java/org/apache/any23/io/nquads/NQuadsParser.java
@@ -273,7 +273,7 @@ public class NQuadsParser extends RDFParserBase {
         } catch (EOS eos) {
             reportFatalError("Unexpected end of stream.", row, col);
             throw new IllegalStateException();
-        } catch (Exception e) {
+        } catch (Exception e) { // FIXME: We should not be catching IOException here as that is used to indicate a failure of the stream/writer
             if(super.stopAtFirstError()) {
                 if(e instanceof RDFParseException)
                     throw (RDFParseException) e;


[17/19] git commit: make NQuadsParserTest pass, including always having an rdfHandler, ignoring column numbers as they are not supported, removing test for relative URL as it is not in the NQuads specification, and fixing blank node identifiers that star

Posted by an...@apache.org.
make NQuadsParserTest pass, including always having an rdfHandler, ignoring column numbers as they are not supported, removing test for relative URL as it is not in the NQuads specification, and fixing blank node identifiers that start with a number, when the specification says they must start with a letter


Project: http://git-wip-us.apache.org/repos/asf/any23/repo
Commit: http://git-wip-us.apache.org/repos/asf/any23/commit/0b695957
Tree: http://git-wip-us.apache.org/repos/asf/any23/tree/0b695957
Diff: http://git-wip-us.apache.org/repos/asf/any23/diff/0b695957

Branch: refs/heads/ANY23-141
Commit: 0b695957607c225d505e2b0ecee7914281396d3d
Parents: 34cee60
Author: Peter Ansell <p_...@yahoo.com>
Authored: Wed Oct 24 14:17:39 2012 +1000
Committer: Peter Ansell <p_...@yahoo.com>
Committed: Fri Apr 19 13:35:47 2013 +1000

----------------------------------------------------------------------
 .../apache/any23/io/nquads/NQuadsParserTest.java   |   60 +++++----------
 1 files changed, 18 insertions(+), 42 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/any23/blob/0b695957/nquads/src/test/java/org/apache/any23/io/nquads/NQuadsParserTest.java
----------------------------------------------------------------------
diff --git a/nquads/src/test/java/org/apache/any23/io/nquads/NQuadsParserTest.java b/nquads/src/test/java/org/apache/any23/io/nquads/NQuadsParserTest.java
index 5a71544..1e7d545 100644
--- a/nquads/src/test/java/org/apache/any23/io/nquads/NQuadsParserTest.java
+++ b/nquads/src/test/java/org/apache/any23/io/nquads/NQuadsParserTest.java
@@ -56,9 +56,13 @@ public class NQuadsParserTest {
 
     private NQuadsParser parser;
 
+    private TestRDFHandler rdfHandler;
+
     @Before
     public void setUp() {
         parser = new NQuadsParser();
+        rdfHandler = new TestRDFHandler();
+        parser.setRDFHandler(rdfHandler);
         parser.setVerifyData(true);
         parser.setDatatypeHandling(RDFParser.DatatypeHandling.VERIFY);
         parser.setStopAtFirstError(true);
@@ -95,8 +99,6 @@ public class NQuadsParserTest {
             "  \n\n\n# This is a comment\n\n#this is another comment."
             .getBytes()
         );
-        final TestRDFHandler rdfHandler = new TestRDFHandler();
-        parser.setRDFHandler(rdfHandler);
         parser.parse(bais, "http://test.base.uri");
         Assert.assertEquals(rdfHandler.getStatements().size(), 0);
     }
@@ -111,11 +113,9 @@ public class NQuadsParserTest {
     @Test
     public void testParseBasic() throws RDFHandlerException, IOException, RDFParseException {
         final ByteArrayInputStream bais = new ByteArrayInputStream(
-            "<http://www.v/dat/4b><http://www.w3.org/20/ica#dtend><http://sin/value/2><http://sin.siteserv.org/def/>."
+            "<http://www.v/dat/4b> <http://www.w3.org/20/ica#dtend> <http://sin/value/2> <http://sin.siteserv.org/def/>."
             .getBytes()
         );
-        final TestRDFHandler rdfHandler = new TestRDFHandler();
-        parser.setRDFHandler(rdfHandler);
         parser.parse(bais, "http://test.base.uri");
         Assert.assertThat(rdfHandler.getStatements().size(), is(1));
         final Statement statement = rdfHandler.getStatements().get(0);
@@ -136,11 +136,9 @@ public class NQuadsParserTest {
     @Test
     public void testParseBasicBNode() throws RDFHandlerException, IOException, RDFParseException {
         final ByteArrayInputStream bais = new ByteArrayInputStream(
-            "_:123456768<http://www.w3.org/20/ica#dtend><http://sin/value/2><http://sin.siteserv.org/def/>."
+            "_:a123456768 <http://www.w3.org/20/ica#dtend> <http://sin/value/2> <http://sin.siteserv.org/def/>."
             .getBytes()
         );
-        final TestRDFHandler rdfHandler = new TestRDFHandler();
-        parser.setRDFHandler(rdfHandler);
         parser.parse(bais, "http://test.base.uri");
         Assert.assertThat(rdfHandler.getStatements().size(), is(1));
         final Statement statement = rdfHandler.getStatements().get(0);
@@ -161,11 +159,9 @@ public class NQuadsParserTest {
     @Test
     public void testParseBasicLiteral() throws RDFHandlerException, IOException, RDFParseException {
         final ByteArrayInputStream bais = new ByteArrayInputStream(
-            "_:123456768<http://www.w3.org/20/ica#dtend>\"2010-05-02\"<http://sin.siteserv.org/def/>."
+            "_:a123456768 <http://www.w3.org/20/ica#dtend> \"2010-05-02\" <http://sin.siteserv.org/def/>."
             .getBytes()
         );
-        final TestRDFHandler rdfHandler = new TestRDFHandler();
-        parser.setRDFHandler(rdfHandler);
         parser.parse(bais, "http://test.base.uri");
         Assert.assertThat(rdfHandler.getStatements().size(), is(1));
         final Statement statement = rdfHandler.getStatements().get(0);
@@ -186,11 +182,9 @@ public class NQuadsParserTest {
     @Test
     public void testParseBasicLiteralLang() throws RDFHandlerException, IOException, RDFParseException {
         final ByteArrayInputStream bais = new ByteArrayInputStream(
-            "<http://www.v/dat/4b2-21><http://www.w3.org/20/ica#dtend>\"2010-05-02\"@en<http://sin.siteserv.org/def/>."
+            "<http://www.v/dat/4b2-21> <http://www.w3.org/20/ica#dtend> \"2010-05-02\"@en <http://sin.siteserv.org/def/>."
             .getBytes()
         );
-        final TestRDFHandler rdfHandler = new TestRDFHandler();
-        parser.setRDFHandler(rdfHandler);
         parser.parse(bais, "http://test.base.uri");
         final Statement statement = rdfHandler.getStatements().get(0);
         Assert.assertEquals("http://www.v/dat/4b2-21", statement.getSubject().stringValue());
@@ -213,14 +207,12 @@ public class NQuadsParserTest {
     @Test
     public void testParseBasicLiteraDatatype() throws RDFHandlerException, IOException, RDFParseException {
         final ByteArrayInputStream bais = new ByteArrayInputStream(
-            ("<http://www.v/dat/4b2-21>" +
-             "<http://www.w3.org/20/ica#dtend>" +
-             "\"2010\"^^<http://www.w3.org/2001/XMLSchema#integer>" +
+            ("<http://www.v/dat/4b2-21> " +
+             "<http://www.w3.org/20/ica#dtend> " +
+             "\"2010\"^^<http://www.w3.org/2001/XMLSchema#integer> " +
              "<http://sin.siteserv.org/def/>."
             ).getBytes()
         );
-        final TestRDFHandler rdfHandler = new TestRDFHandler();
-        parser.setRDFHandler(rdfHandler);
         parser.parse(bais, "http://test.base.uri");
         final Statement statement = rdfHandler.getStatements().get(0);
         Assert.assertEquals("http://www.v/dat/4b2-21", statement.getSubject().stringValue());
@@ -244,9 +236,7 @@ public class NQuadsParserTest {
     public void testLiteralEscapeManagement1()
     throws RDFHandlerException, IOException, RDFParseException {
         TestParseLocationListener parseLocationListener = new TestParseLocationListener();
-        TestRDFHandler rdfHandler = new TestRDFHandler();
         parser.setParseLocationListener(parseLocationListener);
-        parser.setRDFHandler(rdfHandler);
 
         final ByteArrayInputStream bais = new ByteArrayInputStream(
             "<http://a> <http://b> \"\\\\\" <http://c> .".getBytes()
@@ -254,7 +244,8 @@ public class NQuadsParserTest {
         parser.parse(bais, "http://base-uri");
 
         rdfHandler.assertHandler(1);
-        parseLocationListener.assertListener(1, 40);
+        //parseLocationListener.assertListener(1, 40);
+        parseLocationListener.assertListener(1, 1);
     }
 
     /**
@@ -268,9 +259,7 @@ public class NQuadsParserTest {
     public void testLiteralEscapeManagement2()
     throws RDFHandlerException, IOException, RDFParseException {
         TestParseLocationListener parseLocationListener = new TestParseLocationListener();
-        TestRDFHandler rdfHandler = new TestRDFHandler();
         parser.setParseLocationListener(parseLocationListener);
-        parser.setRDFHandler(rdfHandler);
 
         final ByteArrayInputStream bais = new ByteArrayInputStream(
             "<http://a> <http://b> \"Line text 1\\nLine text 2\" <http://c> .".getBytes()
@@ -294,9 +283,7 @@ public class NQuadsParserTest {
     @Test
     public void testURIDecodingManagement() throws RDFHandlerException, IOException, RDFParseException {
         TestParseLocationListener parseLocationListener = new TestParseLocationListener();
-        TestRDFHandler rdfHandler = new TestRDFHandler();
         parser.setParseLocationListener(parseLocationListener);
-        parser.setRDFHandler(rdfHandler);
 
         final ByteArrayInputStream bais = new ByteArrayInputStream(
             "<http://s/\\u306F\\u3080> <http://p/\\u306F\\u3080> <http://o/\\u306F\\u3080> <http://g/\\u306F\\u3080> ."
@@ -330,8 +317,6 @@ public class NQuadsParserTest {
 
     @Test
     public void testUnicodeLiteralManagement() throws RDFHandlerException, IOException, RDFParseException {
-        TestRDFHandler rdfHandler = new TestRDFHandler();
-        parser.setRDFHandler(rdfHandler);
         final String INPUT_LITERAL = "[は、イギリスおよびイングランドの首都である] [是大不列顛及北愛爾蘭聯合王國和英格蘭的首都]";
         final String INPUT_STRING = String.format(
                 "<http://a> <http://b> \"%s\" <http://c> .",
@@ -349,8 +334,6 @@ public class NQuadsParserTest {
 
     @Test
     public void testUnicodeLiteralDecoding() throws RDFHandlerException, IOException, RDFParseException {
-        TestRDFHandler rdfHandler = new TestRDFHandler();
-        parser.setRDFHandler(rdfHandler);
         final String INPUT_LITERAL_PLAIN   = "[は]";
         final String INPUT_LITERAL_ENCODED = "[\\u306F]";
         final String INPUT_STRING = String.format(
@@ -431,9 +414,7 @@ public class NQuadsParserTest {
     public void testParseRealData()
     throws IOException, RDFParseException, RDFHandlerException {
         TestParseLocationListener parseLocationListener = new TestParseLocationListener();
-        TestRDFHandler rdfHandler = new TestRDFHandler();
         parser.setParseLocationListener(parseLocationListener);
-        parser.setRDFHandler(rdfHandler);
 
         parser.parse(
             this.getClass().getClassLoader().getResourceAsStream("application/nquads/test2.nq"),
@@ -490,8 +471,6 @@ public class NQuadsParserTest {
                     "<http://s1> <http://p1> <http://o1> <http://g1> .\n"
                 ).getBytes()
         );
-        final TestRDFHandler rdfHandler = new TestRDFHandler();
-        parser.setRDFHandler(rdfHandler);
         parser.setStopAtFirstError(false);
         parser.parse(bais, "http://base-uri");
         rdfHandler.assertHandler(2);
@@ -514,9 +493,9 @@ public class NQuadsParserTest {
             parser.parse(bais, "http://base-uri");
             Assert.fail("Expected failure here.");
         } catch (RDFParseException e) {
-            Assert.assertTrue(e.getMessage().contains("expected '<'"));
+            Assert.assertTrue(e.getMessage().contains("Expected '<'"));
             Assert.assertEquals(1 , e.getLineNumber());
-            Assert.assertEquals(35, e.getColumnNumber());
+            //Assert.assertEquals(35, e.getColumnNumber());
         }
     }
 
@@ -528,8 +507,6 @@ public class NQuadsParserTest {
              "\"2010\"^^<http://www.w3.org/2001/XMLSchema#integer> ."
             ).getBytes()
         );
-        final TestRDFHandler rdfHandler = new TestRDFHandler();
-        parser.setRDFHandler(rdfHandler);
         parser.parse(bais, "http://test.base.uri");
         final Statement statement = rdfHandler.getStatements().get(0);
         Assert.assertEquals("http://www.v/dat/4b2-21", statement.getSubject().stringValue());
@@ -558,8 +535,6 @@ public class NQuadsParserTest {
 
     private void verifyStatementWithInvalidDatatype(RDFParser.DatatypeHandling datatypeHandling)
     throws RDFHandlerException, IOException, RDFParseException {
-        TestRDFHandler rdfHandler = new TestRDFHandler();
-        parser.setRDFHandler(rdfHandler);
         parser.setDatatypeHandling(datatypeHandling);
         final ByteArrayInputStream bais = new ByteArrayInputStream(
                 (
@@ -584,7 +559,8 @@ public class NQuadsParserTest {
 
         private void assertListener(int row, int col) {
             Assert.assertEquals("Unexpected last row", row , lastRow);
-            Assert.assertEquals("Unexpected last col", col , lastCol);
+            // Column numbers are not supported by the Rio NQuadsParser currently
+            //Assert.assertEquals("Unexpected last col", col , lastCol);
         }
 
     }
@@ -639,7 +615,7 @@ public class NQuadsParserTest {
             }
 
             if( statementIndex == 4) {
-                Assert.assertEquals(new URIImpl("http://test.base.uri#like"), statement.getPredicate() );
+                Assert.assertEquals(new URIImpl("http://example.org/#like"), statement.getPredicate() );
             }
 
             if(statementIndex == 5) {


[06/19] git commit: remove aduna-commons packages that are not used independent of sesame

Posted by an...@apache.org.
remove aduna-commons packages that are not used independent of sesame


Project: http://git-wip-us.apache.org/repos/asf/any23/repo
Commit: http://git-wip-us.apache.org/repos/asf/any23/commit/78c2cdc8
Tree: http://git-wip-us.apache.org/repos/asf/any23/tree/78c2cdc8
Diff: http://git-wip-us.apache.org/repos/asf/any23/diff/78c2cdc8

Branch: refs/heads/ANY23-141
Commit: 78c2cdc82efc823fdf88ccbd6684186a25642f2e
Parents: 2cd26b1
Author: Peter Ansell <p_...@yahoo.com>
Authored: Fri Dec 7 09:57:56 2012 +1000
Committer: Peter Ansell <p_...@yahoo.com>
Committed: Fri Apr 19 13:21:45 2013 +1000

----------------------------------------------------------------------
 core/pom.xml |   28 ----------------------------
 pom.xml      |   35 -----------------------------------
 2 files changed, 0 insertions(+), 63 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/any23/blob/78c2cdc8/core/pom.xml
----------------------------------------------------------------------
diff --git a/core/pom.xml b/core/pom.xml
index e65ceea..94e3c23 100644
--- a/core/pom.xml
+++ b/core/pom.xml
@@ -133,34 +133,6 @@
       <groupId>org.openrdf.sesame</groupId>
       <artifactId>sesame-repository-api</artifactId>
     </dependency>
-    <dependency>
-      <groupId>info.aduna.commons</groupId>
-      <artifactId>aduna-commons-xml</artifactId>
-    </dependency>
-    <dependency>
-      <groupId>info.aduna.commons</groupId>
-      <artifactId>aduna-commons-text</artifactId>
-    </dependency>
-    <dependency>
-      <groupId>info.aduna.commons</groupId>
-      <artifactId>aduna-commons-net</artifactId>
-    </dependency>
-    <dependency>
-      <groupId>info.aduna.commons</groupId>
-      <artifactId>aduna-commons-lang</artifactId>
-    </dependency>
-    <dependency>
-      <groupId>info.aduna.commons</groupId>
-      <artifactId>aduna-commons-iteration</artifactId>
-    </dependency>
-    <dependency>
-      <groupId>info.aduna.commons</groupId>
-      <artifactId>aduna-commons-io</artifactId>
-    </dependency>
-    <dependency>
-      <groupId>info.aduna.commons</groupId>
-      <artifactId>aduna-commons-concurrent</artifactId>
-    </dependency>
     <!-- END: Sesame -->
 
     <!-- BEGIN:  Apache Commons, this version is hosted in the 

http://git-wip-us.apache.org/repos/asf/any23/blob/78c2cdc8/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 1e0a188..a0f1100 100644
--- a/pom.xml
+++ b/pom.xml
@@ -380,41 +380,6 @@
         <artifactId>sesame-repository-api</artifactId>
         <version>${sesame.version}</version>
       </dependency>
-      <dependency>
-        <groupId>info.aduna.commons</groupId>
-        <artifactId>aduna-commons-xml</artifactId>
-        <version>2.7.0</version>
-      </dependency>
-      <dependency>
-        <groupId>info.aduna.commons</groupId>
-        <artifactId>aduna-commons-text</artifactId>
-        <version>2.7.0</version>
-      </dependency>
-      <dependency>
-        <groupId>info.aduna.commons</groupId>
-        <artifactId>aduna-commons-net</artifactId>
-        <version>2.7.0</version>
-      </dependency>
-      <dependency>
-        <groupId>info.aduna.commons</groupId>
-        <artifactId>aduna-commons-lang</artifactId>
-        <version>2.9.0</version>
-      </dependency>
-      <dependency>
-        <groupId>info.aduna.commons</groupId>
-        <artifactId>aduna-commons-iteration</artifactId>
-        <version>2.10.0</version>
-      </dependency>
-      <dependency>
-        <groupId>info.aduna.commons</groupId>
-        <artifactId>aduna-commons-io</artifactId>
-        <version>2.10.0</version>
-      </dependency>
-      <dependency>
-        <groupId>info.aduna.commons</groupId>
-        <artifactId>aduna-commons-concurrent</artifactId>
-        <version>2.7.0</version>
-      </dependency>
       <!-- END: Sesame -->
 
       <!-- BEGIN:  Apache Commons -->