|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.esau.ptarmigan.util.HelperURL
Some static methods for manipulation of URLs
Constructor Summary | |
HelperURL()
|
Method Summary | |
static java.lang.String |
fileToSystemId(java.io.File file)
|
static java.lang.String |
maybeDecode(java.lang.String may_be_coded)
If the specified string contains only ASCII characters, then try to escape any UTF-8 characters present. |
static java.io.File |
systemIdToFile(java.lang.String system_id)
|
static java.net.URL |
toURL(java.io.File file)
produce a UTF-8 encoded URL from a File source |
static java.net.URL |
toURL(java.io.File base_dir,
java.lang.String file_or_url)
produce a UTF-8 encoded URL from various formats. |
static java.io.File |
URLToFile(java.lang.String s_url)
extract a File object from a UTF-8-encoded URL if the URL has a file protocol. |
static java.io.File |
URLToFile(java.net.URL url)
extract a File object from a UTF-8-encoded URL if the URL has a file protocol requires URIUtil from Jakarta Common's HttpClient NOTE: if truncation is occurring, it's probably because the URL wasn't encoded in UTF-8. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public HelperURL()
Method Detail |
public static java.io.File systemIdToFile(java.lang.String system_id)
public static java.lang.String fileToSystemId(java.io.File file) throws java.net.MalformedURLException
public static java.io.File URLToFile(java.lang.String s_url) throws java.io.IOException, java.net.MalformedURLException
Useful for system_ids that specify local sources. BROKEN: may not handle # in filenames
s_url
- that is prefixed by "file:" and represents a local filejava.net.MalformedURLException
- if there's some other problem building the URLpublic static java.io.File URLToFile(java.net.URL url) throws java.io.IOException
url
- java.io.IOException
- public static java.net.URL toURL(java.io.File file) throws java.net.MalformedURLException, java.io.IOException
public static java.net.URL toURL(java.io.File base_dir, java.lang.String file_or_url) throws java.net.MalformedURLException, java.io.IOException
A path in a playlist may be of many different formats. Here we try to figure out which one and assign to a URL.
Convert
C:\Billie Holiday\Body and Soul\01 - Body And Soul.mp3 file:C:\Billie Holiday\Body and Soul\01 - Body And Soul.mp3 file:/C:\Billie Holiday\Body and Soul\01 - Body And Soul.mp3 file:/C%3A\Billie Holiday\Body and Soul\01 - Body And Soul.mp3to
file:/C:/Billie Holiday/Body and Soul/01%20-%20Body%20And%20Soul.mp3
base_dir
- File
the directory to be used with relative file pathsfile_or_url
- String
the url or file path that needs to be resolvedjava.net.MalformedURLException
- java.io.IOException
- public static java.lang.String maybeDecode(java.lang.String may_be_coded) throws java.text.ParseException
This is tolerant of bad coding and will return null if decoding was not done.
java.text.ParseException
- if decoding failed
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |