You are viewing a plain text version of this content. The canonical link for it is here.
Posted to slide-dev@jakarta.apache.org by je...@apache.org on 2001/04/07 21:53:04 UTC

cvs commit: jakarta-slide/src/webdav/client/src/org/apache/webdav/util WebdavResource.java GenericURI.java

jericho     01/04/07 12:53:04

  Modified:    src/webdav/client/src/org/apache/webdav/util
                        WebdavResource.java GenericURI.java
  Log:
  - Change the method name, getAbsPath to getAbsPathQuery
     Because the heir_path include query t, not abs_path.
  
  - Be ready for URI encoding(not doing any encoding yet).
  
  Sorry for the long commit messages.
  
  Revision  Changes    Path
  1.30      +7 -7      jakarta-slide/src/webdav/client/src/org/apache/webdav/util/WebdavResource.java
  
  Index: WebdavResource.java
  ===================================================================
  RCS file: /home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/util/WebdavResource.java,v
  retrieving revision 1.29
  retrieving revision 1.30
  diff -u -r1.29 -r1.30
  --- WebdavResource.java	2001/04/06 11:57:31	1.29
  +++ WebdavResource.java	2001/04/07 19:53:03	1.30
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/util/WebdavResource.java,v 1.29 2001/04/06 11:57:31 jericho Exp $
  - * $Revision: 1.29 $
  - * $Date: 2001/04/06 11:57:31 $
  + * $Header: /home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/util/WebdavResource.java,v 1.30 2001/04/07 19:53:03 jericho Exp $
  + * $Revision: 1.30 $
  + * $Date: 2001/04/07 19:53:03 $
    *
    * ====================================================================
    *
  @@ -1364,7 +1364,7 @@
       public boolean getMethod(File file)
           throws WebdavException, IOException {
   
  -        return getMethod(httpURL.getAbsPath(), file);
  +        return getMethod(httpURL.getAbsPathQuery(), file);
       }
   
   
  @@ -1383,7 +1383,7 @@
           WebdavClient client = WebdavSession.getSessionInstance(httpURL);
   
           // use disk to save by default
  -        GetMethod method = new GetMethod(HttpURL.getAbsPath(path), file);
  +        GetMethod method = new GetMethod(HttpURL.getAbsPathQuery(path), file);
           client.executeMethod(method);
   
           int statusCode = method.getStatusCode();
  @@ -2228,8 +2228,8 @@
               if (anotherCollection && !thisCollection)
                   return 1;
   
  -            String thisPath = httpURL.getAbsPath();
  -            String anotherPath= anotherUrl.getAbsPath();
  +            String thisPath = httpURL.getAbsPathQuery();
  +            String anotherPath= anotherUrl.getAbsPathQuery();
               return thisPath.compareTo(anotherPath);
           } catch (Exception e) {
               // FIXME: not to return 0.
  
  
  
  1.15      +236 -205  jakarta-slide/src/webdav/client/src/org/apache/webdav/util/GenericURI.java
  
  Index: GenericURI.java
  ===================================================================
  RCS file: /home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/util/GenericURI.java,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- GenericURI.java	2001/03/31 15:41:10	1.14
  +++ GenericURI.java	2001/04/07 19:53:03	1.15
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/util/GenericURI.java,v 1.14 2001/03/31 15:41:10 jericho Exp $
  - * $Revision: 1.14 $
  - * $Date: 2001/03/31 15:41:10 $
  + * $Header: /home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/util/GenericURI.java,v 1.15 2001/04/07 19:53:03 jericho Exp $
  + * $Revision: 1.15 $
  + * $Date: 2001/04/07 19:53:03 $
    *
    * ====================================================================
    *
  @@ -63,13 +63,20 @@
   
   package org.apache.webdav.util;
   
  -import java.net.URL;
   import java.net.MalformedURLException;
   
   /**
    * URI (Uniform Resource Identifiers), RFC 2396.
    * This is the generic URI version.
    *
  + * It's assumed that URI is escaped by URI encoding and processed.
  + * Care should be taken when a URL contains escaped delimiters for a
  + * given protocol that these are not unescaped before transmission.
  + * This might violate the protocol, but avoids the potential for such
  + * characters to be used to simulate an extra operation or parameter in
  + * that protocol, which might lead to an unexpected and possibly harmful
  + * remote operation to be performed.
  + *
    * @author <a href="mailto:jericho@thinkfree.com">Park, Sung-Gu</a>
    */
   public abstract class GenericURI implements java.io.Serializable {
  @@ -81,56 +88,77 @@
       /**
        * This Constructor
        *
  -     * @param uri the URI string.
  +     * @param URI The escaped URI string.
        */
  -    public GenericURI(String uri) {
  +    public GenericURI(String escapedURI) {
   
  -        if (uri.indexOf("://") > 0)
  -            this.uri = uri;
  +        if (escapedURI.indexOf("://") > 0)
  +            this.URI = escapedURI;
           else
  -            this.uri = getDefaultScheme() + "://"+ uri;
  +            this.URI = getDefaultScheme() + "://"+ escapedURI;
       }
   
   
       /**
        * This Constructor
        *
  -     * @param scheme the scheme string.
  -     * @param authority the authority string.
  -     * @param path the path string.
  +     * @param scheme The escaped scheme string.
  +     * @param authority The escaped authority string.
  +     * @param path The escaped path string.
        */
       public GenericURI(String scheme, String authority, String path) {
   
           if (!path.startsWith("/"))
               path = "/" + path;
  -        uri = scheme + "://" + authority + path;
  +        URI = scheme + "://" + authority + path;
       }
   
   
       /**
        * This Constructor
        *
  -     * @param scheme the scheme string.
  -     * @param host the host string.
  -     * @param port the port number.
  -     * @param path the path string.
  +     * @param scheme The escaped scheme string.
  +     * @param host The escaped host string.
  +     * @param port The escaped port number.
  +     * @param path The escaped path string.
        */
       public GenericURI(String scheme, String host, int port, String path) {
   
           if (!path.startsWith("/"))
               path = "/" + path;
  -        uri = (port == defaultPort) ? scheme + "://" + host + path :
  +        URI = (port == defaultPort) ? scheme + "://" + host + path :
               scheme + "://" + host + ":" + port + path;
       }
   
   
  +    /**
  +     * This Constructor
  +     *
  +     * @param scheme The escaped scheme string.
  +     * @param host The escaped host string.
  +     * @param port The escaped port number.
  +     * @param path The escaped path string.
  +     * @param query The escaped query string.
  +     */
  +    public GenericURI(String scheme, String host, int port, String path,
  +                      String query) {
  +
  +        if (!path.startsWith("/"))
  +            path = "/" + path;
  +        URI = (port == defaultPort) ?
  +            scheme + "://" + host + path + "?" + query :
  +            scheme + "://" + host + ":" + port + path + "?" + query;
  +    }
  +
  +
       // --------------------------------------------------- Instance Variables
   
   
       /**
  -     * A Uniform Resource Identifier (URI).
  +     * This Uniform Resource Identifier (URI).
  +     * The URI to be escaped must be saved and processed.
        */
  -    private String uri;
  +    private String URI;
   
   
       /**
  @@ -155,10 +183,19 @@
   
   
       /**
  -     * Get the URI string.
  +     * Get the unescaped URI string.
        */
  +    public String getUnscapedURI() {
  +        // TODO: return the unescaped URI string by URI encoding.
  +        return URI;
  +    }
  +
  +
  +    /**
  +     * Get the escaped URI string.
  +     */
       public String getURI() {
  -        return uri;
  +        return URI;
       }
   
   
  @@ -178,7 +215,7 @@
       /**
        * Get the scheme for this Generic URI.
        *
  -     * @return the scheme for this Generic URI.
  +     * @return The scheme for this Generic URI.
        */
       protected abstract String getDefaultScheme();
   
  @@ -186,7 +223,7 @@
       /**
        * Set the default port number for this generic URI.
        *
  -     * @param port the port number to set for this generic URI.
  +     * @param port The port number to set for this generic URI.
        */
       protected void setDefaultPort(int port) {
           defaultPort = port;
  @@ -196,7 +233,7 @@
       /**
        * Get the default port number for this generic URI.
        *
  -     * @return the port number to set for this generic URI.
  +     * @return The port number to set for this generic URI.
        */
       protected abstract int getDefaultPort();
   
  @@ -207,48 +244,48 @@
       /**
        * Get the scheme for this Generic URI.
        *
  -     * @return  the scheme for this Generic URI.
  +     * @return The scheme for this Generic URI.
        * @exception MalformedURLException no scheme.
        */
       public String getScheme()
           throws MalformedURLException {
   
  -        return getScheme(uri);
  +        return getScheme(URI);
       }
   
   
       /**
        * Get the scheme of the given URI string.
        *
  -     * @param uri the URI string to get the scheme.
  -     * @return the scheme of the given URI.
  +     * @param URI The URI string to get the scheme.
  +     * @return The scheme of the given URI.
        * @exception MalformedURLException no scheme.
        */
  -    public static String getScheme(String uri)
  +    public static String getScheme(String URI)
           throws MalformedURLException {
   
  -        return getScheme(uri, defaultScheme);
  +        return getScheme(URI, defaultScheme);
       }
   
   
       /**
        * Get the scheme of the given URI string.
        *
  -     * @param uri the URI string to get the scheme.
  -     * @param defaultScheme the scheme to set.
  -     * @return the scheme of the given URI.
  +     * @param URI The URI string to get the scheme.
  +     * @param defaultScheme The scheme to set.
  +     * @return The scheme of the given URI.
        * @exception MalformedURLException no scheme.
        */
  -    public static String getScheme(String uri, String defaultScheme)
  +    public static String getScheme(String URI, String defaultScheme)
           throws MalformedURLException {
   
  -        int at = uri.indexOf("://");
  +        int at = URI.indexOf("://");
           if (at > 0)
  -            return uri.substring(0, at);
  +            return URI.substring(0, at);
   
           // Check the default.
           if (defaultScheme == null)
  -            throw new MalformedURLException("No default scheme: " + uri);
  +            throw new MalformedURLException("No default scheme: " + URI);
   
           return defaultScheme;
       }
  @@ -257,122 +294,116 @@
       /**
        * Get the authority part for this generic URI.
        *
  -     * @return the authority part of this generic URI.
  +     * @return The authority part of this generic URI.
        * @exception MalformedURLException
        */
       public String getAuthority()
           throws MalformedURLException {
   
  -        return getAuthority(uri);
  +        return getAuthority(URI);
       }
   
   
       /**
  -     * Get the authority part of the given URI string.
  +     * Get the authority part of the given escaped URI string.
        *
  -     * @param uri the URI string to get the authority part.
  -     * @return the authority part of the given URI.
  +     * @param escapedURI The escaped URI string to get the authority part.
  +     * @return The authority part of the given URI.
        * @exception MalformedURLException
        */
  -    public static String getAuthority(String uri)
  +    public static String getAuthority(String escapedURI)
           throws MalformedURLException {
   
  -        int at = uri.indexOf("://");
  +        int at = escapedURI.indexOf("://");
           if (at > 0) {
               int from = at + 3;
  +            int to = escapedURI.indexOf("/", from);
   
  -            int to = uri.indexOf("/", from);
  -            if (to > 0)
  -                return uri.substring(from, to);
  -            else
  -                return uri.substring(from);
  +            return (to > 0) ? escapedURI.substring(from, to) :
  +                escapedURI.substring(from);
           } else
  -            throw new MalformedURLException("No scheme: " + uri);
  +            throw new MalformedURLException("No scheme: " + escapedURI);
       }
   
   
       /**
        * Get the userinfo part for this generic URI.
        *
  -     * @return the userifno of this generic URI.
  +     * @return The userifno of this generic URI.
        * @exception MalformedURLException
        */
       public String getUserInfo()
           throws MalformedURLException {
   
  -        return getUserInfo(uri);
  +        return getUserInfo(URI);
       }
   
   
       /**
  -     * Get the userinfo part of the given URI string.
  +     * Get the userinfo part of the given escaped URI string.
        *
  -     * @param uri the URI string to get the userinfo part.
  -     * @return the userifno of the given URI.
  +     * @param escapedURI The escaped URI string to get the userinfo part.
  +     * @return The userifno of the given URI.
        * @exception MalformedURLException
        */
  -    public static String getUserInfo(String uri)
  +    public static String getUserInfo(String escapedURI)
           throws MalformedURLException {
  -
  -        String authority = getAuthority(uri);
   
  +        String authority = getAuthority(escapedURI);
           int to = authority.indexOf("@");
  -        if (to > 0)
  -            return authority.substring(0, to);
  -        else
  -            return null;
  +
  +        return (to > 0) ? authority.substring(0, to) : null;
       }
   
   
       /**
        * Set the username and password for this URI.
        *
  -     * @param the username of URI
  -     * @param the password of URI
  +     * @param userName The escaped username string.
  +     * @param password The escaped password string.
        * @exception MalformedURLException
        */
       public void setUserInfo(String userName, String password)
           throws MalformedURLException {
  +
  +        // TODO: save the username and passsowrd by URI encoding.
   
  -       uri = getScheme() + "://" +
  +        URI = getScheme() + "://" +
               ((userName != null) ?
                userName + ((password != null) ?  ":" + password : "") + "@" : "")
  -            + getHostPort() + getAbsPath();
  -     }
  +            + getHostPort() + getAbsPathQuery();
  +    }
   
   
       /**
        * Get the username on the userinfo for this generic URI.
        *
  -     * @return the username of URI
  +     * @return The username of URI
        * @exception MalformedURLException
        * @see #getUserName(java.lang.String)
        */
       public String getUserName()
           throws MalformedURLException {
   
  -        return getUserName(uri);
  +        return getUserName(URI);
       }
   
   
       /**
        * Get the username on the userinfo of the given URI string.
        *
  -     * @param uri the URI string to get the username.
  -     * @return the username of URI
  +     * @param escapedURI the escaped URI string to get the username.
  +     * @return The username of URI
        * @exception MalformedURLException
        */
  -    public static String getUserName(String uri)
  +    public static String getUserName(String escapedURI)
           throws MalformedURLException {
   
           try {
  -            String userInfo = getUserInfo(uri);
  -
  +            String userInfo = getUserInfo(escapedURI);
               int to = userInfo.indexOf(":");
  -            if (to > 0)
  -                return userInfo.substring(0, to);
  -            else
  -                return userInfo;
  +
  +            return (to > 0) ? userInfo.substring(0, to) : userInfo;
           } catch (NullPointerException npe) {
               // No userinfo
               return null;
  @@ -383,34 +414,31 @@
       /**
        * Get the password on the userinfo for this URI string.
        *
  -     * @return the password of URI
  +     * @return The password of URI
        * @exception MalformedURLException
        */
       public String getPassword()
           throws MalformedURLException {
   
  -        return getPassword(uri);
  +        return getPassword(URI);
       }
   
   
       /**
        * Get the password on the userinfo of the given URI string.
        *
  -     * @param uri the URI string to get the password.
  -     * @return the password of URI
  +     * @param escapedURI The escaped URI string to get the password.
  +     * @return The password of URI
        * @exception MalformedURLException
        */
  -    public static String getPassword(String uri)
  +    public static String getPassword(String escapedURI)
           throws MalformedURLException {
   
           try {
  -            String userInfo = getUserInfo(uri);
  -
  +            String userInfo = getUserInfo(escapedURI);
               int at = userInfo.indexOf(":");
  -            if (at >= 0)
  -                return userInfo.substring(at + 1);
  -            else
  -                return null;
  +
  +            return (at >= 0) ? userInfo.substring(at + 1) : null;
           } catch (NullPointerException npe) {
               // No userinfo
               return null;
  @@ -421,33 +449,30 @@
       /**
        * Get the hostport part for this generic URI.
        *
  -     * @return the hostport string of the URI
  +     * @return The hostport string
        * @exception MalformedURLException
        */
       public String getHostPort()
           throws MalformedURLException {
   
  -        return getHostPort(uri);
  +        return getHostPort(URI);
       }
   
   
       /**
        * Get the hostport part of the given URI string.
        *
  -     * @param uri the URI string to get the hostport part.
  -     * @return the hostport of URI
  +     * @param escapedURI The escaped URI string to get the hostport part.
  +     * @return The hostport
        * @exception MalformedURLException
        */
  -    public static String getHostPort(String uri)
  +    public static String getHostPort(String escapedURI)
           throws MalformedURLException {
  -
  -        String authority = getAuthority(uri);
   
  +        String authority = getAuthority(escapedURI);
           int at = authority.indexOf("@");
  -        if (at > 0)
  -            return authority.substring(at + 1);
  -        else
  -            return authority;
  +
  +        return (at > 0) ? authority.substring(at + 1) : authority;
       }
   
   
  @@ -460,21 +485,21 @@
       public String getHost()
           throws MalformedURLException {
   
  -        return getHost(uri);
  +        return getHost(URI);
       }
   
   
       /**
        * Get the hostname of the given URI string.
        *
  -     * @param uri the URI string to get the hostname.
  +     * @param escapedURI The escaped URI string to get the hostname.
        * @return The hostname string
        * @exception MalformedURLException
        */
  -    public static String getHost(String uri)
  +    public static String getHost(String escapedURI)
           throws MalformedURLException {
   
  -        String hostPort = getHostPort(uri);
  +        String hostPort = getHostPort(escapedURI);
           int to = hostPort.indexOf(":");
           if (to > 0)
               return hostPort.substring(0, to);
  @@ -492,36 +517,36 @@
       public int getPort()
           throws MalformedURLException {
   
  -        return getPort(uri);
  +        return getPort(URI);
       }
   
   
       /**
        * Get the port number for this generic URI.
        *
  -     * @param uri the URI string to get the port number.
  +     * @param escapedURI The escaped URI string to get the port number.
        * @return The port number
        * @exception MalformedURLException
        */
  -    public static int getPort(String uri)
  +    public static int getPort(String escapedURI)
           throws MalformedURLException {
   
  -        return getPort(uri, defaultPort);
  +        return getPort(escapedURI, defaultPort);
       }
   
   
       /**
        * Get the port number of the given URI string.
        *
  -     * @param uri the URI string to get the port number.
  +     * @param escapedURI the escaped URI string to get the port number.
        * @param defaultPort the default port for the given URI.
        * @return The port number
        * @exception MalformedURLException
        */
  -    public static int getPort(String uri, int defaultPort)
  +    public static int getPort(String escapedURI, int defaultPort)
           throws MalformedURLException {
   
  -        String hostPort = getHostPort(uri);
  +        String hostPort = getHostPort(escapedURI);
           int at = hostPort.indexOf(":");
           if (at > 0) {
               String port = hostPort.substring(at + 1);
  @@ -535,7 +560,7 @@
           }
   
           if (defaultPort == -1)
  -            throw new MalformedURLException("No default port: " + uri);
  +            throw new MalformedURLException("No default port: " + escapedURI);
   
           // The default port number.
           return defaultPort;
  @@ -543,89 +568,91 @@
   
   
       /**
  -     * Get the net_path of the given URI string.
  -     * The net_path consists of the net_loc and abs_path.
  +     * Get the net_path and query of the given escaped URI string.
  +     * The methods returns the net_loc and abs_path.
        *
  -     * @return the nel_path.
  +     * @return the nel_path and query.
        */
  -    public String getNetPath() {
  -        return getNetPath(uri.toString());
  +    public String getNetPathQuery() {
  +        return getNetPathQuery(URI.toString());
       }
   
   
       /**
  -     * Get the net_path of the given URI string.
  -     * The net_path consists of the net_loc and abs_path.
  +     * Get the net_path and query of the given escaped URI string.
  +     * The methods returns the net_loc and abs_path.
        *
  -     * @param uri the specified URI string.
  -     * @return the net_path.
  +     * @param escapedURI the specified URI string.
  +     * @return the net_path and query.
        */
  -    public static String getNetPath(String uri) {
  +    public static String getNetPathQuery(String escapedURI) {
           // consider of net_path
  -        int from = uri.indexOf("//");
  +        int from = escapedURI.indexOf("//");
           // Ignore the authority part of URI
  -        int to = uri.length();
  +        int to = escapedURI.length();
           // Ignore the '?' mark so to ignore the query.
           // check the fragment
  -        if (uri.indexOf("#") > from)
  -            to = uri.indexOf("#");
  +        if (escapedURI.indexOf("#") > from)
  +            to = escapedURI.indexOf("#");
           // get only the path.
  -        uri = (from >= 0) ? uri.substring(from, to) : null;
  +        escapedURI = (from >= 0) ? escapedURI.substring(from, to) : null;
   
  -        return uri;
  +        return escapedURI;
       }
   
   
       /**
  -     * Get the abs_path for this generic URI.
  -     * The abs_path includes the query.
  -     * This method ignores the scheme and authority part of the URI path.
  +     * Get the abs_path and query for this generic URI.
  +     * This method just ignores the scheme and authority part of the URI path.
  +     * So this method doesn't throw any exception.
        *
  -     * @return the abs_path.
  +     * @return the escaped abs_path and query.
        */
  -    public String getAbsPath() {
  -        return getAbsPath(uri.toString());
  +    public String getAbsPathQuery() {
  +        return getAbsPathQuery(URI);
       }
   
   
       /**
  -     * Get the abs_path of the given URI string.
  -     * The abs_path includes the query.
  -     * This method ignores the scheme and authority part of the URI path.
  +     * Get the abs_path and query of the escaped given URI string.
  +     * This method just ignores the scheme and authority part of the URI path.
  +     * So this method doesn't throw any exception.
        *
  -     * @param uri the specified URI string.
  -     * @return the abs_path.
  +     * @param escapedURI the specified escaped URI string.
  +     * @return the escaped abs_path and query.
        */
  -    public static String getAbsPath(String uri) {
  +    public static String getAbsPathQuery(String escapedURI) {
   
           // consider of net_path
  -        int at = uri.indexOf("//");
  -        int from = uri.indexOf("/", (at >= 0) ? at + 2 : 0);
  +        int at = escapedURI.indexOf("//");
  +        int from = escapedURI.indexOf("/", (at >= 0) ? at + 2 : 0);
           // Ignore the authority part of URI
  -        int to = uri.length();
  +        int to = escapedURI.length();
           // Ignore the '?' mark so to ignore the query.
           // check the fragment
  -        if (uri.indexOf("#") > from)
  -            to = uri.indexOf("#");
  +        if (escapedURI.indexOf("#") > from)
  +            to = escapedURI.indexOf("#");
           // get only the wanted path.
  -        uri = (from >= 0) ? uri.substring(from, to) : "/";
  +        escapedURI = (from >= 0) ? escapedURI.substring(from, to) : "/";
   
  -        return uri;
  +        return escapedURI;
      }
   
   
       /**
        * Set the path for this generic URI.
        *
  -     * @return the path.
  +     * @return The specified path.
        * @exception MalformedURLException
        */
       public void setPath(String path)
           throws MalformedURLException {
   
  +        // TODO: save the path by URI encoding.
  +
           if (!path.startsWith("/"))
               path = "/" + path;
  -        uri = getScheme() + "://" + getAuthority() + path;
  +        URI = getScheme() + "://" + getAuthority() + path;
       }
   
   
  @@ -636,34 +663,34 @@
        * @return the path.
        */
       public String getPath() {
  -        return getPath(uri.toString());
  +        return getPath(URI);
       }
   
   
       /**
  -     * Get the path of the given URI string.
  +     * Get the path of the given escaped URI string.
        * This method ignores the scheme and authority part of the URI path.
        *
  -     * @param uri the specified URI string.
  +     * @param escapedURI The specified escaped URI string.
        * @return the path.
        */
  -    public static String getPath(String uri) {
  +    public static String getPath(String escapedURI) {
   
           // consider of net_path
  -        int at = uri.indexOf("//");
  -        int from = uri.indexOf("/", (at >= 0) ? at + 2 : 0);
  +        int at = escapedURI.indexOf("//");
  +        int from = escapedURI.indexOf("/", (at >= 0) ? at + 2 : 0);
           // Ignore the authority part of URI
  -        int to = uri.length();
  +        int to = escapedURI.length();
           // check the query
  -        if (uri.indexOf("?") > from)
  -            to = uri.indexOf("?");
  +        if (escapedURI.indexOf("?") > from)
  +            to = escapedURI.indexOf("?");
           // check the fragment
  -        if (uri.indexOf("#") > from && uri.indexOf("#") < to)
  -            to = uri.indexOf("#");
  +        if (escapedURI.indexOf("#") > from && escapedURI.indexOf("#") < to)
  +            to = escapedURI.indexOf("#");
           // get only the path.
  -        uri = (from >= 0) ? uri.substring(from, to) : "/";
  +        escapedURI = (from >= 0) ? escapedURI.substring(from, to) : "/";
   
  -        return uri;
  +        return escapedURI;
       }
   
   
  @@ -675,7 +702,7 @@
        */
       public String getParent() {
   
  -        return getParent(uri);
  +        return getParent(URI);
       }
   
   
  @@ -683,12 +710,12 @@
        * Get the parent path of the given already-normalized path.
        * This method ignores the forward part of the URI path.
        *
  -     * @param path A path string.
  +     * @param escapedPath The specified escaped path string.
        * @return The parent path of the given already-normalized path.
        */
  -    public static String getParent(String path) {
  +    public static String getParent(String escapedPath) {
   
  -        String pathname = getPath(path);
  +        String pathname = getPath(escapedPath);
   
           if (pathname.endsWith("/")) {
               int at = pathname.lastIndexOf("/");
  @@ -713,21 +740,21 @@
        * @return The resource or collection name string for this generic URI.
        */
       public String getName() {
  -        return getName(uri);
  +        return getName(URI);
       }
   
   
       /**
        * Get the resource or collection name of the already-normalized path.
        *
  -     * @param path the already-normalized path.
  -     * @return the collection name, if the path is a collection,
  -     *         the resource name, if the path is a resource.
  +     * @param escapedPath The already-normalized path.
  +     * @return The collection name, if the path is a collection,
  +     *         The resource name, if the path is a resource.
        */
  -    public static String getName(String path) {
  +    public static String getName(String escapedPath) {
   
           // Return a string starting with the '/' charcater.
  -        String name = getPath(path);
  +        String name = getPath(escapedPath);
           // For the root path.
           if (name.equals("/"))
               return name;
  @@ -742,13 +769,13 @@
        * Get the query for this generic URI.
        * This method ignores the scheme and authority part for this generic URI.
        *
  -     * @return the query string.
  +     * @return The query string.
        * @exception MalformedURLException
        */
       public String getQuery()
           throws MalformedURLException {
   
  -        return getQuery(uri);
  +        return getQuery(URI);
       }
   
   
  @@ -756,25 +783,28 @@
        * Get the query of the given URI string.
        * This method ignores the scheme and authority part of the given URI.
        *
  -     * @param uri the specified URI string.
  -     *            It could be the generic URI and relative URI.
  -     * @return the query string.
  +     * @param escapedURI The specified escaped URI string.
  +     *                   It could be the generic URI and relative URI.
  +     * @return The query string.
        * @exception MalformedURLException
        */
  -    public static String getQuery(String uri)
  +    public static String getQuery(String escapedURI)
           throws MalformedURLException {
   
  -        int at = uri.indexOf("//");
  +        int at = escapedURI.indexOf("//");
           // Just ignore the authority part of URI
  -        at = (at > 0) ? uri.indexOf("/", at + 2) : uri.indexOf("/");
  +        at = (at > 0) ? escapedURI.indexOf("/", at + 2) :
  +            escapedURI.indexOf("/");
           if (at > 0) {
               // check the query
  -            int from = (uri.indexOf("?", at) > 0) ? uri.indexOf("?") + 1 : -1;
  -            int to = uri.length();
  +            int from = (escapedURI.indexOf("?", at) > 0) ?
  +                escapedURI.indexOf("?") + 1 : -1;
  +            int to = escapedURI.length();
               // check the fragment
  -            if (uri.indexOf("#", at) > at && uri.indexOf("#", at) < to)
  -                to = uri.indexOf("#");
  -            return (from > 0) ? uri.substring(from, to) : null;
  +            if (escapedURI.indexOf("#", at) > at &&
  +                escapedURI.indexOf("#", at) < to)
  +                to = escapedURI.indexOf("#");
  +            return (from > 0) ? escapedURI.substring(from, to) : null;
           } else
               throw new MalformedURLException("Need to have the path part");
       }
  @@ -784,36 +814,37 @@
        * Get the fragment for this generic URI.
        * This method ignores the scheme and authority part of the given URI.
        *
  -     * @return the fragment string.
  +     * @return The fragment string.
        * @exception MalformedURLException
        */
       public String getFragment()
           throws MalformedURLException {
   
  -        return getFragment(uri);
  +        return getFragment(URI);
       }
   
   
       /**
  -     * Get the fragment of the given URI string.
  +     * Get the fragment of the given escaped URI string.
        * This method ignores the scheme and authority part of the given URI.
        *
  -     * @param uri the specified URI string.
  -     *            It could be the generic URI and relative URI.
  -     * @return the fragment string.
  +     * @param escapedURI The specified URI string.
  +     *                   It could be the generic URI and relative URI.
  +     * @return The fragment string.
        * @exception MalformedURLException
        */
  -    public static String getFragment(String uri)
  +    public static String getFragment(String escapedURI)
           throws MalformedURLException {
   
  -        int at = uri.indexOf("//");
  +        int at = escapedURI.indexOf("//");
           // Just ignore the authority part of URI
  -        at = (at > 0) ? uri.indexOf("/", at + 2) : uri.indexOf("/");
  +        at = (at > 0) ? escapedURI.indexOf("/", at + 2) :
  +            escapedURI.indexOf("/");
           if (at > 0) {
               // check the fragment
  -            int from = (uri.indexOf("#", at) > 0) ?
  -                uri.indexOf("#", at) + 1 : -1;
  -            return (from > 0) ? uri.substring(from) : null;
  +            int from = (escapedURI.indexOf("#", at) > 0) ?
  +                escapedURI.indexOf("#", at) + 1 : -1;
  +            return (from > 0) ? escapedURI.substring(from) : null;
           } else
               throw new MalformedURLException("Need to have the path part");
       }
  @@ -833,13 +864,13 @@
           if ((obj != null) && (obj instanceof GenericURI)) {
   
               try {
  -                GenericURI uri = (GenericURI) obj;
  +                GenericURI URI = (GenericURI) obj;
   
  -                if (getScheme().equalsIgnoreCase(uri.getScheme()) &&
  -                    getUserInfo().equals(uri.getUserInfo()) &&
  -                    getHost().equalsIgnoreCase(uri.getHost()) &&
  -                    getPort() == uri.getPort() &&
  -                    getPath().equals(uri.getPath()))
  +                if (getScheme().equalsIgnoreCase(URI.getScheme()) &&
  +                    getUserInfo().equals(URI.getUserInfo()) &&
  +                    getHost().equalsIgnoreCase(URI.getHost()) &&
  +                    getPort() == URI.getPort() &&
  +                    getPath().equals(URI.getPath()))
   
                       return true;
   
  @@ -857,7 +888,7 @@
        * @return The URI string.
        */
       public String toString() {
  -        return uri;
  +        return URI;
       }
   
   }