KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > axis > types > URI


1 /*
2  * The Apache Software License, Version 1.1
3  *
4  *
5  * Copyright (c) 1999-2002 The Apache Software Foundation. All rights
6  * reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions
10  * are met:
11  *
12  * 1. Redistributions of source code must retain the above copyright
13  * notice, this list of conditions and the following disclaimer.
14  *
15  * 2. Redistributions in binary form must reproduce the above copyright
16  * notice, this list of conditions and the following disclaimer in
17  * the documentation and/or other materials provided with the
18  * distribution.
19  *
20  * 3. The end-user documentation included with the redistribution,
21  * if any, must include the following acknowledgment:
22  * "This product includes software developed by the
23  * Apache Software Foundation (http://www.apache.org/)."
24  * Alternately, this acknowledgment may appear in the software itself,
25  * if and wherever such third-party acknowledgments normally appear.
26  *
27  * 4. The names "Xerces" and "Apache Software Foundation" must
28  * not be used to endorse or promote products derived from this
29  * software without prior written permission. For written
30  * permission, please contact apache@apache.org.
31  *
32  * 5. Products derived from this software may not be called "Apache",
33  * nor may "Apache" appear in their name, without prior written
34  * permission of the Apache Software Foundation.
35  *
36  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
37  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
38  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
39  * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
40  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
41  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
42  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
43  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
44  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
45  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
46  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
47  * SUCH DAMAGE.
48  * ====================================================================
49  *
50  * This software consists of voluntary contributions made by many
51  * individuals on behalf of the Apache Software Foundation and was
52  * originally based on software copyright (c) 1999, iClick Inc.,
53  * http://www.apache.org. For more information on the Apache Software
54  * Foundation, please see <http://www.apache.org/>.
55  */

56
57 package org.jboss.axis.types;
58
59 import java.io.IOException JavaDoc;
60
61 /**
62  * *******************************************************************
63  * <i>Axis Note: This class was 'borrowed' from Xerces 2.0.2</i>
64  * <p/>
65  * A class to represent a Uniform Resource Identifier (URI). This class
66  * is designed to handle the parsing of URIs and provide access to
67  * the various components (scheme, host, port, userinfo, path, query
68  * string and fragment) that may constitute a URI.
69  * <p/>
70  * Parsing of a URI specification is done according to the URI
71  * syntax described in RFC 2396
72  * <http://www.ietf.org/rfc/rfc2396.txt?number=2396>. Every URI consists
73  * of a scheme, followed by a colon (':'), followed by a scheme-specific
74  * part. For URIs that follow the "generic URI" syntax, the scheme-
75  * specific part begins with two slashes ("//") and may be followed
76  * by an authority segment (comprised of user information, host, and
77  * port), path segment, query segment and fragment. Note that RFC 2396
78  * no longer specifies the use of the parameters segment and excludes
79  * the "user:password" syntax as part of the authority segment. If
80  * "user:password" appears in a URI, the entire user/password string
81  * is stored as userinfo.
82  * <p/>
83  * For URIs that do not follow the "generic URI" syntax (e.g. mailto),
84  * the entire scheme-specific part is treated as the "path" portion
85  * of the URI.
86  * <p/>
87  * Note that, unlike the java.net.URL class, this class does not provide
88  * any built-in network access functionality nor does it provide any
89  * scheme-specific functionality (for example, it does not know a
90  * default port for a specific scheme). Rather, it only knows the
91  * grammar and basic set of operations that can be applied to a URI.
92  *
93  * @version Xerces 2.0.2: Id: URI.java,v 1.6 2002/05/10 16:30:10 sandygao Exp
94  * <p/>
95  * ********************************************************************
96  */

