org.codehaus.classworlds.uberjar.protocol.jar
Class JarUrlConnection

java.lang.Object
  extended byjava.net.URLConnection
      extended byjava.net.JarURLConnection
          extended byorg.codehaus.classworlds.uberjar.protocol.jar.JarUrlConnection

public class JarUrlConnection
extends java.net.JarURLConnection

URLConnection capable of handling multiply-nested jars.

Version:
$Id: JarUrlConnection.java,v 1.1 2003/09/23 18:11:30 jvanzyl Exp $
Author:
bob mcwhirter

Field Summary
private  java.net.URL baseResource
          Base resource.
private  java.io.InputStream in
          Terminal input-stream.
private  java.lang.String[] segments
          Additional nested segments.
 
Fields inherited from class java.net.JarURLConnection
jarFileURLConnection
 
Fields inherited from class java.net.URLConnection
allowUserInteraction, connected, doInput, doOutput, ifModifiedSince, url, useCaches
 
Constructor Summary
(package private) JarUrlConnection(java.net.URL url)
          Construct.
 
Method Summary
 void connect()
           
protected  java.net.URL getBaseResource()
          Retrieve the base resource URL.
 java.io.InputStream getInputStream()
           
 java.util.jar.JarFile getJarFile()
           
protected  java.io.InputStream getSegmentInputStream(java.io.InputStream baseIn, java.lang.String segment)
          Retrieve the InputStream for the nesting segment relative to a base InputStream.
protected  java.lang.String[] getSegments()
          Retrieve the nesting path segments.
protected static java.net.URL normaliseURL(java.net.URL url)
           
protected  void setupBaseResourceInputStream()
          Setup the InputStream purely from the base resource.
protected  void setupPathedInputStream()
          Setup the InputStream for URL with nested segments.
 
Methods inherited from class java.net.JarURLConnection
getAttributes, getCertificates, getEntryName, getJarEntry, getJarFileURL, getMainAttributes, getManifest
 
Methods inherited from class java.net.URLConnection
addRequestProperty, getAllowUserInteraction, getContent, getContent, getContentEncoding, getContentLength, getContentType, getDate, getDefaultAllowUserInteraction, getDefaultRequestProperty, getDefaultUseCaches, getDoInput, getDoOutput, getExpiration, getFileNameMap, getHeaderField, getHeaderField, getHeaderFieldDate, getHeaderFieldInt, getHeaderFieldKey, getHeaderFields, getIfModifiedSince, getLastModified, getOutputStream, getPermission, getRequestProperties, getRequestProperty, getURL, getUseCaches, guessContentTypeFromName, guessContentTypeFromStream, setAllowUserInteraction, setContentHandlerFactory, setDefaultAllowUserInteraction, setDefaultRequestProperty, setDefaultUseCaches, setDoInput, setDoOutput, setFileNameMap, setIfModifiedSince, setRequestProperty, setUseCaches, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

baseResource

private java.net.URL baseResource
Base resource.


segments

private java.lang.String[] segments
Additional nested segments.


in

private java.io.InputStream in
Terminal input-stream.

Constructor Detail

JarUrlConnection

JarUrlConnection(java.net.URL url)
           throws java.io.IOException
Construct.

Parameters:
url - Target URL of the connections.
Throws:
java.io.IOException - If an error occurs while attempting to initialize the connection.
Method Detail

normaliseURL

protected static java.net.URL normaliseURL(java.net.URL url)
                                    throws java.net.MalformedURLException
Throws:
java.net.MalformedURLException

getSegments

protected java.lang.String[] getSegments()
Retrieve the nesting path segments.

Returns:
The segments.

getBaseResource

protected java.net.URL getBaseResource()
Retrieve the base resource URL.

Returns:
The base resource url.

connect

public void connect()
             throws java.io.IOException
Throws:
java.io.IOException
See Also:
URLConnection

setupBaseResourceInputStream

protected void setupBaseResourceInputStream()
                                     throws java.io.IOException
Setup the InputStream purely from the base resource.

Throws:
java.io.IOException - If an I/O error occurs.

setupPathedInputStream

protected void setupPathedInputStream()
                               throws java.io.IOException
Setup the InputStream for URL with nested segments.

Throws:
java.io.IOException - If an I/O error occurs.

getSegmentInputStream

protected java.io.InputStream getSegmentInputStream(java.io.InputStream baseIn,
                                                    java.lang.String segment)
                                             throws java.io.IOException
Retrieve the InputStream for the nesting segment relative to a base InputStream.

Parameters:
baseIn - The base input-stream.
segment - The nesting segment path.
Returns:
The input-stream to the segment.
Throws:
java.io.IOException - If an I/O error occurs.

getInputStream

public java.io.InputStream getInputStream()
                                   throws java.io.IOException
Throws:
java.io.IOException
See Also:
URLConnection

getJarFile

public java.util.jar.JarFile getJarFile()
                                 throws java.io.IOException
Returns:
JarFile
Throws:
java.io.IOException
See Also:
JarURLConnection.getJarFile()