[kaffe] CVS kaffe (dalibor): Replaced a few java.util classes by implementations from GNU Classpath

Kaffe CVS cvs-commits at kaffe.org
Tue Mar 16 19:06:01 PST 2004


PatchSet 4530 
Date: 2004/03/17 02:53:10
Author: dalibor
Branch: HEAD
Tag: (none) 
Log:
Replaced a few java.util classes by implementations from GNU Classpath

2004-03-16  Dalibor Topic <robilad at kaffe.org>

        * libraries/javalib/java/util/Stack.java,
        libraries/javalib/java/util/MissingResourceException.java,
        libraries/javalib/java/util/Observable.java,
        libraries/javalib/java/util/Properties.java,
        libraries/javalib/java/util/StringTokenizer.java,
        libraries/javalib/java/util/Timer.java,
        libraries/javalib/java/util/TimerTask.java:
        Replaced by implementation from GNU Classpath.

Members: 
	ChangeLog:1.2108->1.2109 
	libraries/javalib/java/util/MissingResourceException.java:1.5->1.6 
	libraries/javalib/java/util/Observable.java:1.3->1.4 
	libraries/javalib/java/util/Properties.java:1.21->1.22 
	libraries/javalib/java/util/Stack.java:1.4->1.5 
	libraries/javalib/java/util/StringTokenizer.java:1.5->1.6 
	libraries/javalib/java/util/Timer.java:1.5->1.6 
	libraries/javalib/java/util/TimerTask.java:1.2->1.3 

Index: kaffe/ChangeLog
diff -u kaffe/ChangeLog:1.2108 kaffe/ChangeLog:1.2109
--- kaffe/ChangeLog:1.2108	Wed Mar 17 00:59:43 2004
+++ kaffe/ChangeLog	Wed Mar 17 02:53:10 2004
@@ -1,5 +1,16 @@
 2004-03-16  Dalibor Topic <robilad at kaffe.org>
 
+	* libraries/javalib/java/util/Stack.java,
+	libraries/javalib/java/util/MissingResourceException.java,
+	libraries/javalib/java/util/Observable.java,
+	libraries/javalib/java/util/Properties.java,
+	libraries/javalib/java/util/StringTokenizer.java,
+	libraries/javalib/java/util/Timer.java,
+	libraries/javalib/java/util/TimerTask.java:
+	Replaced by implementation from GNU Classpath.
+
+2004-03-16  Dalibor Topic <robilad at kaffe.org>
+
 	* libraries/javalib/java/util/AbstractListIterator.java,
 	libraries/javalib/java/util/AbstractMapEntry.java,
 	libraries/javalib/java/util/AbstractMapEntrySet.java:
Index: kaffe/libraries/javalib/java/util/MissingResourceException.java
diff -u kaffe/libraries/javalib/java/util/MissingResourceException.java:1.5 kaffe/libraries/javalib/java/util/MissingResourceException.java:1.6
--- kaffe/libraries/javalib/java/util/MissingResourceException.java:1.5	Wed Sep  4 11:10:46 2002
+++ kaffe/libraries/javalib/java/util/MissingResourceException.java	Wed Mar 17 02:53:12 2004
@@ -1,37 +1,105 @@
-/*
- * Java core library component.
- *
- * Copyright (c) 1997, 1998
- *      Transvirtual Technologies, Inc.  All rights reserved.
- *
- * See the file "license.terms" for information on usage and redistribution
- * of this file.
- */
+/* MissingResourceException.java -- thrown for a missing resource
+   Copyright (C) 1998, 1999, 2001, 2002 Free Software Foundation, Inc.
 
-package java.util;
+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., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 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. */
 
