various patches

Aaron Place beavis at ihug.co.nz
Mon Mar 22 01:57:00 PST 1999


Some patches against the latest cvs.

* libraries/javalib/java/io/BufferedReader.java,File.java,
FileInputStream.java,FileOutputStream.java,PipedInputStream.java,
PrintStream.java,WriteAbortedException.java,
libraries/javalib/java/net/ContentHandler.java, URL.java: changed
access modifiers, checked exceptions and implemented interfaces.

* libraries/javalib/java/io/OptionalDataException.java: added private
constructor.

* libraries/javalib/java/net/HttpURLConnection.java: fixed method name
setRequestMethod(String).

* libraries/javalib/java/net/Socket.java: add headers for JDK1.2
constructors.

* libraries/javalib/java/net/URLConnection.java,
libraries/javalib/kaffe/net/www/protocol/BasicURLConnection.java,
http/HttpURLConnection.java: fileNameMap is private as of JDK1.1.6.
streamMap should be private.

* libraries/javalib/java/text/ChoiceFormat.java: implement toPattern(),
parse(). Fix nextDouble(double), previousDouble(double),
format(double,StringBuffer,FieldPosition) ,applyPattern(String).

Aaron.

-------------- next part --------------
diff -ur kaffe-orig/libraries/javalib/java/io/BufferedReader.java kaffe-work/libraries/javalib/java/io/BufferedReader.java
--- kaffe-orig/libraries/javalib/java/io/BufferedReader.java	Thu Dec 10 12:20:09 1998
+++ kaffe-work/libraries/javalib/java/io/BufferedReader.java	Mon Mar 15 16:36:23 1999
@@ -59,7 +59,8 @@
 	return (true);
 }
 
