You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jena.apache.org by an...@apache.org on 2015/04/28 13:35:04 UTC
[2/6] jena git commit: JENA-923: Move IRILib to future jena-base code
tree.
JENA-923: Move IRILib to future jena-base code tree.
This is the first step - moving within ARQ, for later migration to
jena-base.
Project: http://git-wip-us.apache.org/repos/asf/jena/repo
Commit: http://git-wip-us.apache.org/repos/asf/jena/commit/57aa6abc
Tree: http://git-wip-us.apache.org/repos/asf/jena/tree/57aa6abc
Diff: http://git-wip-us.apache.org/repos/asf/jena/diff/57aa6abc
Branch: refs/heads/master
Commit: 57aa6abca72c259c664a30665d5c0c7136d24335
Parents: b9e9281
Author: Andy Seaborne <an...@apache.org>
Authored: Tue Apr 28 11:34:21 2015 +0100
Committer: Andy Seaborne <an...@apache.org>
Committed: Tue Apr 28 11:34:21 2015 +0100
----------------------------------------------------------------------
.../main/java/org/apache/jena/atlas/io/IO.java | 2 +-
.../java/org/apache/jena/atlas/lib/IRILib.java | 243 ++++++++++++++++++
.../apache/jena/atlas/lib/PropertyUtils.java | 3 +-
.../main/java/org/apache/jena/riot/SysRIOT.java | 2 +-
.../jena/riot/adapters/RDFReaderRIOT_ARP.java | 2 +-
.../java/org/apache/jena/riot/lang/LangCSV.java | 2 +-
.../org/apache/jena/riot/system/IRILib.java | 245 -------------------
.../apache/jena/riot/system/IRIResolver.java | 1 +
.../jena/riot/system/stream/LocatorFile.java | 2 +-
.../jena/sparql/expr/nodevalue/XSDFuncOp.java | 2 +-
.../jena/web/DatasetGraphAccessorHTTP.java | 2 +-
.../java/org/apache/jena/atlas/lib/TS_Lib.java | 3 +
.../jena/atlas/lib/TestFilenameProcessing.java | 36 ++-
.../org/apache/jena/atlas/lib/TestXMLLib.java | 1 +
.../java/org/apache/jena/riot/lang/TestIRI.java | 35 ---
.../apache/jena/fuseki/build/FusekiConfig.java | 2 +-
.../org/apache/jena/fuseki/http/TestHttpOp.java | 2 +-
17 files changed, 294 insertions(+), 291 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/jena/blob/57aa6abc/jena-arq/src/main/java/org/apache/jena/atlas/io/IO.java
----------------------------------------------------------------------
diff --git a/jena-arq/src/main/java/org/apache/jena/atlas/io/IO.java b/jena-arq/src/main/java/org/apache/jena/atlas/io/IO.java
index 8772ae3..ac312e8 100644
--- a/jena-arq/src/main/java/org/apache/jena/atlas/io/IO.java
+++ b/jena-arq/src/main/java/org/apache/jena/atlas/io/IO.java
@@ -25,7 +25,7 @@ import java.util.zip.GZIPInputStream ;
import java.util.zip.GZIPOutputStream ;
import org.apache.jena.atlas.RuntimeIOException ;
-import org.apache.jena.riot.system.IRILib ;
+import org.apache.jena.atlas.lib.IRILib ;
public class IO
{
http://git-wip-us.apache.org/repos/asf/jena/blob/57aa6abc/jena-arq/src/main/java/org/apache/jena/atlas/lib/IRILib.java
----------------------------------------------------------------------
diff --git a/jena-arq/src/main/java/org/apache/jena/atlas/lib/IRILib.java b/jena-arq/src/main/java/org/apache/jena/atlas/lib/IRILib.java
new file mode 100644
index 0000000..f25d7c1
--- /dev/null
+++ b/jena-arq/src/main/java/org/apache/jena/atlas/lib/IRILib.java
@@ -0,0 +1,243 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.jena.atlas.lib;
+
+import java.io.File ;
+import java.io.IOException ;
+
+import org.apache.jena.atlas.AtlasException ;
+import org.apache.jena.riot.SysRIOT ;
+
+/** Operations related to IRIs */
+public class IRILib
+{
+ // http://www.w3.org/TR/xpath-functions/#func-encode-for-uri
+ // Encodes delimiters.
+
+ /* RFC 3986
+ *
+ * unreserved = ALPHA / DIGIT / "-" / "." / "_" / "~"
+ * gen-delims = ":" / "/" / "?" / "#" / "[" / "]" / "@"
+ * sub-delims = "!" / "$" / "&" / "'" / "(" / ")"
+ / "*" / "+" / "," / ";" / "="
+ */
+
+ private static char uri_reserved[] =
+ { '!', '*', '"', '\'', '(', ')', ';', ':', '@', '&',
+ '=', '+', '$', ',', '/', '?', '%', '#', '[', ']' } ;
+
+ // No allowed in URIs
+ private static char uri_non_chars[] = { '<', '>', '{', '}', '|', '\\', '`', '^', ' ', '\n', '\r', '\t', '£' } ;
+
+ // RFC 2396
+ //private static char uri_unwise[] = { '{' , '}', '|', '\\', '^', '[', ']', '`' } ;
+
+
+ private static char[] charsComponent =
+ // reserved, + non-chars + nasties.
+ { '!', '*', '"', '\'', '(', ')', ';', ':', '@', '&',
+ '=', '+', '$', ',', '/', '?', '%', '#', '[', ']',
+ '{', '}', '|', '\\', '`', '^',
+ ' ', '<', '>', '\n', '\r', '\t', '£' } ;
+
+ private static char[] charsFilename =
+ // reserved, + non-chars + nasties.
+ // Leave : (Windows drive charcater) and / (separator) alone
+ // include SPC and ~
+ { '!', '*', '"', '\'', '(', ')', ';', /*':',*/ '@', '&',
+ '=', '+', '$', ',', /*'/',*/ '?', '%', '#', '[', ']',
+ '{', '}', '|', '\\', '`', '^',
+ ' ', '<', '>', '\n', '\r', '\t',
+ '~'} ;
+
+ private static char[] charsPath =
+ { // Reserved except leave the separators alone.
+ '!', '*', '"', '\'', '(', ')', ';', /*':',*/ '@', '&',
+ '=', '+', '$', ',', /*'/',*/ '?', '%', '#', '[', ']',
+ '{', '}', '|', '\\', '`', '^',
+ // Other junk
+ ' ', '<', '>', '\n', '\r', '\t' } ;
+
+ // The initializers must have run.
+ static final String cwd ;
+ static final String cwdURL ;
+
+ // Current directory, with trailing "/"
+ // This matters for resolution.
+ static {
+ String x = new File(".").getAbsolutePath() ;
+ x = x.substring(0, x.length()-1) ;
+ cwd = x ;
+ cwdURL = plainFilenameToURL(cwd) ;
+ }
+
+ // See also IRIResolver
+ /** Return a string that is an IRI for the filename.*/
+ public static String fileToIRI(File f) {
+ return filenameToIRI(f.getAbsolutePath()) ;
+ }
+
+ /** Create a string that is a IRI for the filename.
+ * <li>The file name may already have {@code file:}.
+ * <li>The file name may be relative.
+ * <li>Encode using the rules for a path (e.g. ':' and'/' do not get encoded)
+ * <li>Non-IRI characters get %-encoded.
+ */
+ public static String filenameToIRI(String fn) {
+ if ( fn == null ) return cwdURL ;
+
+ if ( fn.length() == 0 ) return cwdURL ;
+
+ if ( fn.startsWith("file:") )
+ return normalizeFilenameURI(fn) ;
+ return plainFilenameToURL(fn) ;
+ }
+
+ /** Convert a file: IRI to a filename */
+ public static String IRIToFilename(String iri) {
+ if ( ! iri.startsWith("file:") )
+ throw new AtlasException("Not a file: URI: "+iri) ;
+
+ String fn ;
+ if ( iri.startsWith("file:///") )
+ fn = iri.substring("file://".length()) ;
+ else
+ fn = iri.substring("file:".length()) ;
+ return decode(fn) ;
+ }
+
+ /** Convert a plain file name (no file:) to a file: URL */
+ private static String plainFilenameToURL(String fn) {
+ // No "file:"
+ // Make Absolute filename.
+ boolean trailingSlash = fn.endsWith("/") ;
+ File file = new File(fn) ;
+
+ try { fn = file.getCanonicalPath() ; }
+ catch (IOException e) { fn = file.getAbsolutePath() ; }
+
+ if ( trailingSlash && ! fn.endsWith("/") )
+ fn = fn + "/" ;
+
+ if ( SysRIOT.isWindows )
+ {
+ // C:\ => file:///C:/...
+ if ( fn.length() >= 2 && fn.charAt(1) == ':' )
+ // Windows drive letter - already absolute path.
+ // Make "URI" absolute path
+ fn = "/"+fn ;
+ // Convert \ to /
+ // Maybe should do this on all platforms? i.e consistency.
+ fn = fn.replace('\\', '/' ) ;
+ }
+
+ fn = encodeFileURL(fn) ;
+ return "file://"+fn ;
+ }
+
+
+ /** Sanitize a "file:" URL. Must start "file:" */
+ private static String normalizeFilenameURI(String fn) {
+ if ( ! fn.startsWith("file:/") )
+ {
+ // Relative path.
+ String fn2 = fn.substring("file:".length()) ;
+ return plainFilenameToURL(fn2) ;
+ }
+
+ // Starts file:///
+ if ( fn.startsWith("file:///") )
+ // Assume it's good and return as-is.
+ return fn ;
+
+ if ( fn.startsWith("file://") )
+ {
+ String fn2 = fn.substring("file:/".length()) ; // Leave one "/"
+ return plainFilenameToURL(fn2) ;
+ }
+
+ // Must be file:/
+ String fn2 = fn.substring("file:".length()) ;
+ return plainFilenameToURL(fn2) ;
+ }
+
+ /** Encode using the rules for a component (e.g. ':' and '/' get encoded)
+ * Does not encode non-ASCII characters
+ */
+ public static String encodeUriComponent(String string) {
+ String encStr = StrUtils.encodeHex(string,'%', charsComponent) ;
+ return encStr ;
+ }
+
+ /** Encode using the rules for a file: URL.
+ * Does not encode non-ASCII characters
+ */
+ public static String encodeFileURL(String string) {
+ String encStr = StrUtils.encodeHex(string,'%', charsFilename) ;
+ return encStr ;
+ }
+
+ /** Encode using the rules for a path (e.g. ':' and '/' do not get encoded) */
+ public static String encodeUriPath(String uri) {
+ // Not perfect.
+ // Encode path.
+ // %-encode chars.
+ uri = StrUtils.encodeHex(uri, '%', charsPath) ;
+ return uri ;
+ }
+
+ public static String decode(String string) {
+ return StrUtils.decodeHex(string, '%') ;
+ }
+
+ public static String encodeNonASCII(String string) {
+ if ( ! containsNonASCII(string) )
+ return string ;
+
+ byte[] bytes = StrUtils.asUTF8bytes(string) ;
+ StringBuilder sw = new StringBuilder() ;
+ for ( byte b : bytes )
+ {
+ // Signed bytes ...
+ if ( b > 0 )
+ {
+ sw.append( (char) b );
+ continue;
+ }
+
+ int hi = ( b & 0xF0 ) >> 4;
+ int lo = b & 0xF;
+ sw.append( '%' );
+ sw.append( Chars.hexDigitsUC[hi] );
+ sw.append( Chars.hexDigitsUC[lo] );
+ }
+ return sw.toString() ;
+ }
+
+ public static boolean containsNonASCII(String string){
+ boolean clean = true ;
+ for ( int i = 0 ; i < string.length() ; i++ )
+ {
+ char ch = string.charAt(i) ;
+ if ( ch >= 127 )
+ return true;
+ }
+ return false ;
+ }
+}
http://git-wip-us.apache.org/repos/asf/jena/blob/57aa6abc/jena-arq/src/main/java/org/apache/jena/atlas/lib/PropertyUtils.java
----------------------------------------------------------------------
diff --git a/jena-arq/src/main/java/org/apache/jena/atlas/lib/PropertyUtils.java b/jena-arq/src/main/java/org/apache/jena/atlas/lib/PropertyUtils.java
index db3dc2b..782b9df 100644
--- a/jena-arq/src/main/java/org/apache/jena/atlas/lib/PropertyUtils.java
+++ b/jena-arq/src/main/java/org/apache/jena/atlas/lib/PropertyUtils.java
@@ -23,6 +23,7 @@ import java.util.Objects ;
import java.util.Properties ;
import org.apache.jena.atlas.AtlasException ;
+import org.apache.jena.atlas.io.IO ;
import org.apache.jena.util.FileUtils ;
public class PropertyUtils
@@ -42,7 +43,7 @@ public class PropertyUtils
if ( "-".equals(filename) )
throw new IllegalArgumentException("Filename is \"-\" (stdin not supported)") ;
- try (InputStream in = new FileInputStream(filename); Reader r = FileUtils.asBufferedUTF8(in);) {
+ try (InputStream in = new FileInputStream(filename); Reader r = IO.asBufferedUTF8(in);) {
properties.load(r) ;
}
}
http://git-wip-us.apache.org/repos/asf/jena/blob/57aa6abc/jena-arq/src/main/java/org/apache/jena/riot/SysRIOT.java
----------------------------------------------------------------------
diff --git a/jena-arq/src/main/java/org/apache/jena/riot/SysRIOT.java b/jena-arq/src/main/java/org/apache/jena/riot/SysRIOT.java
index 202d53a..49a24ef 100644
--- a/jena-arq/src/main/java/org/apache/jena/riot/SysRIOT.java
+++ b/jena-arq/src/main/java/org/apache/jena/riot/SysRIOT.java
@@ -20,7 +20,7 @@ package org.apache.jena.riot;
import java.io.File ;
-import org.apache.jena.riot.system.IRILib ;
+import org.apache.jena.atlas.lib.IRILib ;
import org.apache.jena.riot.system.IRIResolver ;
import org.apache.jena.util.FileUtils ;
import org.slf4j.Logger ;
http://git-wip-us.apache.org/repos/asf/jena/blob/57aa6abc/jena-arq/src/main/java/org/apache/jena/riot/adapters/RDFReaderRIOT_ARP.java
----------------------------------------------------------------------
diff --git a/jena-arq/src/main/java/org/apache/jena/riot/adapters/RDFReaderRIOT_ARP.java b/jena-arq/src/main/java/org/apache/jena/riot/adapters/RDFReaderRIOT_ARP.java
index 96b7a70..4cc726f 100644
--- a/jena-arq/src/main/java/org/apache/jena/riot/adapters/RDFReaderRIOT_ARP.java
+++ b/jena-arq/src/main/java/org/apache/jena/riot/adapters/RDFReaderRIOT_ARP.java
@@ -21,12 +21,12 @@ package org.apache.jena.riot.adapters;
import java.io.InputStream ;
import java.io.Reader ;
+import org.apache.jena.atlas.lib.IRILib ;
import org.apache.jena.rdf.model.Model ;
import org.apache.jena.rdf.model.RDFErrorHandler ;
import org.apache.jena.rdf.model.RDFReader ;
import org.apache.jena.rdfxml.xmlinput.JenaReader ;
import org.apache.jena.riot.SysRIOT ;
-import org.apache.jena.riot.system.IRILib ;
import org.apache.jena.util.FileManager ;
import org.apache.jena.util.FileUtils ;
http://git-wip-us.apache.org/repos/asf/jena/blob/57aa6abc/jena-arq/src/main/java/org/apache/jena/riot/lang/LangCSV.java
----------------------------------------------------------------------
diff --git a/jena-arq/src/main/java/org/apache/jena/riot/lang/LangCSV.java b/jena-arq/src/main/java/org/apache/jena/riot/lang/LangCSV.java
index ff36d8a..da1f4a1 100644
--- a/jena-arq/src/main/java/org/apache/jena/riot/lang/LangCSV.java
+++ b/jena-arq/src/main/java/org/apache/jena/riot/lang/LangCSV.java
@@ -24,13 +24,13 @@ import java.util.ArrayList;
import java.util.List;
import org.apache.jena.atlas.csv.CSVParser;
+import org.apache.jena.atlas.lib.IRILib ;
import org.apache.jena.datatypes.xsd.XSDDatatype ;
import org.apache.jena.graph.Node ;
import org.apache.jena.graph.NodeFactory ;
import org.apache.jena.riot.Lang;
import org.apache.jena.riot.RDFLanguages;
import org.apache.jena.riot.system.ErrorHandler;
-import org.apache.jena.riot.system.IRILib;
import org.apache.jena.riot.system.IRIResolver;
import org.apache.jena.riot.system.ParserProfile;
import org.apache.jena.riot.system.RiotLib;
http://git-wip-us.apache.org/repos/asf/jena/blob/57aa6abc/jena-arq/src/main/java/org/apache/jena/riot/system/IRILib.java
----------------------------------------------------------------------
diff --git a/jena-arq/src/main/java/org/apache/jena/riot/system/IRILib.java b/jena-arq/src/main/java/org/apache/jena/riot/system/IRILib.java
deleted file mode 100644
index 49c03f3..0000000
--- a/jena-arq/src/main/java/org/apache/jena/riot/system/IRILib.java
+++ /dev/null
@@ -1,245 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.jena.riot.system;
-
-import java.io.File ;
-import java.io.IOException ;
-
-import org.apache.jena.atlas.AtlasException ;
-import org.apache.jena.atlas.lib.Chars ;
-import org.apache.jena.atlas.lib.StrUtils ;
-import org.apache.jena.riot.SysRIOT ;
-
-/** Operations related to IRIs */
-public class IRILib
-{
- // http://www.w3.org/TR/xpath-functions/#func-encode-for-uri
- // Encodes delimiters.
-
- /* RFC 3986
- *
- * unreserved = ALPHA / DIGIT / "-" / "." / "_" / "~"
- * gen-delims = ":" / "/" / "?" / "#" / "[" / "]" / "@"
- * sub-delims = "!" / "$" / "&" / "'" / "(" / ")"
- / "*" / "+" / "," / ";" / "="
- */
-
- private static char uri_reserved[] =
- { '!', '*', '"', '\'', '(', ')', ';', ':', '@', '&',
- '=', '+', '$', ',', '/', '?', '%', '#', '[', ']' } ;
-
- // No allowed in URIs
- private static char uri_non_chars[] = { '<', '>', '{', '}', '|', '\\', '`', '^', ' ', '\n', '\r', '\t', '£' } ;
-
- // RFC 2396
- //private static char uri_unwise[] = { '{' , '}', '|', '\\', '^', '[', ']', '`' } ;
-
-
- private static char[] charsComponent =
- // reserved, + non-chars + nasties.
- { '!', '*', '"', '\'', '(', ')', ';', ':', '@', '&',
- '=', '+', '$', ',', '/', '?', '%', '#', '[', ']',
- '{', '}', '|', '\\', '`', '^',
- ' ', '<', '>', '\n', '\r', '\t', '£' } ;
-
- private static char[] charsFilename =
- // reserved, + non-chars + nasties.
- // Leave : (Windows drive charcater) and / (separator) alone
- // include SPC and ~
- { '!', '*', '"', '\'', '(', ')', ';', /*':',*/ '@', '&',
- '=', '+', '$', ',', /*'/',*/ '?', '%', '#', '[', ']',
- '{', '}', '|', '\\', '`', '^',
- ' ', '<', '>', '\n', '\r', '\t',
- '~'} ;
-
- private static char[] charsPath =
- { // Reserved except leave the separators alone.
- '!', '*', '"', '\'', '(', ')', ';', /*':',*/ '@', '&',
- '=', '+', '$', ',', /*'/',*/ '?', '%', '#', '[', ']',
- '{', '}', '|', '\\', '`', '^',
- // Other junk
- ' ', '<', '>', '\n', '\r', '\t' } ;
-
- // The initializers must have run.
- static final String cwd ;
- static final String cwdURL ;
-
- // Current directory, with trailing "/"
- // This matters for resolution.
- static {
- String x = new File(".").getAbsolutePath() ;
- x = x.substring(0, x.length()-1) ;
- cwd = x ;
- cwdURL = plainFilenameToURL(cwd) ;
- }
-
- // See also IRIResolver
- /** Return a string that is an IRI for the filename.*/
- public static String fileToIRI(File f) {
- return filenameToIRI(f.getAbsolutePath()) ;
- }
-
- /** Create a string that is a IRI for the filename.
- * <li>The file name may already have {@code file:}.
- * <li>The file name may be relative.
- * <li>Encode using the rules for a path (e.g. ':' and'/' do not get encoded)
- * <li>Non-IRI characters get %-encoded.
- */
- public static String filenameToIRI(String fn) {
- if ( fn == null ) return cwdURL ;
-
- if ( fn.length() == 0 ) return cwdURL ;
-
- if ( fn.startsWith("file:") )
- return normalizeFilenameURI(fn) ;
- return plainFilenameToURL(fn) ;
- }
-
- /** Convert a file: IRI to a filename */
- public static String IRIToFilename(String iri) {
- if ( ! iri.startsWith("file:") )
- throw new AtlasException("Not a file: URI: "+iri) ;
-
- String fn ;
- if ( iri.startsWith("file:///") )
- fn = iri.substring("file://".length()) ;
- else
- fn = iri.substring("file:".length()) ;
- return decode(fn) ;
- }
-
- /** Convert a plain file name (no file:) to a file: URL */
- private static String plainFilenameToURL(String fn) {
- // No "file:"
- // Make Absolute filename.
- boolean trailingSlash = fn.endsWith("/") ;
- File file = new File(fn) ;
-
- try { fn = file.getCanonicalPath() ; }
- catch (IOException e) { fn = file.getAbsolutePath() ; }
-
- if ( trailingSlash && ! fn.endsWith("/") )
- fn = fn + "/" ;
-
- if ( SysRIOT.isWindows )
- {
- // C:\ => file:///C:/...
- if ( fn.length() >= 2 && fn.charAt(1) == ':' )
- // Windows drive letter - already absolute path.
- // Make "URI" absolute path
- fn = "/"+fn ;
- // Convert \ to /
- // Maybe should do this on all platforms? i.e consistency.
- fn = fn.replace('\\', '/' ) ;
- }
-
- fn = encodeFileURL(fn) ;
- return "file://"+fn ;
- }
-
-
- /** Sanitize a "file:" URL. Must start "file:" */
- private static String normalizeFilenameURI(String fn) {
- if ( ! fn.startsWith("file:/") )
- {
- // Relative path.
- String fn2 = fn.substring("file:".length()) ;
- return plainFilenameToURL(fn2) ;
- }
-
- // Starts file:///
- if ( fn.startsWith("file:///") )
- // Assume it's good and return as-is.
- return fn ;
-
- if ( fn.startsWith("file://") )
- {
- String fn2 = fn.substring("file:/".length()) ; // Leave one "/"
- return plainFilenameToURL(fn2) ;
- }
-
- // Must be file:/
- String fn2 = fn.substring("file:".length()) ;
- return plainFilenameToURL(fn2) ;
- }
-
- /** Encode using the rules for a component (e.g. ':' and '/' get encoded)
- * Does not encode non-ASCII characters
- */
- public static String encodeUriComponent(String string) {
- String encStr = StrUtils.encodeHex(string,'%', charsComponent) ;
- return encStr ;
- }
-
- /** Encode using the rules for a file: URL.
- * Does not encode non-ASCII characters
- */
- public static String encodeFileURL(String string) {
- String encStr = StrUtils.encodeHex(string,'%', charsFilename) ;
- return encStr ;
- }
-
- /** Encode using the rules for a path (e.g. ':' and '/' do not get encoded) */
- public static String encodeUriPath(String uri) {
- // Not perfect.
- // Encode path.
- // %-encode chars.
- uri = StrUtils.encodeHex(uri, '%', charsPath) ;
- return uri ;
- }
-
- public static String decode(String string) {
- return StrUtils.decodeHex(string, '%') ;
- }
-
- public static String encodeNonASCII(String string) {
- if ( ! containsNonASCII(string) )
- return string ;
-
- byte[] bytes = StrUtils.asUTF8bytes(string) ;
- StringBuilder sw = new StringBuilder() ;
- for ( byte b : bytes )
- {
- // Signed bytes ...
- if ( b > 0 )
- {
- sw.append( (char) b );
- continue;
- }
-
- int hi = ( b & 0xF0 ) >> 4;
- int lo = b & 0xF;
- sw.append( '%' );
- sw.append( Chars.hexDigitsUC[hi] );
- sw.append( Chars.hexDigitsUC[lo] );
- }
- return sw.toString() ;
- }
-
- public static boolean containsNonASCII(String string){
- boolean clean = true ;
- for ( int i = 0 ; i < string.length() ; i++ )
- {
- char ch = string.charAt(i) ;
- if ( ch >= 127 )
- return true;
- }
- return false ;
- }
-}
http://git-wip-us.apache.org/repos/asf/jena/blob/57aa6abc/jena-arq/src/main/java/org/apache/jena/riot/system/IRIResolver.java
----------------------------------------------------------------------
diff --git a/jena-arq/src/main/java/org/apache/jena/riot/system/IRIResolver.java b/jena-arq/src/main/java/org/apache/jena/riot/system/IRIResolver.java
index 0f064f9..a4a1433 100644
--- a/jena-arq/src/main/java/org/apache/jena/riot/system/IRIResolver.java
+++ b/jena-arq/src/main/java/org/apache/jena/riot/system/IRIResolver.java
@@ -22,6 +22,7 @@ import java.util.concurrent.Callable ;
import org.apache.jena.atlas.lib.Cache ;
import org.apache.jena.atlas.lib.CacheFactory ;
+import org.apache.jena.atlas.lib.IRILib ;
import org.apache.jena.iri.IRI ;
import org.apache.jena.iri.IRIException ;
import org.apache.jena.iri.IRIFactory ;
http://git-wip-us.apache.org/repos/asf/jena/blob/57aa6abc/jena-arq/src/main/java/org/apache/jena/riot/system/stream/LocatorFile.java
----------------------------------------------------------------------
diff --git a/jena-arq/src/main/java/org/apache/jena/riot/system/stream/LocatorFile.java b/jena-arq/src/main/java/org/apache/jena/riot/system/stream/LocatorFile.java
index da34c6d..984846a 100644
--- a/jena-arq/src/main/java/org/apache/jena/riot/system/stream/LocatorFile.java
+++ b/jena-arq/src/main/java/org/apache/jena/riot/system/stream/LocatorFile.java
@@ -24,10 +24,10 @@ import java.io.InputStream ;
import java.security.AccessControlException ;
import org.apache.jena.atlas.io.IO ;
+import org.apache.jena.atlas.lib.IRILib ;
import org.apache.jena.atlas.web.ContentType ;
import org.apache.jena.atlas.web.TypedInputStream ;
import org.apache.jena.riot.RDFLanguages ;
-import org.apache.jena.riot.system.IRILib ;
import org.apache.jena.util.FileUtils ;
import org.slf4j.Logger ;
import org.slf4j.LoggerFactory ;
http://git-wip-us.apache.org/repos/asf/jena/blob/57aa6abc/jena-arq/src/main/java/org/apache/jena/sparql/expr/nodevalue/XSDFuncOp.java
----------------------------------------------------------------------
diff --git a/jena-arq/src/main/java/org/apache/jena/sparql/expr/nodevalue/XSDFuncOp.java b/jena-arq/src/main/java/org/apache/jena/sparql/expr/nodevalue/XSDFuncOp.java
index e42dddf..439948a 100644
--- a/jena-arq/src/main/java/org/apache/jena/sparql/expr/nodevalue/XSDFuncOp.java
+++ b/jena-arq/src/main/java/org/apache/jena/sparql/expr/nodevalue/XSDFuncOp.java
@@ -44,6 +44,7 @@ import javax.xml.datatype.DatatypeConstants.Field ;
import javax.xml.datatype.Duration ;
import javax.xml.datatype.XMLGregorianCalendar ;
+import org.apache.jena.atlas.lib.IRILib ;
import org.apache.jena.atlas.lib.StrUtils ;
import org.apache.jena.atlas.logging.Log ;
import org.apache.jena.datatypes.RDFDatatype ;
@@ -51,7 +52,6 @@ import org.apache.jena.datatypes.xsd.XSDDatatype ;
import org.apache.jena.datatypes.xsd.XSDDateTime ;
import org.apache.jena.graph.Node ;
import org.apache.jena.graph.NodeFactory ;
-import org.apache.jena.riot.system.IRILib ;
import org.apache.jena.sparql.ARQInternalErrorException ;
import org.apache.jena.sparql.SystemARQ ;
import org.apache.jena.sparql.expr.* ;
http://git-wip-us.apache.org/repos/asf/jena/blob/57aa6abc/jena-arq/src/main/java/org/apache/jena/web/DatasetGraphAccessorHTTP.java
----------------------------------------------------------------------
diff --git a/jena-arq/src/main/java/org/apache/jena/web/DatasetGraphAccessorHTTP.java b/jena-arq/src/main/java/org/apache/jena/web/DatasetGraphAccessorHTTP.java
index 511f2a1..b2781b9 100644
--- a/jena-arq/src/main/java/org/apache/jena/web/DatasetGraphAccessorHTTP.java
+++ b/jena-arq/src/main/java/org/apache/jena/web/DatasetGraphAccessorHTTP.java
@@ -26,6 +26,7 @@ import org.apache.http.client.methods.HttpHead ;
import org.apache.http.client.methods.HttpUriRequest ;
import org.apache.http.entity.ContentProducer ;
import org.apache.http.entity.EntityTemplate ;
+import org.apache.jena.atlas.lib.IRILib ;
import org.apache.jena.atlas.web.HttpException ;
import org.apache.jena.atlas.web.auth.HttpAuthenticator ;
import org.apache.jena.atlas.web.auth.SimpleAuthenticator ;
@@ -34,7 +35,6 @@ import org.apache.jena.graph.Node ;
import org.apache.jena.riot.RDFDataMgr ;
import org.apache.jena.riot.RDFFormat ;
import org.apache.jena.riot.WebContent ;
-import org.apache.jena.riot.system.IRILib ;
import org.apache.jena.riot.web.* ;
import org.apache.jena.shared.JenaException ;
http://git-wip-us.apache.org/repos/asf/jena/blob/57aa6abc/jena-arq/src/test/java/org/apache/jena/atlas/lib/TS_Lib.java
----------------------------------------------------------------------
diff --git a/jena-arq/src/test/java/org/apache/jena/atlas/lib/TS_Lib.java b/jena-arq/src/test/java/org/apache/jena/atlas/lib/TS_Lib.java
index 8d6e0cd..21c4d7c 100644
--- a/jena-arq/src/test/java/org/apache/jena/atlas/lib/TS_Lib.java
+++ b/jena-arq/src/test/java/org/apache/jena/atlas/lib/TS_Lib.java
@@ -45,6 +45,9 @@ import org.junit.runners.Suite ;
, TestRefLong.class
, TestReverseComparator.class
, TestTrie.class
+ , TestFilenameProcessing.class
+ , TestMultiSet.class
+ , TestNumberUtils.class
} )
public class TS_Lib
http://git-wip-us.apache.org/repos/asf/jena/blob/57aa6abc/jena-arq/src/test/java/org/apache/jena/atlas/lib/TestFilenameProcessing.java
----------------------------------------------------------------------
diff --git a/jena-arq/src/test/java/org/apache/jena/atlas/lib/TestFilenameProcessing.java b/jena-arq/src/test/java/org/apache/jena/atlas/lib/TestFilenameProcessing.java
index 4a84759..7782c55 100644
--- a/jena-arq/src/test/java/org/apache/jena/atlas/lib/TestFilenameProcessing.java
+++ b/jena-arq/src/test/java/org/apache/jena/atlas/lib/TestFilenameProcessing.java
@@ -21,7 +21,6 @@ package org.apache.jena.atlas.lib;
import java.io.File ;
import org.apache.jena.atlas.junit.BaseTest ;
-import org.apache.jena.riot.system.IRILib ;
import org.junit.Test ;
public class TestFilenameProcessing extends BaseTest
@@ -38,6 +37,41 @@ public class TestFilenameProcessing extends BaseTest
// Without trailing slash.
static { cwd = cwd.substring(0, cwd.length()-2) ; }
+ @Test public void fileIRI_1()
+ {
+ String uri = testFileIRI("D.ttl") ;
+ assertTrue(uri.endsWith("D.ttl")) ;
+ }
+
+ @Test public void fileIRI_2()
+ {
+ String uri = testFileIRI("file:/D.ttl") ;
+ assertTrue(uri.endsWith("D.ttl")) ;
+ }
+
+ @Test public void fileIRI_3()
+ {
+ String uri = testFileIRI("file://D.ttl") ;
+ assertTrue(uri.endsWith("D.ttl")) ;
+ }
+
+ @Test public void fileIRI_4()
+ {
+ String iri = testFileIRI("file:///D.ttl") ;
+ // Even on windows, this is used as-is so no drive letter.
+ assertEquals("file:///D.ttl", iri) ;
+ }
+
+ private static String testFileIRI(String fn)
+ {
+ String uri1 = IRILib.filenameToIRI(fn) ;
+ assertTrue(uri1.startsWith("file:///")) ;
+ String uri2 = IRILib.filenameToIRI(uri1) ;
+ assertEquals(uri1, uri2) ;
+ return uri1 ;
+ }
+
+
@Test public void fileURL_1() { assertNotEquals(cwd, "") ; assertNotNull(cwd) ; filenameToIRI("abc", "file://"+cwd+"/abc" ) ; }
@Test public void fileURL_2() { filenameToIRI("/abc", "file:///abc" ) ; }
http://git-wip-us.apache.org/repos/asf/jena/blob/57aa6abc/jena-arq/src/test/java/org/apache/jena/atlas/lib/TestXMLLib.java
----------------------------------------------------------------------
diff --git a/jena-arq/src/test/java/org/apache/jena/atlas/lib/TestXMLLib.java b/jena-arq/src/test/java/org/apache/jena/atlas/lib/TestXMLLib.java
index 8ec78b1..cae99ef 100644
--- a/jena-arq/src/test/java/org/apache/jena/atlas/lib/TestXMLLib.java
+++ b/jena-arq/src/test/java/org/apache/jena/atlas/lib/TestXMLLib.java
@@ -22,6 +22,7 @@ import org.apache.jena.atlas.lib.XMLLib ;
import org.junit.Assert ;
import org.junit.Test ;
+/** XML related functionality */
public class TestXMLLib
{
@Test public void ws_collapse_01() { test("abc", "abc") ; }
http://git-wip-us.apache.org/repos/asf/jena/blob/57aa6abc/jena-arq/src/test/java/org/apache/jena/riot/lang/TestIRI.java
----------------------------------------------------------------------
diff --git a/jena-arq/src/test/java/org/apache/jena/riot/lang/TestIRI.java b/jena-arq/src/test/java/org/apache/jena/riot/lang/TestIRI.java
index 4f976fc..b9dfee1 100644
--- a/jena-arq/src/test/java/org/apache/jena/riot/lang/TestIRI.java
+++ b/jena-arq/src/test/java/org/apache/jena/riot/lang/TestIRI.java
@@ -27,7 +27,6 @@ import org.apache.jena.riot.ErrorHandlerTestLib.ExWarning ;
import org.apache.jena.riot.checker.CheckerIRI ;
import org.apache.jena.riot.system.Checker ;
import org.apache.jena.riot.system.ErrorHandler ;
-import org.apache.jena.riot.system.IRILib ;
import org.apache.jena.riot.system.RiotLib ;
import org.junit.Test ;
@@ -73,38 +72,4 @@ public class TestIRI extends BaseTest
assertTrue(n.isURI()) ;
assertEquals("abc", n.getURI()) ;
}
-
- @Test public void fileIRI_1()
- {
- String uri = testFileIRI("D.ttl") ;
- assertTrue(uri.endsWith("D.ttl")) ;
- }
-
- @Test public void fileIRI_2()
- {
- String uri = testFileIRI("file:/D.ttl") ;
- assertTrue(uri.endsWith("D.ttl")) ;
- }
-
- @Test public void fileIRI_3()
- {
- String uri = testFileIRI("file://D.ttl") ;
- assertTrue(uri.endsWith("D.ttl")) ;
- }
-
- @Test public void fileIRI_4()
- {
- String iri = testFileIRI("file:///D.ttl") ;
- // Even on windows, this is used as-is so no drive letter.
- assertEquals("file:///D.ttl", iri) ;
- }
-
- private static String testFileIRI(String fn)
- {
- String uri1 = IRILib.filenameToIRI(fn) ;
- assertTrue(uri1.startsWith("file:///")) ;
- String uri2 = IRILib.filenameToIRI(uri1) ;
- assertEquals(uri1, uri2) ;
- return uri1 ;
- }
}
http://git-wip-us.apache.org/repos/asf/jena/blob/57aa6abc/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/build/FusekiConfig.java
----------------------------------------------------------------------
diff --git a/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/build/FusekiConfig.java b/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/build/FusekiConfig.java
index 3729eb7..a4c0e20 100644
--- a/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/build/FusekiConfig.java
+++ b/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/build/FusekiConfig.java
@@ -32,6 +32,7 @@ import java.util.List ;
import org.apache.jena.assembler.JA ;
import org.apache.jena.atlas.iterator.Iter ;
+import org.apache.jena.atlas.lib.IRILib ;
import org.apache.jena.atlas.lib.StrUtils ;
import org.apache.jena.fuseki.Fuseki ;
import org.apache.jena.fuseki.FusekiConfigException ;
@@ -45,7 +46,6 @@ import org.apache.jena.query.QuerySolution ;
import org.apache.jena.query.ResultSet ;
import org.apache.jena.rdf.model.* ;
import org.apache.jena.riot.RDFDataMgr ;
-import org.apache.jena.riot.system.IRILib ;
import org.apache.jena.sparql.core.assembler.AssemblerUtils ;
import org.apache.jena.update.UpdateAction ;
import org.apache.jena.update.UpdateFactory ;
http://git-wip-us.apache.org/repos/asf/jena/blob/57aa6abc/jena-fuseki2/jena-fuseki-core/src/test/java/org/apache/jena/fuseki/http/TestHttpOp.java
----------------------------------------------------------------------
diff --git a/jena-fuseki2/jena-fuseki-core/src/test/java/org/apache/jena/fuseki/http/TestHttpOp.java b/jena-fuseki2/jena-fuseki-core/src/test/java/org/apache/jena/fuseki/http/TestHttpOp.java
index 0739622..b8ad9de 100644
--- a/jena-fuseki2/jena-fuseki-core/src/test/java/org/apache/jena/fuseki/http/TestHttpOp.java
+++ b/jena-fuseki2/jena-fuseki-core/src/test/java/org/apache/jena/fuseki/http/TestHttpOp.java
@@ -19,11 +19,11 @@
package org.apache.jena.fuseki.http;
import org.apache.jena.atlas.junit.BaseTest ;
+import org.apache.jena.atlas.lib.IRILib ;
import org.apache.jena.atlas.web.HttpException ;
import org.apache.jena.atlas.web.TypedInputStream ;
import org.apache.jena.fuseki.ServerTest ;
import org.apache.jena.riot.WebContent ;
-import org.apache.jena.riot.system.IRILib ;
import org.apache.jena.riot.web.HttpOp ;
import org.apache.jena.sparql.engine.http.Params ;
import org.apache.jena.web.HttpSC ;