gcc/libjava/java/net/URL.java

600 lines
16 KiB
Java
Raw Normal View History

1999-04-07 16:42:40 +02:00
// URL.java - A Uniform Resource Locator.
/* Copyright (C) 1999, 2000, 2002 Free Software Foundation
1999-04-07 16:42:40 +02:00
This file is part of libgcj.
This software is copyrighted work licensed under the terms of the
Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
details. */
package java.net;
import java.io.*;
import java.util.Hashtable;
import java.util.StringTokenizer;
/**
* @author Warren Levy <warrenl@cygnus.com>
* @date March 4, 1999.
*/
/**
* Written using on-line Java Platform 1.2 API Specification, as well
* as "The Java Class Libraries", 2nd edition (Addison-Wesley, 1998).
* Status: Believed complete and correct.
*/
public final class URL implements Serializable
{
private String protocol;
2002-09-25 Michael Koch <konqueror@gmx.de> * java/net/DatagramSocket.java (DatagramSocket): Initialize new instance variables. (close): Reset new instance variables. (getLocalAddress): Remove unneeded SecurityManager usage. (getLocalPort): Check if socket is already bound. (isConnected): New method. (getInetAddress): Implemented. (getPort): Better Implementation, documentation fixed. (getRemoteSocketAddress): New method. * java/net/JarURLConnection.java (element): Typo fixed. (getMainAttributes): New method. (getAttributes): New method (stub only). (getManifest): New method (stub only). * java/net/NetPermission.java: Added serialVersionsUID. * java/net/Socket.java (connect): Check blocking mode of associated channel, documentation added. (getLocalSocketAddress): Better implementation. (getRemoteSocketAddress): Implemented. (isBound): New method. (setSendBufferSize): Documentation added. * java/net/SocketAddress.java: Added serialVersionsUID. * java/net/SocketPermission.java: Added serialVersionsUID. * java/net/URL.java (URL): Wrap for shorter lines, initialize new instance variables, documentation added. (equals): Check new instance variables too. (getContent): Documentation added. (getPath): Documentation added. (getAuthority): New method. (getHost): Documentation added. (getPort): Documentation added. (getDefaultPort): New method. (getProtocol): Documentation added. (getUserInfo): Documentation added. (set): Initialize new instance variables, documentation added. * java/net/URLStreamHandler.java (setURL): New method. * java/net/natPlainDatagramSocketImpl.cc (connect): Fix exception name. (disconnect): Fix exception name. From-SVN: r57501
2002-09-25 19:14:09 +02:00
private String authority;
private String userInfo;
1999-04-07 16:42:40 +02:00
private String host;
private int port = -1; // Initialize for constructor using context.
1999-04-07 16:42:40 +02:00
private String file;
2002-09-25 Michael Koch <konqueror@gmx.de> * java/net/DatagramSocket.java (DatagramSocket): Initialize new instance variables. (close): Reset new instance variables. (getLocalAddress): Remove unneeded SecurityManager usage. (getLocalPort): Check if socket is already bound. (isConnected): New method. (getInetAddress): Implemented. (getPort): Better Implementation, documentation fixed. (getRemoteSocketAddress): New method. * java/net/JarURLConnection.java (element): Typo fixed. (getMainAttributes): New method. (getAttributes): New method (stub only). (getManifest): New method (stub only). * java/net/NetPermission.java: Added serialVersionsUID. * java/net/Socket.java (connect): Check blocking mode of associated channel, documentation added. (getLocalSocketAddress): Better implementation. (getRemoteSocketAddress): Implemented. (isBound): New method. (setSendBufferSize): Documentation added. * java/net/SocketAddress.java: Added serialVersionsUID. * java/net/SocketPermission.java: Added serialVersionsUID. * java/net/URL.java (URL): Wrap for shorter lines, initialize new instance variables, documentation added. (equals): Check new instance variables too. (getContent): Documentation added. (getPath): Documentation added. (getAuthority): New method. (getHost): Documentation added. (getPort): Documentation added. (getDefaultPort): New method. (getProtocol): Documentation added. (getUserInfo): Documentation added. (set): Initialize new instance variables, documentation added. * java/net/URLStreamHandler.java (setURL): New method. * java/net/natPlainDatagramSocketImpl.cc (connect): Fix exception name. (disconnect): Fix exception name. From-SVN: r57501
2002-09-25 19:14:09 +02:00
private String query;
1999-04-07 16:42:40 +02:00
private String ref;
PropertyChangeEvent.java (serialVersionUID): Added. * java/beans/PropertyChangeEvent.java (serialVersionUID): Added. * java/beans/PropertyVetoException.java (serialVersionUID): Added. * java/io/File.java (writeObject): Added. (readObject): Added. (serialVersionUID): Added. * java/io/ObjectOutputStream.java (writeObject): Initialized fieldsAlreadyWritten before recursion rather than after. * java/io/ObjectStreamClass.java (serialVersionUID): Added. * java/io/OptionalDataException.java (serialVersionUID): Added. (OptionalDataException): Made package private. * java/io/SyncFailedException.java (SyncFailedException): Removed default constructor to match spec. * java/lang/Boolean.java (serialVersionUID): Added. * java/lang/Byte.java (serialVersionUID): Added. * java/lang/Character.java (serialVersionUID): Added. * java/lang/Double.java (serialVersionUID): Added. * java/lang/Float.java (serialVersionUID): Added. * java/lang/Integer.java (serialVersionUID): Added. * java/lang/Long.java (serialVersionUID): Added. * java/lang/Number.java (serialVersionUID): Added. * java/lang/Short.java (serialVersionUID): Added. * java/lang/String.java (serialVersionUID): Added. * java/lang/ThreadDeath.java (ThreadDeath): Removed constructor to match spec. * java/lang/reflect/InvocationTargetException.java (serialVersionUID): Added. * java/net/URL.java (handler): Made transient. (hashCode): Added field for serialization, per spec. and use cached value if available. (serialVersionUID): Added. (URL): Initialize hashCode. (set): Adjust hashCode. (readObject): New Method to initialize the protocol handler when deserializing. (writeObject): New method. * java/text/BreakIterator.java: Removed 'implements Serializable'. * java/text/Collator.java: Removed 'implements Serializable'. * java/util/GregorianCalendar.java (serialVersionUID): Added. * java/util/Properties.java (serialVersionUID): Added. * java/util/Random.java (serialVersionUID): Added. (seed): Made private. (nextNextGaussian): Made private. (haveNextNextGaussian): Made private. * java/util/Stack.java (serialVersionUID): Added. * java/util/TimeZone.java (serialVersionUID): Added. * java/util/Vector.java (serialVersionUID): Added. Serialization mods. From-SVN: r36272
2000-09-08 21:37:09 +02:00
private int hashCode = 0;
transient private URLStreamHandler handler;
1999-04-07 16:42:40 +02:00
private static Hashtable handlers = new Hashtable();
private static URLStreamHandlerFactory factory;
PropertyChangeEvent.java (serialVersionUID): Added. * java/beans/PropertyChangeEvent.java (serialVersionUID): Added. * java/beans/PropertyVetoException.java (serialVersionUID): Added. * java/io/File.java (writeObject): Added. (readObject): Added. (serialVersionUID): Added. * java/io/ObjectOutputStream.java (writeObject): Initialized fieldsAlreadyWritten before recursion rather than after. * java/io/ObjectStreamClass.java (serialVersionUID): Added. * java/io/OptionalDataException.java (serialVersionUID): Added. (OptionalDataException): Made package private. * java/io/SyncFailedException.java (SyncFailedException): Removed default constructor to match spec. * java/lang/Boolean.java (serialVersionUID): Added. * java/lang/Byte.java (serialVersionUID): Added. * java/lang/Character.java (serialVersionUID): Added. * java/lang/Double.java (serialVersionUID): Added. * java/lang/Float.java (serialVersionUID): Added. * java/lang/Integer.java (serialVersionUID): Added. * java/lang/Long.java (serialVersionUID): Added. * java/lang/Number.java (serialVersionUID): Added. * java/lang/Short.java (serialVersionUID): Added. * java/lang/String.java (serialVersionUID): Added. * java/lang/ThreadDeath.java (ThreadDeath): Removed constructor to match spec. * java/lang/reflect/InvocationTargetException.java (serialVersionUID): Added. * java/net/URL.java (handler): Made transient. (hashCode): Added field for serialization, per spec. and use cached value if available. (serialVersionUID): Added. (URL): Initialize hashCode. (set): Adjust hashCode. (readObject): New Method to initialize the protocol handler when deserializing. (writeObject): New method. * java/text/BreakIterator.java: Removed 'implements Serializable'. * java/text/Collator.java: Removed 'implements Serializable'. * java/util/GregorianCalendar.java (serialVersionUID): Added. * java/util/Properties.java (serialVersionUID): Added. * java/util/Random.java (serialVersionUID): Added. (seed): Made private. (nextNextGaussian): Made private. (haveNextNextGaussian): Made private. * java/util/Stack.java (serialVersionUID): Added. * java/util/TimeZone.java (serialVersionUID): Added. * java/util/Vector.java (serialVersionUID): Added. Serialization mods. From-SVN: r36272
2000-09-08 21:37:09 +02:00
private static final long serialVersionUID = -7627629688361524110L;
2002-09-25 Michael Koch <konqueror@gmx.de> * java/net/DatagramSocket.java (DatagramSocket): Initialize new instance variables. (close): Reset new instance variables. (getLocalAddress): Remove unneeded SecurityManager usage. (getLocalPort): Check if socket is already bound. (isConnected): New method. (getInetAddress): Implemented. (getPort): Better Implementation, documentation fixed. (getRemoteSocketAddress): New method. * java/net/JarURLConnection.java (element): Typo fixed. (getMainAttributes): New method. (getAttributes): New method (stub only). (getManifest): New method (stub only). * java/net/NetPermission.java: Added serialVersionsUID. * java/net/Socket.java (connect): Check blocking mode of associated channel, documentation added. (getLocalSocketAddress): Better implementation. (getRemoteSocketAddress): Implemented. (isBound): New method. (setSendBufferSize): Documentation added. * java/net/SocketAddress.java: Added serialVersionsUID. * java/net/SocketPermission.java: Added serialVersionsUID. * java/net/URL.java (URL): Wrap for shorter lines, initialize new instance variables, documentation added. (equals): Check new instance variables too. (getContent): Documentation added. (getPath): Documentation added. (getAuthority): New method. (getHost): Documentation added. (getPort): Documentation added. (getDefaultPort): New method. (getProtocol): Documentation added. (getUserInfo): Documentation added. (set): Initialize new instance variables, documentation added. * java/net/URLStreamHandler.java (setURL): New method. * java/net/natPlainDatagramSocketImpl.cc (connect): Fix exception name. (disconnect): Fix exception name. From-SVN: r57501
2002-09-25 19:14:09 +02:00
/**
* Creates an URL object from the given arguments
*
* @param protocol The protocol of the URL
* @param host The host of the URL
* @param port The port of the URL
* @param file The file of the URL
*
* @exception MalformedURLException If an error occurs
*/
1999-04-07 16:42:40 +02:00
public URL(String protocol, String host, int port, String file)
throws MalformedURLException
{
this(protocol, host, port, file, null);
}
2002-09-25 Michael Koch <konqueror@gmx.de> * java/net/DatagramSocket.java (DatagramSocket): Initialize new instance variables. (close): Reset new instance variables. (getLocalAddress): Remove unneeded SecurityManager usage. (getLocalPort): Check if socket is already bound. (isConnected): New method. (getInetAddress): Implemented. (getPort): Better Implementation, documentation fixed. (getRemoteSocketAddress): New method. * java/net/JarURLConnection.java (element): Typo fixed. (getMainAttributes): New method. (getAttributes): New method (stub only). (getManifest): New method (stub only). * java/net/NetPermission.java: Added serialVersionsUID. * java/net/Socket.java (connect): Check blocking mode of associated channel, documentation added. (getLocalSocketAddress): Better implementation. (getRemoteSocketAddress): Implemented. (isBound): New method. (setSendBufferSize): Documentation added. * java/net/SocketAddress.java: Added serialVersionsUID. * java/net/SocketPermission.java: Added serialVersionsUID. * java/net/URL.java (URL): Wrap for shorter lines, initialize new instance variables, documentation added. (equals): Check new instance variables too. (getContent): Documentation added. (getPath): Documentation added. (getAuthority): New method. (getHost): Documentation added. (getPort): Documentation added. (getDefaultPort): New method. (getProtocol): Documentation added. (getUserInfo): Documentation added. (set): Initialize new instance variables, documentation added. * java/net/URLStreamHandler.java (setURL): New method. * java/net/natPlainDatagramSocketImpl.cc (connect): Fix exception name. (disconnect): Fix exception name. From-SVN: r57501
2002-09-25 19:14:09 +02:00
/**
* Creates an URL object from the given arguments
*
* @param protocol The protocol of the URL
* @param host The host of the URL
* @param file The file of the URL
*
* @exception MalformedURLException If an error occurs
*/
1999-04-07 16:42:40 +02:00
public URL(String protocol, String host, String file)
throws MalformedURLException
{
this(protocol, host, -1, file, null);
}
2002-09-25 Michael Koch <konqueror@gmx.de> * java/net/DatagramSocket.java (DatagramSocket): Initialize new instance variables. (close): Reset new instance variables. (getLocalAddress): Remove unneeded SecurityManager usage. (getLocalPort): Check if socket is already bound. (isConnected): New method. (getInetAddress): Implemented. (getPort): Better Implementation, documentation fixed. (getRemoteSocketAddress): New method. * java/net/JarURLConnection.java (element): Typo fixed. (getMainAttributes): New method. (getAttributes): New method (stub only). (getManifest): New method (stub only). * java/net/NetPermission.java: Added serialVersionsUID. * java/net/Socket.java (connect): Check blocking mode of associated channel, documentation added. (getLocalSocketAddress): Better implementation. (getRemoteSocketAddress): Implemented. (isBound): New method. (setSendBufferSize): Documentation added. * java/net/SocketAddress.java: Added serialVersionsUID. * java/net/SocketPermission.java: Added serialVersionsUID. * java/net/URL.java (URL): Wrap for shorter lines, initialize new instance variables, documentation added. (equals): Check new instance variables too. (getContent): Documentation added. (getPath): Documentation added. (getAuthority): New method. (getHost): Documentation added. (getPort): Documentation added. (getDefaultPort): New method. (getProtocol): Documentation added. (getUserInfo): Documentation added. (set): Initialize new instance variables, documentation added. * java/net/URLStreamHandler.java (setURL): New method. * java/net/natPlainDatagramSocketImpl.cc (connect): Fix exception name. (disconnect): Fix exception name. From-SVN: r57501
2002-09-25 19:14:09 +02:00
/**
* Creates an URL object from the given arguments
*
* @param protocol The protocol of the URL
* @param host The host of the URL
* @param port The port of the URL
* @param file The file of the URL
* @param handler The stream handler for the URL
*
* @exception MalformedURLException If an error occurs
* @exception SecurityException If a security manager exists and its
* checkPermission method doesn't allow specifying a stream handler
* explicitly
2002-09-25 Michael Koch <konqueror@gmx.de> * java/net/DatagramSocket.java (DatagramSocket): Initialize new instance variables. (close): Reset new instance variables. (getLocalAddress): Remove unneeded SecurityManager usage. (getLocalPort): Check if socket is already bound. (isConnected): New method. (getInetAddress): Implemented. (getPort): Better Implementation, documentation fixed. (getRemoteSocketAddress): New method. * java/net/JarURLConnection.java (element): Typo fixed. (getMainAttributes): New method. (getAttributes): New method (stub only). (getManifest): New method (stub only). * java/net/NetPermission.java: Added serialVersionsUID. * java/net/Socket.java (connect): Check blocking mode of associated channel, documentation added. (getLocalSocketAddress): Better implementation. (getRemoteSocketAddress): Implemented. (isBound): New method. (setSendBufferSize): Documentation added. * java/net/SocketAddress.java: Added serialVersionsUID. * java/net/SocketPermission.java: Added serialVersionsUID. * java/net/URL.java (URL): Wrap for shorter lines, initialize new instance variables, documentation added. (equals): Check new instance variables too. (getContent): Documentation added. (getPath): Documentation added. (getAuthority): New method. (getHost): Documentation added. (getPort): Documentation added. (getDefaultPort): New method. (getProtocol): Documentation added. (getUserInfo): Documentation added. (set): Initialize new instance variables, documentation added. * java/net/URLStreamHandler.java (setURL): New method. * java/net/natPlainDatagramSocketImpl.cc (connect): Fix exception name. (disconnect): Fix exception name. From-SVN: r57501
2002-09-25 19:14:09 +02:00
*
* @since 1.2
*/
1999-04-07 16:42:40 +02:00
public URL(String protocol, String host, int port, String file,
URLStreamHandler handler) throws MalformedURLException
{
if (protocol == null)
throw new MalformedURLException("null protocol");
this.protocol = protocol;
if (handler != null)
{
SecurityManager s = System.getSecurityManager ();
if (s != null)
s.checkPermission (new NetPermission ("specifyStreamHandler"));
1999-04-07 16:42:40 +02:00
this.handler = handler;
}
else
this.handler = setURLStreamHandler(protocol);
if (this.handler == null)
2002-09-25 Michael Koch <konqueror@gmx.de> * java/net/DatagramSocket.java (DatagramSocket): Initialize new instance variables. (close): Reset new instance variables. (getLocalAddress): Remove unneeded SecurityManager usage. (getLocalPort): Check if socket is already bound. (isConnected): New method. (getInetAddress): Implemented. (getPort): Better Implementation, documentation fixed. (getRemoteSocketAddress): New method. * java/net/JarURLConnection.java (element): Typo fixed. (getMainAttributes): New method. (getAttributes): New method (stub only). (getManifest): New method (stub only). * java/net/NetPermission.java: Added serialVersionsUID. * java/net/Socket.java (connect): Check blocking mode of associated channel, documentation added. (getLocalSocketAddress): Better implementation. (getRemoteSocketAddress): Implemented. (isBound): New method. (setSendBufferSize): Documentation added. * java/net/SocketAddress.java: Added serialVersionsUID. * java/net/SocketPermission.java: Added serialVersionsUID. * java/net/URL.java (URL): Wrap for shorter lines, initialize new instance variables, documentation added. (equals): Check new instance variables too. (getContent): Documentation added. (getPath): Documentation added. (getAuthority): New method. (getHost): Documentation added. (getPort): Documentation added. (getDefaultPort): New method. (getProtocol): Documentation added. (getUserInfo): Documentation added. (set): Initialize new instance variables, documentation added. * java/net/URLStreamHandler.java (setURL): New method. * java/net/natPlainDatagramSocketImpl.cc (connect): Fix exception name. (disconnect): Fix exception name. From-SVN: r57501
2002-09-25 19:14:09 +02:00
throw new MalformedURLException (
"Protocol handler not found: " + protocol);
1999-04-07 16:42:40 +02:00
this.host = host;
this.port = port;
2002-09-25 Michael Koch <konqueror@gmx.de> * java/net/DatagramSocket.java (DatagramSocket): Initialize new instance variables. (close): Reset new instance variables. (getLocalAddress): Remove unneeded SecurityManager usage. (getLocalPort): Check if socket is already bound. (isConnected): New method. (getInetAddress): Implemented. (getPort): Better Implementation, documentation fixed. (getRemoteSocketAddress): New method. * java/net/JarURLConnection.java (element): Typo fixed. (getMainAttributes): New method. (getAttributes): New method (stub only). (getManifest): New method (stub only). * java/net/NetPermission.java: Added serialVersionsUID. * java/net/Socket.java (connect): Check blocking mode of associated channel, documentation added. (getLocalSocketAddress): Better implementation. (getRemoteSocketAddress): Implemented. (isBound): New method. (setSendBufferSize): Documentation added. * java/net/SocketAddress.java: Added serialVersionsUID. * java/net/SocketPermission.java: Added serialVersionsUID. * java/net/URL.java (URL): Wrap for shorter lines, initialize new instance variables, documentation added. (equals): Check new instance variables too. (getContent): Documentation added. (getPath): Documentation added. (getAuthority): New method. (getHost): Documentation added. (getPort): Documentation added. (getDefaultPort): New method. (getProtocol): Documentation added. (getUserInfo): Documentation added. (set): Initialize new instance variables, documentation added. * java/net/URLStreamHandler.java (setURL): New method. * java/net/natPlainDatagramSocketImpl.cc (connect): Fix exception name. (disconnect): Fix exception name. From-SVN: r57501
2002-09-25 19:14:09 +02:00
this.userInfo = null;
this.authority = null;
this.query = null;
1999-04-07 16:42:40 +02:00
int hashAt = file.indexOf('#');
if (hashAt < 0)
{
this.file = file;
this.ref = null;
}
else
{
this.file = file.substring(0, hashAt);
this.ref = file.substring(hashAt + 1);
}
PropertyChangeEvent.java (serialVersionUID): Added. * java/beans/PropertyChangeEvent.java (serialVersionUID): Added. * java/beans/PropertyVetoException.java (serialVersionUID): Added. * java/io/File.java (writeObject): Added. (readObject): Added. (serialVersionUID): Added. * java/io/ObjectOutputStream.java (writeObject): Initialized fieldsAlreadyWritten before recursion rather than after. * java/io/ObjectStreamClass.java (serialVersionUID): Added. * java/io/OptionalDataException.java (serialVersionUID): Added. (OptionalDataException): Made package private. * java/io/SyncFailedException.java (SyncFailedException): Removed default constructor to match spec. * java/lang/Boolean.java (serialVersionUID): Added. * java/lang/Byte.java (serialVersionUID): Added. * java/lang/Character.java (serialVersionUID): Added. * java/lang/Double.java (serialVersionUID): Added. * java/lang/Float.java (serialVersionUID): Added. * java/lang/Integer.java (serialVersionUID): Added. * java/lang/Long.java (serialVersionUID): Added. * java/lang/Number.java (serialVersionUID): Added. * java/lang/Short.java (serialVersionUID): Added. * java/lang/String.java (serialVersionUID): Added. * java/lang/ThreadDeath.java (ThreadDeath): Removed constructor to match spec. * java/lang/reflect/InvocationTargetException.java (serialVersionUID): Added. * java/net/URL.java (handler): Made transient. (hashCode): Added field for serialization, per spec. and use cached value if available. (serialVersionUID): Added. (URL): Initialize hashCode. (set): Adjust hashCode. (readObject): New Method to initialize the protocol handler when deserializing. (writeObject): New method. * java/text/BreakIterator.java: Removed 'implements Serializable'. * java/text/Collator.java: Removed 'implements Serializable'. * java/util/GregorianCalendar.java (serialVersionUID): Added. * java/util/Properties.java (serialVersionUID): Added. * java/util/Random.java (serialVersionUID): Added. (seed): Made private. (nextNextGaussian): Made private. (haveNextNextGaussian): Made private. * java/util/Stack.java (serialVersionUID): Added. * java/util/TimeZone.java (serialVersionUID): Added. * java/util/Vector.java (serialVersionUID): Added. Serialization mods. From-SVN: r36272
2000-09-08 21:37:09 +02:00
hashCode = hashCode(); // Used for serialization.
1999-04-07 16:42:40 +02:00
}
2002-09-25 Michael Koch <konqueror@gmx.de> * java/net/DatagramSocket.java (DatagramSocket): Initialize new instance variables. (close): Reset new instance variables. (getLocalAddress): Remove unneeded SecurityManager usage. (getLocalPort): Check if socket is already bound. (isConnected): New method. (getInetAddress): Implemented. (getPort): Better Implementation, documentation fixed. (getRemoteSocketAddress): New method. * java/net/JarURLConnection.java (element): Typo fixed. (getMainAttributes): New method. (getAttributes): New method (stub only). (getManifest): New method (stub only). * java/net/NetPermission.java: Added serialVersionsUID. * java/net/Socket.java (connect): Check blocking mode of associated channel, documentation added. (getLocalSocketAddress): Better implementation. (getRemoteSocketAddress): Implemented. (isBound): New method. (setSendBufferSize): Documentation added. * java/net/SocketAddress.java: Added serialVersionsUID. * java/net/SocketPermission.java: Added serialVersionsUID. * java/net/URL.java (URL): Wrap for shorter lines, initialize new instance variables, documentation added. (equals): Check new instance variables too. (getContent): Documentation added. (getPath): Documentation added. (getAuthority): New method. (getHost): Documentation added. (getPort): Documentation added. (getDefaultPort): New method. (getProtocol): Documentation added. (getUserInfo): Documentation added. (set): Initialize new instance variables, documentation added. * java/net/URLStreamHandler.java (setURL): New method. * java/net/natPlainDatagramSocketImpl.cc (connect): Fix exception name. (disconnect): Fix exception name. From-SVN: r57501
2002-09-25 19:14:09 +02:00
/**
* Creates an URL object from the given arguments
*
* @param spec The string to parse an URL
*
* @exception MalformedURLException If an error occurs
*/
1999-04-07 16:42:40 +02:00
public URL(String spec) throws MalformedURLException
{
this((URL) null, spec, (URLStreamHandler) null);
}
2002-09-25 Michael Koch <konqueror@gmx.de> * java/net/DatagramSocket.java (DatagramSocket): Initialize new instance variables. (close): Reset new instance variables. (getLocalAddress): Remove unneeded SecurityManager usage. (getLocalPort): Check if socket is already bound. (isConnected): New method. (getInetAddress): Implemented. (getPort): Better Implementation, documentation fixed. (getRemoteSocketAddress): New method. * java/net/JarURLConnection.java (element): Typo fixed. (getMainAttributes): New method. (getAttributes): New method (stub only). (getManifest): New method (stub only). * java/net/NetPermission.java: Added serialVersionsUID. * java/net/Socket.java (connect): Check blocking mode of associated channel, documentation added. (getLocalSocketAddress): Better implementation. (getRemoteSocketAddress): Implemented. (isBound): New method. (setSendBufferSize): Documentation added. * java/net/SocketAddress.java: Added serialVersionsUID. * java/net/SocketPermission.java: Added serialVersionsUID. * java/net/URL.java (URL): Wrap for shorter lines, initialize new instance variables, documentation added. (equals): Check new instance variables too. (getContent): Documentation added. (getPath): Documentation added. (getAuthority): New method. (getHost): Documentation added. (getPort): Documentation added. (getDefaultPort): New method. (getProtocol): Documentation added. (getUserInfo): Documentation added. (set): Initialize new instance variables, documentation added. * java/net/URLStreamHandler.java (setURL): New method. * java/net/natPlainDatagramSocketImpl.cc (connect): Fix exception name. (disconnect): Fix exception name. From-SVN: r57501
2002-09-25 19:14:09 +02:00
/**
* Creates an URL object from the given arguments
*
* @param context The context on which to parse the specification
* @param spec The string to parse an URL
*
* @exception MalformedURLException If an error occurs
*/
1999-04-07 16:42:40 +02:00
public URL(URL context, String spec) throws MalformedURLException
{
this(context, spec, (URLStreamHandler) null);
}
2002-09-25 Michael Koch <konqueror@gmx.de> * java/net/DatagramSocket.java (DatagramSocket): Initialize new instance variables. (close): Reset new instance variables. (getLocalAddress): Remove unneeded SecurityManager usage. (getLocalPort): Check if socket is already bound. (isConnected): New method. (getInetAddress): Implemented. (getPort): Better Implementation, documentation fixed. (getRemoteSocketAddress): New method. * java/net/JarURLConnection.java (element): Typo fixed. (getMainAttributes): New method. (getAttributes): New method (stub only). (getManifest): New method (stub only). * java/net/NetPermission.java: Added serialVersionsUID. * java/net/Socket.java (connect): Check blocking mode of associated channel, documentation added. (getLocalSocketAddress): Better implementation. (getRemoteSocketAddress): Implemented. (isBound): New method. (setSendBufferSize): Documentation added. * java/net/SocketAddress.java: Added serialVersionsUID. * java/net/SocketPermission.java: Added serialVersionsUID. * java/net/URL.java (URL): Wrap for shorter lines, initialize new instance variables, documentation added. (equals): Check new instance variables too. (getContent): Documentation added. (getPath): Documentation added. (getAuthority): New method. (getHost): Documentation added. (getPort): Documentation added. (getDefaultPort): New method. (getProtocol): Documentation added. (getUserInfo): Documentation added. (set): Initialize new instance variables, documentation added. * java/net/URLStreamHandler.java (setURL): New method. * java/net/natPlainDatagramSocketImpl.cc (connect): Fix exception name. (disconnect): Fix exception name. From-SVN: r57501
2002-09-25 19:14:09 +02:00
/**
* Creates an URL from given arguments
*
* @param context The context in which to parse the specification
* @param spec The string to parse as an URL
* @param handler The stream handler for the URL
*
* @exception MalformedURLException If an error occurs
* @exception SecurityException If a security manager exists and its
* checkPermission method doesn't allow specifying a stream handler
* explicitly
2002-09-25 Michael Koch <konqueror@gmx.de> * java/net/DatagramSocket.java (DatagramSocket): Initialize new instance variables. (close): Reset new instance variables. (getLocalAddress): Remove unneeded SecurityManager usage. (getLocalPort): Check if socket is already bound. (isConnected): New method. (getInetAddress): Implemented. (getPort): Better Implementation, documentation fixed. (getRemoteSocketAddress): New method. * java/net/JarURLConnection.java (element): Typo fixed. (getMainAttributes): New method. (getAttributes): New method (stub only). (getManifest): New method (stub only). * java/net/NetPermission.java: Added serialVersionsUID. * java/net/Socket.java (connect): Check blocking mode of associated channel, documentation added. (getLocalSocketAddress): Better implementation. (getRemoteSocketAddress): Implemented. (isBound): New method. (setSendBufferSize): Documentation added. * java/net/SocketAddress.java: Added serialVersionsUID. * java/net/SocketPermission.java: Added serialVersionsUID. * java/net/URL.java (URL): Wrap for shorter lines, initialize new instance variables, documentation added. (equals): Check new instance variables too. (getContent): Documentation added. (getPath): Documentation added. (getAuthority): New method. (getHost): Documentation added. (getPort): Documentation added. (getDefaultPort): New method. (getProtocol): Documentation added. (getUserInfo): Documentation added. (set): Initialize new instance variables, documentation added. * java/net/URLStreamHandler.java (setURL): New method. * java/net/natPlainDatagramSocketImpl.cc (connect): Fix exception name. (disconnect): Fix exception name. From-SVN: r57501
2002-09-25 19:14:09 +02:00
*
* @since 1.2
*/
1999-04-07 16:42:40 +02:00
public URL(URL context, String spec, URLStreamHandler handler)
throws MalformedURLException
{
/* A protocol is defined by the doc as the substring before a ':'
* as long as the ':' occurs before any '/'.
*
* If context is null, then spec must be an absolute URL.
*
* The relative URL need not specify all the components of a URL.
* If the protocol, host name, or port number is missing, the value
* is inherited from the context. A bare file component is appended
* to the context's file. The optional anchor is not inherited.
*/
// If this is an absolute URL, then ignore context completely.
// An absolute URL must have chars prior to "://" but cannot have a colon
// right after the "://". The second colon is for an optional port value
// and implies that the host from the context is used if available.
1999-04-07 16:42:40 +02:00
int colon;
if ((colon = spec.indexOf("://", 1)) > 0 &&
! spec.regionMatches(colon, "://:", 0, 4))
context = null;
1999-04-07 16:42:40 +02:00
int slash;
if ((colon = spec.indexOf(':')) > 0 &&
(colon < (slash = spec.indexOf('/')) || slash < 0))
{
// Protocol specified in spec string.
protocol = spec.substring(0, colon);
if (context != null && context.protocol.equals(protocol))
1999-04-07 16:42:40 +02:00
{
// The 1.2 doc specifically says these are copied to the new URL.
host = context.host;
port = context.port;
file = context.file;
2002-09-25 Michael Koch <konqueror@gmx.de> * java/net/DatagramSocket.java (DatagramSocket): Initialize new instance variables. (close): Reset new instance variables. (getLocalAddress): Remove unneeded SecurityManager usage. (getLocalPort): Check if socket is already bound. (isConnected): New method. (getInetAddress): Implemented. (getPort): Better Implementation, documentation fixed. (getRemoteSocketAddress): New method. * java/net/JarURLConnection.java (element): Typo fixed. (getMainAttributes): New method. (getAttributes): New method (stub only). (getManifest): New method (stub only). * java/net/NetPermission.java: Added serialVersionsUID. * java/net/Socket.java (connect): Check blocking mode of associated channel, documentation added. (getLocalSocketAddress): Better implementation. (getRemoteSocketAddress): Implemented. (isBound): New method. (setSendBufferSize): Documentation added. * java/net/SocketAddress.java: Added serialVersionsUID. * java/net/SocketPermission.java: Added serialVersionsUID. * java/net/URL.java (URL): Wrap for shorter lines, initialize new instance variables, documentation added. (equals): Check new instance variables too. (getContent): Documentation added. (getPath): Documentation added. (getAuthority): New method. (getHost): Documentation added. (getPort): Documentation added. (getDefaultPort): New method. (getProtocol): Documentation added. (getUserInfo): Documentation added. (set): Initialize new instance variables, documentation added. * java/net/URLStreamHandler.java (setURL): New method. * java/net/natPlainDatagramSocketImpl.cc (connect): Fix exception name. (disconnect): Fix exception name. From-SVN: r57501
2002-09-25 19:14:09 +02:00
userInfo = context.userInfo;
authority = context.authority;
query = context.query;
1999-04-07 16:42:40 +02:00
}
}
else if (context != null)
{
// Protocol NOT specified in spec string.
// Use context fields (except ref) as a foundation for relative URLs.
colon = -1;
protocol = context.protocol;
host = context.host;
port = context.port;
file = context.file;
2002-09-25 Michael Koch <konqueror@gmx.de> * java/net/DatagramSocket.java (DatagramSocket): Initialize new instance variables. (close): Reset new instance variables. (getLocalAddress): Remove unneeded SecurityManager usage. (getLocalPort): Check if socket is already bound. (isConnected): New method. (getInetAddress): Implemented. (getPort): Better Implementation, documentation fixed. (getRemoteSocketAddress): New method. * java/net/JarURLConnection.java (element): Typo fixed. (getMainAttributes): New method. (getAttributes): New method (stub only). (getManifest): New method (stub only). * java/net/NetPermission.java: Added serialVersionsUID. * java/net/Socket.java (connect): Check blocking mode of associated channel, documentation added. (getLocalSocketAddress): Better implementation. (getRemoteSocketAddress): Implemented. (isBound): New method. (setSendBufferSize): Documentation added. * java/net/SocketAddress.java: Added serialVersionsUID. * java/net/SocketPermission.java: Added serialVersionsUID. * java/net/URL.java (URL): Wrap for shorter lines, initialize new instance variables, documentation added. (equals): Check new instance variables too. (getContent): Documentation added. (getPath): Documentation added. (getAuthority): New method. (getHost): Documentation added. (getPort): Documentation added. (getDefaultPort): New method. (getProtocol): Documentation added. (getUserInfo): Documentation added. (set): Initialize new instance variables, documentation added. * java/net/URLStreamHandler.java (setURL): New method. * java/net/natPlainDatagramSocketImpl.cc (connect): Fix exception name. (disconnect): Fix exception name. From-SVN: r57501
2002-09-25 19:14:09 +02:00
userInfo = context.userInfo;
authority = context.authority;
query = context.query;
1999-04-07 16:42:40 +02:00
}
else // Protocol NOT specified in spec. and no context available.
throw new
MalformedURLException("Absolute URL required with null context");
if (handler != null)
{
SecurityManager s = System.getSecurityManager ();
if (s != null)
s.checkPermission (new NetPermission ("specifyStreamHandler"));
1999-04-07 16:42:40 +02:00
this.handler = handler;
}
else
this.handler = setURLStreamHandler(protocol);
if (this.handler == null)
throw new MalformedURLException("Protocol handler not found: "
+ protocol);
1999-04-07 16:42:40 +02:00
// JDK 1.2 doc for parseURL specifically states that any '#' ref
// is to be excluded by passing the 'limit' as the indexOf the '#'
// if one exists, otherwise pass the end of the string.
int hashAt = spec.indexOf('#', colon + 1);
this.handler.parseURL(this, spec, colon + 1,
hashAt < 0 ? spec.length() : hashAt);
if (hashAt >= 0)
ref = spec.substring(hashAt + 1);
PropertyChangeEvent.java (serialVersionUID): Added. * java/beans/PropertyChangeEvent.java (serialVersionUID): Added. * java/beans/PropertyVetoException.java (serialVersionUID): Added. * java/io/File.java (writeObject): Added. (readObject): Added. (serialVersionUID): Added. * java/io/ObjectOutputStream.java (writeObject): Initialized fieldsAlreadyWritten before recursion rather than after. * java/io/ObjectStreamClass.java (serialVersionUID): Added. * java/io/OptionalDataException.java (serialVersionUID): Added. (OptionalDataException): Made package private. * java/io/SyncFailedException.java (SyncFailedException): Removed default constructor to match spec. * java/lang/Boolean.java (serialVersionUID): Added. * java/lang/Byte.java (serialVersionUID): Added. * java/lang/Character.java (serialVersionUID): Added. * java/lang/Double.java (serialVersionUID): Added. * java/lang/Float.java (serialVersionUID): Added. * java/lang/Integer.java (serialVersionUID): Added. * java/lang/Long.java (serialVersionUID): Added. * java/lang/Number.java (serialVersionUID): Added. * java/lang/Short.java (serialVersionUID): Added. * java/lang/String.java (serialVersionUID): Added. * java/lang/ThreadDeath.java (ThreadDeath): Removed constructor to match spec. * java/lang/reflect/InvocationTargetException.java (serialVersionUID): Added. * java/net/URL.java (handler): Made transient. (hashCode): Added field for serialization, per spec. and use cached value if available. (serialVersionUID): Added. (URL): Initialize hashCode. (set): Adjust hashCode. (readObject): New Method to initialize the protocol handler when deserializing. (writeObject): New method. * java/text/BreakIterator.java: Removed 'implements Serializable'. * java/text/Collator.java: Removed 'implements Serializable'. * java/util/GregorianCalendar.java (serialVersionUID): Added. * java/util/Properties.java (serialVersionUID): Added. * java/util/Random.java (serialVersionUID): Added. (seed): Made private. (nextNextGaussian): Made private. (haveNextNextGaussian): Made private. * java/util/Stack.java (serialVersionUID): Added. * java/util/TimeZone.java (serialVersionUID): Added. * java/util/Vector.java (serialVersionUID): Added. Serialization mods. From-SVN: r36272
2000-09-08 21:37:09 +02:00
hashCode = hashCode(); // Used for serialization.
1999-04-07 16:42:40 +02:00
}
2002-11-01 Michael Koch <konqueror@gmx.de> * java/net/InetAddress.java: (isAnyLocalAddress): Implemented. (isLoopbackAddress): Implemented, comment added. (isLinkLocalAddress): Implemented, documentation added. (isSiteLocalAddress): Implemented, documentation added. (isMCGlobal): Implemented, documentation added. (isMCNodeLocal): Implemented, documentation added. (isMCLinkLocal): Implemented, documentation added. (isMCSiteLocal): Implemented, documentation added. (isMCOrgLocal): Implemented, documentation added. (getHostName): Documentation added. (getCanonicalHostName): Implemented, documentation added. (getAddress): Documentation added. (hashCode): Documentation added. (equals): Documentation added. (toString): Fixed implementation. (getByAddress): Use Inet4Address and Inet6Address. (lookup): New linewrap. (getByName): SecurityManager check added, support Inet4Address and Inet6address, comments added. (getAllByName): SecurityManager check added, comments added. * java/net/Inet6Address.java: (Inet6Address): Initialize parent class with addr instead of null. * java/net/URL.java (equals): Documentation added. (getFile): Documentation added. (hashCode): Documentation added. * java/net/natInetAddress.cc: (aton): Fix IPv6 support. * java/net/natPlainDatagramSocketImpl.cc: (peek): Throw PortUnreachableException when suitable. (peekData): Throw PortUnreachableException when suitable. (send): Throw PortUnreachableException when suitable. (receive): Throw PortUnreachableException when suitable. From-SVN: r58704
2002-11-01 07:35:14 +01:00
/**
* Checks if two URLs are equal
*/
1999-04-07 16:42:40 +02:00
public boolean equals(Object obj)
{
if (obj == null || ! (obj instanceof URL))
return false;
URL uObj = (URL) obj;
return handler.equals (this, uObj);
1999-04-07 16:42:40 +02:00
}
2002-09-25 Michael Koch <konqueror@gmx.de> * java/net/DatagramSocket.java (DatagramSocket): Initialize new instance variables. (close): Reset new instance variables. (getLocalAddress): Remove unneeded SecurityManager usage. (getLocalPort): Check if socket is already bound. (isConnected): New method. (getInetAddress): Implemented. (getPort): Better Implementation, documentation fixed. (getRemoteSocketAddress): New method. * java/net/JarURLConnection.java (element): Typo fixed. (getMainAttributes): New method. (getAttributes): New method (stub only). (getManifest): New method (stub only). * java/net/NetPermission.java: Added serialVersionsUID. * java/net/Socket.java (connect): Check blocking mode of associated channel, documentation added. (getLocalSocketAddress): Better implementation. (getRemoteSocketAddress): Implemented. (isBound): New method. (setSendBufferSize): Documentation added. * java/net/SocketAddress.java: Added serialVersionsUID. * java/net/SocketPermission.java: Added serialVersionsUID. * java/net/URL.java (URL): Wrap for shorter lines, initialize new instance variables, documentation added. (equals): Check new instance variables too. (getContent): Documentation added. (getPath): Documentation added. (getAuthority): New method. (getHost): Documentation added. (getPort): Documentation added. (getDefaultPort): New method. (getProtocol): Documentation added. (getUserInfo): Documentation added. (set): Initialize new instance variables, documentation added. * java/net/URLStreamHandler.java (setURL): New method. * java/net/natPlainDatagramSocketImpl.cc (connect): Fix exception name. (disconnect): Fix exception name. From-SVN: r57501
2002-09-25 19:14:09 +02:00
/**
* Gets the contents of this URL
*
* @exception IOException If an error occurs
*
2002-09-25 Michael Koch <konqueror@gmx.de> * java/net/DatagramSocket.java (DatagramSocket): Initialize new instance variables. (close): Reset new instance variables. (getLocalAddress): Remove unneeded SecurityManager usage. (getLocalPort): Check if socket is already bound. (isConnected): New method. (getInetAddress): Implemented. (getPort): Better Implementation, documentation fixed. (getRemoteSocketAddress): New method. * java/net/JarURLConnection.java (element): Typo fixed. (getMainAttributes): New method. (getAttributes): New method (stub only). (getManifest): New method (stub only). * java/net/NetPermission.java: Added serialVersionsUID. * java/net/Socket.java (connect): Check blocking mode of associated channel, documentation added. (getLocalSocketAddress): Better implementation. (getRemoteSocketAddress): Implemented. (isBound): New method. (setSendBufferSize): Documentation added. * java/net/SocketAddress.java: Added serialVersionsUID. * java/net/SocketPermission.java: Added serialVersionsUID. * java/net/URL.java (URL): Wrap for shorter lines, initialize new instance variables, documentation added. (equals): Check new instance variables too. (getContent): Documentation added. (getPath): Documentation added. (getAuthority): New method. (getHost): Documentation added. (getPort): Documentation added. (getDefaultPort): New method. (getProtocol): Documentation added. (getUserInfo): Documentation added. (set): Initialize new instance variables, documentation added. * java/net/URLStreamHandler.java (setURL): New method. * java/net/natPlainDatagramSocketImpl.cc (connect): Fix exception name. (disconnect): Fix exception name. From-SVN: r57501
2002-09-25 19:14:09 +02:00
* @since 1.3
*/
1999-04-07 16:42:40 +02:00
public final Object getContent() throws IOException
{
return openConnection().getContent();
}
/**
* Gets the contents of this URL
*
* @exception IOException If an error occurs
*/
public final Object getContent (Class[] classes) throws IOException
{
// FIXME: implement this
return getContent();
}
2002-11-01 Michael Koch <konqueror@gmx.de> * java/net/InetAddress.java: (isAnyLocalAddress): Implemented. (isLoopbackAddress): Implemented, comment added. (isLinkLocalAddress): Implemented, documentation added. (isSiteLocalAddress): Implemented, documentation added. (isMCGlobal): Implemented, documentation added. (isMCNodeLocal): Implemented, documentation added. (isMCLinkLocal): Implemented, documentation added. (isMCSiteLocal): Implemented, documentation added. (isMCOrgLocal): Implemented, documentation added. (getHostName): Documentation added. (getCanonicalHostName): Implemented, documentation added. (getAddress): Documentation added. (hashCode): Documentation added. (equals): Documentation added. (toString): Fixed implementation. (getByAddress): Use Inet4Address and Inet6Address. (lookup): New linewrap. (getByName): SecurityManager check added, support Inet4Address and Inet6address, comments added. (getAllByName): SecurityManager check added, comments added. * java/net/Inet6Address.java: (Inet6Address): Initialize parent class with addr instead of null. * java/net/URL.java (equals): Documentation added. (getFile): Documentation added. (hashCode): Documentation added. * java/net/natInetAddress.cc: (aton): Fix IPv6 support. * java/net/natPlainDatagramSocketImpl.cc: (peek): Throw PortUnreachableException when suitable. (peekData): Throw PortUnreachableException when suitable. (send): Throw PortUnreachableException when suitable. (receive): Throw PortUnreachableException when suitable. From-SVN: r58704
2002-11-01 07:35:14 +01:00
/**
* Returns the file of the URL
*/
1999-04-07 16:42:40 +02:00
public String getFile()
{
return file;
}
2002-09-25 Michael Koch <konqueror@gmx.de> * java/net/DatagramSocket.java (DatagramSocket): Initialize new instance variables. (close): Reset new instance variables. (getLocalAddress): Remove unneeded SecurityManager usage. (getLocalPort): Check if socket is already bound. (isConnected): New method. (getInetAddress): Implemented. (getPort): Better Implementation, documentation fixed. (getRemoteSocketAddress): New method. * java/net/JarURLConnection.java (element): Typo fixed. (getMainAttributes): New method. (getAttributes): New method (stub only). (getManifest): New method (stub only). * java/net/NetPermission.java: Added serialVersionsUID. * java/net/Socket.java (connect): Check blocking mode of associated channel, documentation added. (getLocalSocketAddress): Better implementation. (getRemoteSocketAddress): Implemented. (isBound): New method. (setSendBufferSize): Documentation added. * java/net/SocketAddress.java: Added serialVersionsUID. * java/net/SocketPermission.java: Added serialVersionsUID. * java/net/URL.java (URL): Wrap for shorter lines, initialize new instance variables, documentation added. (equals): Check new instance variables too. (getContent): Documentation added. (getPath): Documentation added. (getAuthority): New method. (getHost): Documentation added. (getPort): Documentation added. (getDefaultPort): New method. (getProtocol): Documentation added. (getUserInfo): Documentation added. (set): Initialize new instance variables, documentation added. * java/net/URLStreamHandler.java (setURL): New method. * java/net/natPlainDatagramSocketImpl.cc (connect): Fix exception name. (disconnect): Fix exception name. From-SVN: r57501
2002-09-25 19:14:09 +02:00
/**
* Returns the path of the URL
*
* @since 1.3
*/
public String getPath()
{
int quest = file.indexOf('?');
return quest < 0 ? file : file.substring(0, quest);
}
2002-09-25 Michael Koch <konqueror@gmx.de> * java/net/DatagramSocket.java (DatagramSocket): Initialize new instance variables. (close): Reset new instance variables. (getLocalAddress): Remove unneeded SecurityManager usage. (getLocalPort): Check if socket is already bound. (isConnected): New method. (getInetAddress): Implemented. (getPort): Better Implementation, documentation fixed. (getRemoteSocketAddress): New method. * java/net/JarURLConnection.java (element): Typo fixed. (getMainAttributes): New method. (getAttributes): New method (stub only). (getManifest): New method (stub only). * java/net/NetPermission.java: Added serialVersionsUID. * java/net/Socket.java (connect): Check blocking mode of associated channel, documentation added. (getLocalSocketAddress): Better implementation. (getRemoteSocketAddress): Implemented. (isBound): New method. (setSendBufferSize): Documentation added. * java/net/SocketAddress.java: Added serialVersionsUID. * java/net/SocketPermission.java: Added serialVersionsUID. * java/net/URL.java (URL): Wrap for shorter lines, initialize new instance variables, documentation added. (equals): Check new instance variables too. (getContent): Documentation added. (getPath): Documentation added. (getAuthority): New method. (getHost): Documentation added. (getPort): Documentation added. (getDefaultPort): New method. (getProtocol): Documentation added. (getUserInfo): Documentation added. (set): Initialize new instance variables, documentation added. * java/net/URLStreamHandler.java (setURL): New method. * java/net/natPlainDatagramSocketImpl.cc (connect): Fix exception name. (disconnect): Fix exception name. From-SVN: r57501
2002-09-25 19:14:09 +02:00
/**
* Returns the authority of the URL
*
* @since 1.3
*/
public String getAuthority()
{
return authority;
}
/**
* Returns the host of the URL
*/
1999-04-07 16:42:40 +02:00
public String getHost()
{
return host;
}
2002-09-25 Michael Koch <konqueror@gmx.de> * java/net/DatagramSocket.java (DatagramSocket): Initialize new instance variables. (close): Reset new instance variables. (getLocalAddress): Remove unneeded SecurityManager usage. (getLocalPort): Check if socket is already bound. (isConnected): New method. (getInetAddress): Implemented. (getPort): Better Implementation, documentation fixed. (getRemoteSocketAddress): New method. * java/net/JarURLConnection.java (element): Typo fixed. (getMainAttributes): New method. (getAttributes): New method (stub only). (getManifest): New method (stub only). * java/net/NetPermission.java: Added serialVersionsUID. * java/net/Socket.java (connect): Check blocking mode of associated channel, documentation added. (getLocalSocketAddress): Better implementation. (getRemoteSocketAddress): Implemented. (isBound): New method. (setSendBufferSize): Documentation added. * java/net/SocketAddress.java: Added serialVersionsUID. * java/net/SocketPermission.java: Added serialVersionsUID. * java/net/URL.java (URL): Wrap for shorter lines, initialize new instance variables, documentation added. (equals): Check new instance variables too. (getContent): Documentation added. (getPath): Documentation added. (getAuthority): New method. (getHost): Documentation added. (getPort): Documentation added. (getDefaultPort): New method. (getProtocol): Documentation added. (getUserInfo): Documentation added. (set): Initialize new instance variables, documentation added. * java/net/URLStreamHandler.java (setURL): New method. * java/net/natPlainDatagramSocketImpl.cc (connect): Fix exception name. (disconnect): Fix exception name. From-SVN: r57501
2002-09-25 19:14:09 +02:00
/**
* Returns of port of the URL
*/
1999-04-07 16:42:40 +02:00
public int getPort()
{
return port;
}
2002-09-25 Michael Koch <konqueror@gmx.de> * java/net/DatagramSocket.java (DatagramSocket): Initialize new instance variables. (close): Reset new instance variables. (getLocalAddress): Remove unneeded SecurityManager usage. (getLocalPort): Check if socket is already bound. (isConnected): New method. (getInetAddress): Implemented. (getPort): Better Implementation, documentation fixed. (getRemoteSocketAddress): New method. * java/net/JarURLConnection.java (element): Typo fixed. (getMainAttributes): New method. (getAttributes): New method (stub only). (getManifest): New method (stub only). * java/net/NetPermission.java: Added serialVersionsUID. * java/net/Socket.java (connect): Check blocking mode of associated channel, documentation added. (getLocalSocketAddress): Better implementation. (getRemoteSocketAddress): Implemented. (isBound): New method. (setSendBufferSize): Documentation added. * java/net/SocketAddress.java: Added serialVersionsUID. * java/net/SocketPermission.java: Added serialVersionsUID. * java/net/URL.java (URL): Wrap for shorter lines, initialize new instance variables, documentation added. (equals): Check new instance variables too. (getContent): Documentation added. (getPath): Documentation added. (getAuthority): New method. (getHost): Documentation added. (getPort): Documentation added. (getDefaultPort): New method. (getProtocol): Documentation added. (getUserInfo): Documentation added. (set): Initialize new instance variables, documentation added. * java/net/URLStreamHandler.java (setURL): New method. * java/net/natPlainDatagramSocketImpl.cc (connect): Fix exception name. (disconnect): Fix exception name. From-SVN: r57501
2002-09-25 19:14:09 +02:00
/**
* Returns the default port of the URL
*/
public int getDefaultPort()
{
return 0;
}
/**
* Returns the protocol of the URL
*/
1999-04-07 16:42:40 +02:00
public String getProtocol()
{
return protocol;
}
public String getRef()
{
return ref;
}
2002-09-25 Michael Koch <konqueror@gmx.de> * java/net/DatagramSocket.java (DatagramSocket): Initialize new instance variables. (close): Reset new instance variables. (getLocalAddress): Remove unneeded SecurityManager usage. (getLocalPort): Check if socket is already bound. (isConnected): New method. (getInetAddress): Implemented. (getPort): Better Implementation, documentation fixed. (getRemoteSocketAddress): New method. * java/net/JarURLConnection.java (element): Typo fixed. (getMainAttributes): New method. (getAttributes): New method (stub only). (getManifest): New method (stub only). * java/net/NetPermission.java: Added serialVersionsUID. * java/net/Socket.java (connect): Check blocking mode of associated channel, documentation added. (getLocalSocketAddress): Better implementation. (getRemoteSocketAddress): Implemented. (isBound): New method. (setSendBufferSize): Documentation added. * java/net/SocketAddress.java: Added serialVersionsUID. * java/net/SocketPermission.java: Added serialVersionsUID. * java/net/URL.java (URL): Wrap for shorter lines, initialize new instance variables, documentation added. (equals): Check new instance variables too. (getContent): Documentation added. (getPath): Documentation added. (getAuthority): New method. (getHost): Documentation added. (getPort): Documentation added. (getDefaultPort): New method. (getProtocol): Documentation added. (getUserInfo): Documentation added. (set): Initialize new instance variables, documentation added. * java/net/URLStreamHandler.java (setURL): New method. * java/net/natPlainDatagramSocketImpl.cc (connect): Fix exception name. (disconnect): Fix exception name. From-SVN: r57501
2002-09-25 19:14:09 +02:00
/**
* Returns the user information of the URL
*/
public String getUserInfo ()
{
int at = host.indexOf('@');
return at < 0 ? null : host.substring(0, at);
}
/**
* Returns the query of the URL
*/
public String getQuery ()
{
return query;
}
2002-11-01 Michael Koch <konqueror@gmx.de> * java/net/InetAddress.java: (isAnyLocalAddress): Implemented. (isLoopbackAddress): Implemented, comment added. (isLinkLocalAddress): Implemented, documentation added. (isSiteLocalAddress): Implemented, documentation added. (isMCGlobal): Implemented, documentation added. (isMCNodeLocal): Implemented, documentation added. (isMCLinkLocal): Implemented, documentation added. (isMCSiteLocal): Implemented, documentation added. (isMCOrgLocal): Implemented, documentation added. (getHostName): Documentation added. (getCanonicalHostName): Implemented, documentation added. (getAddress): Documentation added. (hashCode): Documentation added. (equals): Documentation added. (toString): Fixed implementation. (getByAddress): Use Inet4Address and Inet6Address. (lookup): New linewrap. (getByName): SecurityManager check added, support Inet4Address and Inet6address, comments added. (getAllByName): SecurityManager check added, comments added. * java/net/Inet6Address.java: (Inet6Address): Initialize parent class with addr instead of null. * java/net/URL.java (equals): Documentation added. (getFile): Documentation added. (hashCode): Documentation added. * java/net/natInetAddress.cc: (aton): Fix IPv6 support. * java/net/natPlainDatagramSocketImpl.cc: (peek): Throw PortUnreachableException when suitable. (peekData): Throw PortUnreachableException when suitable. (send): Throw PortUnreachableException when suitable. (receive): Throw PortUnreachableException when suitable. From-SVN: r58704
2002-11-01 07:35:14 +01:00
/**
* Returns a hashcode computed by the URLStreamHandler of this URL
*/
1999-04-07 16:42:40 +02:00
public int hashCode()
{
// JCL book says this is computed using (only) the hashcodes of the
// protocol, host and file fields. Empirical evidence indicates this
// is probably XOR in JDK 1.1. In JDK 1.2 it seems to be a sum including
// the port.
//
// JDK 1.2 online doc infers that host could be null because it
// explicitly states that file cannot be null but is silent on host.
// A simple example with protocol "http" (hashcode 3213448), host null,
// file "/" (hashcode 47) produced a hashcode (3213494) which appeared
// to be the sum of the two hashcodes plus the port. Another example
// using "/index.html" for file bore this out; as well as "#" for file
// (which was reduced to "" with a hashcode of zero). A "" host also
// causes the port number and the two hashcodes to be summed.
PropertyChangeEvent.java (serialVersionUID): Added. * java/beans/PropertyChangeEvent.java (serialVersionUID): Added. * java/beans/PropertyVetoException.java (serialVersionUID): Added. * java/io/File.java (writeObject): Added. (readObject): Added. (serialVersionUID): Added. * java/io/ObjectOutputStream.java (writeObject): Initialized fieldsAlreadyWritten before recursion rather than after. * java/io/ObjectStreamClass.java (serialVersionUID): Added. * java/io/OptionalDataException.java (serialVersionUID): Added. (OptionalDataException): Made package private. * java/io/SyncFailedException.java (SyncFailedException): Removed default constructor to match spec. * java/lang/Boolean.java (serialVersionUID): Added. * java/lang/Byte.java (serialVersionUID): Added. * java/lang/Character.java (serialVersionUID): Added. * java/lang/Double.java (serialVersionUID): Added. * java/lang/Float.java (serialVersionUID): Added. * java/lang/Integer.java (serialVersionUID): Added. * java/lang/Long.java (serialVersionUID): Added. * java/lang/Number.java (serialVersionUID): Added. * java/lang/Short.java (serialVersionUID): Added. * java/lang/String.java (serialVersionUID): Added. * java/lang/ThreadDeath.java (ThreadDeath): Removed constructor to match spec. * java/lang/reflect/InvocationTargetException.java (serialVersionUID): Added. * java/net/URL.java (handler): Made transient. (hashCode): Added field for serialization, per spec. and use cached value if available. (serialVersionUID): Added. (URL): Initialize hashCode. (set): Adjust hashCode. (readObject): New Method to initialize the protocol handler when deserializing. (writeObject): New method. * java/text/BreakIterator.java: Removed 'implements Serializable'. * java/text/Collator.java: Removed 'implements Serializable'. * java/util/GregorianCalendar.java (serialVersionUID): Added. * java/util/Properties.java (serialVersionUID): Added. * java/util/Random.java (serialVersionUID): Added. (seed): Made private. (nextNextGaussian): Made private. (haveNextNextGaussian): Made private. * java/util/Stack.java (serialVersionUID): Added. * java/util/TimeZone.java (serialVersionUID): Added. * java/util/Vector.java (serialVersionUID): Added. Serialization mods. From-SVN: r36272
2000-09-08 21:37:09 +02:00
if (hashCode != 0)
return hashCode; // Use cached value if available.
else
return handler.hashCode (this);
1999-04-07 16:42:40 +02:00
}
/**
* Returns a URLConnection object that represents a connection to the remote
* object referred to by the URL
*
* @exception IOException If an error occurs
*/
1999-04-07 16:42:40 +02:00
public URLConnection openConnection() throws IOException
{
return handler.openConnection(this);
}
/**
* Opens a connection to this URL and returns an InputStream for reading
* from that connection
*
* @exception IOException If an error occurs
*/
1999-04-07 16:42:40 +02:00
public final InputStream openStream() throws IOException
{
return openConnection().getInputStream();
}
public boolean sameFile(URL other)
{
return handler.sameFile(this, other);
1999-04-07 16:42:40 +02:00
}
2002-09-25 Michael Koch <konqueror@gmx.de> * java/net/DatagramSocket.java (DatagramSocket): Initialize new instance variables. (close): Reset new instance variables. (getLocalAddress): Remove unneeded SecurityManager usage. (getLocalPort): Check if socket is already bound. (isConnected): New method. (getInetAddress): Implemented. (getPort): Better Implementation, documentation fixed. (getRemoteSocketAddress): New method. * java/net/JarURLConnection.java (element): Typo fixed. (getMainAttributes): New method. (getAttributes): New method (stub only). (getManifest): New method (stub only). * java/net/NetPermission.java: Added serialVersionsUID. * java/net/Socket.java (connect): Check blocking mode of associated channel, documentation added. (getLocalSocketAddress): Better implementation. (getRemoteSocketAddress): Implemented. (isBound): New method. (setSendBufferSize): Documentation added. * java/net/SocketAddress.java: Added serialVersionsUID. * java/net/SocketPermission.java: Added serialVersionsUID. * java/net/URL.java (URL): Wrap for shorter lines, initialize new instance variables, documentation added. (equals): Check new instance variables too. (getContent): Documentation added. (getPath): Documentation added. (getAuthority): New method. (getHost): Documentation added. (getPort): Documentation added. (getDefaultPort): New method. (getProtocol): Documentation added. (getUserInfo): Documentation added. (set): Initialize new instance variables, documentation added. * java/net/URLStreamHandler.java (setURL): New method. * java/net/natPlainDatagramSocketImpl.cc (connect): Fix exception name. (disconnect): Fix exception name. From-SVN: r57501
2002-09-25 19:14:09 +02:00
/**
* Sets the specified fields of the URL. This is not a public method so
* that only URLStreamHandlers can modify URL fields. URLs are otherwise
* constant
*/
1999-04-07 16:42:40 +02:00
protected void set(String protocol, String host, int port, String file,
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;
2002-09-25 Michael Koch <konqueror@gmx.de> * java/net/DatagramSocket.java (DatagramSocket): Initialize new instance variables. (close): Reset new instance variables. (getLocalAddress): Remove unneeded SecurityManager usage. (getLocalPort): Check if socket is already bound. (isConnected): New method. (getInetAddress): Implemented. (getPort): Better Implementation, documentation fixed. (getRemoteSocketAddress): New method. * java/net/JarURLConnection.java (element): Typo fixed. (getMainAttributes): New method. (getAttributes): New method (stub only). (getManifest): New method (stub only). * java/net/NetPermission.java: Added serialVersionsUID. * java/net/Socket.java (connect): Check blocking mode of associated channel, documentation added. (getLocalSocketAddress): Better implementation. (getRemoteSocketAddress): Implemented. (isBound): New method. (setSendBufferSize): Documentation added. * java/net/SocketAddress.java: Added serialVersionsUID. * java/net/SocketPermission.java: Added serialVersionsUID. * java/net/URL.java (URL): Wrap for shorter lines, initialize new instance variables, documentation added. (equals): Check new instance variables too. (getContent): Documentation added. (getPath): Documentation added. (getAuthority): New method. (getHost): Documentation added. (getPort): Documentation added. (getDefaultPort): New method. (getProtocol): Documentation added. (getUserInfo): Documentation added. (set): Initialize new instance variables, documentation added. * java/net/URLStreamHandler.java (setURL): New method. * java/net/natPlainDatagramSocketImpl.cc (connect): Fix exception name. (disconnect): Fix exception name. From-SVN: r57501
2002-09-25 19:14:09 +02:00
this.authority = null;
this.userInfo = null;
1999-04-07 16:42:40 +02:00
this.port = port;
this.host = host;
this.file = file;
2002-09-25 Michael Koch <konqueror@gmx.de> * java/net/DatagramSocket.java (DatagramSocket): Initialize new instance variables. (close): Reset new instance variables. (getLocalAddress): Remove unneeded SecurityManager usage. (getLocalPort): Check if socket is already bound. (isConnected): New method. (getInetAddress): Implemented. (getPort): Better Implementation, documentation fixed. (getRemoteSocketAddress): New method. * java/net/JarURLConnection.java (element): Typo fixed. (getMainAttributes): New method. (getAttributes): New method (stub only). (getManifest): New method (stub only). * java/net/NetPermission.java: Added serialVersionsUID. * java/net/Socket.java (connect): Check blocking mode of associated channel, documentation added. (getLocalSocketAddress): Better implementation. (getRemoteSocketAddress): Implemented. (isBound): New method. (setSendBufferSize): Documentation added. * java/net/SocketAddress.java: Added serialVersionsUID. * java/net/SocketPermission.java: Added serialVersionsUID. * java/net/URL.java (URL): Wrap for shorter lines, initialize new instance variables, documentation added. (equals): Check new instance variables too. (getContent): Documentation added. (getPath): Documentation added. (getAuthority): New method. (getHost): Documentation added. (getPort): Documentation added. (getDefaultPort): New method. (getProtocol): Documentation added. (getUserInfo): Documentation added. (set): Initialize new instance variables, documentation added. * java/net/URLStreamHandler.java (setURL): New method. * java/net/natPlainDatagramSocketImpl.cc (connect): Fix exception name. (disconnect): Fix exception name. From-SVN: r57501
2002-09-25 19:14:09 +02:00
this.query = null;
1999-04-07 16:42:40 +02:00
this.ref = ref;
PropertyChangeEvent.java (serialVersionUID): Added. * java/beans/PropertyChangeEvent.java (serialVersionUID): Added. * java/beans/PropertyVetoException.java (serialVersionUID): Added. * java/io/File.java (writeObject): Added. (readObject): Added. (serialVersionUID): Added. * java/io/ObjectOutputStream.java (writeObject): Initialized fieldsAlreadyWritten before recursion rather than after. * java/io/ObjectStreamClass.java (serialVersionUID): Added. * java/io/OptionalDataException.java (serialVersionUID): Added. (OptionalDataException): Made package private. * java/io/SyncFailedException.java (SyncFailedException): Removed default constructor to match spec. * java/lang/Boolean.java (serialVersionUID): Added. * java/lang/Byte.java (serialVersionUID): Added. * java/lang/Character.java (serialVersionUID): Added. * java/lang/Double.java (serialVersionUID): Added. * java/lang/Float.java (serialVersionUID): Added. * java/lang/Integer.java (serialVersionUID): Added. * java/lang/Long.java (serialVersionUID): Added. * java/lang/Number.java (serialVersionUID): Added. * java/lang/Short.java (serialVersionUID): Added. * java/lang/String.java (serialVersionUID): Added. * java/lang/ThreadDeath.java (ThreadDeath): Removed constructor to match spec. * java/lang/reflect/InvocationTargetException.java (serialVersionUID): Added. * java/net/URL.java (handler): Made transient. (hashCode): Added field for serialization, per spec. and use cached value if available. (serialVersionUID): Added. (URL): Initialize hashCode. (set): Adjust hashCode. (readObject): New Method to initialize the protocol handler when deserializing. (writeObject): New method. * java/text/BreakIterator.java: Removed 'implements Serializable'. * java/text/Collator.java: Removed 'implements Serializable'. * java/util/GregorianCalendar.java (serialVersionUID): Added. * java/util/Properties.java (serialVersionUID): Added. * java/util/Random.java (serialVersionUID): Added. (seed): Made private. (nextNextGaussian): Made private. (haveNextNextGaussian): Made private. * java/util/Stack.java (serialVersionUID): Added. * java/util/TimeZone.java (serialVersionUID): Added. * java/util/Vector.java (serialVersionUID): Added. Serialization mods. From-SVN: r36272
2000-09-08 21:37:09 +02:00
hashCode = hashCode(); // Used for serialization.
1999-04-07 16:42:40 +02:00
}
2002-09-25 Michael Koch <konqueror@gmx.de> * java/net/DatagramSocket.java (DatagramSocket): Initialize new instance variables. (close): Reset new instance variables. (getLocalAddress): Remove unneeded SecurityManager usage. (getLocalPort): Check if socket is already bound. (isConnected): New method. (getInetAddress): Implemented. (getPort): Better Implementation, documentation fixed. (getRemoteSocketAddress): New method. * java/net/JarURLConnection.java (element): Typo fixed. (getMainAttributes): New method. (getAttributes): New method (stub only). (getManifest): New method (stub only). * java/net/NetPermission.java: Added serialVersionsUID. * java/net/Socket.java (connect): Check blocking mode of associated channel, documentation added. (getLocalSocketAddress): Better implementation. (getRemoteSocketAddress): Implemented. (isBound): New method. (setSendBufferSize): Documentation added. * java/net/SocketAddress.java: Added serialVersionsUID. * java/net/SocketPermission.java: Added serialVersionsUID. * java/net/URL.java (URL): Wrap for shorter lines, initialize new instance variables, documentation added. (equals): Check new instance variables too. (getContent): Documentation added. (getPath): Documentation added. (getAuthority): New method. (getHost): Documentation added. (getPort): Documentation added. (getDefaultPort): New method. (getProtocol): Documentation added. (getUserInfo): Documentation added. (set): Initialize new instance variables, documentation added. * java/net/URLStreamHandler.java (setURL): New method. * java/net/natPlainDatagramSocketImpl.cc (connect): Fix exception name. (disconnect): Fix exception name. From-SVN: r57501
2002-09-25 19:14:09 +02:00
/**
* Sets the specified fields of the URL. This is not a public method so
* that only URLStreamHandlers can modify URL fields. URLs are otherwise
* constant
*
* @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.
}
/**
* Sets an application's URLStreamHandlerFactory
*
* @exception Error If the application has already set a factory
* @exception SecurityException If a security manager exists and its
* checkSetFactory method doesn't allow the operation
*/
1999-04-07 16:42:40 +02:00
public static synchronized void
setURLStreamHandlerFactory(URLStreamHandlerFactory fac)
{
if (factory != null)
throw new Error("URLStreamHandlerFactory already set");
// Throw an exception if an extant security mgr precludes
// setting the factory.
SecurityManager s = System.getSecurityManager();
if (s != null)
s.checkSetFactory();
factory = fac;
}
public String toExternalForm()
{
// Identical to toString().
return handler.toExternalForm(this);
}
public String toString()
{
// Identical to toExternalForm().
return handler.toExternalForm(this);
}
private URLStreamHandler setURLStreamHandler(String protocol)
{
URLStreamHandler handler;
// See if a handler has been cached for this protocol.
if ((handler = (URLStreamHandler) handlers.get(protocol)) != null)
return handler;
// If a non-default factory has been set, use it to find the protocol.
if (factory != null)
handler = factory.createURLStreamHandler(protocol);
else if (protocol.equals ("core"))
{
handler = new gnu.gcj.protocol.core.Handler ();
}
else if (protocol.equals ("file"))
{
// This is an interesting case. It's tempting to think that we
// could call Class.forName ("gnu.gcj.protocol.file.Handler") to
// get the appropriate class. Unfortunately, if we do that the
// program will never terminate, because setURLStreamHandler is
// eventually called by Class.forName.
//
// Treating "file" as a special case is the minimum that will
// fix this problem. If other protocols are required in a
// statically linked application they will need to be handled in
// the same way as "file".
handler = new gnu.gcj.protocol.file.Handler ();
}
1999-04-07 16:42:40 +02:00
// Non-default factory may have returned null or a factory wasn't set.
// Use the default search algorithm to find a handler for this protocol.
if (handler == null)
{
// Get the list of packages to check and append our default handler
// to it, along with the JDK specified default as a last resort.
// Except in very unusual environments the JDK specified one shouldn't
// ever be needed (or available).
String propVal = System.getProperty("java.protocol.handler.pkgs");
propVal = (propVal == null) ? "" : (propVal + "|");
propVal = propVal + "gnu.gcj.protocol|sun.net.www.protocol";
StringTokenizer pkgPrefix = new StringTokenizer(propVal, "|");
do
{
String facName = pkgPrefix.nextToken() + "." + protocol +
".Handler";
try
{
handler =
(URLStreamHandler) Class.forName(facName).newInstance();
}
catch (Exception e)
{
// Can't instantiate; handler still null, go on to next element.
}
} while ((handler == null ||
! (handler instanceof URLStreamHandler)) &&
pkgPrefix.hasMoreTokens());
}
// Update the hashtable with the new protocol handler.
if (handler != null)
if (handler instanceof URLStreamHandler)
handlers.put(protocol, handler);
else
handler = null;
return handler;
}
PropertyChangeEvent.java (serialVersionUID): Added. * java/beans/PropertyChangeEvent.java (serialVersionUID): Added. * java/beans/PropertyVetoException.java (serialVersionUID): Added. * java/io/File.java (writeObject): Added. (readObject): Added. (serialVersionUID): Added. * java/io/ObjectOutputStream.java (writeObject): Initialized fieldsAlreadyWritten before recursion rather than after. * java/io/ObjectStreamClass.java (serialVersionUID): Added. * java/io/OptionalDataException.java (serialVersionUID): Added. (OptionalDataException): Made package private. * java/io/SyncFailedException.java (SyncFailedException): Removed default constructor to match spec. * java/lang/Boolean.java (serialVersionUID): Added. * java/lang/Byte.java (serialVersionUID): Added. * java/lang/Character.java (serialVersionUID): Added. * java/lang/Double.java (serialVersionUID): Added. * java/lang/Float.java (serialVersionUID): Added. * java/lang/Integer.java (serialVersionUID): Added. * java/lang/Long.java (serialVersionUID): Added. * java/lang/Number.java (serialVersionUID): Added. * java/lang/Short.java (serialVersionUID): Added. * java/lang/String.java (serialVersionUID): Added. * java/lang/ThreadDeath.java (ThreadDeath): Removed constructor to match spec. * java/lang/reflect/InvocationTargetException.java (serialVersionUID): Added. * java/net/URL.java (handler): Made transient. (hashCode): Added field for serialization, per spec. and use cached value if available. (serialVersionUID): Added. (URL): Initialize hashCode. (set): Adjust hashCode. (readObject): New Method to initialize the protocol handler when deserializing. (writeObject): New method. * java/text/BreakIterator.java: Removed 'implements Serializable'. * java/text/Collator.java: Removed 'implements Serializable'. * java/util/GregorianCalendar.java (serialVersionUID): Added. * java/util/Properties.java (serialVersionUID): Added. * java/util/Random.java (serialVersionUID): Added. (seed): Made private. (nextNextGaussian): Made private. (haveNextNextGaussian): Made private. * java/util/Stack.java (serialVersionUID): Added. * java/util/TimeZone.java (serialVersionUID): Added. * java/util/Vector.java (serialVersionUID): Added. Serialization mods. From-SVN: r36272
2000-09-08 21:37:09 +02:00
private void readObject(ObjectInputStream ois)
throws IOException, ClassNotFoundException
{
ois.defaultReadObject();
this.handler = setURLStreamHandler(protocol);
if (this.handler == null)
throw new IOException("Handler for protocol " + protocol + " not found");
}
private void writeObject(ObjectOutputStream oos) throws IOException
{
oos.defaultWriteObject();
}
1999-04-07 16:42:40 +02:00
}