Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

org.esau.ptarmigan.util
Class HelperURL  view HelperURL download HelperURL.java

java.lang.Object
  extended byorg.esau.ptarmigan.util.HelperURL

public final class HelperURL
extends java.lang.Object

Some static methods for manipulation of URLs

Version:
$Revision: 1.3 $ $Date: 2002/10/04 11:55:43 $

Field Summary
(package private) static java.lang.String FILE_PREFIX
           
(package private) static org.apache.commons.logging.Log log
          logging object
(package private) static java.lang.String URL_ENCODING
           
 
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
 

Field Detail

URL_ENCODING

static final java.lang.String URL_ENCODING
See Also:
Constant Field Values

FILE_PREFIX

static final java.lang.String FILE_PREFIX
See Also:
Constant Field Values

log

static org.apache.commons.logging.Log log
logging object

Constructor Detail

HelperURL

public HelperURL()
Method Detail

systemIdToFile

public static java.io.File systemIdToFile(java.lang.String system_id)

fileToSystemId

public static java.lang.String fileToSystemId(java.io.File file)
                                       throws java.net.MalformedURLException

URLToFile

public static java.io.File URLToFile(java.lang.String s_url)
                              throws java.io.IOException,
                                     java.net.MalformedURLException
extract a File object from a UTF-8-encoded URL if the URL has a file protocol.

Useful for system_ids that specify local sources. BROKEN: may not handle # in filenames


URLToFile

public static java.io.File URLToFile(java.net.URL url)
                              throws java.io.IOException
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.


toURL

public static java.net.URL toURL(java.io.File file)
                          throws java.net.MalformedURLException,
                                 java.io.IOException
produce a UTF-8 encoded URL from a File source


toURL

public static java.net.URL toURL(java.io.File base_dir,
                                 java.lang.String file_or_url)
                          throws java.net.MalformedURLException,
                                 java.io.IOException
produce a UTF-8 encoded URL from various formats.

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.mp3
 
to
   file:/C:/Billie Holiday/Body and Soul/01%20-%20Body%20And%20Soul.mp3
 


maybeDecode

public static java.lang.String maybeDecode(java.lang.String may_be_coded)
                                    throws java.text.ParseException
If the specified string contains only ASCII characters, then try to escape any UTF-8 characters present.

This is tolerant of bad coding and will return null if decoding was not done.