Provide better support for filenames with spaces in resource URL
----------------------------------------------------------------

                 Key: UIMA-132
                 URL: http://issues.apache.org/jira/browse/UIMA-132
             Project: UIMA
          Issue Type: Improvement
          Components: Core Java Framework
            Reporter: Adam Lally
         Assigned To: Adam Lally
            Priority: Minor
             Fix For: 2.1


The UimaContext.getResourceURL() method is difficult to use correctly.  It is 
tempting for users to write code such as:
        URL url = getContext().getResourceURL(key);
        FileReader fr = new FileReader(url.getPath());

which is not safe since the URL can contain spaces encoded as %20, and the 
url.getPath() does not automatically decode them.

We should add the alternative methods and appropriate JavaDoc comments guiding 
the user toward the appropriate method:
URI getResourceURI() -- this works better because URI.getPath() *does* do 
decoding.
String getResourceFilePath() -- if the URL is a "file:" URL, return its decoded 
path, otherwise throw an exception (e.g., for an "http" URL)

Additionally, it would be nice if we supported filenames (without the file: 
prefix) in the <fileUrl> descriptor element, for example:
<fileUrl>c:/program files/myproj/myfile.txt</fileUrl>

Currently this gives a MalformedUrlException, but it would be helpful for the 
framework to detect that exception and try appending "file:/" to see if that 
makes a valid URL.


-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Reply via email to