Unfortunately that is not an option.

I've hacked the URI class and attached the patch (for 2.6.2 and latest CVS), it's a simple change.

Is there anything I can do to help get this accepted?

 -- Cory

-----Original Message-----
From: Bob Foster [mailto:[EMAIL PROTECTED]
Sent: Thursday, 6 January 2005 6:53 PM
To: [EMAIL PROTECTED]
Subject: Re: Xerces URI does not handle JAR scheme?


Seems like it would be a lot simpler to stop using query strings in your

jar URIs.

Bob Foster

Cory Prowse wrote:
> Yup this refers to Xerces because of the internal implementation of
URI 
> (org.apache.xerces.util.URI).
> 
> Basically it doesn't handle jar URI's which are in the form of:
>   jar:<url>!/{entry}
> 
> In the case of:
>   
>
jar:embeddedzipfile:file:/home/cprowse/data.zip?lib/config.jar!/reposito
ry.xml 
> 
> it should ignore the query string (?lib/config.jar) as it is part of
the 
> url (before the "!/").  This is what the JDK's version of URI appears
to do.
> 
>  -- Cory
> 
> -----Original Message-----
> From: Bob Foster [mailto:[EMAIL PROTECTED]
> Sent: Thursday, 6 January 2005 8:47 AM
> To: [EMAIL PROTECTED]
> Subject: Re: Xerces URI does not handle JAR scheme?
> 
> 
> Does this question have anything to do with Xerces?
> 
> I would expect a query string in a jar: URI to cause problems. To form
a
> URI out of a base URI and a relative URI, the query string and/or
> fragment identifier should be stripped, the URI truncated at the final
/
> and the relative URI processed (in this case, appended). AFAICT, you
> should have wound up with a URI of:
> 
> jar:embeddedzipfile:file:/home/cprowse/repository.dtd
> 
> The result you claim is surprising, but your example is suspicious.
How
> did 'repository.dtd' become 'repository.xml'? Why did you cast base to
URI?
> 
> Bob Foster
> 
> Cory Prowse wrote:
>  > I have an application that loads resources from an embedded zip
file. 
>  > This is done via a protocol handler, so the following URI is
obtained:
>  >
>  >  
>  > 
>
jar:embeddedzipfile:file:/home/cprowse/data.zip?lib/config.jar!/reposito
ry.xml 
> 
>  >
>  >
>  > Which follows the normal JAR symantecs of:  jar:<url>!/{entry}
>  >
>  > However URI is not handling this and parses it as follows:
>  >   Scheme: jar
>  >   SchemeSpecificPart:
>  > 
>
embeddedzipfile:file:/home/cprowse/data.zip?lib/config.jar!/repository.x
ml
>  >   Host: null
>  >   Path:
>  > 
>
embeddedzipfile:file:/home/cprowse/Development/conductor_instance/WEB-IN
F/modules/ComposerCAM-1.01.02.cam 
> 
>  >
>  >   QueryString: lib/ComposerData-1.01.02.jar!/repository.xml
>  >
>  > This breaks things when this is used as a baseURI.
>  >
>  > For example, when the above URI is used in the URI constructor as 
> follows:
>  >   new URI((URI)base, "repository.dtd");
>  >
>  > I get:
>  >   Scheme: jar
>  >   SchemeSpecificPart:
>  > 
>
embeddedzipfile:file:/home/cprowse/Development/conductor_instance/WEB-IN
F/modules/ComposerCAM-1.01.02.cam?lib/ComposerData-1.01.02.jar!/reposito
ry.xml
> 
>  >
>  >   Host: null
>  >   Path:
>  > 
>
embeddedzipfile:file:/home/cprowse/Development/conductor_instance/WEB-IN
F/modules/ComposerCAM-1.01.02.cam 
> 
>  >
>  >   QueryString: lib/ComposerData-1.01.02.jar!/repository.xml
>  >
>  > I've started a small patch on URI to make it aware of the jar
scheme.
>  > Has this come up before for anyone?
>  >
>  >  -- Cory
>  >
>  > Important notice: This message is intended for the individual(s)
and
>  > entity(s) addressed. The information contained in this transmission
and
>  > any attached, may be confidential and may also be the subject of
legal
>  > privilege, public interest immunity or legal professional
privilege. Any
>  > review, retransmission, dissemination or other use of, taking of
any
>  > action in reliance upon this information by person or entities
other
>  > than the recipient is prohibited and requires authorization from
the
>  > sender. If you are not the addressee indicated in this message (or
>  > responsible for delivery of the message to such person) you may not
copy
>  > or deliver this message to anyone. In such cases you should destroy
this
>  > message and kindly notify the sender by reply email.
>  >
>  > WARNING: Although Infocomp has taken reasonable precautions so that
no
>  > viruses are present in this e-mail, the company cannot accept
>  > responsibility for any loss or damage arising from the use of
e-mail
>  > attachments.
>  >
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> Important notice: This message is intended for the individual(s) and 
> entity(s) addressed. The information contained in this transmission
and 
> any attached, may be confidential and may also be the subject of legal

> privilege, public interest immunity or legal professional privilege.
Any 
> review, retransmission, dissemination or other use of, taking of any 
> action in reliance upon this information by person or entities other 
> than the recipient is prohibited and requires authorization from the 
> sender. If you are not the addressee indicated in this message (or 
> responsible for delivery of the message to such person) you may not
copy 
> or deliver this message to anyone. In such cases you should destroy
this 
> message and kindly notify the sender by reply email.
> 
> WARNING: Although Infocomp has taken reasonable precautions so that no

> viruses are present in this e-mail, the company cannot accept 
> responsibility for any loss or damage arising from the use of e-mail 
> attachments.
> 



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Important notice: This message is intended for the individual(s) and entity(s) addressed. The information contained in this transmission and any attached, may be confidential and may also be the subject of legal privilege, public interest immunity or legal professional privilege. Any review, retransmission, dissemination or other use of, taking of any action in reliance upon this information by person or entities other than the recipient is prohibited and requires authorization from the sender. If you are not the addressee indicated in this message (or responsible for delivery of the message to such person) you may not copy or deliver this message to anyone. In such cases you should destroy this message and kindly notify the sender by reply email.

WARNING: Although Infocomp has taken reasonable precautions so that no viruses are present in this e-mail, the company cannot accept responsibility for any loss or damage arising from the use of e-mail attachments.

--- x2/xerces-2_6_2/src/org/apache/xerces/util/URI.java	2004-02-21 05:58:12.000000000 +1100
+++ xerces-2_6_2/src/org/apache/xerces/util/URI.java	2005-01-06 14:42:39.079598973 +1100
@@ -268,6 +268,9 @@
   /** If specified, stores the fragment for this URI; otherwise null */
   private String m_fragment = null;
 
+  /** Stores the full uriSpec for handling jar URIs - Cory Prowse */
+  private String m_uriSpec = null;
+  
   private static boolean DEBUG = false;
 
   /**
@@ -476,6 +479,17 @@
                          throws MalformedURIException {
 	  
     String uriSpec = p_uriSpec;
+
+    // Must handle jar URIs to their spec:  jar:<URI>!/ - Cory Prowse 
+    m_uriSpec = p_uriSpec;
+    if ((p_base != null) && (p_base.m_scheme.equals("jar"))) {
+      m_uriSpec = p_base.m_uriSpec;
+      int end = m_uriSpec.lastIndexOf("!/");
+      if (end > 0) {
+        m_uriSpec = m_uriSpec.substring(0, end + 2);
+      }
+      m_uriSpec += p_uriSpec;
+    }
     int uriSpecLen = (uriSpec != null) ? uriSpec.length() : 0;
 	
     if (p_base == null && uriSpecLen == 0) {
@@ -991,6 +1005,11 @@
     }
     m_path = p_uriSpec.substring(start, index);
 
+    // Must handle jar URIs to their spec:  jar:<URI>!/ - Cory Prowse
+    if ((m_scheme != null) && m_scheme.equals("jar")) {
+        m_path = null;
+    }
+  
     // query - starts with ? and up to fragment or end
     if (testChar == '?') {
       index++;
@@ -1017,6 +1036,10 @@
       }
       m_queryString = p_uriSpec.substring(start, index);
     }
+    // Must handle jar URIs to their spec:  jar:<URI>!/ - Cory Prowse
+    if ((m_scheme != null) && m_scheme.equals("jar")) {
+        m_queryString = null;
+    }
 
     // fragment - starts with #
     if (testChar == '#') {
@@ -1060,6 +1083,11 @@
   * @return the scheme-specific part for this URI
   */
   public String getSchemeSpecificPart() {
+    // Must handle jar URIs to their spec:  jar:<url>!/{entry} - Cory Prowse
+    if ((m_scheme != null) && m_scheme.equals("jar")) {
+        return m_uriSpec.substring(4); 
+    }
+    
     StringBuffer schemespec = new StringBuffer();
 
     if (m_host != null || m_regAuthority != null) {
--- URI.java?rev=1.22	2005-01-06 14:49:47.241529291 +1100
+++ xerces-2_6_2/src/org/apache/xerces/util/URI.java	2005-01-06 14:42:39.079598973 +1100
@@ -1,17 +1,57 @@
 /*
- * Copyright 1999-2004 The Apache Software Foundation.
- * 
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * 
- *      http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * The Apache Software License, Version 1.1
+ *
+ *
+ * Copyright (c) 1999-2003 The Apache Software Foundation.  All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ *    if any, must include the following acknowledgment:
+ *       "This product includes software developed by the
+ *        Apache Software Foundation (http://www.apache.org/)."
+ *    Alternately, this acknowledgment may appear in the software itself,
+ *    if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Xerces" and "Apache Software Foundation" must
+ *    not be used to endorse or promote products derived from this
+ *    software without prior written permission. For written
+ *    permission, please contact [EMAIL PROTECTED]
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ *    nor may "Apache" appear in their name, without prior written
+ *    permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation and was
+ * originally based on software copyright (c) 1999, iClick Inc.,
+ * http://www.apache.org.  For more information on the Apache Software
+ * Foundation, please see <http://www.apache.org/>.
  */
 
 package org.apache.xerces.util;
@@ -51,7 +91,7 @@
 * default port for a specific scheme). Rather, it only knows the
 * grammar and basic set of operations that can be applied to a URI.
 *
-* @version  $Id: URI.java,v 1.22 2004/11/17 19:04:50 mrglavas Exp $
+* @version  $Id: URI.java,v 1.15 2004/01/19 22:35:46 mrglavas Exp $
 *
 **********************************************************************/
  public class URI implements Serializable {
@@ -64,9 +104,6 @@
   ********************************************************************/
   public static class MalformedURIException extends IOException {
 
-   /** Serialization version. */
-   static final long serialVersionUID = -6695054834342951930L;
-   
    /******************************************************************
     * Constructs a <code>MalformedURIException</code> with no specified
     * detail message.
@@ -86,9 +123,6 @@
     }
   }
 
-  /** Serialization version. */
-  static final long serialVersionUID = 1601921774685357214L;
-
   private static final byte [] fgLookupTable = new byte[128];
   
   /**
@@ -234,6 +268,9 @@
   /** If specified, stores the fragment for this URI; otherwise null */
   private String m_fragment = null;
 
+  /** Stores the full uriSpec for handling jar URIs - Cory Prowse */
+  private String m_uriSpec = null;
+  
   private static boolean DEBUG = false;
 
   /**
@@ -270,30 +307,7 @@
   public URI(String p_uriSpec) throws MalformedURIException {
     this((URI)null, p_uriSpec);
   }
-  
-  /**
-   * Construct a new URI from a URI specification string. If the
-   * specification follows the "generic URI" syntax, (two slashes
-   * following the first colon), the specification will be parsed
-   * accordingly - setting the scheme, userinfo, host,port, path, query
-   * string and fragment fields as necessary. If the specification does
-   * not follow the "generic URI" syntax, the specification is parsed
-   * into a scheme and scheme-specific part (stored as the path) only.
-   * Construct a relative URI if boolean is assigned to "true"
-   * and p_uriSpec is not valid absolute URI, instead of throwing an exception. 
-   * 
-   * @param p_uriSpec the URI specification string (cannot be null or
-   *                  empty)
-   * @param allowNonAbsoluteURI true to permit non-absolute URIs, 
-   *                            false otherwise.
-   *
-   * @exception MalformedURIException if p_uriSpec violates any syntax
-   *                                   rules
-   */
-  public URI(String p_uriSpec, boolean allowNonAbsoluteURI) throws MalformedURIException {
-      this((URI)null, p_uriSpec, allowNonAbsoluteURI);
-  }
-  
+
  /**
   * Construct a new URI from a base URI and a URI specification string.
   * The URI specification string may be a relative URI.
@@ -309,27 +323,6 @@
   public URI(URI p_base, String p_uriSpec) throws MalformedURIException {
     initialize(p_base, p_uriSpec);
   }
-  
-  /**
-   * Construct a new URI from a base URI and a URI specification string.
-   * The URI specification string may be a relative URI.
-   * Construct a relative URI if boolean is assigned to "true"
-   * and p_uriSpec is not valid absolute URI and p_base is null
-   * instead of throwing an exception. 
-   *
-   * @param p_base the base URI (cannot be null if p_uriSpec is null or
-   *               empty)
-   * @param p_uriSpec the URI specification string (cannot be null or
-   *                  empty if p_base is null)
-   * @param allowNonAbsoluteURI true to permit non-absolute URIs, 
-   *                            false otherwise.
-   *
-   * @exception MalformedURIException if p_uriSpec violates any syntax
-   *                                  rules
-   */
-  public URI(URI p_base, String p_uriSpec, boolean allowNonAbsoluteURI) throws MalformedURIException {
-      initialize(p_base, p_uriSpec, allowNonAbsoluteURI);
-  }
 
  /**
   * Construct a new URI that does not follow the generic URI syntax.
@@ -465,127 +458,6 @@
     m_queryString = p_other.getQueryString();
     m_fragment = p_other.getFragment();
   }
-  
-  /**
-   * Initializes this URI from a base URI and a URI specification string.
-   * See RFC 2396 Section 4 and Appendix B for specifications on parsing
-   * the URI and Section 5 for specifications on resolving relative URIs
-   * and relative paths.
-   *
-   * @param p_base the base URI (may be null if p_uriSpec is an absolute
-   *               URI)
-   * @param p_uriSpec the URI spec string which may be an absolute or
-   *                  relative URI (can only be null/empty if p_base
-   *                  is not null)
-   * @param allowNonAbsoluteURI true to permit non-absolute URIs, 
-   *                         in case of relative URI, false otherwise.
-   *
-   * @exception MalformedURIException if p_base is null and p_uriSpec
-   *                                  is not an absolute URI or if
-   *                                  p_uriSpec violates syntax rules
-   */
-  private void initialize(URI p_base, String p_uriSpec, boolean allowNonAbsoluteURI)
-      throws MalformedURIException {
-      
-      String uriSpec = p_uriSpec;
-      int uriSpecLen = (uriSpec != null) ? uriSpec.length() : 0;
-      
-      if (p_base == null && uriSpecLen == 0) {
-          if (allowNonAbsoluteURI) {
-              m_path = "";
-              return;
-          }
-          throw new MalformedURIException("Cannot initialize URI with empty parameters.");
-      }
-      
-      // just make a copy of the base if spec is empty
-      if (uriSpecLen == 0) {
-          initialize(p_base);
-          return;
-      }
-      
-      int index = 0;
-      
-      // Check for scheme, which must be before '/', '?' or '#'.
-      int colonIdx = uriSpec.indexOf(':');
-      if (colonIdx != -1) {
-          final int searchFrom = colonIdx - 1;
-          // search backwards starting from character before ':'.
-          int slashIdx = uriSpec.lastIndexOf('/', searchFrom);
-          int queryIdx = uriSpec.lastIndexOf('?', searchFrom);
-          int fragmentIdx = uriSpec.lastIndexOf('#', searchFrom);
-          
-          if (colonIdx == 0 || slashIdx != -1 || 
-              queryIdx != -1 || fragmentIdx != -1) {
-              // A standalone base is a valid URI according to spec
-              if (colonIdx == 0 || (p_base == null && fragmentIdx != 0 && !allowNonAbsoluteURI)) {
-                  throw new MalformedURIException("No scheme found in URI.");
-              }
-          }
-          else {
-              initializeScheme(uriSpec);
-              index = m_scheme.length()+1;
-              
-              // Neither 'scheme:' or 'scheme:#fragment' are valid URIs.
-              if (colonIdx == uriSpecLen - 1 || uriSpec.charAt(colonIdx+1) == '#') {
-                  throw new MalformedURIException("Scheme specific part cannot be empty.");   
-              }
-          }
-      }
-      else if (p_base == null && uriSpec.indexOf('#') != 0 && !allowNonAbsoluteURI) {
-          throw new MalformedURIException("No scheme found in URI.");    
-      }
-      
-      // Two slashes means we may have authority, but definitely means we're either
-      // matching net_path or abs_path. These two productions are ambiguous in that
-      // every net_path (except those containing an IPv6Reference) is an abs_path. 
-      // RFC 2396 resolves this ambiguity by applying a greedy left most matching rule. 
-      // Try matching net_path first, and if that fails we don't have authority so 
-      // then attempt to match abs_path.
-      //
-      // net_path = "//" authority [ abs_path ]
-      // abs_path = "/"  path_segments
-      if (((index+1) < uriSpecLen) &&
-          (uriSpec.charAt(index) == '/' && uriSpec.charAt(index+1) == '/')) {
-          index += 2;
-          int startPos = index;
-          
-          // Authority will be everything up to path, query or fragment
-          char testChar = '\0';
-          while (index < uriSpecLen) {
-              testChar = uriSpec.charAt(index);
-              if (testChar == '/' || testChar == '?' || testChar == '#') {
-                  break;
-              }
-              index++;
-          }
-          
-          // Attempt to parse authority. If the section is an empty string
-          // this is a valid server based authority, so set the host to this
-          // value.
-          if (index > startPos) {
-              // If we didn't find authority we need to back up. Attempt to
-              // match against abs_path next.
-              if (!initializeAuthority(uriSpec.substring(startPos, index))) {
-                  index = startPos - 2;
-              }
-          }
-          else {
-              m_host = "";
-          }
-      }
-      
-      initializePath(uriSpec, index);
-      
-      // Resolve relative URI to base URI - see RFC 2396 Section 5.2
-      // In some cases, it might make more sense to throw an exception
-      // (when scheme is specified is the string spec and the base URI
-      // is also specified, for example), but we're just following the
-      // RFC specifications
-      if (p_base != null) {
-          absolutize(p_base);
-      }
-  }
 
  /**
   * Initializes this URI from a base URI and a URI specification string.
@@ -607,6 +479,17 @@
                          throws MalformedURIException {
 	  
     String uriSpec = p_uriSpec;
+
+    // Must handle jar URIs to their spec:  jar:<URI>!/ - Cory Prowse 
+    m_uriSpec = p_uriSpec;
+    if ((p_base != null) && (p_base.m_scheme.equals("jar"))) {
+      m_uriSpec = p_base.m_uriSpec;
+      int end = m_uriSpec.lastIndexOf("!/");
+      if (end > 0) {
+        m_uriSpec = m_uriSpec.substring(0, end + 2);
+      }
+      m_uriSpec += p_uriSpec;
+    }
     int uriSpecLen = (uriSpec != null) ? uriSpec.length() : 0;
 	
     if (p_base == null && uriSpecLen == 0) {
@@ -622,34 +505,31 @@
 
     int index = 0;
 
-    // Check for scheme, which must be before '/', '?' or '#'.
-    int colonIdx = uriSpec.indexOf(':');
-    if (colonIdx != -1) {
-        final int searchFrom = colonIdx - 1;
-        // search backwards starting from character before ':'.
-        int slashIdx = uriSpec.lastIndexOf('/', searchFrom);
-        int queryIdx = uriSpec.lastIndexOf('?', searchFrom);
-        int fragmentIdx = uriSpec.lastIndexOf('#', searchFrom);
-       
-        if (colonIdx == 0 || slashIdx != -1 || 
-            queryIdx != -1 || fragmentIdx != -1) {
-            // A standalone base is a valid URI according to spec
-            if (colonIdx == 0 || (p_base == null && fragmentIdx != 0)) {
-                throw new MalformedURIException("No scheme found in URI.");
-            }
-        }
-        else {
-            initializeScheme(uriSpec);
-            index = m_scheme.length()+1;
-            
-            // Neither 'scheme:' or 'scheme:#fragment' are valid URIs.
-            if (colonIdx == uriSpecLen - 1 || uriSpec.charAt(colonIdx+1) == '#') {
-            	throw new MalformedURIException("Scheme specific part cannot be empty.");	
-            }
-        }
+    // Check for scheme, which must be before '/', '?' or '#'. Also handle
+    // names with DOS drive letters ('D:'), so 1-character schemes are not
+    // allowed.
+    int colonIdx    = uriSpec.indexOf(':');
+    int slashIdx    = uriSpec.indexOf('/');
+    int queryIdx    = uriSpec.indexOf('?');
+    int fragmentIdx = uriSpec.indexOf('#');
+
+    if ((colonIdx < 2) ||
+        (colonIdx > slashIdx && slashIdx != -1) ||
+        (colonIdx > queryIdx && queryIdx != -1) ||
+        (colonIdx > fragmentIdx && fragmentIdx != -1)) {
+      // A standalone base is a valid URI according to spec
+      if (colonIdx == 0 || (p_base == null && fragmentIdx != 0)) {
+        throw new MalformedURIException("No scheme found in URI.");
+      }
     }
-    else if (p_base == null && uriSpec.indexOf('#') != 0) {
-        throw new MalformedURIException("No scheme found in URI.");    
+    else {
+      initializeScheme(uriSpec);
+      index = m_scheme.length()+1;
+      
+      // Neither 'scheme:' or 'scheme:#fragment' are valid URIs.
+      if (colonIdx == uriSpecLen - 1 || uriSpec.charAt(colonIdx+1) == '#') {
+      	throw new MalformedURIException("Scheme specific part cannot be empty.");	
+      }
     }
 
     // Two slashes means we may have authority, but definitely means we're either
@@ -699,16 +579,6 @@
     // is also specified, for example), but we're just following the
     // RFC specifications
     if (p_base != null) {
-        absolutize(p_base);
-    }
-  }
-
-  /**
-   * Absolutize URI with given base URI.
-   *
-   * @param p_base base URI for absolutization
-   */
-  public void absolutize(URI p_base) {
 
       // check to see if this is the current doc - RFC 2396 5.2 #2
       // note that this is slightly different from the RFC spec in that
@@ -719,113 +589,108 @@
       // identified this as a bug in the RFC
       if (m_path.length() == 0 && m_scheme == null &&
           m_host == null && m_regAuthority == null) {
-          m_scheme = p_base.getScheme();
-          m_userinfo = p_base.getUserinfo();
-          m_host = p_base.getHost();
-          m_port = p_base.getPort();
-          m_regAuthority = p_base.getRegBasedAuthority();
-          m_path = p_base.getPath();
-          
-          if (m_queryString == null) {
-              m_queryString = p_base.getQueryString();
-              
-              if (m_fragment == null) {
-                  m_fragment = p_base.getFragment();
-              }
-          }
-          return;
+        m_scheme = p_base.getScheme();
+        m_userinfo = p_base.getUserinfo();
+        m_host = p_base.getHost();
+        m_port = p_base.getPort();
+        m_regAuthority = p_base.getRegBasedAuthority();
+        m_path = p_base.getPath();
+
+        if (m_queryString == null) {
+          m_queryString = p_base.getQueryString();
+        }
+        return;
       }
-      
+
       // check for scheme - RFC 2396 5.2 #3
       // if we found a scheme, it means absolute URI, so we're done
       if (m_scheme == null) {
-          m_scheme = p_base.getScheme();
+        m_scheme = p_base.getScheme();
       }
       else {
-          return;
+        return;
       }
-      
+
       // check for authority - RFC 2396 5.2 #4
       // if we found a host, then we've got a network path, so we're done
       if (m_host == null && m_regAuthority == null) {
-          m_userinfo = p_base.getUserinfo();
-          m_host = p_base.getHost();
-          m_port = p_base.getPort();
-          m_regAuthority = p_base.getRegBasedAuthority();
+        m_userinfo = p_base.getUserinfo();
+        m_host = p_base.getHost();
+        m_port = p_base.getPort();
+        m_regAuthority = p_base.getRegBasedAuthority();
       }
       else {
-          return;
+        return;
       }
-      
+
       // check for absolute path - RFC 2396 5.2 #5
       if (m_path.length() > 0 &&
-              m_path.startsWith("/")) {
-          return;
+          m_path.startsWith("/")) {
+        return;
       }
-      
+
       // if we get to this point, we need to resolve relative path
       // RFC 2396 5.2 #6
       String path = "";
       String basePath = p_base.getPath();
-      
+
       // 6a - get all but the last segment of the base URI path
       if (basePath != null && basePath.length() > 0) {
-          int lastSlash = basePath.lastIndexOf('/');
-          if (lastSlash != -1) {
-              path = basePath.substring(0, lastSlash+1);
-          }
+        int lastSlash = basePath.lastIndexOf('/');
+        if (lastSlash != -1) {
+          path = basePath.substring(0, lastSlash+1);
+        }
       }
       else if (m_path.length() > 0) {
-          path = "/";
+      	path = "/";
       }
-      
+
       // 6b - append the relative URI path
       path = path.concat(m_path);
-      
+
       // 6c - remove all "./" where "." is a complete path segment
-      int index = -1;
+      index = -1;
       while ((index = path.indexOf("/./")) != -1) {
-          path = path.substring(0, index+1).concat(path.substring(index+3));
+        path = path.substring(0, index+1).concat(path.substring(index+3));
       }
-      
+
       // 6d - remove "." if path ends with "." as a complete path segment
       if (path.endsWith("/.")) {
-          path = path.substring(0, path.length()-1);
+        path = path.substring(0, path.length()-1);
       }
-      
+
       // 6e - remove all "<segment>/../" where "<segment>" is a complete
       // path segment not equal to ".."
       index = 1;
       int segIndex = -1;
       String tempString = null;
-      
+
       while ((index = path.indexOf("/../", index)) > 0) {
-          tempString = path.substring(0, path.indexOf("/../"));
-          segIndex = tempString.lastIndexOf('/');
-          if (segIndex != -1) {
-              if (!tempString.substring(segIndex).equals("..")) {
-                  path = path.substring(0, segIndex+1).concat(path.substring(index+4));
-                  index = segIndex;
-              }
-              else {
-                  index += 4;
-              }
-          }
-          else {
-              index += 4;
+        tempString = path.substring(0, path.indexOf("/../"));
+        segIndex = tempString.lastIndexOf('/');
+        if (segIndex != -1) {
+          if (!tempString.substring(segIndex).equals("..")) {
+            path = path.substring(0, segIndex+1).concat(path.substring(index+4));
+            index = segIndex;
           }
+          else
+            index += 4;
+        }
+        else
+          index += 4;
       }
-      
+
       // 6f - remove ending "<segment>/.." where "<segment>" is a
       // complete path segment
       if (path.endsWith("/..")) {
-          tempString = path.substring(0, path.length()-3);
-          segIndex = tempString.lastIndexOf('/');
-          if (segIndex != -1) {
-              path = path.substring(0, segIndex+1);
-          }
+        tempString = path.substring(0, path.length()-3);
+        segIndex = tempString.lastIndexOf('/');
+        if (segIndex != -1) {
+          path = path.substring(0, segIndex+1);
+        }
       }
       m_path = path;
+    }
   }
 
  /**
@@ -1140,6 +1005,11 @@
     }
     m_path = p_uriSpec.substring(start, index);
 
+    // Must handle jar URIs to their spec:  jar:<URI>!/ - Cory Prowse
+    if ((m_scheme != null) && m_scheme.equals("jar")) {
+        m_path = null;
+    }
+  
     // query - starts with ? and up to fragment or end
     if (testChar == '?') {
       index++;
@@ -1166,6 +1036,10 @@
       }
       m_queryString = p_uriSpec.substring(start, index);
     }
+    // Must handle jar URIs to their spec:  jar:<URI>!/ - Cory Prowse
+    if ((m_scheme != null) && m_scheme.equals("jar")) {
+        m_queryString = null;
+    }
 
     // fragment - starts with #
     if (testChar == '#') {
@@ -1209,6 +1083,11 @@
   * @return the scheme-specific part for this URI
   */
   public String getSchemeSpecificPart() {
+    // Must handle jar URIs to their spec:  jar:<url>!/{entry} - Cory Prowse
+    if ((m_scheme != null) && m_scheme.equals("jar")) {
+        return m_uriSpec.substring(4); 
+    }
+    
     StringBuffer schemespec = new StringBuffer();
 
     if (m_host != null || m_regAuthority != null) {
@@ -1703,17 +1582,6 @@
     // double-slashes which means generic uri
     return (m_host != null);
   }
-  
-  /**
-   * Returns whether this URI represents an absolute URI.
-   *
-   * @return true if this URI represents an absolute URI, false
-   *         otherwise
-   */
-  public boolean isAbsoluteURI() {
-      // presence of the scheme means absolute uri
-      return (m_scheme != null);
-  }
 
  /**
   * Determine whether a scheme conforms to the rules for a scheme name.

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to