summaryrefslogtreecommitdiff
path: root/gnu/java/net/protocol/jar
diff options
context:
space:
mode:
Diffstat (limited to 'gnu/java/net/protocol/jar')
-rw-r--r--gnu/java/net/protocol/jar/Connection.java96
-rw-r--r--gnu/java/net/protocol/jar/Handler.java50
2 files changed, 73 insertions, 73 deletions
diff --git a/gnu/java/net/protocol/jar/Connection.java b/gnu/java/net/protocol/jar/Connection.java
index 386aacef6..85d27bfc9 100644
--- a/gnu/java/net/protocol/jar/Connection.java
+++ b/gnu/java/net/protocol/jar/Connection.java
@@ -7,7 +7,7 @@ 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
@@ -73,13 +73,13 @@ public final class Connection extends JarURLConnection
private JarFile jar_file;
private JarEntry jar_entry;
private URL jar_url;
-
+
public static class JarFileCache
{
private static Hashtable<URL, JarFile> cache
= new Hashtable<URL, JarFile>();
private static final int READBUFSIZE = 4*1024;
-
+
public static synchronized JarFile get (URL url, boolean useCaches)
throws IOException
{
@@ -92,31 +92,31 @@ public final class Connection extends JarURLConnection
}
if ("file".equals (url.getProtocol()))
- {
- String fn = url.getFile();
- fn = gnu.java.net.protocol.file.Connection.unquote(fn);
- File f = new File (fn);
- jf = new JarFile (f, true, ZipFile.OPEN_READ);
- }
+ {
+ String fn = url.getFile();
+ fn = gnu.java.net.protocol.file.Connection.unquote(fn);
+ File f = new File (fn);
+ jf = new JarFile (f, true, ZipFile.OPEN_READ);
+ }
else
- {
- URLConnection urlconn = url.openConnection();
- InputStream is = urlconn.getInputStream();
- byte[] buf = new byte [READBUFSIZE];
- File f = File.createTempFile ("cache", "jar");
- FileOutputStream fos = new FileOutputStream (f);
- int len = 0;
-
- while ((len = is.read (buf)) != -1)
- {
- fos.write (buf, 0, len);
- }
-
- fos.close();
- // Always verify the Manifest, open read only and delete when done.
- jf = new JarFile (f, true,
- ZipFile.OPEN_READ | ZipFile.OPEN_DELETE);
- }
+ {
+ URLConnection urlconn = url.openConnection();
+ InputStream is = urlconn.getInputStream();
+ byte[] buf = new byte [READBUFSIZE];
+ File f = File.createTempFile ("cache", "jar");
+ FileOutputStream fos = new FileOutputStream (f);
+ int len = 0;
+
+ while ((len = is.read (buf)) != -1)
+ {
+ fos.write (buf, 0, len);
+ }
+
+ fos.close();
+ // Always verify the Manifest, open read only and delete when done.
+ jf = new JarFile (f, true,
+ ZipFile.OPEN_READ | ZipFile.OPEN_DELETE);
+ }
if (useCaches)
cache.put (url, jf);
@@ -140,7 +140,7 @@ public final class Connection extends JarURLConnection
jar_url = getJarFileURL();
jar_file = JarFileCache.get (jar_url, useCaches);
String entry_name = getEntryName();
-
+
if (entry_name != null
&& !entry_name.equals (""))
{
@@ -160,7 +160,7 @@ public final class Connection extends JarURLConnection
if (! doInput)
throw new ProtocolException("Can't open InputStream if doInput is false");
-
+
return jar_file.getInputStream (jar_entry);
}
@@ -179,26 +179,26 @@ public final class Connection extends JarURLConnection
{
try
{
- if (!connected)
- connect();
+ if (!connected)
+ connect();
- if (field.equals("content-type"))
+ if (field.equals("content-type"))
return guessContentTypeFromName(getJarEntry().getName());
- else if (field.equals("content-length"))
+ else if (field.equals("content-length"))
return Long.toString(getJarEntry().getSize());
- else if (field.equals("last-modified"))
- {
- // Both creating and manipulating dateFormat need synchronization.
- synchronized (Connection.class)
- {
- if (dateFormat == null)
- dateFormat = new SimpleDateFormat
- ("EEE, dd MMM yyyy hh:mm:ss 'GMT'",
- new Locale ("En", "Us", "Unix"));
-
- return dateFormat.format(new Date(getJarEntry().getTime()));
- }
- }
+ else if (field.equals("last-modified"))
+ {
+ // Both creating and manipulating dateFormat need synchronization.
+ synchronized (Connection.class)
+ {
+ if (dateFormat == null)
+ dateFormat = new SimpleDateFormat
+ ("EEE, dd MMM yyyy hh:mm:ss 'GMT'",
+ new Locale ("En", "Us", "Unix"));
+
+ return dateFormat.format(new Date(getJarEntry().getTime()));
+ }
+ }
}
catch (IOException e)
{
@@ -222,11 +222,11 @@ public final class Connection extends JarURLConnection
try
{
- return getJarEntry().getTime();
+ return getJarEntry().getTime();
}
catch (IOException e)
{
- return -1;
+ return -1;
}
}
}
diff --git a/gnu/java/net/protocol/jar/Handler.java b/gnu/java/net/protocol/jar/Handler.java
index 66f0fb6d9..7d6103e93 100644
--- a/gnu/java/net/protocol/jar/Handler.java
+++ b/gnu/java/net/protocol/jar/Handler.java
@@ -7,7 +7,7 @@ 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
@@ -91,34 +91,34 @@ public class Handler extends URLStreamHandler
// strategy when we encounter an error in parsing is to return without
// doing anything.
String file = url.getFile();
-
+
if (!file.equals(""))
{ //has context url
- url_string = url_string.substring (start, end);
+ url_string = url_string.substring (start, end);
if (url_string.startsWith("/"))
{ //url string is an absolute path
int idx = file.lastIndexOf ("!/");
-
- if (idx < 0)
- throw new URLParseError("no !/ in spec");
-
- file = file.substring (0, idx + 1) + url_string;
+
+ if (idx < 0)
+ throw new URLParseError("no !/ in spec");
+
+ file = file.substring (0, idx + 1) + url_string;
}
else if (url_string.length() > 0)
{
int idx = file.lastIndexOf ("/");
if (idx == -1) //context path is weird
- file = "/" + url_string;
+ file = "/" + url_string;
else if (idx == (file.length() - 1))
//just concatenate two parts
file = file + url_string;
else
- // according to Java API Documentation, here is a little different
+ // according to Java API Documentation, here is a little different
// with URLStreamHandler.parseURL
// but JDK seems doesn't handle it well
file = file.substring(0, idx + 1) + url_string;
}
-
+
setURL (url, "jar", url.getHost(), url.getPort(), flat(file), null);
return;
}
@@ -130,7 +130,7 @@ public class Handler extends URLStreamHandler
return;
if (start > url_string.length())
return;
-
+
// Skip remains of protocol
url_string = url_string.substring (start, end);
@@ -140,16 +140,16 @@ public class Handler extends URLStreamHandler
try
{
- new URL(url_string.substring (0, jar_stop));
+ new URL(url_string.substring (0, jar_stop));
}
catch (MalformedURLException e)
{
- throw new URLParseError("invalid inner URL: " + e.getMessage());
+ throw new URLParseError("invalid inner URL: " + e.getMessage());
}
-
+
if (!url.getProtocol().equals ("jar") )
throw new URLParseError("unexpected protocol " + url.getProtocol());
-
+
setURL (url, "jar", url.getHost(), url.getPort(), url_string, null);
}
@@ -170,16 +170,16 @@ public class Handler extends URLStreamHandler
StringTokenizer st = new StringTokenizer(jar_path, "/");
while (st.hasMoreTokens())
{
- String token = st.nextToken();
+ String token = st.nextToken();
if (token.equals("."))
continue;
else if (token.equals(".."))
- {
- if (! tokens.isEmpty())
- tokens.remove(tokens.size() - 1);
- }
- else
- tokens.add(token);
+ {
+ if (! tokens.isEmpty())
+ tokens.remove(tokens.size() - 1);
+ }
+ else
+ tokens.add(token);
}
CPStringBuilder path = new CPStringBuilder(url_string.length());
@@ -203,8 +203,8 @@ public class Handler extends URLStreamHandler
String ref = url.getRef();
// return "jar:" + file;
- // Performance!!:
- // Do the concatenation manually to avoid resize StringBuffer's
+ // Performance!!:
+ // Do the concatenation manually to avoid resize StringBuffer's
// internal buffer. The length of ref is not taken into consideration
// as it's a rare path.
CPStringBuilder sb = new CPStringBuilder (file.length() + 5);