aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Tromey <tromey@cygnus.com>2000-11-17 20:44:03 +0000
committerTom Tromey <tromey@gcc.gnu.org>2000-11-17 20:44:03 +0000
commit4cdfd292e374089da707399dd3a06ae18f19a094 (patch)
tree0ca710082c0fee778050b7a6372e10201f7c22aa
parent6414587c8b13a4a0a45788f411c9fe5fd87466ce (diff)
downloadgcc-4cdfd292e374089da707399dd3a06ae18f19a094.zip
gcc-4cdfd292e374089da707399dd3a06ae18f19a094.tar.gz
gcc-4cdfd292e374089da707399dd3a06ae18f19a094.tar.bz2
CollationKey.java: Implement Comparable.
* java/text/CollationKey.java: Implement Comparable. (compareTo(Object)): New method. * java/text/Collator.java (compare(Object,Object)): New method. Implement Comparator. * java/util/zip/InflaterInputStream.java (available): New method. (close): New method. (read, available, skip, fill): Throw exception if stream closed. * java/util/zip/ZipInputStream.java (read, skip, readFully, fill, getNextEntry): Throw exception if closed. From-SVN: r37525
-rw-r--r--libjava/ChangeLog29
-rw-r--r--libjava/java/text/CollationKey.java9
-rw-r--r--libjava/java/text/Collator.java8
-rw-r--r--libjava/java/util/zip/InflaterInputStream.java24
-rw-r--r--libjava/java/util/zip/ZipInputStream.java18
5 files changed, 78 insertions, 10 deletions
diff --git a/libjava/ChangeLog b/libjava/ChangeLog
index 95df808..bf5b81a 100644
--- a/libjava/ChangeLog
+++ b/libjava/ChangeLog
@@ -1,3 +1,32 @@
+2000-11-17 Tom Tromey <tromey@cygnus.com>
+
+ * java/text/CollationKey.java: Implement Comparable.
+ (compareTo(Object)): New method.
+ * java/text/Collator.java (compare(Object,Object)): New method.
+ Implement Comparator.
+
+ * java/util/zip/InflaterInputStream.java (available): New method.
+ (close): New method.
+ (read, available, skip, fill): Throw exception if stream closed.
+ * java/util/zip/ZipInputStream.java (read, skip, readFully, fill,
+ getNextEntry): Throw exception if closed.
+
+2000-11-16 Tom Tromey <tromey@cygnus.com>
+
+ * java/io/PushbackReader.java: Merged with Classpath.
+ * java/util/Arrays.java: Updated from Classpath.
+
+ * scripts/blocks.pl: New file.
+ * java/lang/Character.java (Subset): New class.
+ (UnicodeBlock): New class.
+
+ * java/lang/Math.java (toDegrees, toRadians): New methods.
+
+ * java/lang/Float.java: Implement Comparable.
+ (compareTo): New methods.
+ * java/lang/Double.java: Implement Comparable.
+ (compareTo): New methods.
+
2000-11-16 Warren Levy <warrenl@cygnus.com>
* java/beans/PropertyChangeSupport.java (propertyListeners): Made
diff --git a/libjava/java/text/CollationKey.java b/libjava/java/text/CollationKey.java
index 725b66a..966c64d 100644
--- a/libjava/java/text/CollationKey.java
+++ b/libjava/java/text/CollationKey.java
@@ -1,6 +1,6 @@
// CollationKey.java - Sort key for locale-sensitive String.
-/* Copyright (C) 1999 Free Software Foundation
+/* Copyright (C) 1999, 2000 Free Software Foundation
This file is part of libgcj.
@@ -19,7 +19,7 @@ package java.text;
* Status: Believed complete and correct.
*/
-public final class CollationKey
+public final class CollationKey implements Comparable
{
public int compareTo (CollationKey target)
{
@@ -34,6 +34,11 @@ public final class CollationKey
return key.length - target.key.length;
}
+ public int compareTo (Object o)
+ {
+ return compareTo ((CollationKey) o);
+ }
+
public boolean equals (Object obj)
{
if (! (obj instanceof CollationKey))
diff --git a/libjava/java/text/Collator.java b/libjava/java/text/Collator.java
index 4280ea2..60da531 100644
--- a/libjava/java/text/Collator.java
+++ b/libjava/java/text/Collator.java
@@ -13,6 +13,7 @@ package java.text;
import java.util.Locale;
import java.util.MissingResourceException;
import java.util.ResourceBundle;
+import java.util.Comparator;
/**
* @author Tom Tromey <tromey@cygnus.com>
@@ -23,7 +24,7 @@ import java.util.ResourceBundle;
* Status: Mostly complete, but parts stubbed out. Look for FIXME.
*/
-public abstract class Collator implements Cloneable
+public abstract class Collator implements Comparator, Cloneable
{
public static final int NO_DECOMPOSITION = 0;
public static final int CANONICAL_DECOMPOSITION = 1;
@@ -42,6 +43,11 @@ public abstract class Collator implements Cloneable
public abstract int compare (String source, String target);
+ public int compare (Object o1, Object o2)
+ {
+ return compare ((String) o1, (String) o2);
+ }
+
public boolean equals (Object obj)
{
if (! (obj instanceof Collator))
diff --git a/libjava/java/util/zip/InflaterInputStream.java b/libjava/java/util/zip/InflaterInputStream.java
index e09f208..3db1b2a 100644
--- a/libjava/java/util/zip/InflaterInputStream.java
+++ b/libjava/java/util/zip/InflaterInputStream.java
@@ -1,6 +1,6 @@
// InflaterInputStream.java - Input stream filter for decompressing.
-/* Copyright (C) 1999 Free Software Foundation
+/* Copyright (C) 1999, 2000 Free Software Foundation
This file is part of libgcj.
@@ -28,6 +28,8 @@ public class InflaterInputStream extends FilterInputStream
{
protected void fill () throws IOException
{
+ if (inf == null)
+ throw new IOException ("stream closed");
len = in.read(buf, 0, buf.length);
if (len != -1)
inf.setInput(buf, 0, len);
@@ -61,6 +63,8 @@ public class InflaterInputStream extends FilterInputStream
public int read (byte[] buf, int off, int len) throws IOException
{
+ if (inf == null)
+ throw new IOException ("stream closed");
if (inf.finished())
return -1;
if (inf.needsInput())
@@ -79,8 +83,26 @@ public class InflaterInputStream extends FilterInputStream
}
}
+ public void close () throws IOException
+ {
+ inf = null;
+ super.close ();
+ }
+
+ public int available () throws IOException
+ {
+ // According to the JDK 1.2 docs, this should only ever return 0
+ // or 1 and should not be relied upon by Java programs.
+ if (inf == null)
+ throw new IOException ("stream closed");
+ return inf.finished () ? 0 : 1;
+ }
+
public long skip (long n) throws IOException
{
+ if (inf == null)
+ throw new IOException ("stream closed");
+
if (n == 0)
return 0;
diff --git a/libjava/java/util/zip/ZipInputStream.java b/libjava/java/util/zip/ZipInputStream.java
index 79efb59..b50cc7b 100644
--- a/libjava/java/util/zip/ZipInputStream.java
+++ b/libjava/java/util/zip/ZipInputStream.java
@@ -35,6 +35,8 @@ public class ZipInputStream extends InflaterInputStream implements ZipConstants
public ZipEntry getNextEntry () throws IOException
{
+ if (closed)
+ throw new IOException ("stream closed");
if (current != null)
closeEntry();
if (in.read() != 'P'
@@ -112,6 +114,8 @@ public class ZipInputStream extends InflaterInputStream implements ZipConstants
// back data.
protected void fill () throws IOException
{
+ if (closed)
+ throw new IOException ("stream closed");
int count = buf.length;
if (count > compressed_bytes)
count = compressed_bytes;
@@ -127,9 +131,11 @@ public class ZipInputStream extends InflaterInputStream implements ZipConstants
{
return new ZipEntry (name);
}
-
+
public int read (byte[] b, int off, int len) throws IOException
{
+ if (closed)
+ throw new IOException ("stream closed");
if (len > avail)
len = avail;
int count;
@@ -149,6 +155,8 @@ public class ZipInputStream extends InflaterInputStream implements ZipConstants
public long skip (long n) throws IOException
{
+ if (closed)
+ throw new IOException ("stream closed");
if (n > avail)
n = avail;
long count;
@@ -160,11 +168,9 @@ public class ZipInputStream extends InflaterInputStream implements ZipConstants
return count;
}
- public int available() {
- if (closed)
- return 0;
- else
- return 1;
+ public int available()
+ {
+ return closed ? 0 : 1;
}
private void readFully (byte[] b) throws IOException