Updates of the class library for MGC
authorjzhou <jzhou>
Fri, 18 Feb 2011 01:32:38 +0000 (01:32 +0000)
committerjzhou <jzhou>
Fri, 18 Feb 2011 01:32:38 +0000 (01:32 +0000)
33 files changed:
Robust/src/ClassLibrary/File.java
Robust/src/ClassLibrary/HashSet.java
Robust/src/ClassLibrary/MGC/Object.java
Robust/src/ClassLibrary/MGC/ServerSocket.java [new file with mode: 0644]
Robust/src/ClassLibrary/MGC/Set.java
Robust/src/ClassLibrary/MGC/Socket.java [new file with mode: 0644]
Robust/src/ClassLibrary/MGC/System.java
Robust/src/ClassLibrary/MGC/Thread.java
Robust/src/ClassLibrary/MGC/Vector.java
Robust/src/ClassLibrary/MGC/gnu/ArrayList.java
Robust/src/ClassLibrary/MGC/gnu/ArrayListIterator.java [new file with mode: 0644]
Robust/src/ClassLibrary/MGC/gnu/BigInteger.java
Robust/src/ClassLibrary/MGC/gnu/BufferedReader.java
Robust/src/ClassLibrary/MGC/gnu/Cloneable.java [new file with mode: 0644]
Robust/src/ClassLibrary/MGC/gnu/ConsoleHandler.java [new file with mode: 0644]
Robust/src/ClassLibrary/MGC/gnu/DecimalFormat.java
Robust/src/ClassLibrary/MGC/gnu/File.java [new file with mode: 0644]
Robust/src/ClassLibrary/MGC/gnu/FilenameFilter.java [new file with mode: 0644]
Robust/src/ClassLibrary/MGC/gnu/Handler.java
Robust/src/ClassLibrary/MGC/gnu/InputStreamReader.java [new file with mode: 0644]
Robust/src/ClassLibrary/MGC/gnu/Level.java
Robust/src/ClassLibrary/MGC/gnu/LogManager.java
Robust/src/ClassLibrary/MGC/gnu/Logger.java
Robust/src/ClassLibrary/MGC/gnu/PrintWriter.java
Robust/src/ClassLibrary/MGC/gnu/Properties.java
Robust/src/ClassLibrary/MGC/gnu/Short.java
Robust/src/ClassLibrary/MGC/gnu/Stack.java [new file with mode: 0644]
Robust/src/ClassLibrary/MGC/gnu/TreeMap.java
Robust/src/ClassLibrary/MGC/gnu/TreeMapIterator.java
Robust/src/ClassLibrary/MGC/gnu/TreeNode.java
Robust/src/ClassLibrary/MGC/gnu/TreeSubMap.java
Robust/src/ClassLibrary/String.java
Robust/src/ClassLibrary/StringBuffer.java

index a0de2367964bd3d7822567801ab60a405620fb2b..d4f0da39ef25f9e25ccfaf319e7fc8cafa9f98a3 100644 (file)
@@ -1,6 +1,9 @@
+import java.io.FileSystem;
+import java.io.FilenameFilter;
+import java.util.ArrayList;
+
 public class File {
   String path;
-  private static final char separator = '\n';
 
   public File(String path) {
     this.path=path;
index d3fe4fd59de6259100778f4cbed0b68c687a3f93..4145f63610e0d52bf0de6240f93961d153521ce3 100644 (file)
@@ -25,6 +25,6 @@ public class HashSet {
     return map.size();
   }
   public HashMapIterator iterator() {
-    return map.iterator(0);
+    return (HashMapIterator)map.iterator(0);
   }
 }
index 278d5c836e0fb67ff983fd45383d82412fbe7b9b..e94c34dc3b3244357f128163455cb66290835ca4 100644 (file)
@@ -35,5 +35,6 @@ public class Object {
   }
   
   public final native void notify();
+  public final native void notifyAll();
   public final native void wait();
 }
diff --git a/Robust/src/ClassLibrary/MGC/ServerSocket.java b/Robust/src/ClassLibrary/MGC/ServerSocket.java
new file mode 100644 (file)
index 0000000..1cf07f2
--- /dev/null
@@ -0,0 +1,28 @@
+public class ServerSocket {
+  /* File Descriptor */
+  int fd;
+
+  private native int createSocket(int port);
+
+  public ServerSocket(int port) {
+    this.fd=createSocket(port);
+  }
+
+  public Socket accept() {
+    Socket s=new Socket();
+    int newfd=nativeaccept(s);
+    s.setFD(newfd);
+    return s;
+  }
+
+  /* Lets caller pass in their own Socket object. */
+  public void accept(Socket s) {
+    int newfd=nativeaccept(s);
+    s.setFD(newfd);
+  }
+
+  private native int nativeaccept(Socket s);
+
+  public void close();
+
+}
index 8e59b91f9826b1f3c119a5f78927254fe4622fc5..577b0e81d534412892bc3fafeb21385d5ac4ff7b 100644 (file)
@@ -189,7 +189,7 @@ public interface Set//<E> extends Collection<E>
    * @throws NullPointerException if o is null and this set doesn't allow
    *         the removal of a null value.
    */
