+2002-10-08 Michael Koch <konqueror@gmx.de>
+
+ * java/net/HttpURLConnection.java
+ (getPermission): New method.
+ (getErrorStream): New stub method.
+ (getHeaderFieldDate): New stub method.
+ * java/net/Inet4Address.java:
+ (isLinkLocalAddress): Typo fixed.
+ * java/net/InetAddress.java:
+ (readResolve): New stubbed method (for serialization).
+ (isAnyLocalAddress): New stubbed method.
+ (isLoopbackAddress): New stubbed method.
+ (isLinkLocalAddress): New stubbed method.
+ (isSiteLocalAddress): New stubbed method.
+ (isMCGlobal): New stubbed method.
+ (isMCNodeGlobal): New stubbed method.
+ (isMCLinkLocal): New stubbed method.
+ (isMCSiteLocal): New stubbed method.
+ (isMCOrgLocal): New stubbed method.
+ (getCanonicalHostName): New stubbed method.
+ (getByAddress): Create instances of Inet4Address/Inet6Address,
+ instead of InetAddress, documentation added.
+ * java/net/MulticastSocket.java
+ (getInterface): Removed FIXME.
+ (getNetworkInterface): New method.
+ (setNetworkInterface): New method.
+ * java/net/NetworkInterface.java:
+ (toString): Use property "line.separator" instead of "\n".
+ * java/net/URLConnection.java
+ (getContent): New stubbed method.
+ * java/net/URLStreamHandler.java:
+ (equals): New stubbed method.
+ (hostsEqual): New stubbed method.
+ (hashCode): New stubbed method.
+ * java/net/natNetworkInterface.cc:
+ (getRealNetworkInterfaces): Create Inet4Address object
+ instead of InetAddress.
+
2002-10-08 Ulrich Weigand <uweigand@de.ibm.com>
* interpret.cc (_Jv_InterpMethod::run): Use UINT32 instead of
}
}
- // TODO12: public Permission getPermission() throws IOException
- // {
- // }
+ /**
+ * Returns a permission object representing the permission necessary to make
+ * the connection represented by this object
+ *
+ * @exception IOException If an error occurs
+ */
+ public Permission getPermission() throws IOException
+ {
+ return new SocketPermission (url.getHost (), "connect");
+ }
+
+ /**
+ * Returns the error stream if the connection failed but the server sent
+ * useful data nonetheless
+ */
+ public InputStream getErrorStream ()
+ {
+ // FIXME: implement this
+ return null;
+ }
- // TODO12: public InputStream getErrorStream()
- // {
- // }
+ /**
+ * Returns the value of the named field parsed as date
+ */
+ public long getHeaderFieldDate (String key, long value)
+ {
+ // FIXME: implement this correctly
+ // http://www.w3.org/Protocols/HTTP-NG/ng-notes.txt
+
+ return super.getHeaderFieldDate (key, value);
+ }
}
*/
public boolean isLinkLocalAddress ()
{
- // XXX: This seems to net exist with IPv4 addresses
+ // XXX: This seems to not exist with IPv4 addresses
return false;
}
details. */
package java.net;
+
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.IOException;
import java.io.Serializable;
+import java.io.ObjectStreamException;
/**
* @author Per Bothner
int family;
private static final long serialVersionUID = 3286316764910316507L;
+ /**
+ * Needed for serialization
+ */
+ private void readResolve () throws ObjectStreamException
+ {
+ // FIXME: implement this
+ }
+
private void readObject(ObjectInputStream ois)
throws IOException, ClassNotFoundException
{
return false;
}
+ /**
+ * Utility routine to check if the InetAddress in a wildcard address
+ *
+ * @since 1.4
+ */
+ public boolean isAnyLocalAddress ()
+ {
+ // FIXME: implement this
+ return false;
+ }
+
+ /**
+ * Utility routine to check if the InetAddress is a loopback address
+ *
+ * @since 1.4
+ */
+ public boolean isLoopbackAddress ()
+ {
+ // FIXME: implement this
+ return addr [0] == 0x7F;
+ }
+
+ /**
+ * @since 1.4
+ */
+ public boolean isLinkLocalAddress ()
+ {
+ // FIXME: implement this
+ return false;
+ }
+
+ /**
+ * @since 1.4
+ */
+ public boolean isSiteLocalAddress ()
+ {
+ // FIXME: implement this
+ return false;
+ }
+
+ /**
+ * @since 1.4
+ */
+ public boolean isMCGlobal ()
+ {
+ // FIXME: implement this
+ return false;
+ }
+
+ /**
+ * @since 1.4
+ */
+ public boolean isMCNodeLocal ()
+ {
+ // FIXME: implement this
+ return false;
+ }
+
+ /**
+ * @since 1.4
+ */
+ public boolean isMCLinkLocal ()
+ {
+ // FIXME: implement this
+ return false;
+ }
+
+ /**
+ * @since 1.4
+ */
+ public boolean isMCSiteLocal ()
+ {
+ // FIXME: implement this
+ return false;
+ }
+
+ /**
+ * @since 1.4
+ */
+ public boolean isMCOrgLocal ()
+ {
+ // FIXME: implement this
+ return false;
+ }
+
public String getHostName ()
{
if (hostName == null)
return hostName;
}
+ /**
+ * @since 1.4
+ */
+ public String getCanonicalHostName ()
+ {
+ // FIXME: implement this
+ return "";
+ }
+
public byte[] getAddress ()
{
// An experiment shows that JDK1.2 returns a different byte array each
{
if (obj == null || ! (obj instanceof InetAddress))
return false;
+
// "The Java Class Libraries" 2nd edition says "If a machine has
// multiple names instances of InetAddress for different name of
// that same machine are not equal. This is because they have
{
return getHostName()+'/'+getHostAddress();
}
-
+
/**
* Returns an InetAddress object given the raw IP address.
*
* The argument is in network byte order: the highest order byte of the
* address is in getAddress()[0].
*
+ * @param addr The IP address to create the InetAddress object from
+ *
* @exception UnknownHostException If IP address has illegal length
*
* @since 1.4
return new InetAddress (addr, "");
}
-
+
/**
- * Create an InetAddress based on the provided host name and IP address.
+ * Creates an InetAddress based on the provided host name and IP address.
* No name service is checked for the validity of the address.
*
+ * @param host The hostname of the InetAddress object to create
+ * @param addr The IP address to create the InetAddress object from
+ *
* @exception UnknownHostException If IP address is of illegal length
*
* @since 1.4
public static InetAddress getByAddress (String host, byte[] addr)
throws UnknownHostException
{
- if (addr.length == 4 || addr.length == 16)
- return new InetAddress (addr, host);
+ if (addr.length == 4)
+ return new Inet4Address (addr, host);
+
+ if (addr.length == 16)
+ return new Inet6Address (addr, host);
throw new UnknownHostException ("IP address has illegal length");
}
package java.net;
import java.io.IOException;
+import java.util.Enumeration;
/**
* Written using on-line Java Platform 1.2 API Specification, as well
*/
public InetAddress getInterface() throws SocketException
{
- // FIXME: Is it possible that an InetAddress wasn't returned from getOption?
return (InetAddress) impl.getOption(SocketOptions.IP_MULTICAST_IF);
}
impl.setOption(SocketOptions.IP_MULTICAST_IF, inf);
}
+ /**
+ * Sets the local network interface used to send multicast messages
+ *
+ * @param netIF The local network interface used to send multicast messages
+ *
+ * @exception SocketException If an error occurs
+ *
+ * @see MulticastSocket:getNetworkInterface
+ *
+ * @since 1.4
+ */
+ public void setNetworkInterface(NetworkInterface netIf)
+ throws SocketException
+ {
+ if (impl == null)
+ throw new SocketException (
+ "MulticastSocket: Cant access socket implementation");
+
+ Enumeration e = netIf.getInetAddresses ();
+
+ if (!e.hasMoreElements ())
+ throw new SocketException ("MulticastSocket: Error");
+
+ InetAddress address = (InetAddress) e.nextElement ();
+ impl.setOption (SocketOptions.IP_MULTICAST_IF, address);
+ }
+
+ /**
+ * Gets the local network interface which is used to send multicast messages
+ *
+ * @return The local network interface to send multicast messages
+ *
+ * @exception SocketException If an error occurs
+ *
+ * @see MulticastSocket:setNetworkInterface
+ *
+ * @since 1.4
+ */
+ public NetworkInterface getNetworkInterface()
+ throws SocketException
+ {
+ if (impl == null)
+ throw new SocketException (
+ "MulticastSocket: Cant access socket implementation");
+
+ InetAddress address =
+ (InetAddress) impl.getOption (SocketOptions.IP_MULTICAST_IF);
+ NetworkInterface netIf = NetworkInterface.getByInetAddress (address);
+
+ return netIf;
+ }
+
/**
* Disable/Enable local loopback of multicast packets. The option is used by
* the platform's networking code as a hint for setting whether multicast
*/
public void setLoopbackMode(boolean disable) throws SocketException
{
+ if (impl == null)
+ throw new SocketException (
+ "MulticastSocket: Cant access socket implementation");
+
impl.setOption (SocketOptions.IP_MULTICAST_LOOP, new Boolean (disable));
}
{
// FIXME: check if this is correct
String result;
+ String separator = System.getProperty ("line.separator");
result = "name: " + getDisplayName () + " (" + getName () +
- ") addresses:\n";
+ ") addresses:" + separator;
for (Enumeration e = inetAddresses.elements ();
e.hasMoreElements (); )
{
InetAddress address = (InetAddress) e.nextElement ();
- result += address.toString () + "\n";
+ result += address.toString () + separator;
}
return result;
return contentHandler.getContent(this);
}
+ /**
+ * Retrieves the content of this URLConnection
+ *
+ * @exception IOException If an error occurs
+ * @exception UnknownServiceException If the protocol does not support the
+ * content type
+ */
+ public Object getContent(Class[] classes) throws IOException
+ {
+ // FIXME: implement this
+ return getContent ();
+ }
+
/**
* Returns a permission object representing the permission necessary to make
* the connection represented by this object. This method returns null if no
u.set(protocol, host, port, authority, userInfo, path, query, ref);
}
+ /**
+ * Provides the default equals calculation. May be overidden by handlers for
+ * other protocols that have different requirements for equals(). This method
+ * requires that none of its arguments is null. This is guaranteed by the
+ * fact that it is only called by java.net.URL class.
+ *
+ * @param url1 An URL object
+ * @param url2 An URL object
+ */
+ protected boolean equals (URL url1, URL url2)
+ {
+ // FIXME: implement this
+ return false;
+ }
+
+ /**
+ * Compares the host components of two URLs.
+ *
+ * @exception UnknownHostException If an unknown host is found
+ */
+ protected boolean hostsEqual (URL url1, URL url2)
+ {
+ // FIXME: implement this
+ return false;
+ }
+
/**
* Get the IP address of our host. An empty host field or a DNS failure will
* result in a null return.
return -1;
}
+ /**
+ * Provides the default hash calculation. May be overidden by handlers for
+ * other protocols that have different requirements for hashCode calculation.
+ */
+ protected int hashCode (URL url)
+ {
+ // FIXME: implement this
+ return 0;
+ }
+
/**
* Converts an URL of a specific protocol to a string
*
#include <gcj/cni.h>
#include <jvm.h>
#include <java/net/NetworkInterface.h>
-#include <java/net/InetAddress.h>
+#include <java/net/Inet4Address.h>
#include <java/net/SocketException.h>
#include <java/util/Vector.h>
jbyteArray baddr = JvNewByteArray (len);
memcpy (elements (baddr), &(sa.sin_addr), len);
jstring if_name = JvNewStringLatin1 (if_record->ifr_name);
- InetAddress* address =
- new java::net::InetAddress (baddr, JvNewStringLatin1 (""));
+ Inet4Address* address =
+ new java::net::Inet4Address (baddr, JvNewStringLatin1 (""));
ht->add (new NetworkInterface (if_name, address));
if_record++;
}