Author: schor
Date: Wed Sep 15 21:20:39 2010
New Revision: 997507
URL: http://svn.apache.org/viewvc?rev=997507&view=rev
Log:
[UIMA-1748] Applied idea of patch, based on last comment - using url.toURI()
Modified:
uima/sandbox/trunk/BSFAnnotator/src/main/java/org/apache/uima/annotator/bsf/BSFAnnotator.java
Modified:
uima/sandbox/trunk/BSFAnnotator/src/main/java/org/apache/uima/annotator/bsf/BSFAnnotator.java
URL:
http://svn.apache.org/viewvc/uima/sandbox/trunk/BSFAnnotator/src/main/java/org/apache/uima/annotator/bsf/BSFAnnotator.java?rev=997507&r1=997506&r2=997507&view=diff
==============================================================================
---
uima/sandbox/trunk/BSFAnnotator/src/main/java/org/apache/uima/annotator/bsf/BSFAnnotator.java
(original)
+++
uima/sandbox/trunk/BSFAnnotator/src/main/java/org/apache/uima/annotator/bsf/BSFAnnotator.java
Wed Sep 15 21:20:39 2010
@@ -23,6 +23,8 @@ import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.Reader;
+import java.net.URI;
+import java.net.URISyntaxException;
import java.net.URL;
import java.net.URLClassLoader;
import java.util.ArrayList;
@@ -187,21 +189,29 @@ public class BSFAnnotator extends JCasAn
URL url;
// try to use the class loader to load the file resource
if ((url =
this.getClass().getClassLoader().getResource(fileName)) != null) {
- return new File(url.getFile());
- } else {
- if (datapathElements == null || datapathElements.size()
== 0) {
- return null;
- }
- // try to use the datapath to load the file resource
- for (File dataPathDir : datapathElements) {
- File testFile = new File(dataPathDir, fileName);
- if (testFile.exists()) {
- return testFile;
- }
+ URI uri;
+ try {
+ // handle urls with embedded blanks, coded as %20
+ // https://issues.apache.org/jira/browse/UIMA-1748
+ uri = url.toURI();
+ } catch (URISyntaxException e) {
+ uri = null;
+ }
+ if (uri != null) {
+ return new File(uri);
+ }
+ }
+ if (datapathElements == null || datapathElements.size() == 0) {
+ return null;
+ }
+ // try to use the datapath to load the file resource
+ for (File dataPathDir : datapathElements) {
+ File testFile = new File(dataPathDir, fileName);
+ if (testFile.exists()) {
+ return testFile;
}
}
return null;
-
}
/**
* @param urls