[kaffe] CVS kaffe (guilhem): Synchronization with classpath.

Kaffe CVS Kaffe Mailing List <kaffe@kaffe.org>
Mon Dec 29 03:18:03 2003


PatchSet 4241 
Date: 2003/12/29 11:15:14
Author: guilhem
Branch: HEAD
Tag: (none) 
Log:
Synchronization with classpath.

Members: 
	ChangeLog:1.1830->1.1831 
	libraries/javalib/gnu/java/net/HeaderFieldHelper.java:1.1->1.2 
	libraries/javalib/gnu/java/net/protocol/http/Connection.java:1.4->1.5 
	libraries/javalib/java/io/BufferedReader.java:1.12->1.13 
	libraries/javalib/java/net/DatagramPacket.java:1.10->1.11 
	libraries/javalib/java/util/Calendar.java:1.16->1.17 
	libraries/javalib/java/util/GregorianCalendar.java:1.21->1.22 
	libraries/javalib/java/util/IdentityHashMap.java:1.1->1.2 
	libraries/javalib/java/util/SimpleTimeZone.java:1.12->1.13 
	libraries/javalib/java/util/TimeZone.java:1.15->1.16 

Index: kaffe/ChangeLog
diff -u kaffe/ChangeLog:1.1830 kaffe/ChangeLog:1.1831
--- kaffe/ChangeLog:1.1830	Sun Dec 28 09:42:17 2003
+++ kaffe/ChangeLog	Mon Dec 29 11:15:14 2003
@@ -1,3 +1,16 @@
+2003-12-29  Guilhem Lavaux <guilhem@kaffe.org>
+
+	* libraries/javalib/java/io/BufferedReader.java,
+	libraries/javalib/java/net/DatagramPacket.java,
+	libraries/javalib/java/util/Calendar.java,
+	libraries/javalib/java/util/GregorianCalendar.java,
+	libraries/javalib/java/util/IdentityHashMap.java,
+	libraries/javalib/java/util/SimpleTimeZone.java,
+	libraries/javalib/java/util/TimeZone.java,
+	libraries/javalib/gnu/java/net/protocol/HeaderFieldHelper.java,
+	libraries/javalib/gnu/java/net/protocol/http/Connection.java:
+	Synchronization with classpath.
+
 2003-12-28  Casey Marshall <rsdio@metastatic.org>
 
 	* libraries/javalib/kaffe/tools/jar/Jar.java
Index: kaffe/libraries/javalib/gnu/java/net/HeaderFieldHelper.java
diff -u kaffe/libraries/javalib/gnu/java/net/HeaderFieldHelper.java:1.1 kaffe/libraries/javalib/gnu/java/net/HeaderFieldHelper.java:1.2
--- kaffe/libraries/javalib/gnu/java/net/HeaderFieldHelper.java:1.1	Wed Oct 29 18:30:48 2003
+++ kaffe/libraries/javalib/gnu/java/net/HeaderFieldHelper.java	Mon Dec 29 11:15:16 2003
@@ -38,6 +38,8 @@
 
 package gnu.java.net;
 
