diff options
Diffstat (limited to 'libjava/java/net/JarURLConnection.java')
-rw-r--r-- | libjava/java/net/JarURLConnection.java | 102 |
1 files changed, 93 insertions, 9 deletions
diff --git a/libjava/java/net/JarURLConnection.java b/libjava/java/net/JarURLConnection.java index 60adfcd9c61..a90c7f33037 100644 --- a/libjava/java/net/JarURLConnection.java +++ b/libjava/java/net/JarURLConnection.java @@ -1,4 +1,4 @@ -/* Copyright (C) 1999, 2000 Free Software Foundation +/* Copyright (C) 1999, 2000, 2002 Free Software Foundation This file is part of libgcj. @@ -12,11 +12,14 @@ import java.net.*; import java.io.*; import java.util.jar.*; import java.util.zip.*; +import java.util.Map; import java.util.Vector; import java.util.Hashtable; +import java.security.cert.Certificate; /** * @author Kresten Krab Thorup <krab@gnu.org> + * @since 1.2 * @date Aug 10, 1999. */ @@ -31,7 +34,7 @@ public abstract class JarURLConnection extends URLConnection * either case this describes just the jar file itself. */ protected URLConnection jarFileURLConnection; - // If this is a connection to a jar file element this is set, otherwose null. + // If this is a connection to a jar file element this is set, otherwise null. private final String element; // Cached JarURLConnection's @@ -47,7 +50,14 @@ public abstract class JarURLConnection extends URLConnection return element; } - public JarURLConnection(URL url) + /** + * Creates a new JarURLConnection + * + * @exception MalformedURLException If url is invalid + * + * @specnote This constructor is protected since JDK 1.4 + */ + protected JarURLConnection(URL url) throws MalformedURLException { super(url); @@ -103,7 +113,8 @@ public abstract class JarURLConnection extends URLConnection { // This is a JarURLConnection for the entire jar file. - InputStream jar_is = new BufferedInputStream(jarFileURLConnection.getInputStream ()); + InputStream jar_is = new BufferedInputStream( + jarFileURLConnection.getInputStream ()); return new JarInputStream(jar_is); } @@ -128,7 +139,8 @@ public abstract class JarURLConnection extends URLConnection else { // If the jar file is not local, ... - JarInputStream zis = new JarInputStream(jarFileURLConnection.getInputStream ()); + JarInputStream zis = new JarInputStream( + jarFileURLConnection.getInputStream ()); // This is hideous, we're doing a linear search... for (ZipEntry ent = zis.getNextEntry (); @@ -148,7 +160,12 @@ public abstract class JarURLConnection extends URLConnection return null; } - public JarEntry getJarEntry () throws java.io.IOException + /** + * Return the JAR entry object for this connection, if any + * + * @exception IOException If an error occurs + */ + public JarEntry getJarEntry () throws IOException { JarFile jarfile = null; @@ -162,14 +179,15 @@ public abstract class JarURLConnection extends URLConnection { jarfile = getJarFile (); } - catch (java.io.IOException x) + catch (IOException x) { /* ignore */ } if (jarfile == null) { - JarInputStream zis = new JarInputStream(jarFileURLConnection.getInputStream ()); + JarInputStream zis = new JarInputStream( + jarFileURLConnection.getInputStream ()); // This is hideous, we're doing a linear search for the thing... for (ZipEntry ent = zis.getNextEntry (); @@ -191,7 +209,12 @@ public abstract class JarURLConnection extends URLConnection return null; } - public abstract JarFile getJarFile() throws java.io.IOException; + /** + * Return the JAR file for this connection + * + * @exception IOException If an error occurs + */ + public abstract JarFile getJarFile() throws IOException; // Steal and borrow from protocol/file/Connection.java @@ -215,6 +238,20 @@ public abstract class JarURLConnection extends URLConnection } // Override default method in URLConnection. + public Map getHeaderFields() + { + try + { + getHeaders(); + } + catch (IOException x) + { + return null; + } + return hdrHash; + } + + // Override default method in URLConnection. public String getHeaderField(int n) { try @@ -300,4 +337,51 @@ public abstract class JarURLConnection extends URLConnection hdrHash.put(key.toLowerCase(), Long.toString(len)); } + /** + * Returns an array of Certificate objects for the jar file entry specified + * by this URL or null if there are none + * + * @return A Certificate array + * + * @exception IOException If an error occurs + */ + public Certificate[] getCertificates() throws IOException + { + return getJarEntry().getCertificates(); + } + + /** + * Returns the main Attributes for the JAR file for this connection + * + * @exception IOException If an error occurs + */ + public Attributes getMainAttributes () throws IOException + { + return getManifest ().getMainAttributes (); + } + + /** + * Return the Attributes object for this connection if the URL for it points + * to a JAR file entry, null otherwise + * + * @exception IOException If an error occurs + */ + public Attributes getAttributes () throws IOException + { + // FIXME: implement this + return null; + } + + /** + * Returns the Manifest for this connection, or null if none + * + * @exception IOException If an error occurs + */ + public Manifest getManifest () throws IOException + { + JarFile file = getJarFile (); + + // FIXME: implement this + return null; + } } |