97 public class URI
98 {
99    /**
100     * ****************************************************************
101     * MalformedURIExceptions are thrown in the process of building a URI
102     * or setting fields on a URI when an operation would result in an
103     * invalid URI specification.
104     * <p/>
105     * ******************************************************************
106     */

107    public static class MalformedURIException extends IOException JavaDoc
108    {
109
110       /**
111        * ***************************************************************
112        * Constructs a <code>MalformedURIException</code> with no specified
113        * detail message.
114        * ****************************************************************
115        */

116       public MalformedURIException()
117       {
118          super();
119       }
120
121       /**
122        * **************************************************************
123        * Constructs a <code>MalformedURIException</code> with the
124        * specified detail message.
125        *
126        * @param p_msg the detail message.
127        * ****************************************************************
128        */

129       public MalformedURIException(String JavaDoc p_msg)
130       {
131          super(p_msg);
132       }
133    }
134
135    /**
136     * reserved characters
137     */

138    //RFC 2732 added '[' and ']' as reserved characters
139
//private static final String RESERVED_CHARACTERS = ";/?:@&=+$,";
140
private static final String JavaDoc RESERVED_CHARACTERS = ";/?:@&=+$,[]";
141
142    /**
143     * URI punctuation mark characters - these, combined with
144     * alphanumerics, constitute the "unreserved" characters
145     */

146    private static final String JavaDoc MARK_CHARACTERS = "-_.!~*'()";
147
148    /**
149     * scheme can be composed of alphanumerics and these characters
150     */

151    private static final String JavaDoc SCHEME_CHARACTERS = "+-.";
152
153    /**
154     * userinfo can be composed of unreserved, escaped and these
155     * characters
156     */

157    private static final String JavaDoc USERINFO_CHARACTERS = ";:&=+$,";
158
159    /**
160     * Stores the scheme (usually the protocol) for this URI.
161     */

162    private String JavaDoc m_scheme = null;
163
164    /**
165     * If specified, stores the userinfo for this URI; otherwise null
166     */

167    private String JavaDoc m_userinfo = null;
168
169    /**
170     * If specified, stores the host for this URI; otherwise null
171     */

172    private String JavaDoc m_host = null;
173
174    /**
175     * If specified, stores the port for this URI; otherwise -1
176     */

177    private int m_port = -1;
178
179    /**
180     * If specified, stores the path for this URI; otherwise null
181     */

182    private String JavaDoc m_path = null;
183
184    /**
185     * If specified, stores the query string for this URI; otherwise
186     * null.
187     */

188    private String JavaDoc m_queryString = null;
189
190    /**
191     * If specified, stores the fragment for this URI; otherwise null
192     */

193    private String JavaDoc m_fragment = null;
194
195    private static boolean DEBUG = false;
196
197    /**
198     * Construct a new and uninitialized URI.
199     */

200    public URI()
201    {
202    }
203
204    /**
205     * Construct a new URI from another URI. All fields for this URI are
206     * set equal to the fields of the URI passed in.
207     *
208     * @param p_other the URI to copy (cannot be null)
209     */

210    public URI(URI p_other)
211    {
212       initialize(p_other);
213    }
214
215    /**
216     * Construct a new URI from a URI specification string. If the
217     * specification follows the "generic URI" syntax, (two slashes
218     * following the first colon), the specification will be parsed
219     * accordingly - setting the scheme, userinfo, host,port, path, query
220     * string and fragment fields as necessary. If the specification does
221     * not follow the "generic URI" syntax, the specification is parsed
222     * into a scheme and scheme-specific part (stored as the path) only.
223     *
224     * @param p_uriSpec the URI specification string (cannot be null or
225     * empty)
226     * @throws MalformedURIException if p_uriSpec violates any syntax
227     * rules
228     */

229    public URI(String JavaDoc p_uriSpec) throws MalformedURIException
230    {
231       this((URI)null, p_uriSpec);
232    }
233
234    /**
235     * Construct a new URI from a base URI and a URI specification string.
236     * The URI specification string may be a relative URI.
237     *
238     * @param p_base the base URI (cannot be null if p_uriSpec is null or
239     * empty)
240     * @param p_uriSpec the URI specification string (cannot be null or
241     * empty if p_base is null)
242     * @throws MalformedURIException if p_uriSpec violates any syntax
243     * rules
244     */

245    public URI(URI p_base, String JavaDoc p_uriSpec) throws MalformedURIException
246    {
247       initialize(p_base, p_uriSpec);
248    }
249
250    /**
251     * Construct a new URI that does not follow the generic URI syntax.
252     * Only the scheme and scheme-specific part (stored as the path) are
253     * initialized.
254     *
255     * @param p_scheme the URI scheme (cannot be null or empty)
256     * @param p_schemeSpecificPart the scheme-specific part (cannot be
257     * null or empty)
258     * @throws MalformedURIException if p_scheme violates any
259     * syntax rules
260     */

261    public URI(String JavaDoc p_scheme, String JavaDoc p_schemeSpecificPart)
262            throws MalformedURIException
263    {
264       if (p_scheme == null || p_scheme.trim().length() == 0)
265       {
266          throw new MalformedURIException("Cannot construct URI with null/empty scheme!");
267       }
268       if (p_schemeSpecificPart == null ||
269               p_schemeSpecificPart.trim().length() == 0)
270       {
271          throw new MalformedURIException("Cannot construct URI with null/empty scheme-specific part!");
272       }
273       setScheme(p_scheme);
274       setPath(p_schemeSpecificPart);
275    }
276
277    /**
278     * Construct a new URI that follows the generic URI syntax from its
279     * component parts. Each component is validated for syntax and some
280     * basic semantic checks are performed as well. See the individual
281     * setter methods for specifics.
282     *
283     * @param p_scheme the URI scheme (cannot be null or empty)
284     * @param p_host the hostname or IPv4 address for the URI
285     * @param p_path the URI path - if the path contains '?' or '#',
286     * then the query string and/or fragment will be
287     * set from the path; however, if the query and
288     * fragment are specified both in the path and as
289     * separate parameters, an exception is thrown
290     * @param p_queryString the URI query string (cannot be specified
291     * if path is null)
292     * @param p_fragment the URI fragment (cannot be specified if path
293     * is null)
294     * @throws MalformedURIException if any of the parameters violates
295     * syntax rules or semantic rules
296     */

297    public URI(String JavaDoc p_scheme, String JavaDoc p_host, String JavaDoc p_path,
298               String JavaDoc p_queryString, String JavaDoc p_fragment)
299            throws MalformedURIException
300    {
301       this(p_scheme, null, p_host, -1, p_path, p_queryString, p_fragment);
302    }
303
304    /**
305     * Construct a new URI that follows the generic URI syntax from its
306     * component parts. Each component is validated for syntax and some
307     * basic semantic checks are performed as well. See the individual
308     * setter methods for specifics.
309     *
310     * @param p_scheme the URI scheme (cannot be null or empty)
311     * @param p_userinfo the URI userinfo (cannot be specified if host
312     * is null)
313     * @param p_host the hostname or IPv4 address for the URI
314     * @param p_port the URI port (may be -1 for "unspecified"; cannot
315     * be specified if host is null)
316     * @param p_path the URI path - if the path contains '?' or '#',
317     * then the query string and/or fragment will be
318     * set from the path; however, if the query and
319     * fragment are specified both in the path and as
320     * separate parameters, an exception is thrown
321     * @param p_queryString the URI query string (cannot be specified
322     * if path is null)
323     * @param p_fragment the URI fragment (cannot be specified if path
324     * is null)
325     * @throws MalformedURIException if any of the parameters violates
326     * syntax rules or semantic rules
327     */

328    public URI(String JavaDoc p_scheme, String JavaDoc p_userinfo,
329               String JavaDoc p_host, int p_port, String JavaDoc p_path,
330               String JavaDoc p_queryString, String JavaDoc p_fragment)
331            throws MalformedURIException
332    {
333       if (p_scheme == null || p_scheme.trim().length() == 0)
334       {
335          throw new MalformedURIException("Scheme is required!");
336       }
337
338       if (p_host == null)
339       {
340          if (p_userinfo != null)
341          {
342             throw new MalformedURIException("Userinfo may not be specified if host is not specified!");
343          }
344          if (p_port != -1)
345          {
346             throw new MalformedURIException("Port may not be specified if host is not specified!");
347          }
348       }
349
350       if (p_path != null)
351       {
352          if (p_path.indexOf('?') != -1 && p_queryString != null)
353          {
354             throw new MalformedURIException("Query string cannot be specified in path and query string!");
355          }
356
357          if (p_path.indexOf('#') != -1 && p_fragment != null)
358          {
359             throw new MalformedURIException("Fragment cannot be specified in both the path and fragment!");
360          }
361       }
362
363       setScheme(p_scheme);
364       setHost(p_host);
365       setPort(p_port);
366       setUserinfo(p_userinfo);
367       setPath(p_path);
368       setQueryString(p_queryString);
369       setFragment(p_fragment);
370    }
371
372    /**
373     * Initialize all fields of this URI from another URI.
374     *
375     * @param p_other the URI to copy (cannot be null)
376     */

377    private void initialize(URI p_other)
378    {
379       m_scheme = p_other.getScheme();
380       m_userinfo = p_other.getUserinfo();
381       m_host = p_other.getHost();
382       m_port = p_other.getPort();
383       m_path = p_other.getPath();
384       m_queryString = p_other.getQueryString();
385       m_fragment = p_other.getFragment();
386    }
387
388    /**
389     * Initializes this URI from a base URI and a URI specification string.
390     * See RFC 2396 Section 4 and Appendix B for specifications on parsing
391     * the URI and Section 5 for specifications on resolving relative URIs
392     * and relative paths.
393     *
394     * @param p_base the base URI (may be null if p_uriSpec is an absolute
395     * URI)
396     * @param p_uriSpec the URI spec string which may be an absolute or
397     * relative URI (can only be null/empty if p_base
398     * is not null)
399     * @throws MalformedURIException if p_base is null and p_uriSpec
400     * is not an absolute URI or if
401     * p_uriSpec violates syntax rules
402     */

403    private void initialize(URI p_base, String JavaDoc p_uriSpec)
404            throws MalformedURIException
405    {
406       if (p_base == null &&
407               (p_uriSpec == null || p_uriSpec.trim().length() == 0))
408       {
409          throw new MalformedURIException("Cannot initialize URI with empty parameters.");
410       }
411
412       // just make a copy of the base if spec is empty
413
if (p_uriSpec == null || p_uriSpec.trim().length() == 0)
414       {
415          initialize(p_base);
416          return;
417       }
418
419       String JavaDoc uriSpec = p_uriSpec.trim();
420       int uriSpecLen = uriSpec.length();
421       int index = 0;
422
423       // Check for scheme, which must be before '/', '?' or '#'. Also handle
424
// names with DOS drive letters ('D:'), so 1-character schemes are not
425
// allowed.
426
int colonIdx = uriSpec.indexOf(':');
427       int slashIdx = uriSpec.indexOf('/');
428       int queryIdx = uriSpec.indexOf('?');
429       int fragmentIdx = uriSpec.indexOf('#');
430
431       if ((colonIdx < 2) ||
432               (colonIdx > slashIdx && slashIdx != -1) ||
433               (colonIdx > queryIdx && queryIdx != -1) ||
434               (colonIdx > fragmentIdx && fragmentIdx != -1))
435       {
436          // A standalone base is a valid URI according to spec
437
if (p_base == null && fragmentIdx != 0)
438          {
439             throw new MalformedURIException("No scheme found in URI.");
440          }
441       }
442       else
443       {
444          initializeScheme(uriSpec);
445          index = m_scheme.length() + 1;
446       }
447
448       // two slashes means generic URI syntax, so we get the authority
449
if (((index + 1) < uriSpecLen) &&
450               (uriSpec.substring(index).startsWith("//")))
451       {
452          index += 2;
453          int startPos = index;
454
455          // get authority - everything up to path, query or fragment
456
char testChar = '\0';
457          while (index < uriSpecLen)
458          {
459             testChar = uriSpec.charAt(index);
460             if (testChar == '/' || testChar == '?' || testChar == '#')
461             {
462                break;
463             }
464             index++;
465          }
466
467          // if we found authority, parse it out, otherwise we set the
468
// host to empty string
469
if (index > startPos)
470          {
471             initializeAuthority(uriSpec.substring(startPos, index));
472          }
473          else
474          {
475             m_host = "";
476          }
477       }
478
479       initializePath(uriSpec.substring(index));
480
481       // Resolve relative URI to base URI - see RFC 2396 Section 5.2
482
// In some cases, it might make more sense to throw an exception
483
// (when scheme is specified is the string spec and the base URI
484
// is also specified, for example), but we're just following the
485
// RFC specifications
486
if (p_base != null)
487       {
488
489          // check to see if this is the current doc - RFC 2396 5.2 #2
490
// note that this is slightly different from the RFC spec in that
491
// we don't include the check for query string being null
492
// - this handles cases where the urispec is just a query
493
// string or a fragment (e.g. "?y" or "#s") -
494
// see <http://www.ics.uci.edu/~fielding/url/test1.html> which
495
// identified this as a bug in the RFC
496
if (m_path.length() == 0 && m_scheme == null &&
497                  m_host == null)
498          {
499             m_scheme = p_base.getScheme();
500             m_userinfo = p_base.getUserinfo();
501             m_host = p_base.getHost();
502             m_port = p_base.getPort();
503             m_path = p_base.getPath();
504
505             if (m_queryString == null)
506             {
507                m_queryString = p_base.getQueryString();
508             }
509             return;
510          }
511
512          // check for scheme - RFC 2396 5.2 #3
513
// if we found a scheme, it means absolute URI, so we're done
514
if (m_scheme == null)
515          {
516             m_scheme = p_base.getScheme();
517          }
518          else
519          {
520             return;
521          }
522
523          // check for authority - RFC 2396 5.2 #4
524
// if we found a host, then we've got a network path, so we're done
525
if (m_host == null)
526          {
527             m_userinfo = p_base.getUserinfo();
528             m_host = p_base.getHost();
529             m_port = p_base.getPort();
530          }
531          else
532          {
533             return;
534          }
535
536          // check for absolute path - RFC 2396 5.2 #5
537
if (m_path.length() > 0 &&
538                  m_path.startsWith("/"))
539          {
540             return;
541          }
542
543          // if we get to this point, we need to resolve relative path
544
// RFC 2396 5.2 #6
545
String JavaDoc path = new String JavaDoc();
546          String JavaDoc basePath = p_base.getPath();
547
548          // 6a - get all but the last segment of the base URI path
549
if (basePath != null)
550          {
551             int lastSlash = basePath.lastIndexOf('/');
552             if (lastSlash != -1)
553             {
554                path = basePath.substring(0, lastSlash + 1);
555             }
556          }
557
558          // 6b - append the relative URI path
559
path = path.concat(m_path);
560
561          // 6c - remove all "./" where "." is a complete path segment
562
index = -1;
563          while ((index = path.indexOf("/./")) != -1)
564          {
565             path = path.substring(0, index + 1).concat(path.substring(index + 3));
566          }
567
568          // 6d - remove "." if path ends with "." as a complete path segment
569
if (path.endsWith("/."))
570          {
571             path = path.substring(0, path.length() - 1);
572          }
573
574          // 6e - remove all "<segment>/../" where "<segment>" is a complete
575
// path segment not equal to ".."
576
index = 1;
577          int segIndex = -1;
578          String JavaDoc tempString = null;
579
580          while ((index = path.indexOf("/../", index)) > 0)
581          {
582             tempString = path.substring(0, path.indexOf("/../"));
583             segIndex = tempString.lastIndexOf('/');
584             if (segIndex != -1)
585             {
586                if (!tempString.substring(segIndex).equals(".."))
587                {
588                   path = path.substring(0, segIndex + 1).concat(path.substring(index + 4));
589                   index = segIndex;
590                }
591                else
592                   index += 4;
593             }
594             else
595                index += 4;
596          }
597
598          // 6f - remove ending "<segment>/.." where "<segment>" is a
599
// complete path segment
600
if (path.endsWith("/.."))
601          {
602             tempString = path.substring(0, path.length() - 3);
603             segIndex = tempString.lastIndexOf('/');
604             if (segIndex != -1)
605             {
606                path = path.substring(0, segIndex + 1);
607             }
608          }
609          m_path = path;
610       }
611    }
612
613    /**
614     * Initialize the scheme for this URI from a URI string spec.
615     *
616     * @param p_uriSpec the URI specification (cannot be null)
617     * @throws MalformedURIException if URI does not have a conformant
618     * scheme
619     */

620    private void initializeScheme(String JavaDoc p_uriSpec)
621            throws MalformedURIException
622    {
623       int uriSpecLen = p_uriSpec.length();
624       int index = 0;
625       String JavaDoc scheme = null;
626       char testChar = '\0';
627
628       while (index < uriSpecLen)
629       {
630          testChar = p_uriSpec.charAt(index);
631          if (testChar == ':' || testChar == '/' ||
632                  testChar == '?' || testChar == '#')
633          {
634             break;
635          }
636          index++;
637       }
638       scheme = p_uriSpec.substring(0, index);
639
640       if (scheme.length() == 0)
641       {
642          throw new MalformedURIException("No scheme found in URI.");
643       }
644       else
645       {
646          setScheme(scheme);
647       }
648    }
649
650    /**
651     * Initialize the authority (userinfo, host and port) for this
652     * URI from a URI string spec.
653     *
654     * @param p_uriSpec the URI specification (cannot be null)
655     * @throws MalformedURIException if p_uriSpec violates syntax rules
656     */

657    private void initializeAuthority(String JavaDoc p_uriSpec)
658            throws MalformedURIException
659    {
660       int index = 0;
661       int start = 0;
662       int end = p_uriSpec.length();
663       char testChar = '\0';
664       String JavaDoc userinfo = null;
665
666       // userinfo is everything up @
667
if (p_uriSpec.indexOf('@', start) != -1)
668       {
669          while (index < end)
670          {
671             testChar = p_uriSpec.charAt(index);
672             if (testChar == '@')
673             {
674                break;
675             }
676             index++;
677          }
678          userinfo = p_uriSpec.substring(start, index);
679          index++;
680       }
681
682       // host is everything up to ':'
683
String JavaDoc host = null;
684       start = index;
685       while (index < end)
686       {
687          testChar = p_uriSpec.charAt(index);
688          if (testChar == ':')
689          {
690             break;
691          }
692          index++;
693       }
694       host = p_uriSpec.substring(start, index);
695       int port = -1;
696       if (host.length() > 0)
697       {
698          // port
699
if (testChar == ':')
700          {
701             index++;
702             start = index;
703             while (index < end)
704             {
705                index++;
706             }
707             String JavaDoc portStr = p_uriSpec.substring(start, index);
708             if (portStr.length() > 0)
709             {
710                for (int i = 0; i < portStr.length(); i++)
711                {
712                   if (!isDigit(portStr.charAt(i)))
713                   {
714                      throw new MalformedURIException(portStr +
715                              " is invalid. Port should only contain digits!");
716                   }
717                }
718                try
719                {
720                   port = Integer.parseInt(portStr);
721                }
722                catch (NumberFormatException JavaDoc nfe)
723                {
724                   // can't happen
725
}
726             }
727          }
728       }
729       setHost(host);
730       setPort(port);
731       setUserinfo(userinfo);
732    }
733
734    /**
735     * Initialize the path for this URI from a URI string spec.
736     *
737     * @param p_uriSpec the URI specification (cannot be null)
738     * @throws MalformedURIException if p_uriSpec violates syntax rules
739     */

740    private void initializePath(String JavaDoc p_uriSpec)
741            throws MalformedURIException
742    {
743       if (p_uriSpec == null)
744       {
745          throw new MalformedURIException("Cannot initialize path from null string!");
746       }
747
748       int index = 0;
749       int start = 0;
750       int end = p_uriSpec.length();
751       char testChar = '\0';
752
753       // path - everything up to query string or fragment
754
while (index < end)
755       {
756          testChar = p_uriSpec.charAt(index);
757          if (testChar == '?' || testChar == '#')
758          {
759             break;
760          }
761          // check for valid escape sequence
762
if (testChar == '%')
763          {
764             if (index + 2 >= end ||
765                     !isHex(p_uriSpec.charAt(index + 1)) ||
766                     !isHex(p_uriSpec.charAt(index + 2)))
767             {
768                throw new MalformedURIException("Path contains invalid escape sequence!");
769             }
770          }
771          else if (!isReservedCharacter(testChar) &&
772                  !isUnreservedCharacter(testChar))
773          {
774             throw new MalformedURIException("Path contains invalid character: " + testChar);
775          }
776          index++;
777       }
778       m_path = p_uriSpec.substring(start, index);
779
780       // query - starts with ? and up to fragment or end
781
if (testChar == '?')
782       {
783          index++;
784          start = index;
785          while (index < end)
786          {
787             testChar = p_uriSpec.charAt(index);
788             if (testChar == '#')
789             {
790                break;
791             }
792             if (testChar == '%')
793             {
794                if (index + 2 >= end ||
795                        !isHex(p_uriSpec.charAt(index + 1)) ||
796                        !isHex(p_uriSpec.charAt(index + 2)))
797                {
798                   throw new MalformedURIException("Query string contains invalid escape sequence!");
799                }
800             }
801             else if (!isReservedCharacter(testChar) &&
802                     !isUnreservedCharacter(testChar))
803             {
804                throw new MalformedURIException("Query string contains invalid character:" + testChar);
805             }
806             index++;
807          }
808          m_queryString = p_uriSpec.substring(start, index);
809       }
810
811       // fragment - starts with #
812
if (testChar == '#')
813       {
814          index++;
815          start = index;
816          while (index < end)
817          {
818             testChar = p_uriSpec.charAt(index);
819
820             if (testChar == '%')
821             {
822                if (index + 2 >= end ||
823                        !isHex(p_uriSpec.charAt(index + 1)) ||
824                        !isHex(p_uriSpec.charAt(index + 2)))
825                {
826                   throw new MalformedURIException("Fragment contains invalid escape sequence!");
827                }
828             }
829             else if (!isReservedCharacter(testChar) &&
830                     !isUnreservedCharacter(testChar))
831             {
832                throw new MalformedURIException("Fragment contains invalid character:" + testChar);
833             }
834             index++;
835          }
836          m_fragment = p_uriSpec.substring(start, index);
837       }
838    }
839
840    /**
841     * Get the scheme for this URI.
842     *
843     * @return the scheme for this URI
844     */

845    public String JavaDoc getScheme()
846    {
847       return m_scheme;
848    }
849
850    /**
851     * Get the scheme-specific part for this URI (everything following the
852     * scheme and the first colon). See RFC 2396 Section 5.2 for spec.
853     *
854     * @return the scheme-specific part for this URI
855     */

856    public String JavaDoc getSchemeSpecificPart()
857    {
858       StringBuffer JavaDoc schemespec = new StringBuffer JavaDoc();
859
860       if (m_userinfo != null || m_host != null || m_port != -1)
861       {
862          schemespec.append("//");
863       }
864
865       if (m_userinfo != null)
866       {
867          schemespec.append(m_userinfo);
868          schemespec.append('@');
869       }
870
871       if (m_host != null)
872       {
873          schemespec.append(m_host);
874       }
875
876       if (m_port != -1)
877       {
878          schemespec.append(':');
879          schemespec.append(m_port);
880       }
881
882       if (m_path != null)
883       {
884          schemespec.append((m_path));
885       }
886
887       if (m_queryString != null)
888       {
889          schemespec.append('?');
890          schemespec.append(m_queryString);
891       }
892
893       if (m_fragment != null)
894       {
895          schemespec.append('#');
896          schemespec.append(m_fragment);
897       }
898
899       return schemespec.toString();
900    }
901
902    /**
903     * Get the userinfo for this URI.
904     *
905     * @return the userinfo for this URI (null if not specified).
906     */

907    public String JavaDoc getUserinfo()
908    {
909       return m_userinfo;
910    }
911
912    /**
913     * Get the host for this URI.
914     *
915     * @return the host for this URI (null if not specified).
916     */

917    public String JavaDoc getHost()
918    {
919       return m_host;
920    }
921
922    /**
923     * Get the port for this URI.
924     *
925     * @return the port for this URI (-1 if not specified).
926     */

927    public int getPort()
928    {
929       return m_port;
930    }
931
932    /**
933     * Get the path for this URI (optionally with the query string and
934     * fragment).
935     *
936     * @param p_includeQueryString if true (and query string is not null),
937     * then a "?" followed by the query string
938     * will be appended
939     * @param p_includeFragment if true (and fragment is not null),
940     * then a "#" followed by the fragment
941     * will be appended
942     * @return the path for this URI possibly including the query string
943     * and fragment
944     */

945    public String JavaDoc getPath(boolean p_includeQueryString,
946                          boolean p_includeFragment)
947    {
948       StringBuffer JavaDoc pathString = new StringBuffer JavaDoc(m_path);
949
950       if (p_includeQueryString && m_queryString != null)
951       {
952          pathString.append('?');
953          pathString.append(m_queryString);
954       }
955
956       if (p_includeFragment && m_fragment != null)
957       {
958          pathString.append('#');
959          pathString.append(m_fragment);
960       }
961       return pathString.toString();
962    }
963
964    /**
965     * Get the path for this URI. Note that the value returned is the path
966     * only and does not include the query string or fragment.
967     *
968     * @return the path for this URI.
969     */

970    public String JavaDoc getPath()
971    {
972       return m_path;
973    }
974
975    /**
976     * Get the query string for this URI.
977     *
978     * @return the query string for this URI. Null is returned if there
979     * was no "?" in the URI spec, empty string if there was a
980     * "?" but no query string following it.
981     */

982    public String JavaDoc getQueryString()
983    {
984       return m_queryString;
985    }
986
987    /**
988     * Get the fragment for this URI.
989     *
990     * @return the fragment for this URI. Null is returned if there
991     * was no "#" in the URI spec, empty string if there was a
992     * "#" but no fragment following it.
993     */

994    public String JavaDoc getFragment()
995    {
996       return m_fragment;
997    }
998
999    /**
1000    * Set the scheme for this URI. The scheme is converted to lowercase
1001    * before it is set.
1002    *
1003    * @param p_scheme the scheme for this URI (cannot be null)
1004    * @throws MalformedURIException if p_scheme is not a conformant
1005    * scheme name
1006    */

1007   public void setScheme(String JavaDoc p_scheme) throws MalformedURIException
1008   {
1009      if (p_scheme == null)
1010      {
1011         throw new MalformedURIException("Cannot set scheme from null string!");
1012      }
1013      if (!isConformantSchemeName(p_scheme))
1014      {
1015         throw new MalformedURIException("The scheme is not conformant.");
1016      }
1017
1018      m_scheme = p_scheme.toLowerCase();
1019   }
1020
1021   /**
1022    * Set the userinfo for this URI. If a non-null value is passed in and
1023    * the host value is null, then an exception is thrown.
1024    *
1025    * @param p_userinfo the userinfo for this URI
1026    * @throws MalformedURIException if p_userinfo contains invalid
1027    * characters
1028    */

1029   public void setUserinfo(String JavaDoc p_userinfo) throws MalformedURIException
1030   {
1031      if (p_userinfo == null)
1032      {
1033         m_userinfo = null;
1034      }
1035      else
1036      {
1037         if (m_host == null)
1038         {
1039            throw new MalformedURIException("Userinfo cannot be set when host is null!");
1040         }
1041
1042         // userinfo can contain alphanumerics, mark characters, escaped
1043
// and ';',':','&','=','+','$',','
1044
int index = 0;
1045         int end = p_userinfo.length();
1046         char testChar = '\0';
1047         while (index < end)
1048         {
1049            testChar = p_userinfo.charAt(index);
1050            if (testChar == '%')
1051            {
1052               if (index + 2 >= end ||
1053                       !isHex(p_userinfo.charAt(index + 1)) ||
1054                       !isHex(p_userinfo.charAt(index + 2)))
1055               {
1056                  throw new MalformedURIException("Userinfo contains invalid escape sequence!");
1057               }
1058            }
1059            else if (!isUnreservedCharacter(testChar) &&
1060                    USERINFO_CHARACTERS.indexOf(testChar) == -1)
1061            {
1062               throw new MalformedURIException("Userinfo contains invalid character:" + testChar);
1063            }
1064            index++;
1065         }
1066      }
1067      m_userinfo = p_userinfo;
1068   }
1069
1070   /**
1071    * Set the host for this URI. If null is passed in, the userinfo
1072    * field is also set to null and the port is set to -1.
1073    *
1074    * @param p_host the host for this URI
1075    * @throws MalformedURIException if p_host is not a valid IP
1076    * address or DNS hostname.
1077    */

1078   public void setHost(String JavaDoc p_host) throws MalformedURIException
1079   {
1080      if (p_host == null || p_host.trim().length() == 0)
1081      {
1082         m_host = p_host;
1083         m_userinfo = null;
1084         m_port = -1;
1085      }
1086      else if (!isWellFormedAddress(p_host))
1087      {
1088         throw new MalformedURIException("Host is not a well formed address!");
1089      }
1090      m_host = p_host;
1091   }
1092
1093   /**
1094    * Set the port for this URI. -1 is used to indicate that the port is
1095    * not specified, otherwise valid port numbers are between 0 and 65535.
1096    * If a valid port number is passed in and the host field is null,
1097    * an exception is thrown.
1098    *
1099    * @param p_port the port number for this URI
1100    * @throws MalformedURIException if p_port is not -1 and not a
1101    * valid port number
1102    */

1103   public void setPort(int p_port) throws MalformedURIException
1104   {
1105      if (p_port >= 0 && p_port <= 65535)
1106      {
1107         if (m_host == null)
1108         {
1109            throw new MalformedURIException("Port cannot be set when host is null!");
1110         }
1111      }
1112      else if (p_port != -1)
1113      {
1114         throw new MalformedURIException("Invalid port number!");
1115      }
1116      m_port = p_port;
1117   }
1118
1119   /**
1120    * Set the path for this URI. If the supplied path is null, then the
1121    * query string and fragment are set to null as well. If the supplied
1122    * path includes a query string and/or fragment, these fields will be
1123    * parsed and set as well. Note that, for URIs following the "generic
1124    * URI" syntax, the path specified should start with a slash.
1125    * For URIs that do not follow the generic URI syntax, this method
1126    * sets the scheme-specific part.
1127    *
1128    * @param p_path the path for this URI (may be null)
1129    * @throws MalformedURIException if p_path contains invalid
1130    * characters
1131    */

1132   public void setPath(String JavaDoc p_path) throws MalformedURIException
1133   {
1134      if (p_path == null)
1135      {
1136         m_path = null;
1137         m_queryString = null;
1138         m_fragment = null;
1139      }
1140      else
1141      {
1142         initializePath(p_path);
1143      }
1144   }
1145
1146   /**
1147    * Append to the end of the path of this URI. If the current path does
1148    * not end in a slash and the path to be appended does not begin with
1149    * a slash, a slash will be appended to the current path before the
1150    * new segment is added. Also, if the current path ends in a slash
1151    * and the new segment begins with a slash, the extra slash will be
1152    * removed before the new segment is appended.
1153    *
1154    * @param p_addToPath the new segment to be added to the current path
1155    * @throws MalformedURIException if p_addToPath contains syntax
1156    * errors
1157    */

1158   public void appendPath(String JavaDoc p_addToPath)
1159           throws MalformedURIException
1160   {
1161      if (p_addToPath == null || p_addToPath.trim().length() == 0)
1162      {
1163         return;
1164      }
1165
1166      if (!isURIString(p_addToPath))
1167      {
1168         throw new MalformedURIException("Path contains invalid character!");
1169      }
1170
1171      if (m_path == null || m_path.trim().length() == 0)
1172      {
1173         if (p_addToPath.startsWith("/"))
1174         {
1175            m_path = p_addToPath;
1176         }
1177         else
1178         {
1179            m_path = "/" + p_addToPath;
1180         }
1181      }
1182      else if (m_path.endsWith("/"))
1183      {
1184         if (p_addToPath.startsWith("/"))
1185         {
1186            m_path = m_path.concat(p_addToPath.substring(1));
1187         }
1188         else
1189         {
1190            m_path = m_path.concat(p_addToPath);
1191         }
1192      }
1193      else
1194      {
1195         if (p_addToPath.startsWith("/"))
1196         {
1197            m_path = m_path.concat(p_addToPath);
1198         }
1199         else
1200         {
1201            m_path = m_path.concat("/" + p_addToPath);
1202         }
1203      }
1204   }
1205
1206   /**
1207    * Set the query string for this URI. A non-null value is valid only
1208    * if this is an URI conforming to the generic URI syntax and
1209    * the path value is not null.
1210    *
1211    * @param p_queryString the query string for this URI
1212    * @throws MalformedURIException if p_queryString is not null and this
1213    * URI does not conform to the generic
1214    * URI syntax or if the path is null
1215    */

1216   public void setQueryString(String JavaDoc p_queryString) throws MalformedURIException
1217   {
1218      if (p_queryString == null)
1219      {
1220         m_queryString = null;
1221      }
1222      else if (!isGenericURI())
1223      {
1224         throw new MalformedURIException("Query string can only be set for a generic URI!");
1225      }
1226      else if (getPath() == null)
1227      {
1228         throw new MalformedURIException("Query string cannot be set when path is null!");
1229      }
1230      else if (!isURIString(p_queryString))
1231      {
1232         throw new MalformedURIException("Query string contains invalid character!");
1233      }
1234      else
1235      {
1236         m_queryString = p_queryString;
1237      }
1238   }
1239
1240   /**
1241    * Set the fragment for this URI. A non-null value is valid only
1242    * if this is a URI conforming to the generic URI syntax and
1243    * the path value is not null.
1244    *
1245    * @param p_fragment the fragment for this URI
1246    * @throws MalformedURIException if p_fragment is not null and this
1247    * URI does not conform to the generic
1248    * URI syntax or if the path is null
1249    */

1250   public void setFragment(String JavaDoc p_fragment) throws MalformedURIException
1251   {
1252      if (p_fragment == null)
1253      {
1254         m_fragment = null;
1255      }
1256      else if (!isGenericURI())
1257      {
1258         throw new MalformedURIException("Fragment can only be set for a generic URI!");
1259      }
1260      else if (getPath() == null)
1261      {
1262         throw new MalformedURIException("Fragment cannot be set when path is null!");
1263      }
1264      else if (!isURIString(p_fragment))
1265      {
1266         throw new MalformedURIException("Fragment contains invalid character!");
1267      }
1268      else
1269      {
1270         m_fragment = p_fragment;
1271      }
1272   }
1273
1274   /**
1275    * Determines if the passed-in Object is equivalent to this URI.
1276    *
1277    * @param p_test the Object to test for equality.
1278    * @return true if p_test is a URI with all values equal to this
1279    * URI, false otherwise
1280    */

1281   public boolean equals(Object JavaDoc p_test)
1282   {
1283      if (p_test instanceof URI)
1284      {
1285         URI testURI = (URI)p_test;
1286         if (((m_scheme == null && testURI.m_scheme == null) ||
1287                 (m_scheme != null && testURI.m_scheme != null &&
1288                 m_scheme.equals(testURI.m_scheme))) &&
1289                 ((m_userinfo == null && testURI.m_userinfo == null) ||
1290                 (m_userinfo != null && testURI.m_userinfo != null &&
1291                 m_userinfo.equals(testURI.m_userinfo))) &&
1292                 ((m_host == null && testURI.m_host == null) ||
1293                 (m_host != null && testURI.m_host != null &&
1294                 m_host.equals(testURI.m_host))) &&
1295                 m_port == testURI.m_port &&
1296                 ((m_path == null && testURI.m_path == null) ||
1297                 (m_path != null && testURI.m_path != null &&
1298                 m_path.equals(testURI.m_path))) &&
1299                 ((m_queryString == null && testURI.m_queryString == null) ||
1300                 (m_queryString != null && testURI.m_queryString != null &&
1301                 m_queryString.equals(testURI.m_queryString))) &&
1302                 ((m_fragment == null && testURI.m_fragment == null) ||
1303                 (m_fragment != null && testURI.m_fragment != null &&
1304                 m_fragment.equals(testURI.m_fragment))))
1305         {
1306            return true;
1307         }
1308      }
1309      return false;
1310   }
1311
1312   /**
1313    * Get the URI as a string specification. See RFC 2396 Section 5.2.
1314    *
1315    * @return the URI string specification
1316    */

1317   public String JavaDoc toString()
1318   {
1319      StringBuffer JavaDoc uriSpecString = new StringBuffer JavaDoc();
1320
1321      if (m_scheme != null)
1322      {
1323         uriSpecString.append(m_scheme);
1324         uriSpecString.append(':');
1325      }
1326      uriSpecString.append(getSchemeSpecificPart());
1327      return uriSpecString.toString();
1328   }
1329
1330   /**
1331    * Get the indicator as to whether this URI uses the "generic URI"
1332    * syntax.
1333    *
1334    * @return true if this URI uses the "generic URI" syntax, false
1335    * otherwise
1336    */

1337   public boolean isGenericURI()
1338   {
1339      // presence of the host (whether valid or empty) means
1340
// double-slashes which means generic uri
1341
return (m_host != null);
1342   }
1343
1344   /**
1345    * Determine whether a scheme conforms to the rules for a scheme name.
1346    * A scheme is conformant if it starts with an alphanumeric, and
1347    * contains only alphanumerics, '+','-' and '.'.
1348    *
1349    * @return true if the scheme is conformant, false otherwise
1350    */

1351   public static boolean isConformantSchemeName(String JavaDoc p_scheme)
1352   {
1353      if (p_scheme == null || p_scheme.trim().length() == 0)
1354      {
1355         return false;
1356      }
1357
1358      if (!isAlpha(p_scheme.charAt(0)))
1359      {
1360         return false;
1361      }
1362
1363      char testChar;
1364      for (int i = 1; i < p_scheme.length(); i++)
1365      {
1366         testChar = p_scheme.charAt(i);
1367         if (!isAlphanum(testChar) &&
1368                 SCHEME_CHARACTERS.indexOf(testChar) == -1)
1369         {
1370            return false;
1371         }
1372      }
1373
1374      return true;
1375   }
1376
1377   /**
1378    * Determine whether a string is syntactically capable of representing
1379    * a valid IPv4 address or the domain name of a network host. A valid
1380    * IPv4 address consists of four decimal digit groups separated by a
1381    * '.'. A hostname consists of domain labels (each of which must
1382    * begin and end with an alphanumeric but may contain '-') separated
1383    * & by a '.'. See RFC 2396 Section 3.2.2.
1384    *
1385    * @return true if the string is a syntactically valid IPv4 address
1386    * or hostname
1387    */

1388   public static boolean isWellFormedAddress(String JavaDoc p_address)
1389   {
1390      if (p_address == null)
1391      {
1392         return false;
1393      }
1394
1395      String JavaDoc address = p_address.trim();
1396      int addrLength = address.length();
1397      if (addrLength == 0 || addrLength > 255)
1398      {
1399         return false;
1400      }
1401
1402      if (address.startsWith(".") || address.startsWith("-"))
1403      {
1404         return false;
1405      }
1406
1407      // rightmost domain label starting with digit indicates IP address
1408
// since top level domain label can only start with an alpha
1409
// see RFC 2396 Section 3.2.2
1410
int index = address.lastIndexOf('.');
1411      if (address.endsWith("."))
1412      {
1413         index = address.substring(0, index).lastIndexOf('.');
1414      }
1415
1416      if (index + 1 < addrLength && isDigit(p_address.charAt(index + 1)))
1417      {
1418         char testChar;
1419         int numDots = 0;
1420
1421         // make sure that 1) we see only digits and dot separators, 2) that
1422
// any dot separator is preceded and followed by a digit and
1423
// 3) that we find 3 dots
1424
for (int i = 0; i < addrLength; i++)
1425         {
1426            testChar = address.charAt(i);
1427            if (testChar == '.')
1428            {
1429               if (!isDigit(address.charAt(i - 1)) ||
1430                       (i + 1 < addrLength && !isDigit(address.charAt(i + 1))))
1431               {
1432                  return false;
1433               }
1434               numDots++;
1435            }
1436            else if (!isDigit(testChar))
1437            {
1438               return false;
1439            }
1440         }
1441         if (numDots != 3)
1442         {
1443            return false;
1444         }
1445      }
1446      else
1447      {
1448         // domain labels can contain alphanumerics and '-"
1449
// but must start and end with an alphanumeric
1450
char testChar;
1451
1452         for (int i = 0; i < addrLength; i++)
1453         {
1454            testChar = address.charAt(i);
1455            if (testChar == '.')
1456            {
1457               if (!isAlphanum(address.charAt(i - 1)))
1458               {
1459                  return false;
1460               }
1461               if (i + 1 < addrLength && !isAlphanum(address.charAt(i + 1)))
1462               {
1463                  return false;
1464               }
1465            }
1466            else if (!isAlphanum(testChar) && testChar != '-')
1467            {
1468               return false;
1469            }
1470         }
1471      }
1472      return true;
1473   }
1474
1475
1476   /**
1477    * Determine whether a char is a digit.
1478    *
1479    * @return true if the char is betweeen '0' and '9', false otherwise
1480    */

1481   private static boolean isDigit(char p_char)
1482   {
1483      return p_char >= '0' && p_char <= '9';
1484   }
1485
1486   /**
1487    * Determine whether a character is a hexadecimal character.
1488    *
1489    * @return true if the char is betweeen '0' and '9', 'a' and 'f'
1490    * or 'A' and 'F', false otherwise
1491    */

1492   private static boolean isHex(char p_char)
1493   {
1494      return (isDigit(p_char) ||
1495              (p_char >= 'a' && p_char <= 'f') ||
1496              (p_char >= 'A' && p_char <= 'F'));
1497   }
1498
1499   /**
1500    * Determine whether a char is an alphabetic character: a-z or A-Z
1501    *
1502    * @return true if the char is alphabetic, false otherwise
1503    */

1504   private static boolean isAlpha(char p_char)
1505   {
1506      return ((p_char >= 'a' && p_char <= 'z') ||
1507              (p_char >= 'A' && p_char <= 'Z'));
1508   }
1509
1510   /**
1511    * Determine whether a char is an alphanumeric: 0-9, a-z or A-Z
1512    *
1513    * @return true if the char is alphanumeric, false otherwise
1514    */

1515   private static boolean isAlphanum(char p_char)
1516   {
1517      return (isAlpha(p_char) || isDigit(p_char));
1518   }
1519
1520   /**
1521    * Determine whether a character is a reserved character:
1522    * ';', '/', '?', ':', '@', '&', '=', '+', '$' or ','
1523    *
1524    * @return true if the string contains any reserved characters
1525    */

1526   private static boolean isReservedCharacter(char p_char)
1527   {
1528      return RESERVED_CHARACTERS.indexOf(p_char) != -1;
1529   }
1530
1531   /**
1532    * Determine whether a char is an unreserved character.
1533    *
1534    * @return true if the char is unreserved, false otherwise
1535    */

1536   private static boolean isUnreservedCharacter(char p_char)
1537   {
1538      return (isAlphanum(p_char) ||
1539              MARK_CHARACTERS.indexOf(p_char) != -1);
1540   }
1541
1542   /**
1543    * Determine whether a given string contains only URI characters (also
1544    * called "uric" in RFC 2396). uric consist of all reserved
1545    * characters, unreserved characters and escaped characters.
1546    *
1547    * @return true if the string is comprised of uric, false otherwise
1548    */

1549   private static boolean isURIString(String JavaDoc p_uric)
1550   {
1551      if (p_uric == null)
1552      {
1553         return false;
1554      }
1555      int end = p_uric.length();
1556      char testChar = '\0';
1557      for (int i = 0; i < end; i++)
1558      {
1559         testChar = p_uric.charAt(i);
1560         if (testChar == '%')
1561         {
1562            if (i + 2 >= end ||
1563                    !isHex(p_uric.charAt(i + 1)) ||
1564                    !isHex(p_uric.charAt(i + 2)))
1565            {
1566               return false;
1567            }
1568            else
1569            {
1570               i += 2;
1571               continue;
1572            }
1573         }
1574         if (isReservedCharacter(testChar) ||
1575                 isUnreservedCharacter(testChar))
1576         {
1577            continue;
1578         }
1579         else
1580         {
1581            return false;
1582         }
1583      }
1584      return true;
1585   }
1586
1587   /**
1588    * Returns a hash-code value for this URI. The hash code is based upon all
1589    * of the URI's components, and satisfies the general contract of the
1590    * {@link java.lang.Object#hashCode() Object.hashCode} method. </p>
1591    *
1592    * @return A hash-code value for this URI
1593    */

1594   public int hashCode()
1595   {
1596      return toString().toLowerCase().hashCode();
1597   }
1598}
1599
Popular Tags