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 2002/05/16 06:57:42 UTC

cvs commit: jakarta-slide/src/util/org/apache/util URI.java

jericho     02/05/15 21:57:42

  Modified:    src/util/org/apache/util URI.java
  Log:
  - Follow the general java code-convetion for the test methods of URI.
  - Fix javadoc messages for the test methods
  - Remove the userinfo part on the expression of URI.
    And add the reason on the getRawURI method for it.
  
  Revision  Changes    Path
  1.6       +101 -42   jakarta-slide/src/util/org/apache/util/URI.java
  
  Index: URI.java
  ===================================================================
  RCS file: /home/cvs/jakarta-slide/src/util/org/apache/util/URI.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- URI.java	29 Apr 2002 07:45:22 -0000	1.5
  +++ URI.java	16 May 2002 04:57:42 -0000	1.6
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-slide/src/util/org/apache/util/URI.java,v 1.5 2002/04/29 07:45:22 jericho Exp $
  - * $Revision: 1.5 $
  - * $Date: 2002/04/29 07:45:22 $
  + * $Header: /home/cvs/jakarta-slide/src/util/org/apache/util/URI.java,v 1.6 2002/05/16 04:57:42 jericho Exp $
  + * $Revision: 1.6 $
  + * $Date: 2002/05/16 04:57:42 $
    *
    * ====================================================================
    *
  @@ -128,7 +128,7 @@
    * relative URL(RFC 1808).
    *
    * @author <a href="mailto:jericho@apache.org">Sung-Gu</a>
  - * @version $Revision: 1.5 $ $Date: 2002/03/14 15:14:01 
  + * @version $Revision: 1.6 $ $Date: 2002/03/14 15:14:01 
    */
   
   public class URI implements Comparable, java.io.Serializable {
  @@ -1751,6 +1751,46 @@
   
   
       /**
  +     * Get the earlier index that the character as to be indexed is from the
  +     * given character array.
  +     *
  +     * @param s the character array to be indexed
  +     * @param delim the delimiter used to index
  +     * @return the ealier index if there are a delimiter
  +     */
  +    protected int indexOf(char[] s, char delim) {
  +        return indexOf(s, delim, 0);
  +    }
  +
  +
  +    /**
  +     * Get the earlier index that the character as to be indexed is from the
  +     * given character array.
  +     *
  +     * @param s the character array to be indexed
  +     * @param delim the delimiter used to index
  +     * @return the ealier index if there is a delimiter
  +     */
  +    protected int indexOf(char[] s, char delim, int offset) {
  +        if (s == null || s.length == 0) {
  +            return -1;
  +        }
  +        // check boundaries
  +        if (offset < 0) {
  +            offset = 0;
  +        } else if (offset > s.length) {
  +            return -1;
  +        }
  +        for (int i = offset; i < s.length; i++) {
  +            if (s[i] == delim) {
  +                return i;
  +            }
  +        }
  +        return -1;
  +    }
  +
  +
  +    /**
        * Parse the authority component.
        *
        * @param original the original character sequence of authority component
  @@ -1850,7 +1890,17 @@
           if (_is_net_path) {
               buf.append("//");
               if (_authority != null) { // has_authority
  -                buf.append(_authority);
  +                if (_userinfo != null) { // by default, remove userinfo part
  +                    if (_host != null) {
  +                        buf.append(_host);
  +                        if (_port != -1) {
  +                            buf.append(':');
  +                            buf.append(_port);
  +                        }
  +                    }
  +                } else {
  +                    buf.append(_authority);
  +                }
               }
           }
           if (_opaque != null && _is_opaque_part) {
  @@ -1873,7 +1923,7 @@
           _uri = buf.toString().toCharArray();
       }
   
  -    // --------------------------------------------------------- Public methods
  +    // ----------------------------------------------------------- Test methods
     
   
       /**
  @@ -1881,7 +1931,7 @@
        *
        * @return true iif this URI is absoluteURI
        */
  -    public boolean is_absoluteURI() {
  +    public boolean isAbsoluteURI() {
           return _is_only_fragment ? false : (_scheme != null);
       }
     
  @@ -1891,59 +1941,59 @@
        *
        * @return true iif this URI is relativeURI
        */
  -    public boolean is_relativeURI() {
  +    public boolean isRelativeURI() {
           return _is_only_fragment ? false : (_scheme == null);
       }
   
   
       /**
  -     * Tell whether or not this URI is hier_part.
  +     * Tell whether or not the absoluteURI of this URI is hier_part.
        *
  -     * @return true iif this URI is hier_part
  +     * @return true iif the absoluteURI is hier_part
        */
  -    public boolean is_hier_part() {
  +    public boolean isHierPart() {
           return _is_hier_part;
       }
   
   
       /**
  -     * Tell whether or not this URI is opaque_part.
  +     * Tell whether or not the absoluteURI of this URI is opaque_part.
        *
  -     * @return true iif this URI is opaque_part
  +     * @return true iif the absoluteURI is opaque_part
        */
  -    public boolean is_opaque_part() {
  +    public boolean isOpaquePart() {
           return _is_opaque_part;
       }
   
   
       /**
  -     * Tell whether or not this URI is net_path.
  +     * Tell whether or not the relativeURI or heir_part of this URI is net_path.
        * It's the same function as the has_authority() method.
        *
  -     * @return true iif this URI is net_path
  +     * @return true iif the relativeURI or heir_part is net_path
        * @see has_authority
        */
  -    public boolean is_net_path() {
  +    public boolean isNetPath() {
           return _is_net_path || (_authority != null);
       }
   
   
       /**
  -     * Tell whether or not this URI is abs_path.
  +     * Tell whether or not the relativeURI or hier_part of this URI is abs_path.
        *
  -     * @return true iif this URI is abs_path
  +     * @return true iif the relativeURI or hier_part is abs_path
        */
  -    public boolean is_abs_path() {
  +    public boolean isAbsPath() {
           return _is_abs_path;
       }
   
   
       /**
  -     * Tell whether or not this URI is rel_path.
  +     * Tell whether or not the relativeURI of this URI is rel_path.
        *
  -     * @return true iif this URI is rel_path
  +     * @return true iif the relativeURI is rel_path
        */
  -    public boolean is_rel_path() {
  +    public boolean isRelPath() {
           return _is_rel_path;
       }
   
  @@ -1955,26 +2005,26 @@
        * @return true iif this URI has authority
        * @see is_net_path
        */
  -    public boolean has_authority() {
  +    public boolean hasAuthority() {
           return (_authority != null) || _is_net_path;
       }
   
       /**
  -     * Tell whether or not this URI is reg_name.
  +     * Tell whether or not the authority component of this URI is reg_name.
        *
  -     * @return true iif this URI is reg_name
  +     * @return true iif the authority component is reg_name
        */
  -    public boolean is_reg_name() {
  +    public boolean isRegName() {
           return _is_reg_name;
       }
     
   
       /**
  -     * Tell whether or not this URI is_server.
  +     * Tell whether or not the authority component of this URI is server.
        *
  -     * @return true iif this URI is_server
  +     * @return true iif the authority component is server
        */
  -    public boolean is_server() {
  +    public boolean isServer() {
           return _is_server;
       }
     
  @@ -1984,37 +2034,37 @@
        *
        * @return true iif this URI has userinfo
        */
  -    public boolean has_userinfo() {
  +    public boolean hasUserinfo() {
           return (_userinfo != null);
       }
     
   
       /**
  -     * Tell whether or not this URI is hostname.
  +     * Tell whether or not the host part of this URI is hostname.
        *
  -     * @return true iif this URI is hostname
  +     * @return true iif the host part is hostname
        */
  -    public boolean is_hostname() {
  +    public boolean isHostname() {
           return _is_hostname;
       }
   
   
       /**
  -     * Tell whether or not this URI is IPv4address.
  +     * Tell whether or not the host part of this URI is IPv4address.
        *
  -     * @return true iif this URI is IPv4address
  +     * @return true iif the host part is IPv4address
        */
  -    public boolean is_IPv4address() {
  +    public boolean isIPv4address() {
           return _is_IPv4address;
       }
   
   
       /**
  -     * Tell whether or not this URI is IPv6reference.
  +     * Tell whether or not the host part of this URI is IPv6reference.
        *
  -     * @return true iif this URI is IPv6reference
  +     * @return true iif the host part is IPv6reference
        */
  -    public boolean is_IPv6reference() {
  +    public boolean isIPv6reference() {
           return _is_IPv6reference;
       }
   
  @@ -2024,7 +2074,7 @@
        *
        * @return true iif this URI has query
        */
  -    public boolean has_query() {
  +    public boolean hasQuery() {
           return (_query != null);
       }
      
  @@ -2034,7 +2084,7 @@
        *
        * @return true iif this URI has fragment
        */
  -    public boolean has_fragment() {
  +    public boolean hasFragment() {
           return (_fragment != null);
       }
      
  @@ -2790,6 +2840,15 @@
       /**
        * It can be gotten the URI character sequence. It's raw-escaped.
        * For the purpose of the protocol to be transported, it will be useful.
  +     *
  +     * It is clearly unwise to use a URL that contains a password which is
  +     * intended to be secret. In particular, the use of a password within
  +     * the 'userinfo' component of a URL is strongly disrecommended except
  +     * in those rare cases where the 'password' parameter is intended to be
  +     * public.
  +     *
  +     * When you want to get each part of the userinfo, you need to use the
  +     * specific methods in the specific URL. It's depends on the specific URL.
        *
        * @return URI character sequence
        */
  
  
  

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>