FileDocCategorySizeDatePackage
URLResolver.javaAPI DocphoneME MR2 API (J2ME)2375Wed May 02 18:00:34 BST 2007com.sun.perseus.platform

URLResolver

public class URLResolver extends Object
This class is used to provide URL resolution.
version
$Id: URLResolver.java,v 1.4 2006/04/21 06:34:48 st125089 Exp $

Fields Summary
Constructors Summary
Methods Summary
public static java.lang.Stringresolve(java.lang.String context, java.lang.String spec)

param
contect the context URL string, also called the base URL.
param
spec the URL specification. May be a relative URL.
return
an absolute URL value.
throws
IllegalArgumentException if an absolute URL cannot be computed.

        
        try {
            if (context != null) {
                return (new PURL(new PURL(context), spec)).toString();
            } else {
                // We are dealing with a URL and we do not have a base
                // URI. Check if there is any protocol specified. If there is,
                // then we use the URL class to make the URL absolute. Otherwise,
                // we simply return the relative URL.
                if (spec.indexOf(':") != -1) {
                    return (new PURL(spec)).toString();
                } else {
                    return spec;
                }
            }
        } catch (Error e) {
            e.printStackTrace();
            throw new IllegalArgumentException();
        }