From 4c322bff290ba4cf86aefa934a8c26acd3350aae Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Fri, 30 Aug 2002 18:16:00 +0000 Subject: JarURLConnection.java (getCertificates): New method from Classpath. * java/net/JarURLConnection.java (getCertificates): New method from Classpath. * java/net/URLClassLoader.java (URLClassLoader): Extends SecureClassLoader. (definePackage): New method from Classpath. (getPermissions): Likewise. (newInstance): Likewise. (findClass): Construct CodeSource for new class (from Classpath). * java/net/SocketImpl.java (shutdownInput, shutdownOutput): New methods. * java/net/URL.java (getUserInfo): New method. (set(String,String,int,String,String,String,String,String)): New method. * java/net/PlainSocketImpl.java (_Jv_SO_KEEPALIVE_): Define. (shutdownInput, shutdownOutput): Declare. * java/net/PlainDatagramSocketImpl.java (_Jv_SO_KEEPALIVE_): Define. * java/net/natPlainSocketImpl.cc (setOption): Handle keepalive. (getOption): Likewise. (shutdownInput): New method. (shutdownOutput): Likewise. * java/net/natPlainDatagramSocketImpl.cc (setOption): Handle keepalive. (getOption): Likewise. * java/net/SocketOptions.java (SO_KEEPALIVE): New constant. * java/net/Socket.java (setKeepAlive): New method. (getKeepAlive): Likewise. (shutdownInput, shutdownOutput): New methods. From-SVN: r56685 --- libjava/java/net/URL.java | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) (limited to 'libjava/java/net/URL.java') diff --git a/libjava/java/net/URL.java b/libjava/java/net/URL.java index a3e9d78..73edeca 100644 --- a/libjava/java/net/URL.java +++ b/libjava/java/net/URL.java @@ -175,7 +175,8 @@ public final class URL implements Serializable this.handler = setURLStreamHandler(protocol); if (this.handler == null) - throw new MalformedURLException("Protocol handler not found: " + protocol); + throw new MalformedURLException("Protocol handler not found: " + + protocol); // JDK 1.2 doc for parseURL specifically states that any '#' ref // is to be excluded by passing the 'limit' as the indexOf the '#' @@ -245,6 +246,12 @@ public final class URL implements Serializable return ref; } + public String getUserInfo () + { + int at = host.indexOf('@'); + return at < 0 ? null : host.substring(0, at); + } + public int hashCode() { // JCL book says this is computed using (only) the hashcodes of the @@ -299,6 +306,30 @@ public final class URL implements Serializable hashCode = hashCode(); // Used for serialization. } + /** @since 1.3 */ + protected void set(String protocol, String host, int port, + String authority, String userInfo, + String path, String query, String ref) + { + // TBD: Theoretically, a poorly written StreamHandler could pass an + // invalid protocol. It will cause the handler to be set to null + // thus overriding a valid handler. Callers of this method should + // be aware of this. + this.handler = setURLStreamHandler(protocol); + this.protocol = protocol; + if (userInfo == null) + this.host = host; + else + this.host = userInfo + "@" + host; + this.port = port; + if (query == null) + this.file = path; + else + this.file = path + "?" + query; + this.ref = ref; + hashCode = hashCode(); // Used for serialization. + } + public static synchronized void setURLStreamHandlerFactory(URLStreamHandlerFactory fac) { -- cgit v1.1