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 2018/01/15 11:48:08 UTC
[03/10] jena git commit: Deprecate FileUtils.toURL
Deprecate FileUtils.toURL
Project: http://git-wip-us.apache.org/repos/asf/jena/repo
Commit: http://git-wip-us.apache.org/repos/asf/jena/commit/a8c99ff7
Tree: http://git-wip-us.apache.org/repos/asf/jena/tree/a8c99ff7
Diff: http://git-wip-us.apache.org/repos/asf/jena/diff/a8c99ff7
Branch: refs/heads/master
Commit: a8c99ff7a095b473a756f6709fdb5803e42f625e
Parents: ed34030
Author: Andy Seaborne <an...@apache.org>
Authored: Sat Jan 13 17:15:15 2018 +0000
Committer: Andy Seaborne <an...@apache.org>
Committed: Sat Jan 13 17:15:15 2018 +0000
----------------------------------------------------------------------
.../main/java/org/apache/jena/util/FileUtils.java | 15 ++++++++++-----
.../java/org/apache/jena/util/TestFileUtils.java | 3 ++-
2 files changed, 12 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/jena/blob/a8c99ff7/jena-core/src/main/java/org/apache/jena/util/FileUtils.java
----------------------------------------------------------------------
diff --git a/jena-core/src/main/java/org/apache/jena/util/FileUtils.java b/jena-core/src/main/java/org/apache/jena/util/FileUtils.java
index 046d7dc..9c6473f 100644
--- a/jena-core/src/main/java/org/apache/jena/util/FileUtils.java
+++ b/jena-core/src/main/java/org/apache/jena/util/FileUtils.java
@@ -177,23 +177,28 @@ public class FileUtils
return sbuff.toString();
}
-
- /** Turn a plain filename into a "file:" URL */
+ /** Turn a plain filename into a "file:" URL
+ * Use IRILib.filenameToIRI
+ * This remains only for legacy compatibility.
+ */
+ @Deprecated
public static String toURL(String filename)
{
if ( filename.length()>5
&& filename.substring(0,5).equalsIgnoreCase("file:") )
return filename ;
+ if ( filename.equals(".") )
+ filename = "" ;
+
/**
- * Convert a File, note java.net.URI appears to do the right thing.
+ * Convert a File, note java.net.URI does the right thing.
* viz:
* Convert to absolute path.
* Convert all % to %25.
* then convert all ' ' to %20.
* It quite probably does more e.g. ? #
- * But has bug in only having one / not three at beginning
-
+ * But has one /, not three, at beginning
*/
return "file://" + new File(filename).toURI().toString().substring(5);
}
http://git-wip-us.apache.org/repos/asf/jena/blob/a8c99ff7/jena-core/src/test/java/org/apache/jena/util/TestFileUtils.java
----------------------------------------------------------------------
diff --git a/jena-core/src/test/java/org/apache/jena/util/TestFileUtils.java b/jena-core/src/test/java/org/apache/jena/util/TestFileUtils.java
index e800d30..b78b810 100644
--- a/jena-core/src/test/java/org/apache/jena/util/TestFileUtils.java
+++ b/jena-core/src/test/java/org/apache/jena/util/TestFileUtils.java
@@ -213,7 +213,8 @@ public class TestFileUtils extends TestCase {
checkToURL("ü","ü");
}
private void checkToURL(String fn, String match) {
- String r = FileUtils.toURL(fn);
+ @SuppressWarnings("deprecation")
+ String r = FileUtils.toURL(fn);
if (!r.matches("^.*/[^/]*" + match + "[^/]*$"))
fail("Converted \"" + fn + "\" to <" + r
+ "> which did not match /" + match + "/");