JarURLConnection.java revision 0
0N/A * Copyright 1997-2006 Sun Microsystems, Inc. All Rights Reserved. 0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 0N/A * This code is free software; you can redistribute it and/or modify it 0N/A * under the terms of the GNU General Public License version 2 only, as 0N/A * published by the Free Software Foundation. Sun designates this 0N/A * particular file as subject to the "Classpath" exception as provided 0N/A * by Sun in the LICENSE file that accompanied this code. 0N/A * This code is distributed in the hope that it will be useful, but WITHOUT 0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 0N/A * version 2 for more details (a copy is included in the LICENSE file that 0N/A * accompanied this code). 0N/A * You should have received a copy of the GNU General Public License version 0N/A * 2 along with this work; if not, write to the Free Software Foundation, 0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 0N/A * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 0N/A * CA 95054 USA or visit www.sun.com if you need additional information or 0N/A * have any questions. 0N/A * A URL Connection to a Java ARchive (JAR) file or an entry in a JAR 0N/A * <p>The syntax of a JAR URL is: 0N/A * jar:<url>!/{entry} 0N/A * <p>Jar URLs should be used to refer to a JAR file or entries in 0N/A * a JAR file. The example above is a JAR URL which refers to a JAR 0N/A * entry. If the entry name is omitted, the URL refers to the whole 0N/A * <p>Users should cast the generic URLConnection to a 0N/A * JarURLConnection when they know that the URL they created is a JAR 0N/A * URL, and they need JAR-specific functionality. For example: 0N/A * JarURLConnection jarConnection = (JarURLConnection)url.openConnection(); 0N/A * Manifest manifest = jarConnection.getManifest(); 0N/A * <p>JarURLConnection instances can only be used to read from JAR files. 0N/A * It is not possible to get a {@link java.io.OutputStream} to modify or write 0N/A * to the underlying JAR file using this class. 0N/A * <dt>A Jar directory 0N/A * <p><code>!/</code> is refered to as the <em>separator</em>. 0N/A * <p>When constructing a JAR url via <code>new URL(context, spec)</code>, 0N/A * the following rules apply: 0N/A * <li>if there is no context URL and the specification passed to the 0N/A * URL constructor doesn't contain a separator, the URL is considered 0N/A * to refer to a JarFile. 0N/A * <li>if there is a context URL, the context URL is assumed to refer 0N/A * to a JAR file or a Jar directory. 0N/A * <li>if the specification begins with a '/', the Jar directory is 0N/A * ignored, and the spec is considered to be at the root of the Jar 0N/A * @see java.net.URLConnection 0N/A * @see java.util.jar.JarFile 0N/A * @see java.util.jar.JarInputStream 0N/A * @see java.util.jar.Manifest 0N/A * @see java.util.zip.ZipEntry 0N/A * @author Benjamin Renaud 0N/A * The connection to the JAR file URL, if the connection has been 0N/A * initiated. This should be set by connect. 0N/A * Creates the new JarURLConnection to the specified URL. 0N/A * @param url the URL 0N/A * @throws MalformedURLException if no legal protocol 0N/A * could be found in a specification string or the 0N/A * string could not be parsed. 0N/A /* get the specs for a given url out of the cache, and compute and 0N/A * cache them if they're not there. 0N/A * REMIND: we don't handle nested JAR URLs 0N/A /* if ! is the last letter of the innerURL, entryName is null */ 0N/A * Returns the URL for the Jar file for this connection. 0N/A * @return the URL for the Jar file for this connection. 0N/A * Return the entry name for this connection. This method 0N/A * returns null if the JAR file URL corresponding to this 0N/A * connection points to a JAR file and not a JAR file entry. 0N/A * @return the entry name for this connection, if any. 0N/A * Return the JAR file for this connection. 0N/A * @return the JAR file for this connection. If the connection is 0N/A * a connection to an entry of a JAR file, the JAR file object is 0N/A * @exception IOException if an IOException occurs while trying to 0N/A * connect to the JAR file for this connection. 0N/A * Returns the Manifest for this connection, or null if none. 0N/A * @return the manifest object corresponding to the JAR file object 0N/A * for this connection. 0N/A * @exception IOException if getting the JAR file for this 0N/A * connection causes an IOException to be trown. 0N/A * Return the JAR entry object for this connection, if any. This 0N/A * method returns null if the JAR file URL corresponding to this 0N/A * connection points to a JAR file and not a JAR file entry. 0N/A * @return the JAR entry object for this connection, or null if 0N/A * the JAR URL for this connection points to a JAR file. 0N/A * @exception IOException if getting the JAR file for this 0N/A * connection causes an IOException to be trown. 0N/A * Return the Attributes object for this connection if the URL 0N/A * for it points to a JAR file entry, null otherwise. 0N/A * @return the Attributes object for this connection if the URL 0N/A * for it points to a JAR file entry, null otherwise. 0N/A * @exception IOException if getting the JAR entry causes an 0N/A * IOException to be thrown. 0N/A * Returns the main Attributes for the JAR file for this 0N/A * @return the main Attributes for the JAR file for this 0N/A * @exception IOException if getting the manifest causes an 0N/A * IOException to be thrown. 0N/A * Return the Certificate object for this connection if the URL 0N/A * for it points to a JAR file entry, null otherwise. This method 0N/A * can only be called once 0N/A * the connection has been completely verified by reading 0N/A * from the input stream until the end of the stream has been 0N/A * reached. Otherwise, this method will return <code>null</code> 0N/A * @return the Certificate object for this connection if the URL 0N/A * for it points to a JAR file entry, null otherwise. 0N/A * @exception IOException if getting the JAR entry causes an 0N/A * IOException to be thrown.