+import java.util.HashMap;
+import java.util.Map;
 import java.util.Vector;
 
 /**
@@ -95,6 +97,36 @@
       }
 
     return value;
+  }
+
+  public String getHeaderFieldValueByKey(String key)
+  {
+    String value = null;
+
+    try
+      {
+	value = (String) headerFieldValues.elementAt
+			   (headerFieldKeys.indexOf(key));
+      }
+    catch (ArrayIndexOutOfBoundsException e)
+      {
+      }
+    
+    return value;
+  }
+
+  public Map getHeaderFields()
+  {
+    HashMap headers = new HashMap();
+    int max = headerFieldKeys.size();
+
+    for (int index = 0; index < max; index++)
+      {
+	headers.put(headerFieldKeys.elementAt(index),
+		    headerFieldValues.elementAt(index));
+      }
+
+    return headers;
   }
 
   public int getNumberOfEntries()
Index: kaffe/libraries/javalib/gnu/java/net/protocol/http/Connection.java
diff -u kaffe/libraries/javalib/gnu/java/net/protocol/http/Connection.java:1.4 kaffe/libraries/javalib/gnu/java/net/protocol/http/Connection.java:1.5
--- kaffe/libraries/javalib/gnu/java/net/protocol/http/Connection.java:1.4	Sat Dec 27 21:15:57 2003
+++ kaffe/libraries/javalib/gnu/java/net/protocol/http/Connection.java	Mon Dec 29 11:15:16 2003
@@ -161,7 +161,6 @@
 
     inputStream =
       new DataInputStream(new BufferedInputStream(socket.getInputStream()));
-
     outputStream = new BufferedOutputStream (socket.getOutputStream());
     bufferedOutputStream = new ByteArrayOutputStream (256); //default is too small
 
@@ -250,7 +249,7 @@
     String line = inputStream.readLine();
     String saveline = line;
     int idx = line.indexOf (" ");
-    
+
     if ((idx == -1)
         || (line.length() < (idx + 6)))
       throw new IOException ("Server reply was unparseable: " + saveline);
@@ -303,7 +302,7 @@
           {
             if (key != null)
               {
-                headers.addHeaderField (key, value);
+                headers.addHeaderField (key.toLowerCase(), value);
                 key = null;
                 value = null;
               }
@@ -333,7 +332,7 @@
     
     if (key != null)
       {
-        headers.addHeaderField (key, value);
+        headers.addHeaderField (key.toLowerCase(), value.toLowerCase());
       }
   }
 
@@ -411,6 +410,36 @@
                                    method);
   }
 
+  public String getHeaderField(String name)
+  {
+    if (!connected)
+      try
+        {
+	  connect();
+	}
+      catch (IOException x)
+        {
+	  return null;
+	}
+
+    return (String) headers.getHeaderFieldValueByKey(name.toLowerCase());
+  }
+
+  public Map getHeaderFields()
+  {
+    if (!connected)
+      try
+        {
+	  connect();
+	}
+      catch (IOException x)
+        {
+	  return null;
+	}
+
+    return headers.getHeaderFields();
+  }
+
   /**
    * This method returns the header field value at the specified numeric
    * index.
@@ -424,11 +453,11 @@
   {
     if (!connected)
       try
-	{
+        {
 	  connect();
 	}
-      catch (IOException e)
-	{
+      catch (IOException x)
+        {
 	  return null;
 	}
 
@@ -448,11 +477,11 @@
   {
     if (!connected)
       try
-	{
+        {
 	  connect();
 	}
-      catch (IOException e)
-	{
+      catch (IOException x)
+        {
 	  return null;
 	}
 
Index: kaffe/libraries/javalib/java/io/BufferedReader.java
diff -u kaffe/libraries/javalib/java/io/BufferedReader.java:1.12 kaffe/libraries/javalib/java/io/BufferedReader.java:1.13
--- kaffe/libraries/javalib/java/io/BufferedReader.java:1.12	Sun Nov  2 13:29:36 2003
+++ kaffe/libraries/javalib/java/io/BufferedReader.java	Mon Dec 29 11:15:17 2003
@@ -107,13 +107,13 @@
    * @param in The subordinate stream to read from
    * @param size The buffer size to use
    *
-   * @exception IllegalArgumentException if size <= 0
+   * @exception IllegalArgumentException if size &lt;&eq; 0
    */
   public BufferedReader(Reader in, int size)
   {
     super(in.lock);
     if (size <= 0)
-      throw new IllegalArgumentException ("Buffer size is negative");
+      throw new IllegalArgumentException("Illegal buffer size: " + size);
     this.in = in;
     buffer = new char[size];
   }
@@ -193,7 +193,7 @@
 	    int extraBuffSpace = 0;
 	    if (pos > limit)
 	      extraBuffSpace = 1;
-	    if (readLimit + extraBuffSpace > buffer.length)
+	    if (readLimit + extraBuffSpace > limit)
 	      buffer = new char[readLimit + extraBuffSpace];
 	    limit -= pos;
 	    if (limit >= 0)
