summaryrefslogtreecommitdiff
path: root/gnu/java/net/protocol/jar
diff options
context:
space:
mode:
authorMichael Koch <konqueror@gmx.de>2003-10-18 09:12:37 +0000
committerMichael Koch <konqueror@gmx.de>2003-10-18 09:12:37 +0000
commitd30467dc028976faf72f71a33e2b08a1058fc0db (patch)
tree6c5d85655a63c59b03846e7b2356ef5da8cd1ae8 /gnu/java/net/protocol/jar
parent35caa0474579565f118efb6087e1465015c6c33b (diff)
downloadclasspath-d30467dc028976faf72f71a33e2b08a1058fc0db.tar.gz
2003-10-18 Michael Koch <konqueror@gmx.de>
* gnu/java/net/protocol/file/Handler.java, gnu/java/net/protocol/http/Handler.java, gnu/java/net/protocol/jar/Handler.java: Reformated.
Diffstat (limited to 'gnu/java/net/protocol/jar')
-rw-r--r--gnu/java/net/protocol/jar/Handler.java181
1 files changed, 83 insertions, 98 deletions
diff --git a/gnu/java/net/protocol/jar/Handler.java b/gnu/java/net/protocol/jar/Handler.java
index 75c3e405e..940d03709 100644
--- a/gnu/java/net/protocol/jar/Handler.java
+++ b/gnu/java/net/protocol/jar/Handler.java
@@ -1,5 +1,5 @@
/* gnu.java.net.protocol.jar.Handler - jar protocol handler for java.net
- Copyright (C) 2002 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2003 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -38,130 +38,115 @@ exception statement from your version. */
package gnu.java.net.protocol.jar;
+import gnu.java.io.PlatformHelper;
+import java.io.IOException;
import java.net.URL;
import java.net.URLStreamHandler;
import java.net.URLConnection;
-import java.io.IOException;
-import gnu.java.io.PlatformHelper;
public class Handler extends URLStreamHandler
{
-
-/*************************************************************************/
-
-/*
- * Constructors
- */
-
-/**
- * A do nothing constructor
- */
-public
-Handler()
-{
- ;
-}
-
-/*************************************************************************/
-
-/*
- * Instance Methods
- */
-
-/**
- * This method returs a new JarURLConnection for the specified URL
- *
- * @param url The URL to return a connection for
- *
- * @return The URLConnection
- *
- * @exception IOException If an error occurs
- */
-protected URLConnection
-openConnection(URL url) throws IOException
-{
- return(new gnu.java.net.protocol.jar.JarURLConnection(url));
-}
-
-/**
- * This method overrides URLStreamHandler's for parsing url of protocol "file"
- *
- * @param url The URL object in which to store the results
- * @param url_string The String-ized URL to parse
- * @param start The position in the string to start scanning from
- * @param end The position in the string to stop scanning
- */
-protected void
-parseURL(URL url, String url_string, int start, int end)
-{
+ /**
+ * A do nothing constructor
+ */
+ public Handler()
+ {
+ }
+
+ /**
+ * This method returs a new JarURLConnection for the specified URL
+ *
+ * @param url The URL to return a connection for
+ *
+ * @return The URLConnection
+ *
+ * @exception IOException If an error occurs
+ */
+ protected URLConnection openConnection (URL url) throws IOException
+ {
+ return new gnu.java.net.protocol.jar.JarURLConnection (url);
+ }
+
+ /**
+ * This method overrides URLStreamHandler's for parsing url of protocol "file"
+ *
+ * @param url The URL object in which to store the results
+ * @param url_string The String-ized URL to parse
+ * @param start The position in the string to start scanning from
+ * @param end The position in the string to stop scanning
+ */
+ protected void parseURL (URL url, String url_string, int start, int end)
+ {
// This method does not throw an exception or return a value. Thus our
// strategy when we encounter an error in parsing is to return without
// doing anything.
String file = url.getFile();
- if (file != null && file != ""){ //has context url
- url_string = url_string.substring(start, end);
- if (url_string.startsWith("/")){ //url string is an absolute path
- int idx = file.lastIndexOf("!/");
+ if (file != null
+ && file != "")
+ { //has context url
+ url_string = url_string.substring (start, end);
+ if (url_string.startsWith("/"))
+ { //url string is an absolute path
+ int idx = file.lastIndexOf ("!/");
if (idx == -1) //context path is weird
file = file + "!" + url_string;
else
- file = file.substring(0, idx+1) + url_string;
- }else{
- int idx = file.lastIndexOf("/");
+ file = file.substring (0, idx + 1) + url_string;
+ }
+ else
+ {
+ 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;
+ //just concatenate two parts
+ file = file + url_string;
else
- // according to Java API Documentation, here is a little different
- // with URLStreamHandler.parseURL
- // but JDK seems doesn't handle it well
- file = file + "/" + url_string;
- }
- setURL(url, "jar", url.getHost(), url.getPort(), file, null);
+ // according to Java API Documentation, here is a little different
+ // with URLStreamHandler.parseURL
+ // but JDK seems doesn't handle it well
+ file = file + "/" + url_string;
+ }
+
+ setURL (url, "jar", url.getHost(), url.getPort(), file, null);
return;
- }
+ }
// Bunches of things should be true. Make sure.
if (end < start)
- return;
+ return;
if (end - start < 2)
- return;
+ return;
if (start > url_string.length())
- return;
+ return;
// Skip remains of protocol
- url_string = url_string.substring(start, end);
+ url_string = url_string.substring (start, end);
- if ( !url.getProtocol().equals("jar") )
- return;
+ if (!url.getProtocol().equals ("jar") )
+ return;
- setURL(url, "jar", url.getHost(), url.getPort(), url_string, null);
-}
-
-/**
- * This method converts a Jar URL object into a String.
- *
- * @param url The URL object to convert
- */
-protected String
-toExternalForm(URL url)
-{
- String file = url.getFile();
-
- // return "jar:" + file;
- // Performance!!:
- // Do the concatenation mannually to avoid resize StringBuffer's
- // internal buffer.
- StringBuffer sb = new StringBuffer(file.length() + 5);
- sb.append("jar:");
- sb.append(file);
-
- return sb.toString();
-}
+ setURL (url, "jar", url.getHost(), url.getPort(), url_string, null);
+ }
+
+ /**
+ * This method converts a Jar URL object into a String.
+ *
+ * @param url The URL object to convert
+ */
+ protected String toExternalForm (URL url)
+ {
+ String file = url.getFile();
+ // return "jar:" + file;
+ // Performance!!:
+ // Do the concatenation manually to avoid resize StringBuffer's
+ // internal buffer.
+ StringBuffer sb = new StringBuffer (file.length() + 5);
+ sb.append ("jar:");
+ sb.append (file);
+ return sb.toString();
+ }
} // class Handler
-