java.net

Class JarURLConnection

Known Direct Subclasses:
Connection

public abstract class JarURLConnection
extends URLConnection

This abstract class represents a common superclass for implementations of jar URL's. A jar URL is a special type of URL that allows JAR files on remote systems to be accessed. It has the form:

jar:<standard URL pointing to jar filei>!/file/within/jarfile

for example:

jar:http://www.urbanophile.com/java/foo.jar!/com/urbanophile/bar.class

That example URL points to the file /com/urbanophile/bar.class in the remote JAR file http://www.urbanophile.com/java/foo.jar. The HTTP protocol is used only as an example. Any supported remote protocol can be used.

This class currently works by retrieving the entire jar file into a local cache file, then performing standard jar operations on it. (At least this is true for the default protocol implementation).

Since:
1.2

Field Summary

protected URLConnection
jarFileURLConnection
The connection to the jar file itself.

Fields inherited from class java.net.URLConnection

allowUserInteraction, connected, doInput, doOutput, ifModifiedSince, url, useCaches

Constructor Summary

JarURLConnection(URL url)
Creates a JarURLConnection from an URL object

Method Summary

Attributes
getAttributes()
Returns the Attributes for the Jar entry specified by the URL or null if none
Certificate[]
getCertificates()
Returns an array of Certificate objects for the jar file entry specified by this URL or null if there are none
String
getEntryName()
Returns the "entry name" portion of the jar URL.
JarEntry
getJarEntry()
Returns the entry in this jar file specified by the URL.
abstract JarFile
getJarFile()
Returns a read-only JarFile object for the remote jar file
URL
getJarFileURL()
This method returns the "real" URL where the JarFile is located.
Attributes
getMainAttributes()
Returns the main Attributes for the jar file specified in the URL or null if there are none
Manifest
getManifest()
Returns a Manifest object for this jar file, or null if there is no manifest.

Methods inherited from class java.net.URLConnection

addRequestProperty, connect, getAllowUserInteraction, getConnectTimeout, getContent, getContent, getContentEncoding, getContentLength, getContentType, getDate, getDefaultAllowUserInteraction, getDefaultRequestProperty, getDefaultUseCaches, getDoInput, getDoOutput, getExpiration, getFileNameMap, getHeaderField, getHeaderField, getHeaderFieldDate, getHeaderFieldInt, getHeaderFieldKey, getHeaderFields, getIfModifiedSince, getInputStream, getLastModified, getOutputStream, getPermission, getReadTimeout, getRequestProperties, getRequestProperty, getURL, getUseCaches, guessContentTypeFromName, guessContentTypeFromStream, setAllowUserInteraction, setConnectTimeout, setContentHandlerFactory, setDefaultAllowUserInteraction, setDefaultRequestProperty, setDefaultUseCaches, setDoInput, setDoOutput, setFileNameMap, setIfModifiedSince, setReadTimeout, setRequestProperty, setUseCaches, toString

Methods inherited from class java.lang.Object

clone, equals, extends Object> getClass, finalize, hashCode, notify, notifyAll, toString, wait, wait, wait

Field Details

jarFileURLConnection

protected URLConnection jarFileURLConnection
The connection to the jar file itself. A JarURLConnection can represent an entry in a jar file or an entire jar file. In either case this describes just the jar file itself.

Constructor Details

JarURLConnection

protected JarURLConnection(URL url)
            throws MalformedURLException
Creates a JarURLConnection from an URL object
Parameters:
url - The URL object for this connection.
Throws:
MalformedURLException - If url is invalid

Method Details

getAttributes

public Attributes getAttributes()
            throws IOException
Returns the Attributes for the Jar entry specified by the URL or null if none
Returns:
The Attributes object for this connection if the URL for it points to a JAR file entry, null otherwise
Throws:
IOException - If an error occurs

getCertificates

public Certificate[] getCertificates()
            throws IOException
Returns an array of Certificate objects for the jar file entry specified by this URL or null if there are none
Returns:
A Certificate array
Throws:
IOException - If an error occurs

getEntryName

public String getEntryName()
Returns the "entry name" portion of the jar URL. This is the portion after the "!/" in the jar URL that represents the pathname inside the actual jar file.
Returns:
The entry name.

getJarEntry

public JarEntry getJarEntry()
            throws IOException
Returns the entry in this jar file specified by the URL.
Returns:
The jar entry
Throws:
IOException - If an error occurs

getJarFile

public abstract JarFile getJarFile()
            throws IOException
Returns a read-only JarFile object for the remote jar file
Returns:
The JarFile object
Throws:
IOException - If an error occurs

getJarFileURL

public URL getJarFileURL()
This method returns the "real" URL where the JarFile is located. //****Is this right?*****
Returns:
The remote URL

getMainAttributes

public Attributes getMainAttributes()
            throws IOException
Returns the main Attributes for the jar file specified in the URL or null if there are none
Returns:
The main Attributes for the JAR file for this connection
Throws:
IOException - If an error occurs

getManifest

public Manifest getManifest()
            throws IOException
Returns a Manifest object for this jar file, or null if there is no manifest.
Returns:
The Manifest for this connection, or null if none
Throws:
IOException - If an error occurs

JarURLConnection.java -- Class for manipulating remote jar files Copyright (C) 1998, 2002, 2003, 2005 Free Software Foundation, Inc. This file is part of GNU Classpath. GNU Classpath is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. GNU Classpath is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with GNU Classpath; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. Linking this library statically or dynamically with other modules is making a combined work based on this library. Thus, the terms and conditions of the GNU General Public License cover the whole combination. As a special exception, the copyright holders of this library give you permission to link this library with independent modules to produce an executable, regardless of the license terms of these independent modules, and to copy and distribute the resulting executable under terms of your choice, provided that you also meet, for each linked independent module, the terms and conditions of the license of that module. An independent module is a module which is not derived from or based on this library. If you modify this library, you may extend this exception to your version of the library, but you are not obligated to do so. If you do not wish to do so, delete this exception statement from your version.