More information


de.spieleck.net
Class URLTools

java.lang.Object
  |
  +--de.spieleck.net.URLTools

public class URLTools
extends java.lang.Object

XXX This is work in progress, i.e. works as long as needed so far. Part of below code has been modified from Suns JDK Sources :-( Static methods to help certain problems with urls. Some of these are rather special String functions than actually working with the datatype URL.


Field Summary
static java.lang.String defaultEncoding
          Default assumption for urlDecode (XXX should be use UTF-8?)
protected static java.util.BitSet dontNeedEncoding
           
protected static java.lang.String FILEPROTO
           
protected static int MAXBYTESPERCHAR
           
 
Method Summary
static java.lang.String decode(java.lang.String s)
          Decode String from application/x-www-form-urlencoded to regular Java encoding.
static java.lang.String decode(java.lang.String s, java.lang.String enc)
          Decodes a application/x-www-form-urlencoded to regular Java encoding with specified URL encoding.
static java.lang.String encode(java.lang.String s)
           
static java.lang.String encodeQueryString(java.lang.String s)
          Currently a quick hack to encode certain special characters in a URL's querystring part.
static java.lang.String getFileString(java.lang.String url)
          Alternative call with String Argument
static java.lang.String getFileString(java.net.URL url)
          XXX method to obtain the absolut path of a file-url. this method is necessary due to a missing constructor File(URL url) in java.io.File (JDK1.3.1)
static java.net.URL toURL(java.lang.String fname)
          Ugly method for the hopefully most compatible way to create a URI-String from a local file identifier.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

defaultEncoding

public static java.lang.String defaultEncoding
Default assumption for urlDecode (XXX should be use UTF-8?)

FILEPROTO

protected static final java.lang.String FILEPROTO

MAXBYTESPERCHAR

protected static int MAXBYTESPERCHAR

dontNeedEncoding

protected static java.util.BitSet dontNeedEncoding
Method Detail

encode

public static java.lang.String encode(java.lang.String s)

encodeQueryString

public static java.lang.String encodeQueryString(java.lang.String s)
Currently a quick hack to encode certain special characters in a URL's querystring part. XXX Read the RFC's and do it the right way.

toURL

public static java.net.URL toURL(java.lang.String fname)
                          throws java.net.MalformedURLException
Ugly method for the hopefully most compatible way to create a URI-String from a local file identifier. Is similar to java.io.File.toURL in JDK1.2+

getFileString

public static java.lang.String getFileString(java.net.URL url)
XXX method to obtain the absolut path of a file-url. this method is necessary due to a missing constructor File(URL url) in java.io.File (JDK1.3.1)

getFileString

public static java.lang.String getFileString(java.lang.String url)
Alternative call with String Argument

decode

public static java.lang.String decode(java.lang.String s)
Decode String from application/x-www-form-urlencoded to regular Java encoding.

decode

public static java.lang.String decode(java.lang.String s,
                                      java.lang.String enc)
                               throws java.io.UnsupportedEncodingException
Decodes a application/x-www-form-urlencoded to regular Java encoding with specified URL encoding.
Parameters:
s - the String to decode
enc - The name of a supported encoding.
Returns:
the newly decoded String
Throws:
java.io.UnsupportedEncodingException - If the named encoding is not supported

More information