Merge remote branch 'origin/master' into openjdk

Conflicts:
	classpath/java/lang/String.java
	src/posix.cpp
This commit is contained in:
Joel Dice
2010-11-03 11:54:41 -06:00
25 changed files with 345 additions and 33 deletions

View File

@ -148,5 +148,11 @@ public class Arrays {
array[i] = value;
}
}
public static <T> void fill(T[] array, T value) {
for (int i=0;i<array.length;i++) {
array[i] = value;
}
}
}

View File

@ -11,6 +11,7 @@
package java.util;
public class Collections {
private Collections() { }
public static void shuffle(List list, Random random) {
@ -84,6 +85,10 @@ public class Collections {
return new IteratorEnumeration<T> (c.iterator());
}
public static <T> Comparator<T> reverseOrder(Comparator<T> cmp) {
return new ReverseComparator<T>(cmp);
}
static class IteratorEnumeration<T> implements Enumeration<T> {
private final Iterator<T> it;
@ -379,4 +384,20 @@ public class Collections {
it.remove();
}
}
private static final class ReverseComparator<T> implements Comparator<T> {
Comparator<T> cmp;
public ReverseComparator(Comparator<T> cmp) {
this.cmp = cmp;
}
@Override
public int compare(T o1, T o2) {
return - cmp.compare(o1, o2);
}
}
}

View File

@ -0,0 +1,47 @@
/* Copyright (c) 2010, Avian Contributors
Permission to use, copy, modify, and/or distribute this software
for any purpose with or without fee is hereby granted, provided
that the above copyright notice and this permission notice appear
in all copies.
There is NO WARRANTY for this software. See license.txt for
details. */
package java.util;
/**
* @author zsombor
*
*/
public class ConcurrentModificationException extends RuntimeException {
/**
* @param message
* @param cause
*/
public ConcurrentModificationException(String message, Throwable cause) {
super(message, cause);
}
/**
* @param message
*/
public ConcurrentModificationException(String message) {
super(message);
}
/**
* @param cause
*/
public ConcurrentModificationException(Throwable cause) {
super(cause);
}
/**
*
*/
public ConcurrentModificationException() {
}
}

View File

@ -269,8 +269,10 @@ public class HashMap<K, V> implements Map<K, V> {
return value;
}
public void setValue(V value) {
public V setValue(V value) {
V old = this.value;
this.value = value;
return old;
}
public HashMap.Cell<K, V> next() {

View File

@ -40,6 +40,6 @@ public interface Map<K, V> {
public V getValue();
public void setValue(V value);
public V setValue(V value);
}
}

View File

@ -14,10 +14,15 @@ import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintStream;
import java.io.IOException;
import java.io.Reader;
public class Properties extends Hashtable {
public void load(InputStream in) throws IOException {
new Parser().parse(in, this);
new InputStreamParser(in).parse(this);
}
public void load(Reader reader) throws IOException {
new ReaderParser(reader).parse(this);
}
public void store(OutputStream out, String comment) throws IOException {
@ -53,7 +58,7 @@ public class Properties extends Hashtable {
return keys();
}
private static class Parser {
private abstract static class Parser {
private StringBuilder key = null;
private StringBuilder value = null;
private StringBuilder current = null;
@ -79,13 +84,15 @@ public class Properties extends Hashtable {
key = value = current = null;
}
private void parse(InputStream in, Map map)
abstract int readCharacter() throws IOException;
void parse(Map map)
throws IOException
{
boolean escaped = false;
int c;
while ((c = in.read()) != -1) {
while ((c = readCharacter()) != -1) {
if (c == '\\') {
if (escaped) {
escaped = false;
@ -98,7 +105,7 @@ public class Properties extends Hashtable {
case '#':
case '!':
if (key == null) {
while ((c = in.read()) != -1 && c != '\n');
while ((c = readCharacter()) != -1 && c != '\n');
} else {
append(c);
}
@ -153,4 +160,32 @@ public class Properties extends Hashtable {
finishLine(map);
}
}
static class InputStreamParser extends Parser {
InputStream in;
public InputStreamParser(InputStream in) {
this.in = in;
}
@Override
int readCharacter() throws IOException {
return in.read();
}
}
static class ReaderParser extends Parser {
Reader in;
public ReaderParser(Reader in) {
this.in = in;
}
@Override
int readCharacter() throws IOException {
return in.read();
}
}
}

View File

@ -112,9 +112,12 @@ public class TreeMap<K,V> implements Map<K,V> {
return value;
}
public void setValue(V value) {
public V setValue(V value) {
V old = this.value;
this.value = value;
return old;
}
}
private class KeySet implements Set<K> {

View File

@ -114,8 +114,10 @@ public class WeakHashMap<K, V> implements Map<K, V> {
return value;
}
public void setValue(V value) {
public V setValue(V value) {
V old = this.value;
this.value = value;
return old;
}
public HashMap.Cell<K, V> next() {