Multivalent API

phelps.net
Class URIs

java.lang.Object
  extended by phelps.net.URIs

public class URIs
extends java.lang.Object

URI-related utility classes.

Version:
$Revision: 1.5 $ $Date: 2005/01/02 07:57:11 $

Method Summary
static java.net.URI canonicalize(java.net.URI uri)
          Canonicalizes URI
static java.lang.String decode(java.lang.String s)
          Like URLDecoder but without the hassle.
static java.lang.String encode(java.lang.String s)
          Like URLEncoder but without the hassle.
static java.lang.String fix(java.lang.String s)
          Fixes up alleged URIs to be acceptable to the strict parsing of URI.
static java.net.URL toURL(java.net.URI uri)
          With toURL(URI), safe interconversion between URI and URL, working around Java bugs.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

encode

public static java.lang.String encode(java.lang.String s)
Like URLEncoder but without the hassle. Java's URLEncode and URLDecode are too complicated. First, they are separate classes of one method each, whereas they should both be stuffed in java.net.URL or java.net.URI. Second, starting in Java 1.4, you have to explicitly supply "UTF-8" in order to meet the W3C's recommendation, which is a hassle, and you have to catch "UnsupportedEncodingException", which should never happen. Bah!


decode

public static java.lang.String decode(java.lang.String s)
Like URLDecoder but without the hassle.


fix

public static java.lang.String fix(java.lang.String s)
Fixes up alleged URIs to be acceptable to the strict parsing of URI. In practice browsers have to be robust against invalid URIs.
  • convert Netscape syntax for Windows drive letters to Java syntax -->


  • canonicalize

    public static java.net.URI canonicalize(java.net.URI uri)
    Canonicalizes URI.


    toURL

    public static java.net.URL toURL(java.net.URI uri)
                              throws java.net.MalformedURLException
    With toURL(URI), safe interconversion between URI and URL, working around Java bugs.

    Throws:
    java.net.MalformedURLException

    Multivalent API