@@ -463,6 +463,7 @@
 	// readLine should block. So we must not return until a -1 is reached.
 	if (pos >= limit)
 	  {
+	    // here count == 0 isn't sufficient to give a failure.
 	    int count = fill();
 	    if (count < 0)
 	      {
Index: kaffe/libraries/javalib/java/net/DatagramPacket.java
diff -u kaffe/libraries/javalib/java/net/DatagramPacket.java:1.10 kaffe/libraries/javalib/java/net/DatagramPacket.java:1.11
--- kaffe/libraries/javalib/java/net/DatagramPacket.java:1.10	Wed Dec  3 21:54:09 2003
+++ kaffe/libraries/javalib/java/net/DatagramPacket.java	Mon Dec 29 11:15:17 2003
@@ -78,13 +78,18 @@
   private int offset;
 
   /**
-   * The length of the data buffer to send
+   * The length of the data buffer to send.
    */
-  private int length;
+  int length;
 
   /**
+   * The maximal length of the buffer.
+   */
+  int maxlen;
+  
+  /**
    * The address to which the packet should be sent or from which it
-   * was received
+   * was received.
    */
   private InetAddress address;
 
@@ -106,21 +111,9 @@
    */
   public DatagramPacket(byte[] buf, int offset, int length)
   {
-    if (buf == null)
-      throw new NullPointerException("Null buffer");
-    if (offset < 0)
-      throw new IllegalArgumentException("Invalid offset: " + offset);
-    if (length < 0)
-      throw new IllegalArgumentException("Invalid length: " + length);
-    if (offset + length > buf.length)
-      throw new IllegalArgumentException("Potential buffer overflow - offset: "
-			+ offset + " length: " + length);
-
-    buffer = buf;
-    this.offset = offset;
-    this.length = length;
-    this.address = null;
-    this.port = -1;
+    setData(buf, offset, length);
+    address = null;
+    port = -1;
   }
 
   /**
@@ -150,25 +143,9 @@
   public DatagramPacket(byte[] buf, int offset, int length,
 	InetAddress address, int port)
   {
-    if (buf == null)
-      throw new NullPointerException("Null buffer");
-    if (offset < 0)
-      throw new IllegalArgumentException("Invalid offset: " + offset);
-    if (length < 0)
-      throw new IllegalArgumentException("Invalid length: " + length);
-    if (offset + length > buf.length)
-      throw new IllegalArgumentException("Potential buffer overflow - offset: "
-			+ offset + " length: " + length);
-    if (port < 0 || port > 65535)
-      throw new IllegalArgumentException("Invalid port: " + port);
-    if (address == null)
-      throw new NullPointerException("Null address");
-
-    buffer = buf;
-    this.offset = offset;
-    this.length = length;
-    this.address = address;
-    this.port = port;
+    setData(buf, offset, length);
+    setAddress(address);
+    setPort(port);
   }
 
   /**
@@ -203,8 +180,13 @@
 		        SocketAddress address)
      throws SocketException
   {
-    this(buf, offset, length, ((InetSocketAddress)address).getAddress(),
-         ((InetSocketAddress)address).getPort());
+    if (! (address instanceof InetSocketAddress))
+      throw new IllegalArgumentException("unsupported address type");
+
+    InetSocketAddress tmp = (InetSocketAddress) address;
+    setData(buf, offset, length);
+    setAddress(tmp.getAddress());
+    setPort(tmp.getPort());
   }
 
   /**
@@ -223,8 +205,7 @@
   public DatagramPacket(byte[] buf, int length, SocketAddress address)
     throws SocketException
   {
-    this(buf, 0, length, ((InetSocketAddress)address).getAddress(),
-         ((InetSocketAddress)address).getPort());
+    this(buf, 0, length, address);
   }
 
   /**
@@ -330,9 +311,10 @@
   public void setSocketAddress(SocketAddress address)
     throws IllegalArgumentException
   {
-    if (address == null) throw new IllegalArgumentException();
+    if (address == null)
+      throw new IllegalArgumentException("address may not be null");
 
-    InetSocketAddress tmp = (InetSocketAddress)address;
+    InetSocketAddress tmp = (InetSocketAddress) address;
     this.address = tmp.getAddress();
     this.port = tmp.getPort();
   }
@@ -359,14 +341,9 @@
    *
    * @since 1.1
    */
-  public synchronized void setData(byte[] buf)
+  public void setData(byte[] buf)
   {
-    // This form of setData requires setLength to be called separately
-    // and subsequently.
-    if (buf == null)
-      throw new NullPointerException("Null buffer");
-
-    buffer = buf;
+    setData(buf, 0, buf.length);
   }
 
   /**
@@ -388,15 +365,10 @@
       throw new NullPointerException("Null buffer");
     if (offset < 0)
       throw new IllegalArgumentException("Invalid offset: " + offset);
-    if (length < 0)
-      throw new IllegalArgumentException("Invalid length: " + length);
-    if (offset + length > buf.length)
-      throw new IllegalArgumentException("Potential buffer overflow - offset: "
-			+ offset + " length: " + length);
 
     buffer = buf;
     this.offset = offset;
-    this.length = length;
+    setLength(length);
   }
 
   /**
@@ -418,6 +390,6 @@
 			+ offset + " length: " + length);
 
     this.length = length;
+    this.maxlen = length;
   }
-} // class DatagramPacket
-
+}
Index: kaffe/libraries/javalib/java/util/Calendar.java
diff -u kaffe/libraries/javalib/java/util/Calendar.java:1.16 kaffe/libraries/javalib/java/util/Calendar.java:1.17
--- kaffe/libraries/javalib/java/util/Calendar.java:1.16	Wed Oct 22 10:35:00 2003
+++ kaffe/libraries/javalib/java/util/Calendar.java	Mon Dec 29 11:15:17 2003
@@ -37,8 +37,12 @@
 
 
 package java.util;
+
 import java.lang.reflect.InvocationTargetException;
-import java.io.*;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.Serializable;
 
 /**
  * This class is an abstract base class for Calendars, which can be
Index: kaffe/libraries/javalib/java/util/GregorianCalendar.java
diff -u kaffe/libraries/javalib/java/util/GregorianCalendar.java:1.21 kaffe/libraries/javalib/java/util/GregorianCalendar.java:1.22
--- kaffe/libraries/javalib/java/util/GregorianCalendar.java:1.21	Wed Oct 22 10:35:00 2003
+++ kaffe/libraries/javalib/java/util/GregorianCalendar.java	Mon Dec 29 11:15:17 2003
@@ -1,5 +1,5 @@
 /* java.util.GregorianCalendar
-   Copyright (C) 1998, 1999, 2001, 2002 Free Software Foundation, Inc.
+   Copyright (C) 1998, 1999, 2001, 2002, 2003 Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
 
@@ -265,8 +265,7 @@
 	// The additional leap year factor accounts for the fact that
 	// a leap day is not seen on Jan 1 of the leap year.
 	// And on and after the leap day, the leap day has already been
-	// included in dayOfYear.
-
+	// included in dayOfYear. 
 	int gregOffset = (year / 400) - (year / 100) + 2;
 	if (isLeapYear (year, true))
 	  --gregOffset;
@@ -404,7 +403,7 @@
 	hour = fields[HOUR];
         if (isSet[AM_PM] && fields[AM_PM] == PM)
 	  if (hour != 12) /* not Noon */
-	    hour += 12;
+            hour += 12;
 	/* Fix the problem of the status of 12:00 AM (midnight). */
 	if (isSet[AM_PM] && fields[AM_PM] == AM && hour == 12)
 	  hour = 0;
Index: kaffe/libraries/javalib/java/util/IdentityHashMap.java
diff -u kaffe/libraries/javalib/java/util/IdentityHashMap.java:1.1 kaffe/libraries/javalib/java/util/IdentityHashMap.java:1.2
--- kaffe/libraries/javalib/java/util/IdentityHashMap.java:1.1	Tue Aug 12 23:02:19 2003
+++ kaffe/libraries/javalib/java/util/IdentityHashMap.java	Mon Dec 29 11:15:17 2003
@@ -38,7 +38,10 @@
 
 package java.util;
 
-import java.io.*;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.Serializable;
 
 /**
  * This class provides a hashtable-backed implementation of the
Index: kaffe/libraries/javalib/java/util/SimpleTimeZone.java
diff -u kaffe/libraries/javalib/java/util/SimpleTimeZone.java:1.12 kaffe/libraries/javalib/java/util/SimpleTimeZone.java:1.13
--- kaffe/libraries/javalib/java/util/SimpleTimeZone.java:1.12	Sat Aug 16 11:03:48 2003
+++ kaffe/libraries/javalib/java/util/SimpleTimeZone.java	Mon Dec 29 11:15:17 2003
@@ -1,5 +1,5 @@
 /* java.util.SimpleTimeZone
-   Copyright (C) 1998, 1999, 2000 Free Software Foundation, Inc.
+   Copyright (C) 1998, 1999, 2000, 2003 Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
 
@@ -390,7 +390,8 @@
    * @param dayOfWeek The day of week where daylight savings start.
    * @param time The time in milliseconds standard time where daylight
    * savings start.
-   * @see SimpleTimeZone */
+   * @see SimpleTimeZone
+   */
   public void setStartRule(int month, int day, int dayOfWeek, int time)
   {
     this.startMode = checkRule(month, day, dayOfWeek);
@@ -411,11 +412,12 @@
    *
    * @param rawOffset The time offset from GMT.
    * @param id  The identifier of this time zone.
-   * @param Month The end month of daylight savings.
+   * @param month The end month of daylight savings.
    * @param day A day in month, or a day of week in month.
-   * @param DayOfWeek A day of week, when daylight savings ends.
-   * @param Time A time in millis in standard time.
-   * @see #setStartRule */
+   * @param dayOfWeek A day of week, when daylight savings ends.
+   * @param time A time in millis in standard time.
+   * @see #setStartRule
+   */
   public void setEndRule(int month, int day, int dayOfWeek, int time)
   {
     this.endMode = checkRule(month, day, dayOfWeek);
@@ -509,11 +511,27 @@
    * is one hour, but for some time zones this may be half an our.
    * @return the daylight savings offset in milliseconds.
    * 
-   * @since JDK1.2
+   * @since 1.2
    */
   public int getDSTSavings()
   {
     return dstSavings;
+  }
+
+  /**
+   * Sets the daylight savings offset.  This is a positive offset in
+   * milliseconds with respect to standard time.
+   *
+   * @param dstSavings the daylight savings offset in milliseconds.
+   *
+   * @since 1.2
+   */
+  public void setDSTSavings(int dstSavings)
+  {
+    if (dstSavings <= 0)
+      throw new IllegalArgumentException("illegal value for dstSavings");
+    
+    this.dstSavings = dstSavings;
   }
 
   /**
Index: kaffe/libraries/javalib/java/util/TimeZone.java
diff -u kaffe/libraries/javalib/java/util/TimeZone.java:1.15 kaffe/libraries/javalib/java/util/TimeZone.java:1.16
--- kaffe/libraries/javalib/java/util/TimeZone.java:1.15	Sat Aug 16 11:03:48 2003
+++ kaffe/libraries/javalib/java/util/TimeZone.java	Mon Dec 29 11:15:17 2003
@@ -1,5 +1,6 @@
 /* java.util.TimeZone
-   Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
+   Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003
+   Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
 
@@ -809,6 +810,21 @@
   public abstract int getOffset(int era, int year, int month,
 				int day, int dayOfWeek, int milliseconds);
 
+  /**
+   * Get the time zone offset for the specified date, modified in case of
+   * daylight savings.  This is the offset to add to UTC to get the local
+   * time.
+   * @param date the date represented in millisecends
+   * since January 1, 1970 00:00:00 GMT.
+   * @since 1.4
+   */
+  public int getOffset(long date)
+  {
+    return (inDaylightTime(new Date(date))
+            ? getRawOffset() + getDSTSavings()
+            : getRawOffset());
+  }
+  
   /**
    * Gets the time zone offset, ignoring daylight savings.  This is
    * the offset to add to UTC to get the local time.