From 43a2cb7cc5a3dbaa4093d2a337e859bb36171502 Mon Sep 17 00:00:00 2001 From: Eric Scharff Date: Fri, 28 Sep 2007 11:38:58 -0600 Subject: [PATCH] Tie up some loose ends, implementing methods that are useful but not yet implemented. --- classpath/java/lang/Math.java | 5 +---- classpath/java/util/Calendar.java | 2 +- classpath/java/util/Properties.java | 12 +++++++++++- classpath/java/util/zip/Inflater.java | 9 +++++++-- 4 files changed, 20 insertions(+), 8 deletions(-) diff --git a/classpath/java/lang/Math.java b/classpath/java/lang/Math.java index 2d3f2bbad4..9ad1f139ed 100644 --- a/classpath/java/lang/Math.java +++ b/classpath/java/lang/Math.java @@ -62,10 +62,7 @@ public final class Math { return (int) Math.floor(v + 0.5); } - public static double random() { - // TODO - throw new UnsupportedOperationException(); - } + public static native double random(); public static native double floor(double v); diff --git a/classpath/java/util/Calendar.java b/classpath/java/util/Calendar.java index a57bf03066..640b7a237a 100644 --- a/classpath/java/util/Calendar.java +++ b/classpath/java/util/Calendar.java @@ -35,7 +35,7 @@ public abstract class Calendar { } public void setTime(Date date) { - // TODO + time = date.getTime(); } public abstract void roll(int field, boolean up); diff --git a/classpath/java/util/Properties.java b/classpath/java/util/Properties.java index 41a37bc303..8a9fe5892f 100644 --- a/classpath/java/util/Properties.java +++ b/classpath/java/util/Properties.java @@ -2,6 +2,7 @@ package java.util; import java.io.InputStream; import java.io.OutputStream; +import java.io.PrintStream; import java.io.IOException; public class Properties extends Hashtable { @@ -10,7 +11,16 @@ public class Properties extends Hashtable { } public void store(OutputStream out, String comment) throws IOException { - // TODO + PrintStream os = new PrintStream(out); + os.println("# " + comment); + for (Iterator it = entrySet().iterator(); + it.hasNext();) { + Map.Entry entry = (Map.Entry)it.next(); + os.print(entry.getKey()); + os.print('='); + os.println(entry.getValue()); + } + os.flush(); } public String getProperty(String key) { diff --git a/classpath/java/util/zip/Inflater.java b/classpath/java/util/zip/Inflater.java index 4969f79637..ecb32b6320 100644 --- a/classpath/java/util/zip/Inflater.java +++ b/classpath/java/util/zip/Inflater.java @@ -15,8 +15,10 @@ public class Inflater { private int length; private boolean needDictionary; private boolean finished; + private final boolean nowrap; public Inflater(boolean nowrap) { + this.nowrap = nowrap; peer = make(nowrap); } @@ -55,8 +57,11 @@ public class Inflater { } public void reset() { - // TODO - throw new UnsupportedOperationException(); + dispose(); + peer = make(nowrap); + input = null; + offset = length = 0; + needDictionary = finished = false; } public int inflate(byte[] output) throws DataFormatException {