-protected void pushback() {
+//Used in java.io.BufferedLineReader
+void pushback() {
 	pos--;
 }
 
diff -ur kaffe-orig/libraries/javalib/java/io/File.java kaffe-work/libraries/javalib/java/io/File.java
--- kaffe-orig/libraries/javalib/java/io/File.java	Thu Feb 11 11:52:26 1999
+++ kaffe-work/libraries/javalib/java/io/File.java	Fri Mar 12 14:15:04 1999
@@ -1,5 +1,6 @@
 package java.io;
 
+import java.io.Serializable;
 import java.lang.String;
 import java.util.Vector;
 
@@ -12,7 +13,7 @@
  * See the file "license.terms" for information on usage and redistribution
  * of this file.
  */
-public class File
+public class File implements Serializable
 {
 	final public static String separator = System.getProperty("file.separator");
 	final public static char separatorChar = separator.charAt(0);
diff -ur kaffe-orig/libraries/javalib/java/io/FileInputStream.java kaffe-work/libraries/javalib/java/io/FileInputStream.java
--- kaffe-orig/libraries/javalib/java/io/FileInputStream.java	Thu Dec 10 12:20:10 1998
+++ kaffe-work/libraries/javalib/java/io/FileInputStream.java	Mon Mar 15 16:46:17 1999
@@ -47,9 +47,14 @@
 
 native public void close() throws IOException;
 
-protected void finalize() throws Throwable {
+protected void finalize() throws IOException {
 	close();
-	super.finalize();
+	try {
+	    super.finalize();
+	}
+	catch(Throwable e){
+	    throw new IOException(e.getMessage());
+	}
 }
 
 final public FileDescriptor getFD() throws IOException {
diff -ur kaffe-orig/libraries/javalib/java/io/FileOutputStream.java kaffe-work/libraries/javalib/java/io/FileOutputStream.java
--- kaffe-orig/libraries/javalib/java/io/FileOutputStream.java	Thu Dec 10 12:20:11 1998
+++ kaffe-work/libraries/javalib/java/io/FileOutputStream.java	Mon Mar 15 16:46:49 1999
@@ -50,10 +50,15 @@
 
 native public void close() throws IOException;
 
-protected void finalize() throws Throwable
+protected void finalize() throws IOException
 {
 	close();
-	super.finalize();
+	try {
+	    super.finalize();
+	}
+	catch(Throwable e){
+	    throw new IOException(e.getMessage());
+	}
 }
 
 final public FileDescriptor getFD()  throws IOException
diff -ur kaffe-orig/libraries/javalib/java/io/OptionalDataException.java kaffe-work/libraries/javalib/java/io/OptionalDataException.java
--- kaffe-orig/libraries/javalib/java/io/OptionalDataException.java	Wed Jul 15 05:02:05 1998
+++ kaffe-work/libraries/javalib/java/io/OptionalDataException.java	Fri Mar 12 15:11:16 1999
@@ -16,4 +16,5 @@
 	public int length;
 	public boolean eof;
 
+        private OptionalDataException() {}
 }
diff -ur kaffe-orig/libraries/javalib/java/io/PipedInputStream.java kaffe-work/libraries/javalib/java/io/PipedInputStream.java
--- kaffe-orig/libraries/javalib/java/io/PipedInputStream.java	Thu Sep  3 11:39:21 1998
+++ kaffe-work/libraries/javalib/java/io/PipedInputStream.java	Mon Mar 15 16:49:12 1999
@@ -70,7 +70,7 @@
 	return super.read(b, off, len);
 }
 
-protected synchronized void receive(int b) {
+protected synchronized void receive(int b) throws IOException {
 	while (out == in+1) {
 		try {
 			this.wait();
@@ -83,7 +83,8 @@
 	this.notifyAll();
 }
 
-protected void receivedLast() {
+//Used in java.io.PipedOutputStream
+void receivedLast() {
 	closed = true;
 }
 }
diff -ur kaffe-orig/libraries/javalib/java/io/PrintStream.java kaffe-work/libraries/javalib/java/io/PrintStream.java
--- kaffe-orig/libraries/javalib/java/io/PrintStream.java	Tue Mar  9 12:42:40 1999
+++ kaffe-work/libraries/javalib/java/io/PrintStream.java	Fri Mar 12 15:23:18 1999
@@ -30,7 +30,7 @@
 	return error;
 }
 
-public void setError()
+protected void setError()
 {
 	error = true;
 }
diff -ur kaffe-orig/libraries/javalib/java/io/WriteAbortedException.java kaffe-work/libraries/javalib/java/io/WriteAbortedException.java
--- kaffe-orig/libraries/javalib/java/io/WriteAbortedException.java	Thu Dec 10 12:20:14 1998
+++ kaffe-work/libraries/javalib/java/io/WriteAbortedException.java	Fri Mar 12 15:30:01 1999
@@ -11,7 +11,7 @@
  * See the file "license.terms" for information on usage and redistribution
  * of this file.
  */
-class WriteAbortedException
+public class WriteAbortedException
   extends ObjectStreamException
 {
 	public Exception detail;
diff -ur kaffe-orig/libraries/javalib/java/net/ContentHandler.java kaffe-work/libraries/javalib/java/net/ContentHandler.java
--- kaffe-orig/libraries/javalib/java/net/ContentHandler.java	Wed Jul 15 04:47:36 1998
+++ kaffe-work/libraries/javalib/java/net/ContentHandler.java	Fri Mar 12 15:34:46 1999
@@ -1,5 +1,6 @@
 package java.net;
 
+import java.io.IOException;
 
 /*
  * Java core library component.
@@ -15,5 +16,5 @@
 {
 public ContentHandler() {}
 
-abstract public Object getContent(URLConnection urlc);
+abstract public Object getContent(URLConnection urlc) throws IOException;
 }
diff -ur kaffe-orig/libraries/javalib/java/net/HttpURLConnection.java kaffe-work/libraries/javalib/java/net/HttpURLConnection.java
--- kaffe-orig/libraries/javalib/java/net/HttpURLConnection.java	Thu Feb 11 10:34:47 1999
+++ kaffe-work/libraries/javalib/java/net/HttpURLConnection.java	Fri Mar 12 15:41:22 1999
@@ -86,7 +86,7 @@
         return responseMessage;
 }
 
-public void setRequestMessage (String message) throws ProtocolException {
+public void setRequestMethod (String message) throws ProtocolException {
 	if (!message.equals("DELETE") &&
 	    !message.equals("GET") &&
 	    !message.equals("HEAD") &&
diff -ur kaffe-orig/libraries/javalib/java/net/Socket.java kaffe-work/libraries/javalib/java/net/Socket.java
--- kaffe-orig/libraries/javalib/java/net/Socket.java	Thu Mar 11 16:59:25 1999
+++ kaffe-work/libraries/javalib/java/net/Socket.java	Fri Mar 12 16:07:45 1999
@@ -31,6 +31,14 @@
 	this(InetAddress.getByName(host), port, true);
 }
 
+public Socket(InetAddress address, int port, InetAddress localAddr, int localPort) throws IOException {
+    throw new kaffe.util.NotImplemented();
+}
+    
+public Socket(String host, int port, InetAddress localAddr, int localPort) throws IOException {
+    throw new kaffe.util.NotImplemented();
+}
+
 /**
  * @deprecated.
  */
diff -ur kaffe-orig/libraries/javalib/java/net/URL.java kaffe-work/libraries/javalib/java/net/URL.java
--- kaffe-orig/libraries/javalib/java/net/URL.java	Wed Feb 10 21:44:18 1999
+++ kaffe-work/libraries/javalib/java/net/URL.java	Fri Mar 12 16:15:33 1999
@@ -207,7 +207,7 @@
 	return (conn);
 }
 
-public InputStream openStream() throws IOException {
+public final InputStream openStream() throws IOException {
 	if (conn == null) {
 		openConnection();
 	}
diff -ur kaffe-orig/libraries/javalib/java/net/URLConnection.java kaffe-work/libraries/javalib/java/net/URLConnection.java
--- kaffe-orig/libraries/javalib/java/net/URLConnection.java	Thu Feb 11 11:52:30 1999
+++ kaffe-work/libraries/javalib/java/net/URLConnection.java	Sat Mar 13 11:33:59 1999
@@ -21,8 +21,8 @@
 
 abstract public class URLConnection
 {
-	public static FileNameMap fileNameMap = new DefaultFileNameMap();
-	public static StreamMap streamMap = new DefaultStreamMap();
+	private static FileNameMap fileNameMap = new DefaultFileNameMap();
+	private static StreamMap streamMap = new DefaultStreamMap();
 
 	protected boolean allowUserInteraction = defaultAllowUserInteraction;
 	protected boolean connected = false;
@@ -90,6 +90,10 @@
 	return getHeaderFieldDate("expiration", -1);
 }
 
+public static FileNameMap getFileNameMap() {
+	return (fileNameMap);
+}
+    
 public String getHeaderField(String name) {
 	return (null);
 }
@@ -198,6 +202,10 @@
 	doOutput = dooutput;
 }
 
+public static void setFileNameMap(FileNameMap filenameMap) {
+        fileNameMap = filenameMap;
+}
+    
 public void setIfModifiedSince(long ifmodifiedsince) {
 	ifModifiedSince = ifmodifiedsince;
 }
diff -ur kaffe-orig/libraries/javalib/java/text/ChoiceFormat.java kaffe-work/libraries/javalib/java/text/ChoiceFormat.java
--- kaffe-orig/libraries/javalib/java/text/ChoiceFormat.java	Thu Dec 10 12:20:27 1998
+++ kaffe-work/libraries/javalib/java/text/ChoiceFormat.java	Mon Mar 22 21:23:43 1999
@@ -11,13 +11,15 @@
 package java.text;
 
 import java.lang.String;
-import kaffe.util.NotImplemented;
+import java.util.Hashtable;
 
 public class ChoiceFormat extends NumberFormat {
 
 private double[] limits;
 private String[] strings;
-
+private String pattern = null;
+private Hashtable patternNames = null;
+    
 public ChoiceFormat(String patt) {
 	applyPattern(patt);
 }
@@ -29,43 +31,41 @@
 public void applyPattern(String patt) {
 	int len = patt.length();
 	int argcount = 0;
+
 	for (int i = 0; i < len; i++) {
-		if (patt.charAt(i) == '|') {
-			argcount++;
-		}
-		// We need to add an extra 'phantom' argument for '<'
-		else if (patt.charAt(i) == '<') {
+	        if (patt.charAt(i) == '|') {
 			argcount++;
 		}
 	}
-	limits = new double[argcount];
-	strings = new String[argcount];
+	limits = new double[argcount+1];
+	strings = new String[argcount+1];
 
 	int s = 0;
 	int c = 0;
-	boolean needphantom = false;
+	StringBuffer str = new StringBuffer();
+
 	for (int i = 0; i < len; i++) {
 		char ch = patt.charAt(i);
 		if (ch == '#') {
 			limits[c] = Double.valueOf(patt.substring(s, i)).doubleValue();
-			s = c+1;
+			str.append(limits[c]+"#");
+			s = i+1;
 		}
 		else if (ch == '<') {
-			needphantom = true;
-			limits[c] = Double.valueOf(patt.substring(s, i)).doubleValue();
-			s = c+1;
+			limits[c] = nextDouble(Double.valueOf(patt.substring(s, i)).doubleValue());
+			str.append(Double.valueOf(patt.substring(s, i)).doubleValue()+"<");
+			s = i+1;
 		}
 		else if (ch == '|') {
 			strings[c] = patt.substring(s, i);
+			str.append(strings[c]+"|");
 			c++;
-			if (needphantom) {
-				needphantom = false;
-				limits[c] = nextDouble(limits[c-1]);
-				strings[c] = strings[c-1];
-				c++;
-			}
+			s = i+1;
 		}
 	}
+	strings[c] = patt.substring(s, len);
+	str.append(strings[c]);
+	pattern = new String(str);
 }
 
 public Object clone() {
@@ -92,7 +92,7 @@
 }
 
 public StringBuffer format(double num, StringBuffer buf, FieldPosition ign) {
-	if (num < limits[0]) {
+        if (num < limits[0] || Double.isNaN(num)) {
 		buf.append(strings[0]);
 		return (buf);
 	}
@@ -122,11 +122,33 @@
 }
 
 public final static double nextDouble(double d) {
-	return (d + Double.MIN_VALUE);
+        if(Double.isNaN(d))
+	        return (d);
+	else if(Double.POSITIVE_INFINITY == d)
+	        return (d);
+	else if(-0.0d == d)
+	        return (Double.longBitsToDouble(0x1L));
+
+	long l = Double.doubleToLongBits(d);
+	if(d < 0.0d)
+	        return(Double.longBitsToDouble(l-1));
+	else
+	        return(Double.longBitsToDouble(l+1));
 }
 
 public final static double previousDouble(double d) {
-	return (d - Double.MIN_VALUE);
+        if(Double.isNaN(d))
+	        return (d);
+	else if(Double.NEGATIVE_INFINITY == d)
+	        return (d);
+	else if(0.0d == d)
+	        return (Double.longBitsToDouble(0x8000000000000001L));
+
+	long l = Double.doubleToLongBits(d);
+	if(d > 0.0d)
+	        return(Double.longBitsToDouble(l-1));
+	else
+	        return(Double.longBitsToDouble(l+1));
 }
 
 public static double nextDouble(double d, boolean next) {
@@ -139,7 +161,26 @@
 }
 
 public Number parse(String str, ParsePosition pos) {
-	throw new NotImplemented();
+        int startIndex = pos.getIndex();
+	int stopIndex = startIndex+1;
+	
+	if(patternNames == null){
+	        patternNames = new Hashtable();
+		for(int i=0;i<limits.length;i++)
+		    patternNames.put(strings[i],new Double(limits[i]));
+	}
+
+	Double number;
+	while(stopIndex < str.length()){
+	    number = (Double)patternNames.get(str.substring(startIndex,stopIndex));
+	    if(number == null)
+		stopIndex++;
+	    else {
+		pos.setIndex(stopIndex);
+		return (number);
+	    }
+	}
+	return new Double(Double.NaN);
 }
 
 public void setChoices(double[] limits, String[] strings) {
@@ -148,7 +189,20 @@
 }
 
 public String toPattern() {
-	throw new NotImplemented();
+	if(limits.length == 0)
+	    return ("");
+
+        if(pattern == null){
+	    StringBuffer str = new StringBuffer();
+	    
+	    for(int i=0;i<limits.length;i++){
+		str.append(limits[i]+"#"+strings[i]);
+		if(i < limits.length-1)
+		    str.append("|");
+		pattern = new String(str);
+	    }
+	}
+	return (pattern);
 }
 
 }
diff -ur kaffe-orig/libraries/javalib/kaffe/net/www/protocol/BasicURLConnection.java kaffe-work/libraries/javalib/kaffe/net/www/protocol/BasicURLConnection.java
--- kaffe-orig/libraries/javalib/kaffe/net/www/protocol/BasicURLConnection.java	Thu Feb 11 10:34:56 1999
+++ kaffe-work/libraries/javalib/kaffe/net/www/protocol/BasicURLConnection.java	Sat Mar 13 00:02:11 1999
@@ -93,7 +93,7 @@
 }
 
 protected void setContentTypeFromName() {
-	String ct = fileNameMap.getContentTypeFor( url.getFile());
+	String ct = getFileNameMap().getContentTypeFor( url.getFile());
 	headersValue[ContentType] = ct;
 	headersValue[ContentEncoding] = ct;
 }
diff -ur kaffe-orig/libraries/javalib/kaffe/net/www/protocol/http/HttpURLConnection.java kaffe-work/libraries/javalib/kaffe/net/www/protocol/http/HttpURLConnection.java
--- kaffe-orig/libraries/javalib/kaffe/net/www/protocol/http/HttpURLConnection.java	Thu Feb 11 10:34:58 1999
+++ kaffe-work/libraries/javalib/kaffe/net/www/protocol/http/HttpURLConnection.java	Fri Mar 12 23:54:28 1999
@@ -156,7 +156,7 @@
 }
 
 protected void setContentTypeFromName() {
-	String ct = fileNameMap.getContentTypeFor( url.getFile());
+	String ct = getFileNameMap().getContentTypeFor( url.getFile());
 	headersValue[ContentType] = ct;
 	headersValue[ContentEncoding] = ct;
 }


More information about the kaffe mailing list