-public class MissingResourceException extends RuntimeException {
 
-  // NB: both are part of serialized form
-  private String className;
-  private String key;
+package java.util;
 
-  public MissingResourceException(String s, String className, String ky)
+/**
+ * This exception is thrown when a resource is missing.
+ *
+ * @author Jochen Hoenicke
+ * @author Warren Levy <warrenl at cygnus.com>
+ * @see ResourceBundle
+ * @since 1.1
+ * @status updated to 1.4
+ */
+public class MissingResourceException extends RuntimeException
+{
+  /**
+   * Compatible with JDK 1.1+.
+   */
+  private static final long serialVersionUID = -4876345176062000401L;
+
+  /**
+   * The name of the resource bundle requested by user.
+   *
+   * @serial the class name of the resource bundle
+   */
+  private final String className;
+
+  /**
+   * The key of the resource in the bundle requested by user.
+   *
+   * @serial the name of the resouce
+   */
+  private final String key;
+
+  /**
+   * Creates a new exception, with the specified parameters.
+   *
+   * @param s the detail message
+   * @param className the name of the resource bundle
+   * @param key the key of the missing resource
+   */
+  public MissingResourceException(String s, String className, String key)
   {
-    super(s + "\t" + className + "\t" + ky);
+    super(s);
     this.className = className;
-    key = ky;
+    this.key = key;
   }
 
+  /**
+   * Gets the name of the resource bundle, for which a resource is missing.
+   *
+   * @return the name of the resource bundle
+   */
   public String getClassName()
   {
-    return (className);
+    return className;
   }
 
+  /**
+   * Gets the key of the resource that is missing bundle, this is an empty
+   * string if the whole resource bundle is missing.
+   *
+   * @return the name of the resource bundle
+   */
   public String getKey()
   {
-    return (key);
+    return key;
   }
-
 }
Index: kaffe/libraries/javalib/java/util/Observable.java
diff -u kaffe/libraries/javalib/java/util/Observable.java:1.3 kaffe/libraries/javalib/java/util/Observable.java:1.4
--- kaffe/libraries/javalib/java/util/Observable.java:1.3	Fri Oct 15 18:22:31 1999
+++ kaffe/libraries/javalib/java/util/Observable.java	Wed Mar 17 02:53:12 2004
@@ -1,74 +1,180 @@
+/* Observable.java -- an object to be observed
+   Copyright (C) 1999, 2000, 2001, 2002 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., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 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. */
 
-/*
- * Java core library component.
- *
- * Copyright (c) 1999
- *	Archie L. Cobbs.  All rights reserved.
- * Copyright (c) 1999
- *	Transvirtual Technologies, Inc.  All rights reserved.
- *
- * See the file "license.terms" for information on usage and redistribution
- * of this file.
- *
- * Author: Archie L. Cobbs <archie at whistle.com>
- */
 
 package java.util;
 
-public class Observable {
-	private final ArrayList observers;
-	private boolean changed;
-
-	public Observable() {
-		observers = new ArrayList();
-		changed = false;
-	}
-
-	public synchronized void addObserver(Observer o) {
-		observers.add(o);
-	}
-
-	public synchronized void deleteObserver(Observer o) {
-		int index = observers.indexOf(o);
-		if (index != -1) {
-			observers.remove(index);
-		}
-	}
-
-	public void notifyObservers() {
-		notifyObservers(null);
-	}
-
-	public synchronized void notifyObservers(Object arg) {
-		if (changed) {
-			// Need to clone list to avoid any concurrent
-			// modification exceptions.
-			for (Iterator i = ((ArrayList)(observers.clone())).listIterator();
-			    i.hasNext(); ) {
-				((Observer)i.next()).update(this, arg);
-			}
-			clearChanged();
-		}
-	}
-
-	public synchronized void deleteObservers() {
-		observers.clear();
-	}
-
-	protected void setChanged() {
-		changed = true;
-	}
-
-	protected void clearChanged() {
-		changed = false;
-	}
-
-	public boolean hasChanged() {
-		return changed;
-	}
-
-	public synchronized int countObservers() {
-		return observers.size();
-	}
+/**
+ * This class represents an object which is observable.  Other objects may
+ * register their intent to be notified when this object changes; and when
+ * this object does change, it will trigger the <code>update</code> method
+ * of each observer.
+ *
+ * Note that the <code>notifyObservers()</code> method of this class is
+ * unrelated to the <code>notify()</code> of Object.
+ *
+ * @author Warren Levy <warrenl at cygnus.com>
+ * @author Eric Blake <ebb9 at email.byu.edu>
+ * @see Observer
+ * @status updated to 1.4
+ */
+public class Observable
+{
+  /** Tracks whether this object has changed. */
+  private boolean changed;
+
+  /* List of the Observers registered as interested in this Observable. */
+  private LinkedHashSet observers;
+
+  /**
+   * Constructs an Observable with zero Observers.
+   */
+  public Observable()
+  {
+    observers = new LinkedHashSet();
+  }
+
+  /**
+   * Adds an Observer. If the observer was already added this method does
+   * nothing.
+   *
+   * @param observer Observer to add
+   * @throws NullPointerException if observer is null
+   */
+  public synchronized void addObserver(Observer observer)
+  {
+    observers.add(observer);
+  }
+
+  /**
+   * Reset this Observable's state to unchanged. This is called automatically
+   * by <code>notifyObservers</code> once all observers have been notified.
+   *
+   * @see #notifyObservers()
+   */
+  protected synchronized void clearChanged()
+  {
+    changed = false;
+  }
+
+  /**
+   * Returns the number of observers for this object.
+   *
+   * @return number of Observers for this
+   */
+  public synchronized int countObservers()
+  {
+    return observers.size();
+  }
+
+  /**
+   * Deletes an Observer of this Observable.
+   *
+   * @param victim Observer to delete
+   */
+  public synchronized void deleteObserver(Observer victim)
+  {
+    observers.remove(victim);
+  }
+
+  /**
+   * Deletes all Observers of this Observable.
+   */
+  public synchronized void deleteObservers()
+  {
+    observers.clear();
+  }
+
+  /**
+   * True if <code>setChanged</code> has been called more recently than
+   * <code>clearChanged</code>.
+   *
+   * @return whether or not this Observable has changed
+   */
+  public synchronized boolean hasChanged()
+  {
+    return changed;
+  }
+
+  /**
+   * If the Observable has actually changed then tell all Observers about it,
+   * then reset state to unchanged.
+   *
+   * @see #notifyObservers(Object)
+   * @see Observer#update(Observable, Object)
+   */
+  public void notifyObservers()
+  {
+    notifyObservers(null);
+  }
+
+  /**
+   * If the Observable has actually changed then tell all Observers about it,
+   * then reset state to unchanged. Note that though the order of
+   * notification is unspecified in subclasses, in Observable it is in the
+   * order of registration.
+   *
+   * @param obj argument to Observer's update method
+   * @see Observer#update(Observable, Object)
+   */
+  public void notifyObservers(Object obj)
+  {
+    if (! hasChanged())
+      return;
+    // Create clone inside monitor, as that is relatively fast and still
+    // important to keep threadsafe, but update observers outside of the
+    // lock since update() can call arbitrary code.
+    Set s;
+    synchronized (this)
+      {
+        s = (Set) observers.clone();
+      }
+    int i = s.size();
+    Iterator iter = s.iterator();
+    while (--i >= 0)
+      ((Observer) iter.next()).update(this, obj);
+    clearChanged();
+  }
+
+  /**
+   * Marks this Observable as having changed.
+   */
+  protected synchronized void setChanged()
+  {
+    changed = true;
+  }
 }
-
Index: kaffe/libraries/javalib/java/util/Properties.java
diff -u kaffe/libraries/javalib/java/util/Properties.java:1.21 kaffe/libraries/javalib/java/util/Properties.java:1.22
--- kaffe/libraries/javalib/java/util/Properties.java:1.21	Thu Mar 28 11:24:13 2002
+++ kaffe/libraries/javalib/java/util/Properties.java	Wed Mar 17 02:53:12 2004
@@ -1,345 +1,577 @@
+/* Properties.java -- a set of persistent properties
+   Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 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., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 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. */
 
-/*
- * Java core library component.
- *
- * Copyright (c) 1997, 1998
- *      Transvirtual Technologies, Inc.  All rights reserved.
- *
- * See the file "license.terms" for information on usage and redistribution
- * of this file.
- */
 
 package java.util;
 
 import java.io.IOException;
 import java.io.InputStream;
+import java.io.BufferedReader;
+import java.io.InputStreamReader;
 import java.io.OutputStream;
-import java.io.PrintStream;
 import java.io.PrintWriter;
-import java.io.PushbackInputStream;
-
-public class Properties extends Hashtable {
-	private static final long serialVersionUID = 4112578634029874840L;
-	protected Properties defaults;
-	private StringBuffer key, value;
-
-public Properties() {
-	this(null);
-}
-
-public Properties(Properties defaults) {
-	this.defaults=defaults;
-}
-
-private static String escape(String str, boolean isKey) {
-	StringBuffer sb = new StringBuffer();
-	for (int pos = 0; pos < str.length(); pos++) {
-		char ch = str.charAt(pos);
-		switch (ch) {
-		case '!':
-		case '#':
-			if (pos == 0)
-				sb.append("\\");
-			sb.append(ch);
-			break;
-		case ':':
-		case '=':
-		case ' ':
-			if (!isKey) {
-				sb.append(ch);
-				break;
-			}			// fall through
-		case '\\':
-			sb.append("\\" + ch);
-			break;
-		case '\n':
-			sb.append("\\n");
-			break;
-		case '\t':
-			sb.append("\\t");
-			break;
-		case '\r':
-			sb.append("\\r");
-			break;
-		default:
-			if (ch < 0x20 || ch > 0x7e) {
-				sb.append("\\u");
-				sb.append(Character.forDigit((ch >> 12) & 0xf, 16));
-				sb.append(Character.forDigit((ch >> 8) & 0xf, 16));
-				sb.append(Character.forDigit((ch >> 4) & 0xf, 16));
-				sb.append(Character.forDigit(ch & 0xf, 16));
-			} else
-				sb.append(ch);
-			break;
-		}
-	}
-
-	return sb.toString();
-}
-
-public String getProperty(String key) {
-	// Apparently we should use the superclass get method rather than
-	// our own because it may be overridden
-	// Software: HotJava
-  // if (System.out != null) System.out.println("getProperty: " + key);
-	if( key == null )
-		return null;
-	Object propSearch = super.get(key);
-	if (propSearch != null) {
-		return ((String)propSearch);
-	}
-	else if (defaults != null) {
-		return (defaults.getProperty(key));
-	}
-	else {
-		return (null);
-	}
-}
-
-public String getProperty(String key, String defaultValue) {
-	String result=getProperty(key);
-
-	if (result==null) return defaultValue; else return result;
-}
-
-public Object setProperty(String key, String value) {
-	return super.put(key, value);
-}
-
-public void list(PrintStream out) {
-	list(new PrintWriter(out, true));
-}
-
-public void list(PrintWriter out) {
-	try {
-		save(out, "Properties list");
-	} catch (IOException _) { 
-		System.err.println("unable to list properties");
-	}
-}
-
-public Enumeration propertyNames() {
-	SortedSet nameSet = new TreeSet();	// sort keys just for fun
-
-	// Add main properties
-	for (Enumeration e = keys(); e.hasMoreElements(); ) {
-		nameSet.add(e.nextElement());
-	}
-
-	// Add non-overridden default properties
-	if (defaults != null) {
-		for (Enumeration e = defaults.keys(); e.hasMoreElements(); ) {
-			Object def = e.nextElement();
-			if (!nameSet.contains(def))
-				nameSet.add(def);
-		}
-	}
-
-	// Return enumeration of vector
-	return Collections.enumeration(nameSet);
-}
-
-public synchronized void load(InputStream in) throws IOException {
-	PushbackInputStream pin = new PushbackInputStream(in, 16);
-
-	while (readKeyAndValue(pin)) {
-		put(key.toString(), value.toString());
-	}
-	key = null;
-	value = null;
-	//pin.close(); ??
-}
-
-private boolean readKeyAndValue(PushbackInputStream in) throws IOException {
-	int ch;
-
-	while (true) {
-		// Eat initial white space
-		while ((ch = in.read()) != -1 && ch <= ' ');
-
-		// Skip comments
-		switch (ch) {
-			case '#':
-			case '!':
-				while ((ch = in.read()) != -1 && ch != '\n');
-				continue;
-			case -1:
-				return false;
-		}
-
-		// Initialize
-		this.key = new StringBuffer();
-		this.value = new StringBuffer();
-
-		// Read in key
-		boolean eatSeparator = false;
-getKey:		while (true) {
-			switch (ch) {
-			case '=':
-			case ':':
-				break getKey;
-			case '\r':
-				switch ((ch = in.read())) {
-				case '\n':
-					break;
-				case -1:
-					return true;
-				default:
-					in.unread(ch);
-					break getKey;
-				}				// fall through
-			case -1:
-			case '\n':
-				return true;
-			default:
-				if (ch <= ' ') {
-					eatSeparator = true;
-					break getKey;
-				}
-				in.unread(ch);
-				key.append((char) getEscapedChar(in));
-			}
-			ch = in.read();
-		}
-
-		// Eat white space (and separator, if expecting) before value
-		while (true) {
-			while ((ch = in.read()) <= ' ') {
-				if (ch == -1 || ch == '\n')
-					return true;
-			}
-			if (eatSeparator && (ch == '=' || ch == ':')) {
-				eatSeparator = false;
-			} else {
-				break;
-			}
-		}
-
-		// Read in value
-		while (true) {
-			switch (ch) {
-			case '\r':
-				switch ((ch = in.read())) {
-				case -1:
-					value.append('\r');	// fall through
-				case '\n':
-					return true;
-				default:
-					in.unread(ch);
-					value.append('\r');
-					break;
-				}
-				break;
-			case -1:
-			case '\n':
-				return true;
-			default:
-				in.unread(ch);
-				value.append((char) getEscapedChar(in));
-				break;
-			}
-			ch = in.read();
-		}
-	}
-}
-
-// Get next char, respecting backslash escape codes and end-of-line stuff
-private static int getEscapedChar(PushbackInputStream in) throws IOException {
-	int ch;
-	switch ((ch = in.read())) {
-	case '\\':
-		switch ((ch = in.read())) {
-		case '\r':
-			switch ((ch = in.read())) {
-			default:
-				in.unread(ch);		// fall through
-			case -1:
-				in.unread('\r');
-				return '\\';
-			case '\n':
-				break;
-			}				// fall through
-		case '\n':				// line continuation
-			while ((ch = in.read()) != -1 && ch <= ' ');
-			in.unread(ch);
-			return getEscapedChar(in);
-		case 'n':
-			return '\n';
-		case 'r':
-			return '\r';
-		case 't':
-			return '\t';
-		case 'u':
-			{
-				int[] dig = new int[4];
-				int n;
-			    getUnicode:
-				{
-					int dval, cval = 0;
-					for (n = 0; n < 4; ) {
-						if ((dig[n] = in.read()) == -1)
-							break getUnicode;
-						if ((dval = Character.digit(
-						    (char) dig[n++], 16)) == -1)
-							break getUnicode;
-						cval = (cval << 4) | dval;
-					}
-					return cval;
-				}
-				// not unreachable, break getUnicode go here
-				while (n > 0)
-				    in.unread(dig[--n]);
-				return 'u';
-			}
-
-		// not fall through, previous switch always return
-		case -1:
-			return '\\';
-		default:
-			return ch;
-		}
-	// not fall through, previous switch always return
-	case '\r':
-		switch ((ch = in.read())) {
-		default:
-			in.unread(ch);		// fall through
-		case -1:
-			return '\r';
-		case '\n':
-			break;
-		}				// fall through
-	default:
-		return ch;
-	}
-}
-
-public synchronized void save(OutputStream out, String header) {
-	try {
-		store(out, header);
-	}
-	catch (IOException e) {
-		System.err.println("Unable to save properties: "+header);
-	}
-}
-
-public synchronized void store(OutputStream out, String header) throws IOException {
-	save(new PrintWriter(out, true), header);
-}
-
-// NB: use a PrintWriter here to get platform-specific line separator
-private synchronized void save(PrintWriter out, String header) throws IOException {
-	if (header != null) {
-		out.println("# " + escape(header, false));
-	}
-
-	Enumeration keys = propertyNames();
-
-	while (keys.hasMoreElements()) {
-		String key=(String)keys.nextElement();
-		out.println(escape(key, true)
-			+ "=" + escape(getProperty(key), false));
-	}
-	out.flush();	// shouldn't be necessary
-}
-}
+import java.io.PrintStream;
+import java.io.OutputStreamWriter;
 
+/**
+ * A set of persistent properties, which can be saved or loaded from a stream.
+ * A property list may also contain defaults, searched if the main list
+ * does not contain a property for a given key.
+ *
+ * An example of a properties file for the german language is given
+ * here.  This extends the example given in ListResourceBundle.
+ * Create a file MyResource_de.properties with the following contents
+ * and put it in the CLASSPATH.  (The character
+ * <code>\</code><code>u00e4</code> is the german umlaut)
+ *
+ * 
+<pre>s1=3
+s2=MeineDisk
+s3=3. M\<code></code>u00e4rz 96
+s4=Die Diskette ''{1}'' enth\<code></code>u00e4lt {0} in {2}.
+s5=0
+s6=keine Dateien
+s7=1
+s8=eine Datei
+s9=2
+s10={0,number} Dateien
+s11=Das Formatieren schlug fehl mit folgender Exception: {0}
+s12=FEHLER
+s13=Ergebnis
+s14=Dialog
+s15=Auswahlkriterium
+s16=1,3</pre>
+ *
+ * <p>Although this is a sub class of a hash table, you should never
+ * insert anything other than strings to this property, or several
+ * methods, that need string keys and values, will fail.  To ensure
+ * this, you should use the <code>get/setProperty</code> method instead
+ * of <code>get/put</code>.
+ *
+ * Properties are saved in ISO 8859-1 encoding, using Unicode escapes with
+ * a single <code>u</code> for any character which cannot be represented.
+ *
+ * @author Jochen Hoenicke
+ * @author Eric Blake <ebb9 at email.byu.edu>
+ * @see PropertyResourceBundle
+ * @status updated to 1.4
+ */
+public class Properties extends Hashtable
+{
+  // WARNING: Properties is a CORE class in the bootstrap cycle. See the
+  // comments in vm/reference/java/lang/Runtime for implications of this fact.
+
+  /**
+   * The property list that contains default values for any keys not
+   * in this property list.
+   *
+   * @serial the default properties
+   */
+  protected Properties defaults;
+
+  /**
+   * Compatible with JDK 1.0+.
+   */
+  private static final long serialVersionUID = 4112578634029874840L;
+
+  /**
+   * Creates a new empty property list with no default values.
+   */
+  public Properties()
+  {
+  }
+
+  /**
+   * Create a new empty property list with the specified default values.
+   *
+   * @param defaults a Properties object containing the default values
+   */
+  public Properties(Properties defaults)
+  {
+    this.defaults = defaults;
+  }
+
+  /**
+   * Adds the given key/value pair to this properties.  This calls
+   * the hashtable method put.
+   *
+   * @param key the key for this property
+   * @param value the value for this property
+   * @return The old value for the given key
+   * @see #getProperty(String)
+   * @since 1.2
+   */
+  public Object setProperty(String key, String value)
+  {
+    return put(key, value);
+  }
+
+  /**
+   * Reads a property list from an input stream.  The stream should
+   * have the following format: <br>
+   *
+   * An empty line or a line starting with <code>#</code> or
+   * <code>!</code> is ignored.  An backslash (<code>\</code>) at the
+   * end of the line makes the line continueing on the next line
+   * (but make sure there is no whitespace after the backslash).
+   * Otherwise, each line describes a key/value pair. <br>
+   *
+   * The chars up to the first whitespace, = or : are the key.  You
+   * can include this caracters in the key, if you precede them with
+   * a backslash (<code>\</code>). The key is followed by optional
+   * whitespaces, optionally one <code>=</code> or <code>:</code>,
+   * and optionally some more whitespaces.  The rest of the line is
+   * the resource belonging to the key. <br>
+   *
+   * Escape sequences <code>\t, \n, \r, \\, \", \', \!, \#, \ </code>(a
+   * space), and unicode characters with the
+   * <code>\\u</code><em>xxxx</em> notation are detected, and
+   * converted to the corresponding single character. <br>
+   *
+   * 
+<pre># This is a comment
+key     = value
+k\:5      \ a string starting with space and ending with newline\n
+# This is a multiline specification; note that the value contains
+# no white space.
+weekdays: Sunday,Monday,Tuesday,Wednesday,\\
+          Thursday,Friday,Saturday
+# The safest way to include a space at the end of a value:
+label   = Name:\\u0020</pre>
+   *
+   * @param in the input stream
+   * @throws IOException if an error occurred when reading the input
+   * @throws NullPointerException if in is null
+   */
+  public void load(InputStream inStream) throws IOException
+  {
+    // The spec says that the file must be encoded using ISO-8859-1.
+    BufferedReader reader =
+      new BufferedReader(new InputStreamReader(inStream, "ISO-8859-1"));
+    String line;
+
+    while ((line = reader.readLine()) != null)
+      {
+        char c = 0;
+        int pos = 0;
+        // If empty line or begins with a comment character, skip this line.
+        if (line.length() == 0
+	    || line.charAt(0) == '#' || line.charAt(0) == '!')
+          continue;
+
+        while (pos < line.length()
+               && Character.isWhitespace(c = line.charAt(pos)))
+          pos++;
+
+        // If line is empty skip this line.
+        if (pos == line.length())
+          continue;
+
+        // The characters up to the next Whitespace, ':', or '='
+        // describe the key.  But look for escape sequences.
+        StringBuffer key = new StringBuffer();
+        while (pos < line.length()
+               && ! Character.isWhitespace(c = line.charAt(pos++))
+               && c != '=' && c != ':')
+          {
+            if (c == '\\')
+              {
+                if (pos == line.length())
+                  {
+                    // The line continues on the next line.
+                    line = reader.readLine();
+                    pos = 0;
+                    while (pos < line.length()
+                           && Character.isWhitespace(c = line.charAt(pos)))
+                      pos++;
+                  }
+                else
+                  {
+                    c = line.charAt(pos++);
+                    switch (c)

*** Patch too long, truncated ***




More information about the kaffe mailing list