-  boolean remove(Object o);
+  //boolean remove(Object o);
 
   /**
    * Removes from this set all elements contained in the specified collection
diff --git a/Robust/src/ClassLibrary/MGC/Socket.java b/Robust/src/ClassLibrary/MGC/Socket.java
new file mode 100644 (file)
index 0000000..b4f54be
--- /dev/null
@@ -0,0 +1,83 @@
+public class Socket {
+  /* File Descriptor */
+  int fd;
+  SocketInputStream sin;
+  SocketOutputStream sout;
+
+  public Socket() {
+    sin=new SocketInputStream(this);
+    sout=new SocketOutputStream(this);
+  }
+
+  public InputStream getInputStream() {
+    return sin;
+  }
+
+  public OutputStream getOutputStream() {
+    return sout;
+  }
+
+  public Socket(String host, int port) {
+    InetAddress address=InetAddress.getByName(host);
+    fd=nativeBind(address.getAddress(), port);
+    nativeConnect(fd, address.getAddress(), port);
+    sin=new SocketInputStream(this);
+    sout=new SocketOutputStream(this);
+  }
+
+  public Socket(InetAddress address, int port) {
+    fd=nativeBind(address.getAddress(), port);
+    nativeConnect(fd, address.getAddress(), port);
+    sin=new SocketInputStream(this);
+    sout=new SocketOutputStream(this);
+  }
+
+       public int connect(String host, int port) {
+    InetAddress address=InetAddress.getByName(host);
+               if (address != null) {
+                       fd=nativeBind(address.getAddress(), port);
+                       nativeConnect(fd, address.getAddress(), port);
+                       return 0;
+               }
+               else {
+                       return -1;
+               }
+       }
+
+  public static native int nativeBind(byte[] address, int port);
+
+  public static native int nativeConnect(int fd, byte[] address, int port);
+
+  int setFD(int filed) {
+    fd=filed;
+  }
+
+  public int read(byte[] b) {
+    return nativeRead(b);
+  }
+  public int write(byte[] b) {
+    nativeWrite(b, 0, b.length);
+    if(fd==-1) {
+      System.out.println("here: " + "fd= " + fd);
+      return -1;
+    } else { 
+      return 0;
+    }
+  }
+
+  public int write(byte[] b, int offset, int len) {
+    nativeWrite(b, offset, len);
+    if(fd==-1)
+      return -1;
+    else 
+      return 0;
+  }
+
+  private native int nativeRead(byte[] b);
+  private native void nativeWrite(byte[] b, int offset, int len);
+  private native void nativeClose();
+
+  public void close() {
+    nativeClose();
+  }
+}
index 74a6c66f548a51ba6d7b87a91aa87b8e50f5a853..01d46c8149e7d7038a6359cf49808a1cddb17a08 100644 (file)
@@ -1,10 +1,9 @@
-import java.util.Properties;
-
 public class System {
-  PrintStream out;
+  public static PrintStream out = new PrintStream("System.out");
+  public static PrintStream err = new PrintStream("System.err");
+  public static InputStream in = new InputStream();
   
   public System() {
-    out = new PrintStream("System.out");
   }
   
   public static void printInt(int x) {
@@ -101,4 +100,26 @@ public class System {
   public static Properties getProperties() {
     return props;
   }
+  
+  public static String getProperty(String key) {
+    if(props != null) {
+      return (String)props.getProperty(key);
+    }
+    return "";
+  }
+  
+  public static String setProperty(String key, String value) {
+    if(props != null) {
+      return (String)props.setProperty(key, value);
+    }
+    return "";
+  }
+  
+  public static void setOut(PrintStream out) {
+    out = out;
+  }
+
+  public static void setErr(PrintStream err) {
+    err = err;
+  }
 }
index af67dbf7e8592b9670bec3a4126191a82c3ad60e..14ed23e539a67f83bc537b8ec92da028745b00e6 100644 (file)
@@ -37,5 +37,7 @@ public class Thread implements Runnable {
   }
 
   private native void nativeCreate();
+  
+  public final native boolean isAlive();
 
 }
index 5f506edf469550f02e0af76495e50b6cc9d97b83..738b78a68f4e643bfdc2f97acaae3e8b4c5e9721 100644 (file)
@@ -1,3 +1,5 @@
+import java.util.NoSuchElementException;
+
 public class Vector implements Set {
   Object[] array;
   int size;
@@ -40,10 +42,23 @@ public class Vector implements Set {
     return indexOf(e)!=-1;
   }
 
-  public void remove(Object o) {
+  /*public boolean remove(Object o) {
     int in=indexOf(o);
-    if (in!=-1)
+    if (in!=-1) {
       removeElementAt(in);
+      return true;
+    } else {
+      return false;
+    }
+  }*/
+  
+  public Object remove(int index) {
+    Object r = null;
+    if (index!=-1) {
+      r = array[index];
+      removeElementAt(index);
+    }
+    return r;
   }
 
   public Object elementAt(int index) {
@@ -154,4 +169,10 @@ public class Vector implements Set {
     array=sarray;
   }
   
+  public synchronized Object firstElement() {
+    if (size == 0) {
+      throw new /*NoSuchElement*/Exception("NoSuchElement");
+    }
+    return array[0];
+  }
 }
index 607a40cc3786e340331cd4cb93373fb524f9934f..08bb4c649899269fd2ed75183da1e570811cb37f 100644 (file)
@@ -612,4 +612,10 @@ public class ArrayList
     for (int i = 0; i < size; i++)
       data[i] = (E) s.readObject();
   }*/
+  
+  public ArrayListIterator iterator()
+  {
+    // Bah, Sun's implementation forbids using listIterator(0).
+    return new ArrayListIterator(this);
+  }
 }
diff --git a/Robust/src/ClassLibrary/MGC/gnu/ArrayListIterator.java b/Robust/src/ClassLibrary/MGC/gnu/ArrayListIterator.java
new file mode 100644 (file)
index 0000000..cb3b226
--- /dev/null
@@ -0,0 +1,64 @@
+public class ArrayListIterator extends Iterator {
+  private int pos;
+  private int size;
+  private int last;
+  private ArrayList list;
+
+  public ArrayListIterator(ArrayList list) {
+    this.list = list;
+    this.pos = 0;
+    this.size = this.list.size();
+    this.last = -1;
+  }
+
+  /**
+   * Tests to see if there are any more objects to
+   * return.
+   *
+   * @return True if the end of the list has not yet been
+   *         reached.
+   */
+  public boolean hasNext()
+  {
+    return pos < size;
+  }
+
+  /**
+   * Retrieves the next object from the list.
+   *
+   * @return The next object.
+   * @throws NoSuchElementException if there are
+   *         no more objects to retrieve.
+   * @throws ConcurrentModificationException if the
+   *         list has been modified elsewhere.
+   */
+  public Object next()
+  {
+    if (pos == size)
+      throw new /*NoSuchElement*/Exception("NoSuchElementException");
+    last = pos;
+    return this.list.get(pos++);
+  }
+
+  /**
+   * Removes the last object retrieved by <code>next()</code>
+   * from the list, if the list supports object removal.
+   *
+   * @throws ConcurrentModificationException if the list
+   *         has been modified elsewhere.
+   * @throws IllegalStateException if the iterator is positioned
+   *         before the start of the list or the last object has already
+   *         been removed.
+   * @throws UnsupportedOperationException if the list does
+   *         not support removing elements.
+   */
+  public void remove()
+  {
+    if (last < 0)
+      throw new /*IllegalState*/Exception("IllegalStateException");
+    this.list.remove(last);
+    pos--;
+    size--;
+    last = -1;
+  }
+}
\ No newline at end of file
index f9762df363b8ded174fa903ab3adafba05d0f8d5..c61d48954fc4b5736023863a13aedbe8ffa0b98c 100644 (file)
@@ -695,7 +695,7 @@ public class BigInteger //extends Number implements Comparable<BigInteger>
   private void set(BigInteger y)
   {
     if (y.words == null)
-      set(y.ival);
+      set((long)y.ival);
     else if (this != y)
       {
        realloc(y.ival);
index f91bc4c8d029675b9b25beb1813259995854de29..d4d162973e5269abbd21ae5c606ecf323b4bddda 100644 (file)
@@ -540,7 +540,7 @@ public class BufferedReader extends Reader
 
        if (count < avail)
          {
-           pos += count;
+           pos += (int)count;
            return count;
          }
 
diff --git a/Robust/src/ClassLibrary/MGC/gnu/Cloneable.java b/Robust/src/ClassLibrary/MGC/gnu/Cloneable.java
new file mode 100644 (file)
index 0000000..10f20ce
--- /dev/null
@@ -0,0 +1,78 @@
+/* Cloneable.java -- Interface for marking objects cloneable by Object.clone()
+   Copyright (C) 1998, 1999, 2001, 2002, 2005  Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.lang;
+
+/**
+ * This interface should be implemented by classes wishing to
+ * support of override <code>Object.clone()</code>.  The default
+ * behaviour of <code>clone()</code> performs a shallow copy, but
+ * subclasses often change this to perform a deep copy.  Therefore,
+ * it is a good idea to document how deep your clone will go.
+ * If <code>clone()</code> is called on an object which does not
+ * implement this interface, a <code>CloneNotSupportedException</code>
+ * will be thrown.
+ *
+ * <p>This interface is simply a tagging interface; it carries no
+ * requirements on methods to implement.  However, it is typical for
+ * a Cloneable class to implement at least <code>equals</code>,
+ * <code>hashCode</code>, and <code>clone</code>, sometimes
+ * increasing the accessibility of clone to be public. The typical
+ * implementation of <code>clone</code> invokes <code>super.clone()</code>
+ * rather than a constructor, but this is not a requirement.
+ *
+ * <p>If an object that implement Cloneable should not be cloned,
+ * simply override the <code>clone</code> method to throw a
+ * <code>CloneNotSupportedException</code>.
+ *
+ * <p>All array types implement Cloneable, and have a public
+ * <code>clone</code> method that will never fail with a
+ * <code>CloneNotSupportedException</code>.
+ *
+ * @author Paul Fisher
+ * @author Eric Blake (ebb9@email.byu.edu)
+ * @author Warren Levy (warrenl@cygnus.com)
+ * @see Object#clone()
+ * @see CloneNotSupportedException
+ * @since 1.0
+ * @status updated to 1.4
+ */
+public interface Cloneable
+{
+  // Tagging interface only.
+}
diff --git a/Robust/src/ClassLibrary/MGC/gnu/ConsoleHandler.java b/Robust/src/ClassLibrary/MGC/gnu/ConsoleHandler.java
new file mode 100644 (file)
index 0000000..d064c54
--- /dev/null
@@ -0,0 +1,127 @@
+/* ConsoleHandler.java -- a class for publishing log messages to System.err
+   Copyright (C) 2002, 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.util.logging;
+
+/**
+ * A <code>ConsoleHandler</code> publishes log records to
+ * <code>System.err</code>.
+ *
+ * <p><strong>Configuration:</strong> Values of the subsequent
+ * <code>LogManager</code> properties are taken into consideration
+ * when a <code>ConsoleHandler</code> is initialized.
+ * If a property is not defined, or if it has an invalid
+ * value, a default is taken without an exception being thrown.
+ *
+ * <ul>
+ *
+ * <li><code>java.util.logging.ConsoleHandler.level</code> - specifies
+ *     the initial severity level threshold. Default value:
+ *     <code>Level.INFO</code>.</li>
+ *
+ * <li><code>java.util.logging.ConsoleHandler.filter</code> - specifies
+ *     the name of a Filter class. Default value: No Filter.</li>
+ *
+ * <li><code>java.util.logging.ConsoleHandler.formatter</code> - specifies
+ *     the name of a Formatter class. Default value:
+ *     <code>java.util.logging.SimpleFormatter</code>.</li>
+ *
+ * <li><code>java.util.logging.ConsoleHandler.encoding</code> - specifies
+ *     the name of the character encoding. Default value:
+ *     the default platform encoding.</li>
+ *
+ * </ul>
+ *
+ * @author Sascha Brawer (brawer@acm.org)
+ */
+public class ConsoleHandler
+  extends StreamHandler
+{
+  /**
+   * Constructs a <code>StreamHandler</code> that publishes
+   * log records to <code>System.err</code>.  The initial
+   * configuration is determined by the <code>LogManager</code>
+   * properties described above.
+   */
+  public ConsoleHandler()
+  {
+    super(System.out, "java.util.logging.ConsoleHandler", Level.INFO,
+        /* formatter */ null/*, SimpleFormatter.class*/);
+  }
+
+
+  /**
+   * Forces any data that may have been buffered to the underlying
+   * output device, but does <i>not</i> close <code>System.err</code>.
+   *
+   * <p>In case of an I/O failure, the <code>ErrorManager</code>
+   * of this <code>ConsoleHandler</code> will be informed, but the caller
+   * of this method will not receive an exception.
+   */
+  public void close()
+  {
+    //flush();
+    System.println("Unimplemented ConsoleHandler.close()");
+  }
+
+
+  /**
+   * Publishes a <code>LogRecord</code> to the console, provided the
+   * record passes all tests for being loggable.
+   *
+   * <p>Most applications do not need to call this method directly.
+   * Instead, they will use use a <code>Logger</code>, which will
+   * create LogRecords and distribute them to registered handlers.
+   *
+   * <p>In case of an I/O failure, the <code>ErrorManager</code>
+   * of this <code>SocketHandler</code> will be informed, but the caller
+   * of this method will not receive an exception.
+   *
+   * <p>The GNU implementation of <code>ConsoleHandler.publish</code>
+   * calls flush() for every request to publish a record, so
+   * they appear immediately on the console.
+   *
+   * @param record the log event to be published.
+   */
+  public void publish(LogRecord record)
+  {
+    /*super.publish(record);
+    flush();*/
+    System.println("Unimplemented ConsoleHandler.publish(LogRecord)");
+  }
+}
index 57cd7b93f5f9ac8f5c374b140381a74a7dbb6b5d..5cafa937c3021f9e347e22ac3ac97e35fb5d057c 100644 (file)
@@ -299,13 +299,19 @@ public class DecimalFormat //extends NumberFormat
    *
    * @return A hash code.
    */
-  public int hashCode()
+  /*public int hashCode()
   {
     return toPattern().hashCode();
-  }
+  }*/
   
   public StringBuffer format(long l) {
-    return null;
+    System.println("Unimplemented DecimalFormat.format(long)");
+    return new StringBuffer("");
+  }
+  
+  public StringBuffer format(double l) {
+    System.println("Unimplemented DecimalFormat.format(double)");
+    return new StringBuffer("");
   }
   
   /**
@@ -2096,7 +2102,7 @@ public class DecimalFormat //extends NumberFormat
    * The integer totalDigitCount defines the total number of digits
    * of the number to which we are appending zeroes.
    */
-  private void appendZero(StringBuffer dest, int zeroes, int totalDigitCount)
+  /*private void appendZero(StringBuffer dest, int zeroes, int totalDigitCount)
   {
     char ch = symbols.getZeroDigit();
     char gSeparator = symbols.getGroupingSeparator();
@@ -2118,7 +2124,7 @@ public class DecimalFormat //extends NumberFormat
         (this.groupingUsed && this.groupingSize != 0) &&
         (gPos % groupingSize == 0))
       dest.append(gSeparator);
-  }
+  }*/
   
   /**
    * Append src to <code>dest</code>.
@@ -2126,7 +2132,7 @@ public class DecimalFormat //extends NumberFormat
    * Grouping is added if <code>groupingUsed</code> is set
    * to <code>true</code>.
    */
-  private void appendDigit(String src, StringBuffer dest,
+  /*private void appendDigit(String src, StringBuffer dest,
                              boolean groupingUsed)
   {
     int zero = symbols.getZeroDigit() - '0';
@@ -2144,7 +2150,7 @@ public class DecimalFormat //extends NumberFormat
 
         dest.append((char) (zero + ch));
       }
-  }
+  }*/
   
   /**
    * Calculate the exponent to use if eponential notation is used.
@@ -2152,7 +2158,7 @@ public class DecimalFormat //extends NumberFormat
    * <code>number</code> should be positive, if is zero, or less than zero,
    * zero is returned.
    */
-  private long getExponent(BigDecimal number)
+  /*private long getExponent(BigDecimal number)
   {
     long exponent = 0;
     
@@ -2176,7 +2182,7 @@ public class DecimalFormat //extends NumberFormat
       }
     
     return exponent;
-  }
+  }*/
  
   /**
    * Remove contiguos zeros from the end of the <code>src</code> string,
@@ -2252,7 +2258,7 @@ public class DecimalFormat //extends NumberFormat
     // Anyway, these seem to be good values for a default in most languages.
     // Note that most of these will change based on the format string.
     
-    this.negativePrefix = String.valueOf(symbols.getMinusSign());
+    this.negativePrefix = "-";//String.valueOf(symbols.getMinusSign());
     this.negativeSuffix = "";
     this.positivePrefix = "";
     this.positiveSuffix = "";
@@ -2263,10 +2269,10 @@ public class DecimalFormat //extends NumberFormat
     
     this.hasNegativePrefix = false;
     
-    this.minimumIntegerDigits = 1;
+    /*this.minimumIntegerDigits = 1;
     this.maximumIntegerDigits = DEFAULT_INTEGER_DIGITS;
     this.minimumFractionDigits = 0;
-    this.maximumFractionDigits = DEFAULT_FRACTION_DIGITS;
+    this.maximumFractionDigits = DEFAULT_FRACTION_DIGITS;*/
     this.minExponentDigits = 0;
     
     this.groupingSize = 0;
@@ -2274,7 +2280,7 @@ public class DecimalFormat //extends NumberFormat
     this.decimalSeparatorAlwaysShown = false;
     this.showDecimalSeparator = false;
     this.useExponentialNotation = false;
-    this.groupingUsed = false;
+    //this.groupingUsed = false;
     this.groupingSeparatorInPattern = false;
     
     this.useCurrencySeparator = false;
diff --git a/Robust/src/ClassLibrary/MGC/gnu/File.java b/Robust/src/ClassLibrary/MGC/gnu/File.java
new file mode 100644 (file)
index 0000000..5ecf4d3
--- /dev/null
@@ -0,0 +1,60 @@
+import java.io.FileSystem;
+import java.io.FilenameFilter;
+import java.util.ArrayList;
+
+public class File {
+  String path;
+  private static final char separator = '\n';
+  private static final char separatorChar = '\n';
+  private static final char pathSeparatorChar = ';';
+
+  public File(String path) {
+    this.path=path;
+  }
+
+  String getPath() {
+    return path;
+  }
+
+  long length() {
+    return nativeLength(path.getBytes());
+  }
+
+  private static native long nativeLength(byte[] pathname);
+  
+  public boolean exists() {
+    System.println("Unimplemented File.exists()");
+    return false;
+  }
+  
+  public boolean isDirectory() {
+    System.println("Unimplemented File.isDirectory()");
+    return false;
+  }
+  
+  public boolean mkdirs() {
+    System.println("Unimplemented File.mkdirs()");
+    return false;
+  }
+  
+  public boolean delete() {
+    System.println("Unimplemented File.delete()");
+    return false;
+  }
+  
+  public String[] list(FilenameFilter filter) {
+    /*String names[] = list();
+    if ((names == null) || (filter == null)) {
+      return names;
+    }
+    ArrayList v = new ArrayList();
+    for (int i = 0 ; i < names.length ; i++) {
+      if (filter.accept(this, names[i])) {
+        v.add(names[i]);
+      }
+    }
+    return (String[])(v.toArray(new String[0]));*/
+    System.println("Unimplemented File.list()");
+    return null;
+  }
+}
diff --git a/Robust/src/ClassLibrary/MGC/gnu/FilenameFilter.java b/Robust/src/ClassLibrary/MGC/gnu/FilenameFilter.java
new file mode 100644 (file)
index 0000000..57b4d3b
--- /dev/null
@@ -0,0 +1,76 @@
+/* FilenameFilter.java -- Filter a list of filenames
+   Copyright (C) 1998, 1999, 2001, 2003, 2005  Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.io;
+
+/* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3
+ * "The Java Language Specification", ISBN 0-201-63451-1
+ * Status:  Complete to 1.1.
+ */
+
+/**
+ * This interface has one method which is used for filtering filenames
+ * returned in a directory listing.  It is currently used by the 
+ * <code>File.list(FilenameFilter)</code> method and by the filename 
+ * dialog in AWT.
+ * <p>
+ * The method in this interface determines if a particular file should
+ * or should not be included in the file listing.
+ *
+ * @author Aaron M. Renn (arenn@urbanophile.com)
+ * @author Tom Tromey (tromey@cygnus.com)
+ *
+ * @see File#listFiles(java.io.FilenameFilter)
+ * @see java.awt.FileDialog#setFilenameFilter(java.io.FilenameFilter)
+ */
+public interface FilenameFilter
+{
+  /**
+   * This method determines whether or not a given file should be included
+   * in a directory listing.
+   *
+   * @param dir The <code>File</code> instance for the directory being read
+   * @param name The name of the file to test
+   *
+   * @return <code>true</code> if the file should be included in the list,
+   * <code>false</code> otherwise.
+   */
+  boolean accept(File dir, String name);
+
+} // interface FilenameFilter
+
index 09d5a8e87dd80f95102c148fe8cafea36a0cade2..774d39a5fe9ee73d421fdb7b979e7f3cec9aaec4 100644 (file)
@@ -116,7 +116,7 @@ h.setFormatter(h.getFormatter());</pre>
    * of this <code>Handler</code> will be informed, but the caller
    * of this method will not receive an exception.
    */
-  //public abstract void flush();
+  public /*abstract */void flush(){}
 
 
   /**
@@ -135,7 +135,7 @@ h.setFormatter(h.getFormatter());</pre>
    *         the caller is not granted the permission to control
    *         the logging infrastructure.
    */
-  //public abstract void close()
+  public /*abstract*/ void close(){}
   //  throws SecurityException;
 
 
diff --git a/Robust/src/ClassLibrary/MGC/gnu/InputStreamReader.java b/Robust/src/ClassLibrary/MGC/gnu/InputStreamReader.java
new file mode 100644 (file)
index 0000000..0db5b71
--- /dev/null
@@ -0,0 +1,499 @@
+/* InputStreamReader.java -- Reader than transforms bytes to chars
+   Copyright (C) 1998, 1999, 2001, 2003, 2004, 2005, 2006
+   Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.io;
+
+/**
+ * This class reads characters from a byte input stream.   The characters
+ * read are converted from bytes in the underlying stream by a 
+ * decoding layer.  The decoding layer transforms bytes to chars according
+ * to an encoding standard.  There are many available encodings to choose 
+ * from.  The desired encoding can either be specified by name, or if no
+ * encoding is selected, the system default encoding will be used.  The
+ * system default encoding name is determined from the system property
+ * <code>file.encoding</code>.  The only encodings that are guaranteed to 
+ * be availalbe are "8859_1" (the Latin-1 character set) and "UTF8".
+ * Unforunately, Java does not provide a mechanism for listing the
+ * ecodings that are supported in a given implementation.
+ * <p>
+ * Here is a list of standard encoding names that may be available:
+ * <p>
+ * <ul>
+ * <li>8859_1 (ISO-8859-1/Latin-1)</li>
+ * <li>8859_2 (ISO-8859-2/Latin-2)</li>
+ * <li>8859_3 (ISO-8859-3/Latin-3)</li>
+ * <li>8859_4 (ISO-8859-4/Latin-4)</li>
+ * <li>8859_5 (ISO-8859-5/Latin-5)</li>
+ * <li>8859_6 (ISO-8859-6/Latin-6)</li>
+ * <li>8859_7 (ISO-8859-7/Latin-7)</li>
+ * <li>8859_8 (ISO-8859-8/Latin-8)</li>
+ * <li>8859_9 (ISO-8859-9/Latin-9)</li>
+ * <li>ASCII (7-bit ASCII)</li>
+ * <li>UTF8 (UCS Transformation Format-8)</li>
+ * <li>More later</li>
+ * </ul>
+ * <p>
+ * It is recommended that applications do not use 
+ * <code>InputStreamReader</code>'s
+ * directly.  Rather, for efficiency purposes, an object of this class
+ * should be wrapped by a <code>BufferedReader</code>.
+ * <p>
+ * Due to a deficiency the Java class library design, there is no standard
+ * way for an application to install its own byte-character encoding.
+ *
+ * @see BufferedReader
+ * @see InputStream
+ *
+ * @author Robert Schuster
+ * @author Aaron M. Renn (arenn@urbanophile.com)
+ * @author Per Bothner (bothner@cygnus.com)
+ * @date April 22, 1998.  
+ */
+public class InputStreamReader extends Reader
+{
+  /**
+   * The input stream.
+   */
+  private InputStream in;
+
+  /**
+   * The charset decoder.
+   */
+  //private CharsetDecoder decoder;
+
+  /**
+   * End of stream reached.
+   */
+  private boolean isDone = false;
+
+  /**
+   * Need this.
+   */
+  //private float maxBytesPerChar;
+
+  /**
+   * Buffer holding surplus loaded bytes (if any)
+   */
+  //private ByteBuffer byteBuffer;
+
+  /**
+   * java.io canonical name of the encoding.
+   */
+  //private String encoding;
+
+  /**
+   * We might decode to a 2-char UTF-16 surrogate, which won't fit in the
+   * output buffer. In this case we need to save the surrogate char.
+   */
+  //private char savedSurrogate;
+  //private boolean hasSavedSurrogate = false;
+
+  /**
+   * A byte array to be reused in read(byte[], int, int).
+   */
+  //private byte[] bytesCache;
+
+  /**
+   * Locks the bytesCache above in read(byte[], int, int).
+   */
+  //private Object cacheLock = new Object();
+
+  /**
+   * This method initializes a new instance of <code>InputStreamReader</code>
+   * to read from the specified stream using the default encoding.
+   *
+   * @param in The <code>InputStream</code> to read from 
+   */
+  public InputStreamReader(InputStream in)
+  {
+    if (in == null)
+      throw new /*NullPointer*/Exception("NullPointerException");
+    this.in = in;
+    /*try 
+       { 
+         encoding = SystemProperties.getProperty("file.encoding");
+         // Don't use NIO if avoidable
+         if(EncodingHelper.isISOLatin1(encoding))
+           {
+             encoding = "ISO8859_1";
+             maxBytesPerChar = 1f;
+             decoder = null;
+             return;
+           }
+         Charset cs = EncodingHelper.getCharset(encoding);
+         decoder = cs.newDecoder();
+         encoding = EncodingHelper.getOldCanonical(cs.name());
+         try {
+             maxBytesPerChar = cs.newEncoder().maxBytesPerChar();
+         } catch(UnsupportedOperationException _){
+             maxBytesPerChar = 1f;
+         } 
+         decoder.onMalformedInput(CodingErrorAction.REPLACE);
+         decoder.onUnmappableCharacter(CodingErrorAction.REPLACE);
+         decoder.reset();
+       } catch(RuntimeException e) {
+         encoding = "ISO8859_1";
+         maxBytesPerChar = 1f;
+         decoder = null;
+       } catch(UnsupportedEncodingException e) {
+         encoding = "ISO8859_1";
+         maxBytesPerChar = 1f;
+         decoder = null;
+       }*/
+  }
+
+  /**
+   * This method initializes a new instance of <code>InputStreamReader</code>
+   * to read from the specified stream using a caller supplied character
+   * encoding scheme.  Note that due to a deficiency in the Java language
+   * design, there is no way to determine which encodings are supported.
+   * 
+   * @param in The <code>InputStream</code> to read from
+   * @param encoding_name The name of the encoding scheme to use
+   *
+   * @exception UnsupportedEncodingException If the encoding scheme 
+   * requested is not available.
+   */
+  /*public InputStreamReader(InputStream in, String encoding_name)
+    throws UnsupportedEncodingException
+  {
+    if (in == null
+        || encoding_name == null)
+      throw new NullPointerException();
+    
+    this.in = in;
+    // Don't use NIO if avoidable
+    if(EncodingHelper.isISOLatin1(encoding_name))
+      {
+       encoding = "ISO8859_1";
+       maxBytesPerChar = 1f;
+       decoder = null;
+       return;
+      }
+    try {
+      Charset cs = EncodingHelper.getCharset(encoding_name);
+      try {
+        maxBytesPerChar = cs.newEncoder().maxBytesPerChar();
+      } catch(UnsupportedOperationException _){
+       maxBytesPerChar = 1f;
+      } 
+
+      decoder = cs.newDecoder();
+      decoder.onMalformedInput(CodingErrorAction.REPLACE);
+      decoder.onUnmappableCharacter(CodingErrorAction.REPLACE);
+      decoder.reset();
+
+      // The encoding should be the old name, if such exists.
+      encoding = EncodingHelper.getOldCanonical(cs.name());
+    } catch(RuntimeException e) {
+      encoding = "ISO8859_1";
+      maxBytesPerChar = 1f;
+      decoder = null;
+    }
+  }*/
+
+  /**
+   * Creates an InputStreamReader that uses a decoder of the given
+   * charset to decode the bytes in the InputStream into
+   * characters.
+   * 
+   * @since 1.4
+   */
+  /*public InputStreamReader(InputStream in, Charset charset) {
+    if (in == null)
+      throw new NullPointerException();
+    this.in = in;
+    decoder = charset.newDecoder();
+
+    try {
+      maxBytesPerChar = charset.newEncoder().maxBytesPerChar();
+    } catch(UnsupportedOperationException _){
+      maxBytesPerChar = 1f;
+    }
+
+    decoder.onMalformedInput(CodingErrorAction.REPLACE);
+    decoder.onUnmappableCharacter(CodingErrorAction.REPLACE);
+    decoder.reset();
+    encoding = EncodingHelper.getOldCanonical(charset.name());
+  }*/
+
+  /**
+   * Creates an InputStreamReader that uses the given charset decoder
+   * to decode the bytes in the InputStream into characters.
+   * 
+   * @since 1.4
+   */
+  /*public InputStreamReader(InputStream in, CharsetDecoder decoder) {
+    if (in == null)
+      throw new NullPointerException();
+    this.in = in;
+    this.decoder = decoder;
+
+    Charset charset = decoder.charset();
+    try {
+      if (charset == null)
+        maxBytesPerChar = 1f;
+      else
+        maxBytesPerChar = charset.newEncoder().maxBytesPerChar();
+    } catch(UnsupportedOperationException _){
+       maxBytesPerChar = 1f;
+    } 
+
+    decoder.onMalformedInput(CodingErrorAction.REPLACE);
+    decoder.onUnmappableCharacter(CodingErrorAction.REPLACE);
+    decoder.reset();
+    if (charset == null)
+      encoding = "US-ASCII";
+    else
+      encoding = EncodingHelper.getOldCanonical(decoder.charset().name());      
+  }*/
+  
+  /**
+   * This method closes this stream, as well as the underlying 
+   * <code>InputStream</code>.
+   *
+   * @exception IOException If an error occurs
+   */
+  /*public void close() //throws IOException
+  {
+    synchronized (lock)
+      {
+       // Makes sure all intermediate data is released by the decoder.
+       if (decoder != null)
+          decoder.reset();
+       if (in != null)
+          in.close();
+       in = null;
+       isDone = true;
+       decoder = null;
+      }
+  }*/
+
+  /**
+   * This method returns the name of the encoding that is currently in use
+   * by this object.  If the stream has been closed, this method is allowed
+   * to return <code>null</code>.
+   *
+   * @return The current encoding name
+   */
+  /*public String getEncoding()
+  {
+    return in != null ? encoding : null;
+  }*/
+
+  /**
+   * This method checks to see if the stream is ready to be read.  It
+   * will return <code>true</code> if is, or <code>false</code> if it is not.
+   * If the stream is not ready to be read, it could (although is not required
+   * to) block on the next read attempt.
+   *
+   * @return <code>true</code> if the stream is ready to be read, 
+   * <code>false</code> otherwise
+   *
+   * @exception IOException If an error occurs
+   */
+  /*public boolean ready() throws IOException
+  {
+    if (in == null)
+      throw new IOException("Reader has been closed");
+    
+    return in.available() != 0;
+  }*/
+
+  /**
+   * This method reads up to <code>length</code> characters from the stream into
+   * the specified array starting at index <code>offset</code> into the
+   * array.
+   *
+   * @param buf The character array to recieve the data read
+   * @param offset The offset into the array to start storing characters
+   * @param length The requested number of characters to read.
+   *
+   * @return The actual number of characters read, or -1 if end of stream.
+   *
+   * @exception IOException If an error occurs
+   */
+  /*public int read(char[] buf, int offset, int length) throws IOException
+  {
+    if (in == null)
+      throw new IOException("Reader has been closed");
+    if (isDone)
+      return -1;
+    if(decoder != null)
+      {
+       int totalBytes = (int)((double) length * maxBytesPerChar);
+        if (byteBuffer != null)
+          totalBytes = Math.max(totalBytes, byteBuffer.remaining());
+       byte[] bytes;
+        // Fetch cached bytes array if available and big enough.
+        synchronized(cacheLock)
+          {
+            bytes = bytesCache;
+            if (bytes == null || bytes.length < totalBytes)
+              bytes = new byte[totalBytes];
+            else
+              bytesCache = null;
+          }
+
+       int remaining = 0;
+       if(byteBuffer != null)
+       {
+           remaining = byteBuffer.remaining();
+           byteBuffer.get(bytes, 0, remaining);
+       }
+       int read;
+       if(totalBytes - remaining > 0)
+         {
+           read = in.read(bytes, remaining, totalBytes - remaining);
+           if(read == -1){
+             read = remaining;
+             isDone = true;
+           } else
+             read += remaining;
+         } else 
+            read = remaining;
+       byteBuffer = ByteBuffer.wrap(bytes, 0, read);   
+       CharBuffer cb = CharBuffer.wrap(buf, offset, length);
+       int startPos = cb.position();
+
+       if(hasSavedSurrogate){
+           hasSavedSurrogate = false;
+           cb.put(savedSurrogate);
+           read++;
+       }
+
+       CoderResult cr = decoder.decode(byteBuffer, cb, isDone);
+       decoder.reset();
+       // 1 char remains which is the first half of a surrogate pair.
+       if(cr.isOverflow() && cb.hasRemaining()){
+           CharBuffer overflowbuf = CharBuffer.allocate(2);
+           cr = decoder.decode(byteBuffer, overflowbuf, isDone);
+           overflowbuf.flip();
+           if(overflowbuf.hasRemaining())
+           {
+             cb.put(overflowbuf.get());
+             savedSurrogate = overflowbuf.get();
+             hasSavedSurrogate = true;     
+             isDone = false;
+           }
+       }
+
+       if(byteBuffer.hasRemaining()) {
+           byteBuffer.compact();
+           byteBuffer.flip();    
+           isDone = false;
+       } else
+           byteBuffer = null;
+
+       read = cb.position() - startPos;
+
+        // Put cached bytes array back if we are finished and the cache
+        // is null or smaller than the used bytes array.
+        synchronized (cacheLock)
+          {
+            if (byteBuffer == null
+                && (bytesCache == null || bytesCache.length < bytes.length))
+              bytesCache = bytes;
+          }
+        return (read <= 0) ? -1 : read;
+      }
+    else
+      {
+       byte[] bytes;
+        // Fetch cached bytes array if available and big enough.
+        synchronized (cacheLock)
+          {
+            bytes = bytesCache;
+            if (bytes == null || length < bytes.length)
+              bytes = new byte[length];
+            else
+              bytesCache = null;
+          }
+
+       int read = in.read(bytes);
+       for(int i=0;i<read;i++)
+          buf[offset+i] = (char)(bytes[i]&0xFF);
+
+        // Put back byte array into cache if appropriate.
+        synchronized (cacheLock)
+          {
+            if (bytesCache == null || bytesCache.length < bytes.length)
+              bytesCache = bytes;
+          }
+       return read;
+    }
+  }*/
+
+  /**
+   * Reads an char from the input stream and returns it
+   * as an int in the range of 0-65535.  This method also will return -1 if
+   * the end of the stream has been reached.
+   * <p>
+   * This method will block until the char can be read.
+   *
+   * @return The char read or -1 if end of stream
+   *
+   * @exception IOException If an error occurs
+   */
+  /*public int read() throws IOException
+  {
+    char[] buf = new char[1];
+    int count = read(buf, 0, 1);
+    return count > 0 ? buf[0] : -1;
+  }*/
+
+  /**
+   * Skips the specified number of chars in the stream.  It
+   * returns the actual number of chars skipped, which may be less than the
+   * requested amount.
+   *
+   * @param count The requested number of chars to skip
+   *
+   * @return The actual number of chars skipped.
+   *
+   * @exception IOException If an error occurs
+   */
+   /*public long skip(long count) throws IOException
+   {
+     if (in == null)
+       throw new IOException("Reader has been closed");
+     
+     return super.skip(count);
+   }*/
+}
index 70cf86ed4fbc99cb5a53c98497592963a3f3e456..9b150fe47a093bab5b0dfee38a2699d7edf7b28b 100644 (file)
@@ -139,7 +139,7 @@ public class Level //implements Serializable
    *
    * @see Logger#setLevel(java.util.logging.Level)
    */
-  public static final Level ALL = new Level ("ALL", Integer.MIN_VALUE);
+  public static final Level ALL = new Level ("ALL", 0x80000000/*Integer.MIN_VALUE*/);
 
 
   private static final Level[] knownLevels = {
index 3e4a61de021be0b41da8950e9821d8555be2dd5e..9365cd37d5dbb5527591f0796b6cd87a9738a0c4 100644 (file)
@@ -319,7 +319,7 @@ public class LogManager
      * When adding "foo.bar", the logger "foo.bar.baz" should change
      * its parent to "foo.bar".
      */
-    for (HashMapIterator iter = loggers./*.keySet().*/iterator(0); iter.hasNext();)
+    for (HashMapIterator iter = (HashMapIterator)loggers./*.keySet().*/iterator(0); iter.hasNext();)
       {
        Logger possChild = (Logger) /*((WeakReference) */loggers.get(iter.next());//)
         // .get();
@@ -369,7 +369,7 @@ public class LogManager
       return null;
 
     //for (String candName : loggers.keySet())
-    HashMapIterator it_key = loggers.iterator(0);
+    HashMapIterator it_key = (HashMapIterator)loggers.iterator(0);
     while(it_key.hasNext())
       {
       String candName = (String)it_key.next();
@@ -380,7 +380,7 @@ public class LogManager
            && childName.startsWith(candName)
            && childName.charAt(candNameLength) == '.')
          {
-           cand = loggers.get(candName);//.get();
+           cand = (Logger)loggers.get(candName);//.get();
            if ((cand == null) || (cand == child))
              continue;
 
@@ -615,7 +615,7 @@ public class LogManager
      * be determined that the Sun J2SE 1.4 reference
      * implementation uses null for the property name.
      */
-    pcs.firePropertyChange(null, null, null);
+    /*pcs.firePropertyChange(null, null, null);
   }*/
 
   /**
index 26e949d3f72a72fe7007a64f6e0f499eca6d8414..d173b7d50d5bed2a61a20c0a680919224ce0be88 100644 (file)
@@ -1041,17 +1041,19 @@ public class Logger
    * {@link #setUseParentHandlers(boolean) setUseParentHandlers}, the log
    * record will be passed to the parent's handlers.
    */
-  /*public Handler[] getHandlers()
+  public Handler[] getHandlers()
   {
-    synchronized (lock)
+    /*synchronized (lock)
       {
         /*
          * We cannot return our internal handlers array because we do not have
          * any guarantee that the caller would not change the array entries.
          */
         /*return (Handler[]) handlerList.toArray(new Handler[handlerList.size()]);
-      }
-  }*/
+      }*/
+    System.println("Unimplemented Logger.getHandlers()");
+    return new Handler[0];
+  }
 
   /**
    * Returns whether or not this Logger forwards log records to handlers
@@ -1086,7 +1088,7 @@ public class Logger
    *             anonymous logger through the static factory method
    *             {@link #getAnonymousLogger(java.lang.String) getAnonymousLogger}.
    */
-  /*public void setUseParentHandlers(boolean useParentHandlers)
+  public void setUseParentHandlers(boolean useParentHandlers)
   {
     synchronized (lock)
       {
@@ -1095,11 +1097,11 @@ public class Logger
          * having the permission to control the logging infrastructure.
          */
         /*if (! anonymous)
-          LogManager.getLogManager().checkAccess();
+          LogManager.getLogManager().checkAccess();*/
 
         this.useParentHandlers = useParentHandlers;
       }
-  }*/
+  }
 
   /**
    * Returns the parent of this logger. By default, the parent is assigned by
index 6ea297f4ee4559ffd94a855b5bbcbd8815c4171f..12007a59cf674e0666137f5479488efb6e6d023c 100644 (file)
@@ -80,6 +80,8 @@ public class PrintWriter extends Writer
    * to
    */
   protected Writer out;
+  
+  protected Object lock;
 
   /**
    * This method intializes a new <code>PrintWriter</code> object to write
@@ -92,6 +94,7 @@ public class PrintWriter extends Writer
   {
     //super(wr.lock);
     this.out = wr;
+    this.lock = wr;
   }
 
   /**
@@ -109,6 +112,7 @@ public class PrintWriter extends Writer
     //super(wr.lock);
     this.out = wr;
     this.autoflush = autoflush;
+    this.lock = wr;
   }
 
   /**
@@ -380,7 +384,7 @@ public class PrintWriter extends Writer
    * This is the system dependent line separator
    */
   private static final char[] line_separator
-    = {"\n"}; //System.getProperty("line.separator", "\n").toCharArray(); 
+    = {'\n'}; //System.getProperty("line.separator", "\n").toCharArray(); 
 
   /**
    * This method prints a line separator sequence to the stream.  The value
@@ -568,7 +572,7 @@ public class PrintWriter extends Writer
   {
     try
       {
-       out.write(ch);
+       out.write(new String((char)ch));
       }
     catch (/*IO*/Exception ex)
       {
@@ -588,7 +592,7 @@ public class PrintWriter extends Writer
   {
     try
       {
-       out.write(charArray, offset, count);
+       out.write(new String(charArray, offset, count));
       }
     catch (/*IO*/Exception ex)
       {
index 97737886ddf732ea8692f7a0806c527989e96e5a..e71684aa25ef14bb3c0fa064ab470cd3ca4e0feb 100644 (file)
@@ -522,7 +522,7 @@ label   = Name:\\u0020</pre>
   }
   
   public Set keySet() {
-    HashMapIterator it = this.proptbl.iterator(0);
+    HashMapIterator it = (HashMapIterator)this.proptbl.iterator(0);
     Set keys = new Vector();
     while(it.hasNext()) {
       keys.add(it.next());
index 887fdb3b812218aa71ebb34910b7569a9e7b62e4..d0cf2372f50863b9723cf9796f59ddff77135de6 100644 (file)
@@ -170,7 +170,7 @@ public final class Short
    */
   public static short parseShort(String s, int radix)
   {
-    int i = Integer.parseInt(s, radix, false);
+    int i = Integer.parseInt(s, radix);
     if ((short) i != i)
       throw new /*NumberFormat*/Exception("NumberFormatException");
     return (short) i;
@@ -258,7 +258,7 @@ public final class Short
    */
   public static Short decode(String s)
   {
-    int i = Integer.parseInt(s, 10, true);
+    int i = Integer.parseInt(s, 10);
     if ((short) i != i)
       throw new /*NumberFormat*/Exception("NumberFormatException");
     return valueOf((short) i);
diff --git a/Robust/src/ClassLibrary/MGC/gnu/Stack.java b/Robust/src/ClassLibrary/MGC/gnu/Stack.java
new file mode 100644 (file)
index 0000000..b9fb394
--- /dev/null
@@ -0,0 +1,160 @@
+/* Stack.java - Class that provides a Last In First Out (LIFO)
+   datatype, known more commonly as a Stack
+   Copyright (C) 1998, 1999, 2001, 2004, 2005
+   Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.util;
+
+/* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3
+ * "The Java Language Specification", ISBN 0-201-63451-1
+ * plus online API docs for JDK 1.2 beta from http://www.javasoft.com.
+ * Status:  Believed complete and correct
+
+/**
+ * Stack provides a Last In First Out (LIFO) data type, commonly known
+ * as a Stack.  Stack itself extends Vector and provides the additional
+ * methods for stack manipulation (push, pop, peek). You can also seek for
+ * the 1-based position of an element on the stack.
+ *
+ * @author Warren Levy (warrenl@cygnus.com)
+ * @author Eric Blake (ebb9@email.byu.edu)
+ * @see List
+ * @see AbstractList
+ * @see LinkedList
+ * @since 1.0
+ * @status updated to 1.4
+ */
+public class Stack/*<T>*/ extends Vector/*<T>*/
+{
+  // We could use Vector methods internally for the following methods,
+  // but have used Vector fields directly for efficiency (i.e. this
+  // often reduces out duplicate bounds checking).
+
+  /**
+   * Compatible with JDK 1.0+.
+   */
+  private static final long serialVersionUID = 1224463164541339165L;
+
+  /**
+   * This constructor creates a new Stack, initially empty
+   */
+  public Stack()
+  {
+  }
+
+  /**
+   * Pushes an Object onto the top of the stack.  This method is effectively
+   * the same as addElement(item).
+   *
+   * @param item the Object to push onto the stack
+   * @return the Object pushed onto the stack
+   * @see Vector#addElement(Object)
+   */
+  public Object push(Object item)
+  {
+    // When growing the Stack, use the Vector routines in case more
+    // memory is needed.
+    // Note: spec indicates that this method *always* returns obj passed in!
+
+    addElement(item);
+    return item;
+  }
+
+  /**
+   * Pops an item from the stack and returns it.  The item popped is
+   * removed from the Stack.
+   *
+   * @return the Object popped from the stack
+   * @throws EmptyStackException if the stack is empty
+   */
+  //@SuppressWarnings("unchecked")
+  public synchronized Object pop()
+  {
+    if (size == 0)
+      throw new /*EmptyStack*/Exception("EmptyStackException");
+
+    Object obj = array[--size];
+
+    // Set topmost element to null to assist the gc in cleanup.
+    array[size] = null;
+    return obj;
+  }
+
+  /**
+   * Returns the top Object on the stack without removing it.
+   *
+   * @return the top Object on the stack
+   * @throws EmptyStackException if the stack is empty
+   */
+  //@SuppressWarnings("unchecked")
+  public synchronized Object peek()
+  {
+    if (size == 0)
+      throw new /*EmptyStack*/Exception("EmptyStackException");
+
+    return array[size - 1];
+  }
+
+  /**
+   * Tests if the stack is empty.
+   *
+   * @return true if the stack contains no items, false otherwise
+   */
+  public synchronized boolean empty()
+  {
+    return size == 0;
+  }
+
+  /**
+   * Returns the position of an Object on the stack, with the top
+   * most Object being at position 1, and each Object deeper in the
+   * stack at depth + 1.
+   *
+   * @param o The object to search for
+   * @return The 1 based depth of the Object, or -1 if the Object
+   *         is not on the stack
+   */
+  public synchronized int search(Object o)
+  {
+    int i = size;
+    while (--i >= 0)
+      if (o.equals(array[i]))
+        return size - i;
+    return -1;
+  }
+}
index 2a0b3f62c06d4c5f042c461ec4fb0467d0ce02d7..54b23c02c7f0d1e212ff3b13b2d51ec7cc955512 100644 (file)
@@ -39,9 +39,6 @@ exception statement from your version. */
 
 package java.util;
 
-import java.util.TreeMap.Node;
-
-
 /**
  * This class provides a red-black tree implementation of the SortedMap
  * interface.  Elements in the Map will be sorted by either a user-provided
@@ -90,7 +87,7 @@ import java.util.TreeMap.Node;
  * @status updated to 1.6
  */
 public class TreeMap//<K, V> extends AbstractMap<K, V>
-  implements Map, SortedMap //NavigableMap<K, V>, Cloneable, Serializable
+  implements Map//, SortedMap //NavigableMap<K, V>, Cloneable, Serializable
 {
   // Implementation note:
   // A red-black tree is a binary search tree with the additional properties
@@ -994,9 +991,9 @@ public class TreeMap//<K, V> extends AbstractMap<K, V>
     node.parent = child;
   }
   
-  public TreeMap subMap(Object fromKey, Object toKey)
+  public TreeSubMap subMap(Object fromKey, Object toKey)
   {
-    new SubMap(fromKey, toKey)
+    return new TreeSubMap(this, fromKey, toKey);
   }
   
   /**
index dfb499643ad333b50c878dd92c8d33b3d671dd5c..19b15da615dbfd1ba0d18e41c5a51f56f9106a14 100644 (file)
@@ -1,4 +1,4 @@
-public final class TreeMapIterator implements Iterator
+public final class TreeMapIterator extends Iterator
 {
   /**
    * The type of this Iterator: {@link #KEYS}, {@link #VALUES},
@@ -6,7 +6,7 @@ public final class TreeMapIterator implements Iterator
    */
   private final int type;
   /** The number of modifications to the backing Map that we know about. */
-  private int knownMod = modCount;
+  private int knownMod;
   /** The last Entry returned by a next() call. */
   private TreeNode last;
   /** The next entry that should be returned by next(). */
@@ -25,7 +25,7 @@ public final class TreeMapIterator implements Iterator
    */
   TreeMapIterator(TreeMap map, int type)
   {
-    this(type, map, map.firstNode(), nil);
+    this(map, type, map.firstNode(), TreeMap.nil);
   }
 
   /**
@@ -36,12 +36,13 @@ public final class TreeMapIterator implements Iterator
    * @param first where to start iteration, nil for empty iterator
    * @param max the cutoff for iteration, nil for all remaining nodes
    */
-  TreeIterator(int type, TreeMap map, TreeNode first, TreeNode max)
+  TreeMapIterator(TreeMap map, int type, TreeNode first, TreeNode max)
   {
     this.map = map;
     this.type = type;
     this.next = first;
     this.max = max;
+    this.knownMod = this.map.modCount;
   }
 
   /**
@@ -61,10 +62,10 @@ public final class TreeMapIterator implements Iterator
    */
   public Object next()
   {
-    if (knownMod != modCount)
+    if (knownMod != this.map.modCount)
       throw new /*ConcurrentModification*/Exception("ConcurrentModificationException");
     if (next == max)
-      throw new /*NoSuchElementException*/("NoSuchElementException");
+      throw new /*NoSuchElement*/Exception("NoSuchElementException");
     last = next;
     next = map.successor(last);
 
@@ -85,7 +86,7 @@ public final class TreeMapIterator implements Iterator
   {
     if (last == null)
       throw new /*IllegalState*/Exception("IllegalStateException");
-    if (knownMod != modCount)
+    if (knownMod != this.map.modCount)
       throw new /*ConcurrentModification*/Exception("ConcurrentModificationException");
 
     map.removeNode(last);
index cccd08aef66965da999e7dd5fa7151da9e6f7076..1c985f93505aac83425d57917d7e1bd1239b1f1e 100644 (file)
-import TreeMap.Node;
-
 /**
-   * Class to represent an entry in the tree. Holds a single key-value pair,
-   * plus pointers to parent and child nodes.
+ * Class to represent an entry in the tree. Holds a single key-value pair,
+ * plus pointers to parent and child nodes.
+ *
+ * @author Eric Blake (ebb9@email.byu.edu)
+ */
+public static final class TreeNode//<K, V> extends AbstractMap.SimpleEntry<K, V>
+{
+  // All fields package visible for use by nested classes.
+  /** The color of this node. */
+  int color;
+  Object key;
+  Object value;
+
+  /** The left child node. */
+  TreeNode left = TreeMap.nil;
+  /** The right child node. */
+  TreeNode right = TreeMap.nil;
+  /** The parent node. */
+  TreeNode parent = TreeMap.nil;
+
+  /**
+   * Simple constructor.
+   * @param key the key
+   * @param value the value
+   */
+  TreeNode(Object key, Object value, int color)
+  {
+    key = key;
+    value = value;
+    this.color = color;
+  }
+
+  public boolean equals(Object o)
+  {
+    if (! (o instanceof TreeNode))
+      return false;
+    // Optimize for our own entries.
+    TreeNode e = (TreeNode) o;
+    return (key.equals(e.key) && value.equals(e.value));
+  }
+
+  /**
+   * Get the key corresponding to this entry.
+   *
+   * @return the key
+   */
+  public Object getKey()
+  {
+    return key;
+  }
+
+  /**
+   * Get the value corresponding to this entry. If you already called
+   * Iterator.remove(), the behavior undefined, but in this case it works.
+   *
+   * @return the value
+   */
+  public Object getValue()
+  {
+    return value;
+  }
+
+  /**
+   * Returns the hash code of the entry.  This is defined as the exclusive-or
+   * of the hashcodes of the key and value (using 0 for null). In other
+   * words, this must be:<br>
+   * <pre>(getKey() == null ? 0 : getKey().hashCode())
+   *       ^ (getValue() == null ? 0 : getValue().hashCode())</pre>
+   *
+   * @return the hash code
+   */
+  public int hashCode()
+  {
+    return (key.hashCode() ^ value.hashCode());
+  }
+
+  /**
+   * Replaces the value with the specified object. This writes through
+   * to the map, unless you have already called Iterator.remove(). It
+   * may be overridden to restrict a null value.
+   *
+   * @param newVal the new value to store
+   * @return the old value
+   * @throws NullPointerException if the map forbids null values.
+   * @throws UnsupportedOperationException if the map doesn't support
+   *          <code>put()</code>.
+   * @throws ClassCastException if the value is of a type unsupported
+   *         by the map.
+   * @throws IllegalArgumentException if something else about this
+   *         value prevents it being stored in the map.
+   */
+  public Object setValue(Object newVal)
+  {
+    Object r = value;
+    value = newVal;
+    return r;
+  }
+
+  /**
+   * This provides a string representation of the entry. It is of the form
+   * "key=value", where string concatenation is used on key and value.
    *
-   * @author Eric Blake (ebb9@email.byu.edu)
+   * @return the string representation
    */
-  public static final class TreeNode//<K, V> extends AbstractMap.SimpleEntry<K, V>
+  public String toString()
   {
-    // All fields package visible for use by nested classes.
-    /** The color of this node. */
-    int color;
-    Object key;
-    Object value;
-
-    /** The left child node. */
-    TreeNode left = nil;
-    /** The right child node. */
-    TreeNode right = nil;
-    /** The parent node. */
-    TreeNode parent = nil;
-
-    /**
-     * Simple constructor.
-     * @param key the key
-     * @param value the value
-     */
-    TreeNode(Object key, Object value, int color)
-    {
-      key = key;
-      value = value;
-      this.color = color;
-    }
-  }
\ No newline at end of file
+    return key + "=" + value;
+  }
+}
\ No newline at end of file
index 1bdea0a168b3c64612001f78cc0a00747264c3dc..4489e379e1cad2a0b357ca624b20c41071348639 100644 (file)
@@ -25,7 +25,7 @@ public final class TreeSubMap
   TreeSubMap(TreeMap map, Object minKey, Object maxKey)
   {
     this.map = map;
-    if (minKey != nil && maxKey != nil && map.compare(minKey, maxKey) > 0)
+    if (minKey != TreeMap.nil && maxKey != TreeMap.nil && map.compare(minKey, maxKey) > 0)
       throw new /*IllegalArgument*/Exception("IllegalArgumentException: fromKey > toKey");
     this.minKey = minKey;
     this.maxKey = maxKey;
index b685780a5071f5fb9ec00ae69ec8e1f0ebb7af65..e68450351d47d33137a27aa0a05444719c308e9d 100644 (file)
@@ -256,6 +256,10 @@ public class String {
     return str;
   }
   
+  public void getChars(char dst[], int dstBegin) {
+    getChars(0, count, dst, dstBegin);
+  }
+  
   public void getChars(int srcBegin, int srcEnd, char dst[], int dstBegin) {
     if((srcBegin < 0) || (srcEnd > count) || (srcBegin > srcEnd)) {
       // FIXME
@@ -505,4 +509,9 @@ public class String {
     }
     return ((st > 0) || (len < count)) ? substring(st, len) : this;
   }
+  
+  public boolean matches(String regex) {
+    System.println("String.matches() is not fully supported");
+    return this.equals(regex);
+  }
 }
index 88e6c0cc16b656aaa63051f51cd32471361faf12..74d4a3056a72fb73f05d1e031d2cef61e7b647d3 100644 (file)
@@ -85,8 +85,58 @@ public class StringBuffer {
     }
     return this;
   }
+  
+  public int indexOf(String str) {
+    return indexOf(str, 0);
+  }
+  
+  public synchronized int indexOf(String str, int fromIndex) {
+    String vstr = new String(value, 0, count);
+    return vstr.indexOf(str, fromIndex);
+  }
 
   public String toString() {
     return new String(this);
   }
+  
+  public synchronized StringBuffer replace(int start, int end, String str) {
+    if (start < 0) {
+      // FIXME
+      System.printString("StringIndexOutOfBoundsException: "+start+"\n");
+    }
+    if (start > count) {
+      // FIXME
+      System.printString("StringIndexOutOfBoundsException: start > length()\n");
+    }
+    if (start > end) {
+      // FIXME
+      System.printString("StringIndexOutOfBoundsException: start > end\n");
+    }
+    if (end > count)
+      end = count;
+
+    if (end > count)
+      end = count;
+    int len = str.length();
+    int newCount = count + len - (end - start);
+    if (newCount > value.length)
+      expandCapacity(newCount);
+
+    System.arraycopy(value, end, value, start + len, count - end);
+    str.getChars(value, start);
+    count = newCount;
+    return this;
+  }
+  
+  void expandCapacity(int minimumCapacity) {
+    int newCapacity = (value.length + 1) * 2;
+    if (newCapacity < 0) {
+      newCapacity = 0x7fffffff/*Integer.MAX_VALUE*/;
+    } else if (minimumCapacity > newCapacity) {
+      newCapacity = minimumCapacity;
+    }   
+    char newValue[] = new char[newCapacity];
+    System.arraycopy(value, 0, newValue, 0, count);
+    value = newValue;
+  }
 }