You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by te...@apache.org on 2007/01/02 17:22:07 UTC
svn commit: r491834 [6/7] - in
/harmony/enhanced/classlib/trunk/modules/luni/src/main/java: java/net/
java/util/ org/apache/harmony/luni/internal/nls/
org/apache/harmony/luni/internal/reflect/ org/apache/harmony/luni/net/
Modified: harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/Hashtable.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/Hashtable.java?view=diff&rev=491834&r1=491833&r2=491834
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/Hashtable.java (original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/Hashtable.java Tue Jan 2 08:22:05 2007
@@ -17,12 +17,13 @@
package java.util;
-
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;
+import org.apache.harmony.luni.internal.nls.Messages;
+
/**
* Hashtable associates keys with values. Keys and values cannot be null. The
* size of the Hashtable is the number of key/value pairs it contains. The
@@ -37,473 +38,479 @@
* @see java.lang.Object#hashCode
*/
-public class Hashtable<K,V> extends Dictionary<K,V> implements Map<K,V>, Cloneable,
- Serializable {
+public class Hashtable<K, V> extends Dictionary<K, V> implements Map<K, V>,
+ Cloneable, Serializable {
- private static final long serialVersionUID = 1421746759512286392L;
+ private static final long serialVersionUID = 1421746759512286392L;
- transient int elementCount;
+ transient int elementCount;
- transient Entry<K, V>[] elementData;
+ transient Entry<K, V>[] elementData;
- private float loadFactor;
+ private float loadFactor;
- private int threshold;
+ private int threshold;
- transient int firstSlot;
+ transient int firstSlot;
- transient int lastSlot = -1;
+ transient int lastSlot = -1;
- transient int modCount;
+ transient int modCount;
- private static final Enumeration<?> EMPTY_ENUMERATION = new Enumeration<Object>() {
+ private static final Enumeration<?> EMPTY_ENUMERATION = new Enumeration<Object>() {
public boolean hasMoreElements() {
return false;
}
-
+
public Object nextElement() {
throw new NoSuchElementException();
}
};
- private static <K, V> Entry<K, V> newEntry(K key, V value, int hash) {
- return new Entry<K, V>(key, value);
- }
-
- private static class Entry<K,V> extends MapEntry<K,V> {
- Entry<K, V> next;
-
- final int hashcode;
-
- Entry(K theKey, V theValue) {
- super(theKey, theValue);
- hashcode = theKey.hashCode();
- }
+ private static <K, V> Entry<K, V> newEntry(K key, V value, int hash) {
+ return new Entry<K, V>(key, value);
+ }
+
+ private static class Entry<K, V> extends MapEntry<K, V> {
+ Entry<K, V> next;
+
+ final int hashcode;
- @Override
+ Entry(K theKey, V theValue) {
+ super(theKey, theValue);
+ hashcode = theKey.hashCode();
+ }
+
+ @Override
@SuppressWarnings("unchecked")
public Object clone() {
- Entry<K, V> entry = (Entry<K, V>) super.clone();
- if (next != null) {
+ Entry<K, V> entry = (Entry<K, V>) super.clone();
+ if (next != null) {
entry.next = (Entry<K, V>) next.clone();
}
- return entry;
- }
+ return entry;
+ }
- @Override
+ @Override
public V setValue(V object) {
- if (object == null) {
+ if (object == null) {
throw new NullPointerException();
}
- V result = value;
- value = object;
- return result;
- }
-
- public int getKeyHash() {
- return key.hashCode();
- }
-
- public boolean equalsKey(Object aKey, int hash) {
- return hashcode == aKey.hashCode() && key.equals(aKey);
- }
+ V result = value;
+ value = object;
+ return result;
+ }
+
+ public int getKeyHash() {
+ return key.hashCode();
+ }
+
+ public boolean equalsKey(Object aKey, int hash) {
+ return hashcode == aKey.hashCode() && key.equals(aKey);
+ }
- @Override
+ @Override
public String toString() {
- return key + "=" + value;
- }
- }
+ return key + "=" + value; //$NON-NLS-1$
+ }
+ }
- private final class HashIterator<E> implements Iterator<E> {
- private int position, expectedModCount;
+ private final class HashIterator<E> implements Iterator<E> {
+ private int position, expectedModCount;
- private final MapEntry.Type<E, K, V> type;
+ private final MapEntry.Type<E, K, V> type;
- private Entry<K, V> lastEntry;
+ private Entry<K, V> lastEntry;
- private int lastPosition;
+ private int lastPosition;
- private boolean canRemove = false;
+ private boolean canRemove = false;
- HashIterator(MapEntry.Type<E, K, V> value) {
- type = value;
- position = lastSlot;
- expectedModCount = modCount;
- }
+ HashIterator(MapEntry.Type<E, K, V> value) {
+ type = value;
+ position = lastSlot;
+ expectedModCount = modCount;
+ }
- public boolean hasNext() {
- if (lastEntry != null && lastEntry.next != null) {
- return true;
- }
- while (position >= firstSlot) {
- if (elementData[position] == null) {
+ public boolean hasNext() {
+ if (lastEntry != null && lastEntry.next != null) {
+ return true;
+ }
+ while (position >= firstSlot) {
+ if (elementData[position] == null) {
position--;
} else {
return true;
}
- }
- return false;
- }
-
- public E next() {
- if (expectedModCount == modCount) {
- if (lastEntry != null) {
- lastEntry = lastEntry.next;
- }
- if (lastEntry == null) {
- while (position >= firstSlot
- && (lastEntry = elementData[position]) == null) {
- position--;
- }
- if (lastEntry != null) {
- lastPosition = position;
- // decrement the position so we don't find the same slot
- // next time
- position--;
- }
- }
- if (lastEntry != null) {
- canRemove = true;
- return type.get(lastEntry);
- }
- throw new NoSuchElementException();
- }
+ }
+ return false;
+ }
+
+ public E next() {
+ if (expectedModCount == modCount) {
+ if (lastEntry != null) {
+ lastEntry = lastEntry.next;
+ }
+ if (lastEntry == null) {
+ while (position >= firstSlot
+ && (lastEntry = elementData[position]) == null) {
+ position--;
+ }
+ if (lastEntry != null) {
+ lastPosition = position;
+ // decrement the position so we don't find the same slot
+ // next time
+ position--;
+ }
+ }
+ if (lastEntry != null) {
+ canRemove = true;
+ return type.get(lastEntry);
+ }
+ throw new NoSuchElementException();
+ }
throw new ConcurrentModificationException();
- }
+ }
- public void remove() {
- if (expectedModCount == modCount) {
- if (canRemove) {
- canRemove = false;
- synchronized (Hashtable.this) {
- boolean removed = false;
- Entry<K, V> entry = elementData[lastPosition];
- if (entry == lastEntry) {
- elementData[lastPosition] = entry.next;
- removed = true;
- } else {
- while (entry != null && entry.next != lastEntry) {
- entry = entry.next;
- }
- if (entry != null) {
- entry.next = lastEntry.next;
- removed = true;
- }
- }
- if (removed) {
- modCount++;
- elementCount--;
- expectedModCount++;
- return;
- }
- // the entry must have been (re)moved outside of the
- // iterator
- // but this condition wasn't caught by the modCount
- // check
- // throw ConcurrentModificationException() outside of
- // synchronized block
- }
- } else {
+ public void remove() {
+ if (expectedModCount == modCount) {
+ if (canRemove) {
+ canRemove = false;
+ synchronized (Hashtable.this) {
+ boolean removed = false;
+ Entry<K, V> entry = elementData[lastPosition];
+ if (entry == lastEntry) {
+ elementData[lastPosition] = entry.next;
+ removed = true;
+ } else {
+ while (entry != null && entry.next != lastEntry) {
+ entry = entry.next;
+ }
+ if (entry != null) {
+ entry.next = lastEntry.next;
+ removed = true;
+ }
+ }
+ if (removed) {
+ modCount++;
+ elementCount--;
+ expectedModCount++;
+ return;
+ }
+ // the entry must have been (re)moved outside of the
+ // iterator
+ // but this condition wasn't caught by the modCount
+ // check
+ // throw ConcurrentModificationException() outside of
+ // synchronized block
+ }
+ } else {
throw new IllegalStateException();
}
- }
- throw new ConcurrentModificationException();
- }
- }
+ }
+ throw new ConcurrentModificationException();
+ }
+ }
- private final class HashEnumerator<E> implements Enumeration<E> {
- boolean key;
+ private final class HashEnumerator<E> implements Enumeration<E> {
+ boolean key;
- int start;
+ int start;
- Entry<K, V> entry;
+ Entry<K, V> entry;
- HashEnumerator(boolean isKey) {
- key = isKey;
- start = lastSlot + 1;
- }
+ HashEnumerator(boolean isKey) {
+ key = isKey;
+ start = lastSlot + 1;
+ }
- public boolean hasMoreElements() {
- if (entry != null) {
+ public boolean hasMoreElements() {
+ if (entry != null) {
return true;
}
- while (--start >= firstSlot) {
+ while (--start >= firstSlot) {
if (elementData[start] != null) {
- entry = elementData[start];
- return true;
- }
+ entry = elementData[start];
+ return true;
+ }
}
- return false;
- }
+ return false;
+ }
- @SuppressWarnings("unchecked")
+ @SuppressWarnings("unchecked")
public E nextElement() {
- if (hasMoreElements()) {
- Object result = key ? entry.key : entry.value;
- entry = entry.next;
- return (E)result;
- }
+ if (hasMoreElements()) {
+ Object result = key ? entry.key : entry.value;
+ entry = entry.next;
+ return (E) result;
+ }
throw new NoSuchElementException();
- }
- }
+ }
+ }
- /**
- * Constructs a new Hashtable using the default capacity and load factor.
- */
- public Hashtable() {
- this(11);
- }
-
- /**
- * Constructs a new Hashtable using the specified capacity and the default
- * load factor.
- *
- * @param capacity
- * the initial capacity
- */
- public Hashtable(int capacity) {
- if (capacity >= 0) {
- elementCount = 0;
- elementData = newElementArray(capacity == 0 ? 1 : capacity);
- firstSlot = elementData.length;
- loadFactor = 0.75f;
- computeMaxSize();
- } else {
+ /**
+ * Constructs a new Hashtable using the default capacity and load factor.
+ */
+ public Hashtable() {
+ this(11);
+ }
+
+ /**
+ * Constructs a new Hashtable using the specified capacity and the default
+ * load factor.
+ *
+ * @param capacity
+ * the initial capacity
+ */
+ public Hashtable(int capacity) {
+ if (capacity >= 0) {
+ elementCount = 0;
+ elementData = newElementArray(capacity == 0 ? 1 : capacity);
+ firstSlot = elementData.length;
+ loadFactor = 0.75f;
+ computeMaxSize();
+ } else {
throw new IllegalArgumentException();
}
- }
+ }
- /**
- * Constructs a new Hashtable using the specified capacity and load factor.
- *
- * @param capacity
- * the initial capacity
- * @param loadFactor
- * the initial load factor
- */
- public Hashtable(int capacity, float loadFactor) {
- if (capacity >= 0 && loadFactor > 0) {
- elementCount = 0;
- firstSlot = capacity;
- elementData = newElementArray(capacity == 0 ? 1 : capacity);
- this.loadFactor = loadFactor;
- computeMaxSize();
- } else {
+ /**
+ * Constructs a new Hashtable using the specified capacity and load factor.
+ *
+ * @param capacity
+ * the initial capacity
+ * @param loadFactor
+ * the initial load factor
+ */
+ public Hashtable(int capacity, float loadFactor) {
+ if (capacity >= 0 && loadFactor > 0) {
+ elementCount = 0;
+ firstSlot = capacity;
+ elementData = newElementArray(capacity == 0 ? 1 : capacity);
+ this.loadFactor = loadFactor;
+ computeMaxSize();
+ } else {
throw new IllegalArgumentException();
}
- }
+ }
- /**
- * Constructs a new instance of Hashtable containing the mappings from the
- * specified Map.
- *
- * @param map
- * the mappings to add
- */
- public Hashtable(Map<? extends K, ? extends V> map) {
- this(map.size() < 6 ? 11 : (map.size() * 4 / 3) + 11);
- putAll(map);
- }
+ /**
+ * Constructs a new instance of Hashtable containing the mappings from the
+ * specified Map.
+ *
+ * @param map
+ * the mappings to add
+ */
+ public Hashtable(Map<? extends K, ? extends V> map) {
+ this(map.size() < 6 ? 11 : (map.size() * 4 / 3) + 11);
+ putAll(map);
+ }
@SuppressWarnings("unchecked")
private Entry<K, V>[] newElementArray(int size) {
return new Entry[size];
}
- /**
- * Removes all key/value pairs from this Hashtable, leaving the size zero
- * and the capacity unchanged.
- *
- * @see #isEmpty
- * @see #size
- */
- public synchronized void clear() {
- elementCount = 0;
- Arrays.fill(elementData, null);
- modCount++;
- }
-
- /**
- * Answers a new Hashtable with the same key/value pairs, capacity and load
- * factor.
- *
- * @return a shallow copy of this Hashtable
- *
- * @see java.lang.Cloneable
- */
- @Override
+ /**
+ * Removes all key/value pairs from this Hashtable, leaving the size zero
+ * and the capacity unchanged.
+ *
+ * @see #isEmpty
+ * @see #size
+ */
+ public synchronized void clear() {
+ elementCount = 0;
+ Arrays.fill(elementData, null);
+ modCount++;
+ }
+
+ /**
+ * Answers a new Hashtable with the same key/value pairs, capacity and load
+ * factor.
+ *
+ * @return a shallow copy of this Hashtable
+ *
+ * @see java.lang.Cloneable
+ */
+ @Override
@SuppressWarnings("unchecked")
public synchronized Object clone() {
- try {
- Hashtable<K, V> hashtable = (Hashtable<K, V>) super.clone();
- hashtable.elementData = elementData.clone();
- Entry<K, V> entry;
- for (int i = elementData.length; --i >= 0;) {
+ try {
+ Hashtable<K, V> hashtable = (Hashtable<K, V>) super.clone();
+ hashtable.elementData = elementData.clone();
+ Entry<K, V> entry;
+ for (int i = elementData.length; --i >= 0;) {
if ((entry = elementData[i]) != null) {
hashtable.elementData[i] = (Entry<K, V>) entry.clone();
}
}
- return hashtable;
- } catch (CloneNotSupportedException e) {
- return null;
- }
- }
-
- private void computeMaxSize() {
- threshold = (int) (elementData.length * loadFactor);
- }
-
- /**
- * Answers if this Hashtable contains the specified object as the value of
- * at least one of the key/value pairs.
- *
- * @param value
- * the object to look for as a value in this Hashtable
- * @return true if object is a value in this Hashtable, false otherwise
- *
- * @see #containsKey
- * @see java.lang.Object#equals
- */
- public synchronized boolean contains(Object value) {
- if (value == null) {
+ return hashtable;
+ } catch (CloneNotSupportedException e) {
+ return null;
+ }
+ }
+
+ private void computeMaxSize() {
+ threshold = (int) (elementData.length * loadFactor);
+ }
+
+ /**
+ * Answers if this Hashtable contains the specified object as the value of
+ * at least one of the key/value pairs.
+ *
+ * @param value
+ * the object to look for as a value in this Hashtable
+ * @return true if object is a value in this Hashtable, false otherwise
+ *
+ * @see #containsKey
+ * @see java.lang.Object#equals
+ */
+ public synchronized boolean contains(Object value) {
+ if (value == null) {
throw new NullPointerException();
}
- for (int i = elementData.length; --i >= 0;) {
- Entry<K, V> entry = elementData[i];
- while (entry != null) {
- if (value.equals(entry.value)) {
- return true;
- }
- entry = entry.next;
- }
- }
- return false;
- }
-
- /**
- * Answers if this Hashtable contains the specified object as a key of one
- * of the key/value pairs.
- *
- * @param key
- * the object to look for as a key in this Hashtable
- * @return true if object is a key in this Hashtable, false otherwise
- *
- * @see #contains
- * @see java.lang.Object#equals
- */
- public synchronized boolean containsKey(Object key) {
- return getEntry(key) != null;
- }
-
- /**
- * Searches this Hashtable for the specified value.
- *
- * @param value
- * the object to search for
- * @return true if <code>value</code> is a value of this Hashtable, false
- * otherwise
- */
- public boolean containsValue(Object value) {
- return contains(value);
- }
-
- /**
- * Answers an Enumeration on the values of this Hashtable. The results of
- * the Enumeration may be affected if the contents of this Hashtable are
- * modified.
- *
- * @return an Enumeration of the values of this Hashtable
- *
- * @see #keys
- * @see #size
- * @see Enumeration
- */
- @Override
+ for (int i = elementData.length; --i >= 0;) {
+ Entry<K, V> entry = elementData[i];
+ while (entry != null) {
+ if (value.equals(entry.value)) {
+ return true;
+ }
+ entry = entry.next;
+ }
+ }
+ return false;
+ }
+
+ /**
+ * Answers if this Hashtable contains the specified object as a key of one
+ * of the key/value pairs.
+ *
+ * @param key
+ * the object to look for as a key in this Hashtable
+ * @return true if object is a key in this Hashtable, false otherwise
+ *
+ * @see #contains
+ * @see java.lang.Object#equals
+ */
+ public synchronized boolean containsKey(Object key) {
+ return getEntry(key) != null;
+ }
+
+ /**
+ * Searches this Hashtable for the specified value.
+ *
+ * @param value
+ * the object to search for
+ * @return true if <code>value</code> is a value of this Hashtable, false
+ * otherwise
+ */
+ public boolean containsValue(Object value) {
+ return contains(value);
+ }
+
+ /**
+ * Answers an Enumeration on the values of this Hashtable. The results of
+ * the Enumeration may be affected if the contents of this Hashtable are
+ * modified.
+ *
+ * @return an Enumeration of the values of this Hashtable
+ *
+ * @see #keys
+ * @see #size
+ * @see Enumeration
+ */
+ @Override
@SuppressWarnings("unchecked")
public synchronized Enumeration<V> elements() {
- if (elementCount == 0) {
- return (Enumeration<V>)EMPTY_ENUMERATION;
+ if (elementCount == 0) {
+ return (Enumeration<V>) EMPTY_ENUMERATION;
}
- return new HashEnumerator<V>(false);
- }
+ return new HashEnumerator<V>(false);
+ }
- /**
- * Answers a Set of the mappings contained in this Hashtable. Each element
- * in the set is a Map.Entry. The set is backed by this Hashtable so changes
- * to one are reflected by the other. The set does not support adding.
- *
- * @return a Set of the mappings
- */
- public Set<Map.Entry<K,V>> entrySet() {
- return new Collections.SynchronizedSet<Map.Entry<K, V>>(new AbstractSet<Map.Entry<K,V>>() {
- @Override
- public int size() {
- synchronized (Hashtable.this) {
- return elementCount;
- }
- }
+ /**
+ * Answers a Set of the mappings contained in this Hashtable. Each element
+ * in the set is a Map.Entry. The set is backed by this Hashtable so changes
+ * to one are reflected by the other. The set does not support adding.
+ *
+ * @return a Set of the mappings
+ */
+ public Set<Map.Entry<K, V>> entrySet() {
+ return new Collections.SynchronizedSet<Map.Entry<K, V>>(
+ new AbstractSet<Map.Entry<K, V>>() {
+ @Override
+ public int size() {
+ synchronized (Hashtable.this) {
+ return elementCount;
+ }
+ }
- @Override
- public void clear() {
- Hashtable.this.clear();
- }
+ @Override
+ public void clear() {
+ Hashtable.this.clear();
+ }
- @Override
- @SuppressWarnings("unchecked")
- public boolean remove(Object object) {
- synchronized (Hashtable.this) {
- if (contains(object)) {
- Hashtable.this.remove(((Map.Entry<K, V>)object).getKey());
- return true;
- }
- return false;
- }
- }
+ @Override
+ @SuppressWarnings("unchecked")
+ public boolean remove(Object object) {
+ synchronized (Hashtable.this) {
+ if (contains(object)) {
+ Hashtable.this
+ .remove(((Map.Entry<K, V>) object)
+ .getKey());
+ return true;
+ }
+ return false;
+ }
+ }
- @Override
- @SuppressWarnings("unchecked")
- public boolean contains(Object object) {
- synchronized (Hashtable.this) {
- Entry<K, V> entry = getEntry(((Map.Entry<K, V>)object).getKey());
- return object.equals(entry);
- }
- }
+ @Override
+ @SuppressWarnings("unchecked")
+ public boolean contains(Object object) {
+ synchronized (Hashtable.this) {
+ Entry<K, V> entry = getEntry(((Map.Entry<K, V>) object)
+ .getKey());
+ return object.equals(entry);
+ }
+ }
+
+ @Override
+ public Iterator<Map.Entry<K, V>> iterator() {
+ return new HashIterator<Map.Entry<K, V>>(
+ new MapEntry.Type<Map.Entry<K, V>, K, V>() {
+ public Map.Entry<K, V> get(
+ MapEntry<K, V> entry) {
+ return entry;
+ }
+ });
+ }
+ }, this);
+ }
- @Override
- public Iterator<Map.Entry<K,V>> iterator() {
- return new HashIterator<Map.Entry<K, V>>(new MapEntry.Type<Map.Entry<K, V>, K, V>() {
- public Map.Entry<K, V> get(MapEntry<K, V> entry) {
- return entry;
- }
- });
- }
- }, this);
- }
-
- /**
- * Compares the specified object to this Hashtable and answer if they are
- * equal. The object must be an instance of Map and contain the same
- * key/value pairs.
- *
- * @param object
- * the object to compare with this object
- * @return true if the specified object is equal to this Map, false
- * otherwise
- *
- * @see #hashCode
- */
- @Override
+ /**
+ * Compares the specified object to this Hashtable and answer if they are
+ * equal. The object must be an instance of Map and contain the same
+ * key/value pairs.
+ *
+ * @param object
+ * the object to compare with this object
+ * @return true if the specified object is equal to this Map, false
+ * otherwise
+ *
+ * @see #hashCode
+ */
+ @Override
public synchronized boolean equals(Object object) {
- if (this == object) {
+ if (this == object) {
return true;
}
- if (object instanceof Map) {
- Map<?, ?> map = (Map<?, ?>) object;
- if (size() != map.size()) {
+ if (object instanceof Map) {
+ Map<?, ?> map = (Map<?, ?>) object;
+ if (size() != map.size()) {
return false;
}
-
+
Set<Map.Entry<K, V>> entries = entrySet();
for (Map.Entry<?, ?> e : map.entrySet()) {
if (!entries.contains(e)) {
@@ -511,413 +518,415 @@
}
}
return true;
- }
- return false;
- }
-
- /**
- * Answers the value associated with the specified key in this Hashtable.
- *
- * @param key
- * the key of the value returned
- * @return the value associated with the specified key, null if the
- * specified key does not exist
- *
- * @see #put
- */
- @Override
+ }
+ return false;
+ }
+
+ /**
+ * Answers the value associated with the specified key in this Hashtable.
+ *
+ * @param key
+ * the key of the value returned
+ * @return the value associated with the specified key, null if the
+ * specified key does not exist
+ *
+ * @see #put
+ */
+ @Override
public synchronized V get(Object key) {
- int hash = key.hashCode();
- int index = (hash & 0x7FFFFFFF) % elementData.length;
- Entry<K,V> entry = elementData[index];
- while (entry != null) {
- if (entry.equalsKey(key, hash)) {
+ int hash = key.hashCode();
+ int index = (hash & 0x7FFFFFFF) % elementData.length;
+ Entry<K, V> entry = elementData[index];
+ while (entry != null) {
+ if (entry.equalsKey(key, hash)) {
return entry.value;
}
- entry = entry.next;
- }
- return null;
- }
-
- Entry<K, V> getEntry(Object key) {
- int hash = key.hashCode();
- int index = (hash & 0x7FFFFFFF) % elementData.length;
- Entry<K, V> entry = elementData[index];
- while (entry != null) {
- if (entry.equalsKey(key, hash)) {
+ entry = entry.next;
+ }
+ return null;
+ }
+
+ Entry<K, V> getEntry(Object key) {
+ int hash = key.hashCode();
+ int index = (hash & 0x7FFFFFFF) % elementData.length;
+ Entry<K, V> entry = elementData[index];
+ while (entry != null) {
+ if (entry.equalsKey(key, hash)) {
return entry;
}
- entry = entry.next;
- }
- return null;
- }
-
- /**
- * Answers an integer hash code for the receiver. Objects which are equal
- * answer the same value for this method.
- *
- * @return the receiver's hash
- *
- * @see #equals
- */
- @Override
+ entry = entry.next;
+ }
+ return null;
+ }
+
+ /**
+ * Answers an integer hash code for the receiver. Objects which are equal
+ * answer the same value for this method.
+ *
+ * @return the receiver's hash
+ *
+ * @see #equals
+ */
+ @Override
public synchronized int hashCode() {
- int result = 0;
- Iterator<Map.Entry<K, V>> it = entrySet().iterator();
- while (it.hasNext()) {
- Map.Entry<K, V> entry = it.next();
- Object key = entry.getKey();
- Object value = entry.getValue();
- int hash = (key != this ? key.hashCode() : 0)
- ^ (value != this ? (value != null ? value.hashCode() : 0)
- : 0);
- result += hash;
- }
- return result;
- }
-
- /**
- * Answers if this Hashtable has no key/value pairs, a size of zero.
- *
- * @return true if this Hashtable has no key/value pairs, false otherwise
- *
- * @see #size
- */
- @Override
+ int result = 0;
+ Iterator<Map.Entry<K, V>> it = entrySet().iterator();
+ while (it.hasNext()) {
+ Map.Entry<K, V> entry = it.next();
+ Object key = entry.getKey();
+ Object value = entry.getValue();
+ int hash = (key != this ? key.hashCode() : 0)
+ ^ (value != this ? (value != null ? value.hashCode() : 0)
+ : 0);
+ result += hash;
+ }
+ return result;
+ }
+
+ /**
+ * Answers if this Hashtable has no key/value pairs, a size of zero.
+ *
+ * @return true if this Hashtable has no key/value pairs, false otherwise
+ *
+ * @see #size
+ */
+ @Override
public synchronized boolean isEmpty() {
- return elementCount == 0;
- }
+ return elementCount == 0;
+ }
- /**
- * Answers an Enumeration on the keys of this Hashtable. The results of the
- * Enumeration may be affected if the contents of this Hashtable are
- * modified.
- *
- * @return an Enumeration of the keys of this Hashtable
- *
- * @see #elements
- * @see #size
- * @see Enumeration
- */
- @Override
+ /**
+ * Answers an Enumeration on the keys of this Hashtable. The results of the
+ * Enumeration may be affected if the contents of this Hashtable are
+ * modified.
+ *
+ * @return an Enumeration of the keys of this Hashtable
+ *
+ * @see #elements
+ * @see #size
+ * @see Enumeration
+ */
+ @Override
@SuppressWarnings("unchecked")
public synchronized Enumeration<K> keys() {
- if (elementCount == 0) {
- return (Enumeration<K>)EMPTY_ENUMERATION;
+ if (elementCount == 0) {
+ return (Enumeration<K>) EMPTY_ENUMERATION;
}
- return new HashEnumerator<K>(true);
- }
+ return new HashEnumerator<K>(true);
+ }
- /**
- * Answers a Set of the keys contained in this Hashtable. The set is backed
- * by this Hashtable so changes to one are reflected by the other. The set
- * does not support adding.
- *
- * @return a Set of the keys
- */
- public Set<K> keySet() {
- return new Collections.SynchronizedSet<K>(
- new AbstractSet<K>() {
- @Override
- public boolean contains(Object object) {
- synchronized (Hashtable.this) {
- return containsKey(object);
+ /**
+ * Answers a Set of the keys contained in this Hashtable. The set is backed
+ * by this Hashtable so changes to one are reflected by the other. The set
+ * does not support adding.
+ *
+ * @return a Set of the keys
+ */
+ public Set<K> keySet() {
+ return new Collections.SynchronizedSet<K>(new AbstractSet<K>() {
+ @Override
+ public boolean contains(Object object) {
+ synchronized (Hashtable.this) {
+ return containsKey(object);
+ }
+ }
+
+ @Override
+ public int size() {
+ synchronized (Hashtable.this) {
+ return elementCount;
+ }
+ }
+
+ @Override
+ public void clear() {
+ Hashtable.this.clear();
+ }
+
+ @Override
+ public boolean remove(Object key) {
+ synchronized (Hashtable.this) {
+ if (containsKey(key)) {
+ Hashtable.this.remove(key);
+ return true;
}
- }
-
- @Override
- public int size() {
- synchronized (Hashtable.this) {
- return elementCount;
+ return false;
+ }
+ }
+
+ @Override
+ public Iterator<K> iterator() {
+ return new HashIterator<K>(new MapEntry.Type<K, K, V>() {
+ public K get(MapEntry<K, V> entry) {
+ return entry.key;
}
- }
-
- @Override
- public void clear() {
- Hashtable.this.clear();
- }
-
- @Override
- public boolean remove(Object key) {
- synchronized (Hashtable.this) {
- if (containsKey(key)) {
- Hashtable.this.remove(key);
- return true;
- }
- return false;
- }
- }
-
- @Override
- public Iterator<K> iterator() {
- return new HashIterator<K>(
- new MapEntry.Type<K, K, V>() {
- public K get(MapEntry<K, V> entry) {
- return entry.key;
- }
- });
- }
- }, this);
- }
-
- /**
- * Associate the specified value with the specified key in this Hashtable.
- * If the key already exists, the old value is replaced. The key and value
- * cannot be null.
- *
- * @param key
- * the key to add
- * @param value
- * the value to add
- * @return the old value associated with the specified key, null if the key
- * did not exist
- *
- * @see #elements
- * @see #get
- * @see #keys
- * @see java.lang.Object#equals
- */
- @Override
+ });
+ }
+ }, this);
+ }
+
+ /**
+ * Associate the specified value with the specified key in this Hashtable.
+ * If the key already exists, the old value is replaced. The key and value
+ * cannot be null.
+ *
+ * @param key
+ * the key to add
+ * @param value
+ * the value to add
+ * @return the old value associated with the specified key, null if the key
+ * did not exist
+ *
+ * @see #elements
+ * @see #get
+ * @see #keys
+ * @see java.lang.Object#equals
+ */
+ @Override
public synchronized V put(K key, V value) {
- if (key != null && value != null) {
- int hash = key.hashCode();
- int index = (hash & 0x7FFFFFFF) % elementData.length;
- Entry<K,V> entry = elementData[index];
- while (entry != null && !entry.equalsKey(key, hash)) {
+ if (key != null && value != null) {
+ int hash = key.hashCode();
+ int index = (hash & 0x7FFFFFFF) % elementData.length;
+ Entry<K, V> entry = elementData[index];
+ while (entry != null && !entry.equalsKey(key, hash)) {
entry = entry.next;
}
- if (entry == null) {
- modCount++;
- if (++elementCount > threshold) {
- rehash();
- index = (hash & 0x7FFFFFFF) % elementData.length;
- }
- if (index < firstSlot) {
+ if (entry == null) {
+ modCount++;
+ if (++elementCount > threshold) {
+ rehash();
+ index = (hash & 0x7FFFFFFF) % elementData.length;
+ }
+ if (index < firstSlot) {
firstSlot = index;
}
- if (index > lastSlot) {
+ if (index > lastSlot) {
lastSlot = index;
}
- entry = newEntry(key, value, hash);
- entry.next = elementData[index];
- elementData[index] = entry;
- return null;
- }
- V result = entry.value;
- entry.value = value;
- return result;
- }
+ entry = newEntry(key, value, hash);
+ entry.next = elementData[index];
+ elementData[index] = entry;
+ return null;
+ }
+ V result = entry.value;
+ entry.value = value;
+ return result;
+ }
throw new NullPointerException();
- }
+ }
+
+ /**
+ * Copies every mapping in the specified Map to this Hashtable.
+ *
+ * @param map
+ * the Map to copy mappings from
+ */
+ public synchronized void putAll(Map<? extends K, ? extends V> map) {
+ for (Map.Entry<? extends K, ? extends V> entry : map.entrySet()) {
+ put(entry.getKey(), entry.getValue());
+ }
+ }
- /**
- * Copies every mapping in the specified Map to this Hashtable.
- *
- * @param map
- * the Map to copy mappings from
- */
- public synchronized void putAll(Map<? extends K,? extends V> map) {
- for (Map.Entry<? extends K, ? extends V> entry : map.entrySet()) {
- put(entry.getKey(), entry.getValue());
- }
- }
-
- /**
- * Increases the capacity of this Hashtable. This method is sent when the
- * size of this Hashtable exceeds the load factor.
- */
+ /**
+ * Increases the capacity of this Hashtable. This method is sent when the
+ * size of this Hashtable exceeds the load factor.
+ */
protected void rehash() {
- int length = (elementData.length << 1) + 1;
- if (length == 0) {
+ int length = (elementData.length << 1) + 1;
+ if (length == 0) {
length = 1;
}
- int newFirst = length;
- int newLast = -1;
- Entry<K, V>[] newData = newElementArray(length);
- for (int i = lastSlot + 1; --i >= firstSlot;) {
- Entry<K, V> entry = elementData[i];
- while (entry != null) {
- int index = (entry.getKeyHash() & 0x7FFFFFFF) % length;
- if (index < newFirst) {
+ int newFirst = length;
+ int newLast = -1;
+ Entry<K, V>[] newData = newElementArray(length);
+ for (int i = lastSlot + 1; --i >= firstSlot;) {
+ Entry<K, V> entry = elementData[i];
+ while (entry != null) {
+ int index = (entry.getKeyHash() & 0x7FFFFFFF) % length;
+ if (index < newFirst) {
newFirst = index;
}
- if (index > newLast) {
+ if (index > newLast) {
newLast = index;
}
- Entry<K, V> next = entry.next;
- entry.next = newData[index];
- newData[index] = entry;
- entry = next;
- }
- }
- firstSlot = newFirst;
- lastSlot = newLast;
- elementData = newData;
- computeMaxSize();
- }
-
- /**
- * Remove the key/value pair with the specified key from this Hashtable.
- *
- * @param key
- * the key to remove
- * @return the value associated with the specified key, null if the
- * specified key did not exist
- *
- * @see #get
- * @see #put
- */
- @Override
+ Entry<K, V> next = entry.next;
+ entry.next = newData[index];
+ newData[index] = entry;
+ entry = next;
+ }
+ }
+ firstSlot = newFirst;
+ lastSlot = newLast;
+ elementData = newData;
+ computeMaxSize();
+ }
+
+ /**
+ * Remove the key/value pair with the specified key from this Hashtable.
+ *
+ * @param key
+ * the key to remove
+ * @return the value associated with the specified key, null if the
+ * specified key did not exist
+ *
+ * @see #get
+ * @see #put
+ */
+ @Override
public synchronized V remove(Object key) {
- int hash = key.hashCode();
- int index = (hash & 0x7FFFFFFF) % elementData.length;
- Entry<K, V> last = null;
- Entry<K, V> entry = elementData[index];
- while (entry != null && !entry.equalsKey(key, hash)) {
- last = entry;
- entry = entry.next;
- }
- if (entry != null) {
- modCount++;
- if (last == null) {
+ int hash = key.hashCode();
+ int index = (hash & 0x7FFFFFFF) % elementData.length;
+ Entry<K, V> last = null;
+ Entry<K, V> entry = elementData[index];
+ while (entry != null && !entry.equalsKey(key, hash)) {
+ last = entry;
+ entry = entry.next;
+ }
+ if (entry != null) {
+ modCount++;
+ if (last == null) {
elementData[index] = entry.next;
} else {
last.next = entry.next;
}
- elementCount--;
- V result = entry.value;
- entry.value = null;
- return result;
- }
- return null;
- }
-
- /**
- * Answers the number of key/value pairs in this Hashtable.
- *
- * @return the number of key/value pairs in this Hashtable
- *
- * @see #elements
- * @see #keys
- */
- @Override
+ elementCount--;
+ V result = entry.value;
+ entry.value = null;
+ return result;
+ }
+ return null;
+ }
+
+ /**
+ * Answers the number of key/value pairs in this Hashtable.
+ *
+ * @return the number of key/value pairs in this Hashtable
+ *
+ * @see #elements
+ * @see #keys
+ */
+ @Override
public synchronized int size() {
- return elementCount;
- }
+ return elementCount;
+ }
- /**
- * Answers the string representation of this Hashtable.
- *
- * @return the string representation of this Hashtable
- */
- @Override
+ /**
+ * Answers the string representation of this Hashtable.
+ *
+ * @return the string representation of this Hashtable
+ */
+ @Override
public synchronized String toString() {
- if (isEmpty()) {
- return "{}";
+ if (isEmpty()) {
+ return "{}"; //$NON-NLS-1$
}
- StringBuilder buffer = new StringBuilder(size() * 28);
- buffer.append('{');
- for (int i = lastSlot; i >= firstSlot; i--) {
- Entry<K, V> entry = elementData[i];
- while (entry != null) {
- if (entry.key != this) {
- buffer.append(entry.key);
- } else {
- buffer.append("(this Map)");
- }
- buffer.append('=');
- if (entry.value != this) {
- buffer.append(entry.value);
- } else {
- buffer.append("(this Map)");
- }
- buffer.append(", ");
- entry = entry.next;
- }
- }
- // Remove the last ", "
- if (elementCount > 0) {
+ StringBuilder buffer = new StringBuilder(size() * 28);
+ buffer.append('{');
+ for (int i = lastSlot; i >= firstSlot; i--) {
+ Entry<K, V> entry = elementData[i];
+ while (entry != null) {
+ if (entry.key != this) {
+ buffer.append(entry.key);
+ } else {
+ // luni.04=this Map
+ buffer.append("(" + Messages.getString("luni.04") + ")"); //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$
+ }
+ buffer.append('=');
+ if (entry.value != this) {
+ buffer.append(entry.value);
+ } else {
+ // luni.04=this Map
+ buffer.append("(" + Messages.getString("luni.04") + ")"); //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$
+ }
+ buffer.append(", "); //$NON-NLS-1$
+ entry = entry.next;
+ }
+ }
+ // Remove the last ", "
+ if (elementCount > 0) {
buffer.setLength(buffer.length() - 2);
}
- buffer.append('}');
- return buffer.toString();
- }
-
- /**
- * Answers a Collection of the values contained in this Hashtable. The
- * collection is backed by this Hashtable so changes to one are reflected by
- * the other. The collection does not support adding.
- *
- * @return a Collection of the values
- */
- public Collection<V> values() {
- return new Collections.SynchronizedCollection<V>(new AbstractCollection<V>() {
- @Override
- public boolean contains(Object object) {
- synchronized (Hashtable.this) {
- return Hashtable.this.contains(object);
- }
- }
+ buffer.append('}');
+ return buffer.toString();
+ }
- @Override
- public int size() {
- synchronized (Hashtable.this) {
- return elementCount;
- }
- }
+ /**
+ * Answers a Collection of the values contained in this Hashtable. The
+ * collection is backed by this Hashtable so changes to one are reflected by
+ * the other. The collection does not support adding.
+ *
+ * @return a Collection of the values
+ */
+ public Collection<V> values() {
+ return new Collections.SynchronizedCollection<V>(
+ new AbstractCollection<V>() {
+ @Override
+ public boolean contains(Object object) {
+ synchronized (Hashtable.this) {
+ return Hashtable.this.contains(object);
+ }
+ }
- @Override
- public void clear() {
- Hashtable.this.clear();
- }
+ @Override
+ public int size() {
+ synchronized (Hashtable.this) {
+ return elementCount;
+ }
+ }
+
+ @Override
+ public void clear() {
+ Hashtable.this.clear();
+ }
- @Override
- public Iterator<V> iterator() {
- return new HashIterator<V>(new MapEntry.Type<V, K, V>() {
- public V get(MapEntry<K, V> entry) {
- return entry.value;
- }
- });
- }
- }, this);
- }
-
- private synchronized void writeObject(ObjectOutputStream stream)
- throws IOException {
- stream.defaultWriteObject();
- stream.writeInt(elementData.length);
- stream.writeInt(elementCount);
- for (int i = elementData.length; --i >= 0;) {
- Entry<K, V> entry = elementData[i];
- while (entry != null) {
- stream.writeObject(entry.key);
- stream.writeObject(entry.value);
- entry = entry.next;
- }
- }
- }
+ @Override
+ public Iterator<V> iterator() {
+ return new HashIterator<V>(
+ new MapEntry.Type<V, K, V>() {
+ public V get(MapEntry<K, V> entry) {
+ return entry.value;
+ }
+ });
+ }
+ }, this);
+ }
- @SuppressWarnings("unchecked")
+ private synchronized void writeObject(ObjectOutputStream stream)
+ throws IOException {
+ stream.defaultWriteObject();
+ stream.writeInt(elementData.length);
+ stream.writeInt(elementCount);
+ for (int i = elementData.length; --i >= 0;) {
+ Entry<K, V> entry = elementData[i];
+ while (entry != null) {
+ stream.writeObject(entry.key);
+ stream.writeObject(entry.value);
+ entry = entry.next;
+ }
+ }
+ }
+
+ @SuppressWarnings("unchecked")
private void readObject(ObjectInputStream stream) throws IOException,
- ClassNotFoundException {
- stream.defaultReadObject();
- int length = stream.readInt();
- elementData = newElementArray(length);
- elementCount = stream.readInt();
- for (int i = elementCount; --i >= 0;) {
- Object key = stream.readObject();
- int hash = key.hashCode();
- int index = (hash & 0x7FFFFFFF) % length;
- if (index < firstSlot) {
+ ClassNotFoundException {
+ stream.defaultReadObject();
+ int length = stream.readInt();
+ elementData = newElementArray(length);
+ elementCount = stream.readInt();
+ for (int i = elementCount; --i >= 0;) {
+ Object key = stream.readObject();
+ int hash = key.hashCode();
+ int index = (hash & 0x7FFFFFFF) % length;
+ if (index < firstSlot) {
firstSlot = index;
}
- if (index > lastSlot) {
+ if (index > lastSlot) {
lastSlot = index;
}
- Entry<K, V> entry = newEntry((K)key, (V)stream.readObject(), hash);
- entry.next = elementData[index];
- elementData[index] = entry;
- }
- }
+ Entry<K, V> entry = newEntry((K) key, (V) stream.readObject(), hash);
+ entry.next = elementData[index];
+ elementData[index] = entry;
+ }
+ }
}
Modified: harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/PropertyPermission.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/PropertyPermission.java?view=diff&rev=491834&r1=491833&r2=491834
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/PropertyPermission.java (original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/PropertyPermission.java Tue Jan 2 08:22:05 2007
@@ -17,7 +17,6 @@
package java.util;
-
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
@@ -30,131 +29,131 @@
* PropertyPermission objects represent permission to access system properties.
*/
public final class PropertyPermission extends BasicPermission {
- private static final long serialVersionUID = 885438825399942851L;
+ private static final long serialVersionUID = 885438825399942851L;
- transient private boolean read, write;
+ transient private boolean read, write;
- /**
- * Constructs a new instance of this class.
- *
- * @param name
- * java.lang.String the (possibly wildcarded) name of the
- * property.
- * @param actions
- * java.lang.String the actions which are applicable to it.
- */
- public PropertyPermission(String name, String actions) {
- super(name);
- decodeActions(actions);
- }
-
- private void decodeActions(String actions) {
- StringTokenizer tokenizer = new StringTokenizer(actions.toLowerCase(),
- " \t\n\r,"); //$NON-NLS-1$
- while (tokenizer.hasMoreTokens()) {
- String token = tokenizer.nextToken();
- if (token.equals("read")) {
+ /**
+ * Constructs a new instance of this class.
+ *
+ * @param name
+ * java.lang.String the (possibly wildcarded) name of the
+ * property.
+ * @param actions
+ * java.lang.String the actions which are applicable to it.
+ */
+ public PropertyPermission(String name, String actions) {
+ super(name);
+ decodeActions(actions);
+ }
+
+ private void decodeActions(String actions) {
+ StringTokenizer tokenizer = new StringTokenizer(actions.toLowerCase(),
+ " \t\n\r,"); //$NON-NLS-1$
+ while (tokenizer.hasMoreTokens()) {
+ String token = tokenizer.nextToken();
+ if (token.equals("read")) { //$NON-NLS-1$
read = true;
- } else if (token.equals("write")) {
+ } else if (token.equals("write")) { //$NON-NLS-1$
write = true;
} else {
throw new IllegalArgumentException();
}
- }
- if (!read && !write) {
+ }
+ if (!read && !write) {
throw new IllegalArgumentException();
}
- }
+ }
- /**
- * Compares the argument to the receiver, and answers true if they represent
- * the <em>same</em> object using a class specific comparison. In this
- * case, the receiver must be for the same property as the argument, and
- * must have the same actions.
- *
- * @param o
- * the object to compare with this object
- * @return <code>true</code> if the object is the same as this object
- * <code>false</code> if it is different from this object
- * @see #hashCode
- */
- @Override
+ /**
+ * Compares the argument to the receiver, and answers true if they represent
+ * the <em>same</em> object using a class specific comparison. In this
+ * case, the receiver must be for the same property as the argument, and
+ * must have the same actions.
+ *
+ * @param o
+ * the object to compare with this object
+ * @return <code>true</code> if the object is the same as this object
+ * <code>false</code> if it is different from this object
+ * @see #hashCode
+ */
+ @Override
public boolean equals(Object o) {
- if (super.equals(o)) {
- PropertyPermission pp = (PropertyPermission) o;
- return read == pp.read && write == pp.write;
- }
- return false;
- }
-
- /**
- * Answers the actions associated with the receiver. The result will be
- * either "read", "write", or "read,write".
- *
- * @return String the actions associated with the receiver.
- */
- @Override
+ if (super.equals(o)) {
+ PropertyPermission pp = (PropertyPermission) o;
+ return read == pp.read && write == pp.write;
+ }
+ return false;
+ }
+
+ /**
+ * Answers the actions associated with the receiver. The result will be
+ * either "read", "write", or "read,write".
+ *
+ * @return String the actions associated with the receiver.
+ */
+ @Override
public String getActions() {
- return read ? (write ? "read,write" : "read") : "write"; //$NON-NLS-1$ //$NON-NLS-2$//$NON-NLS-3$
- }
+ return read ? (write ? "read,write" : "read") : "write"; //$NON-NLS-1$ //$NON-NLS-2$//$NON-NLS-3$
+ }
- /**
- * Answers an integer hash code for the receiver. Any two objects which
- * answer <code>true</code> when passed to <code>equals</code> must
- * answer the same value for this method.
- *
- * @return the receiver's hash
- *
- * @see #equals
- */
- @Override
+ /**
+ * Answers an integer hash code for the receiver. Any two objects which
+ * answer <code>true</code> when passed to <code>equals</code> must
+ * answer the same value for this method.
+ *
+ * @return the receiver's hash
+ *
+ * @see #equals
+ */
+ @Override
public int hashCode() {
- return super.hashCode();
- }
+ return super.hashCode();
+ }
- /**
- * Indicates whether the argument permission is implied by the receiver.
- *
- * @return boolean <code>true</code> if the argument permission is implied
- * by the receiver, and <code>false</code> if it is not.
- * @param permission
- * java.security.Permission the permission to check
- */
- @Override
+ /**
+ * Indicates whether the argument permission is implied by the receiver.
+ *
+ * @return boolean <code>true</code> if the argument permission is implied
+ * by the receiver, and <code>false</code> if it is not.
+ * @param permission
+ * java.security.Permission the permission to check
+ */
+ @Override
public boolean implies(Permission permission) {
- if (super.implies(permission)) {
- PropertyPermission pp = (PropertyPermission) permission;
- return (read || !pp.read) && (write || !pp.write);
- }
- return false;
- }
-
- /**
- * Answers a new PermissionCollection for holding permissions of this class.
- * Answer null if any permission collection can be used.
- *
- * @return a new PermissionCollection or null
- *
- * see java.security.BasicPermissionCollection
- */
- @Override
+ if (super.implies(permission)) {
+ PropertyPermission pp = (PropertyPermission) permission;
+ return (read || !pp.read) && (write || !pp.write);
+ }
+ return false;
+ }
+
+ /**
+ * Answers a new PermissionCollection for holding permissions of this class.
+ * Answer null if any permission collection can be used.
+ *
+ * @return a new PermissionCollection or null
+ *
+ * see java.security.BasicPermissionCollection
+ */
+ @Override
public PermissionCollection newPermissionCollection() {
- return new PropertyPermissionCollection();
- }
+ return new PropertyPermissionCollection();
+ }
- private static final ObjectStreamField[] serialPersistentFields = { new ObjectStreamField(
- "actions", String.class) }; //$NON-NLS-1$
+ private static final ObjectStreamField[] serialPersistentFields = { new ObjectStreamField(
+ "actions", String.class) }; //$NON-NLS-1$
- private void writeObject(ObjectOutputStream stream) throws IOException {
- ObjectOutputStream.PutField fields = stream.putFields();
- fields.put("actions", getActions()); //$NON-NLS-1$
- stream.writeFields();
- }
-
- private void readObject(ObjectInputStream stream) throws IOException,
- ClassNotFoundException {
- ObjectInputStream.GetField fields = stream.readFields();
- String actions = (String) fields.get("actions", ""); //$NON-NLS-1$ //$NON-NLS-2$
- decodeActions(actions);
- }
+ private void writeObject(ObjectOutputStream stream) throws IOException {
+ ObjectOutputStream.PutField fields = stream.putFields();
+ fields.put("actions", getActions()); //$NON-NLS-1$
+ stream.writeFields();
+ }
+
+ private void readObject(ObjectInputStream stream) throws IOException,
+ ClassNotFoundException {
+ ObjectInputStream.GetField fields = stream.readFields();
+ String actions = (String) fields.get("actions", ""); //$NON-NLS-1$ //$NON-NLS-2$
+ decodeActions(actions);
+ }
}
Modified: harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/PropertyPermissionCollection.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/PropertyPermissionCollection.java?view=diff&rev=491834&r1=491833&r2=491834
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/PropertyPermissionCollection.java (original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/PropertyPermissionCollection.java Tue Jan 2 08:22:05 2007
@@ -17,7 +17,6 @@
package java.util;
-
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
@@ -29,12 +28,13 @@
* A PermissionCollection for holding PropertyPermissions.
*/
class PropertyPermissionCollection extends PermissionCollection {
-
- private static final long serialVersionUID = 7015263904581634791L;
- Hashtable<String, Permission> permissions = new Hashtable<String, Permission>(30);
+ private static final long serialVersionUID = 7015263904581634791L;
+
+ Hashtable<String, Permission> permissions = new Hashtable<String, Permission>(
+ 30);
- @Override
+ @Override
public void add(Permission perm) {
if (!isReadOnly()) {
Permission prev = permissions.put(perm.getName(), perm);
@@ -44,52 +44,53 @@
*/
if (prev != null && !prev.getActions().equals(perm.getActions())) {
Permission np = new PropertyPermission(perm.getName(),
- "read,write");
- permissions.put(perm.getName(), np);
+ "read,write"); //$NON-NLS-1$
+ permissions.put(perm.getName(), np);
}
} else {
throw new IllegalStateException();
}
}
- @Override
+ @Override
public Enumeration<Permission> elements() {
- return permissions.elements();
- }
+ return permissions.elements();
+ }
- @Override
+ @Override
public boolean implies(Permission perm) {
- Enumeration<Permission> elemEnum = elements();
- while (elemEnum.hasMoreElements()) {
+ Enumeration<Permission> elemEnum = elements();
+ while (elemEnum.hasMoreElements()) {
if ((elemEnum.nextElement()).implies(perm)) {
return true;
}
}
- /*
+ /*
* At this point, the only way it can succeed is if both read and write
* are set, and these are separately granted by two different
* permissions with one representing a parent directory.
*/
- return perm.getActions().equals("read,write") //$NON-NLS-1$
- && implies(new PropertyPermission(perm.getName(), "read")) //$NON-NLS-1$
- && implies(new PropertyPermission(perm.getName(), "write")); //$NON-NLS-1$
- }
-
- private static final ObjectStreamField[] serialPersistentFields = {
- new ObjectStreamField("permissions", Hashtable.class), //$NON-NLS-1$
- new ObjectStreamField("all_allowed", Boolean.TYPE) }; //$NON-NLS-1$
-
- private void writeObject(ObjectOutputStream stream) throws IOException {
- ObjectOutputStream.PutField fields = stream.putFields();
- fields.put("permissions", permissions); //$NON-NLS-1$
- fields.put("all_allowed", false); //$NON-NLS-1$
- stream.writeFields();
- }
+ return perm.getActions().equals("read,write") //$NON-NLS-1$
+ && implies(new PropertyPermission(perm.getName(), "read")) //$NON-NLS-1$
+ && implies(new PropertyPermission(perm.getName(), "write")); //$NON-NLS-1$
+ }
- @SuppressWarnings("unchecked")
+ private static final ObjectStreamField[] serialPersistentFields = {
+ new ObjectStreamField("permissions", Hashtable.class), //$NON-NLS-1$
+ new ObjectStreamField("all_allowed", Boolean.TYPE) }; //$NON-NLS-1$
+
+ private void writeObject(ObjectOutputStream stream) throws IOException {
+ ObjectOutputStream.PutField fields = stream.putFields();
+ fields.put("permissions", permissions); //$NON-NLS-1$
+ fields.put("all_allowed", false); //$NON-NLS-1$
+ stream.writeFields();
+ }
+
+ @SuppressWarnings("unchecked")
private void readObject(ObjectInputStream stream) throws IOException,
- ClassNotFoundException {
- ObjectInputStream.GetField fields = stream.readFields();
- permissions = (Hashtable<String, Permission>) fields.get("permissions", null); //$NON-NLS-1$
- }
+ ClassNotFoundException {
+ ObjectInputStream.GetField fields = stream.readFields();
+ permissions = (Hashtable<String, Permission>) fields.get(
+ "permissions", null); //$NON-NLS-1$
+ }
}
Modified: harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/ResourceBundle.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/ResourceBundle.java?view=diff&rev=491834&r1=491833&r2=491834
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/ResourceBundle.java (original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/ResourceBundle.java Tue Jan 2 08:22:05 2007
@@ -17,7 +17,6 @@
package java.util;
-
import java.io.IOException;
import java.io.InputStream;
import java.security.AccessController;
@@ -37,335 +36,338 @@
* @since 1.1
*/
public abstract class ResourceBundle {
-
- /**
- * The parent of this ResourceBundle.
- */
- protected ResourceBundle parent;
- private Locale locale;
+ /**
+ * The parent of this ResourceBundle.
+ */
+ protected ResourceBundle parent;
+
+ private Locale locale;
- static class MissingBundle extends ResourceBundle {
- @Override
+ static class MissingBundle extends ResourceBundle {
+ @Override
public Enumeration<String> getKeys() {
- return null;
- }
+ return null;
+ }
- @Override
+ @Override
public Object handleGetObject(String name) {
- return null;
- }
- }
-
- private static final ResourceBundle MISSING = new MissingBundle();
-
- private static final ResourceBundle MISSINGBASE = new MissingBundle();
-
- private static final WeakHashMap<Object,Hashtable<String,ResourceBundle>> cache = new WeakHashMap<Object,Hashtable<String,ResourceBundle>>();
-
- /**
- * Constructs a new instance of this class.
- *
- */
- public ResourceBundle() {
- /*empty*/
- }
-
- /**
- * Finds the named resource bundle for the default locale.
- *
- * @param bundleName
- * the name of the resource bundle
- * @return ResourceBundle
- *
- * @exception MissingResourceException
- * when the resource bundle cannot be found
- */
- public static final ResourceBundle getBundle(String bundleName)
- throws MissingResourceException {
- return getBundleImpl(bundleName, Locale.getDefault(), VM
- .callerClassLoader());
- }
-
- /**
- * Finds the named resource bundle for the specified locale.
- *
- * @param bundleName
- * the name of the resource bundle
- * @param locale
- * the locale
- * @return ResourceBundle
- *
- * @exception MissingResourceException
- * when the resource bundle cannot be found
- */
- public static final ResourceBundle getBundle(String bundleName,
- Locale locale) {
- return getBundleImpl(bundleName, locale, VM.callerClassLoader());
- }
-
- /**
- * Finds the named resource bundle for the specified locale.
- *
- * @param bundleName
- * the name of the resource bundle
- * @param locale
- * the locale
- * @param loader
- * the ClassLoader to use
- * @return ResourceBundle
- *
- * @exception MissingResourceException
- * when the resource bundle cannot be found
- */
- public static ResourceBundle getBundle(String bundleName, Locale locale,
- ClassLoader loader) throws MissingResourceException {
- if (loader == null) {
+ return null;
+ }
+ }
+
+ private static final ResourceBundle MISSING = new MissingBundle();
+
+ private static final ResourceBundle MISSINGBASE = new MissingBundle();
+
+ private static final WeakHashMap<Object, Hashtable<String, ResourceBundle>> cache = new WeakHashMap<Object, Hashtable<String, ResourceBundle>>();
+
+ /**
+ * Constructs a new instance of this class.
+ *
+ */
+ public ResourceBundle() {
+ /* empty */
+ }
+
+ /**
+ * Finds the named resource bundle for the default locale.
+ *
+ * @param bundleName
+ * the name of the resource bundle
+ * @return ResourceBundle
+ *
+ * @exception MissingResourceException
+ * when the resource bundle cannot be found
+ */
+ public static final ResourceBundle getBundle(String bundleName)
+ throws MissingResourceException {
+ return getBundleImpl(bundleName, Locale.getDefault(), VM
+ .callerClassLoader());
+ }
+
+ /**
+ * Finds the named resource bundle for the specified locale.
+ *
+ * @param bundleName
+ * the name of the resource bundle
+ * @param locale
+ * the locale
+ * @return ResourceBundle
+ *
+ * @exception MissingResourceException
+ * when the resource bundle cannot be found
+ */
+ public static final ResourceBundle getBundle(String bundleName,
+ Locale locale) {
+ return getBundleImpl(bundleName, locale, VM.callerClassLoader());
+ }
+
+ /**
+ * Finds the named resource bundle for the specified locale.
+ *
+ * @param bundleName
+ * the name of the resource bundle
+ * @param locale
+ * the locale
+ * @param loader
+ * the ClassLoader to use
+ * @return ResourceBundle
+ *
+ * @exception MissingResourceException
+ * when the resource bundle cannot be found
+ */
+ public static ResourceBundle getBundle(String bundleName, Locale locale,
+ ClassLoader loader) throws MissingResourceException {
+ if (loader == null) {
throw new NullPointerException();
}
- if (bundleName != null) {
- ResourceBundle bundle;
- if (!locale.equals(Locale.getDefault())) {
+ if (bundleName != null) {
+ ResourceBundle bundle;
+ if (!locale.equals(Locale.getDefault())) {
if ((bundle = handleGetBundle(bundleName, "_" + locale, false, //$NON-NLS-1$
- loader)) != null) {
+ loader)) != null) {
return bundle;
}
}
- if ((bundle = handleGetBundle(bundleName,
- "_" + Locale.getDefault(), true, loader)) != null) {
+ if ((bundle = handleGetBundle(bundleName,
+ "_" + Locale.getDefault(), true, loader)) != null) { //$NON-NLS-1$
return bundle;
}
- throw new MissingResourceException(null, bundleName + '_' + locale, ""); //$NON-NLS-1$
- }
+ throw new MissingResourceException(null, bundleName + '_' + locale,
+ ""); //$NON-NLS-1$
+ }
throw new NullPointerException();
- }
+ }
- private static ResourceBundle getBundleImpl(String bundleName,
- Locale locale, ClassLoader loader) throws MissingResourceException {
- if (bundleName != null) {
- ResourceBundle bundle;
- if (!locale.equals(Locale.getDefault())) {
- String localeName = locale.toString();
- if (localeName.length() > 0) {
+ private static ResourceBundle getBundleImpl(String bundleName,
+ Locale locale, ClassLoader loader) throws MissingResourceException {
+ if (bundleName != null) {
+ ResourceBundle bundle;
+ if (!locale.equals(Locale.getDefault())) {
+ String localeName = locale.toString();
+ if (localeName.length() > 0) {
localeName = "_" + localeName; //$NON-NLS-1$
}
- if ((bundle = handleGetBundle(bundleName, localeName, false,
- loader)) != null) {
+ if ((bundle = handleGetBundle(bundleName, localeName, false,
+ loader)) != null) {
return bundle;
}
- }
- String localeName = Locale.getDefault().toString();
- if (localeName.length() > 0) {
+ }
+ String localeName = Locale.getDefault().toString();
+ if (localeName.length() > 0) {
localeName = "_" + localeName; //$NON-NLS-1$
}
- if ((bundle = handleGetBundle(bundleName, localeName, true, loader)) != null) {
+ if ((bundle = handleGetBundle(bundleName, localeName, true, loader)) != null) {
return bundle;
}
- throw new MissingResourceException(null, bundleName + '_' + locale , ""); //$NON-NLS-1$
- }
+ throw new MissingResourceException(null, bundleName + '_' + locale,
+ ""); //$NON-NLS-1$
+ }
throw new NullPointerException();
- }
+ }
- /**
- * Answers the names of the resources contained in this ResourceBundle.
- *
- * @return an Enumeration of the resource names
- */
- public abstract Enumeration<String> getKeys();
-
- /**
- * Gets the Locale of this ResourceBundle.
- *
- * @return the Locale of this ResourceBundle
- */
- public Locale getLocale() {
- return locale;
- }
-
- /**
- * Answers the named resource from this ResourceBundle.
- *
- * @param key
- * the name of the resource
- * @return the resource object
- *
- * @exception MissingResourceException
- * when the resource is not found
- */
- public final Object getObject(String key) {
- ResourceBundle last, theParent = this;
- do {
- Object result = theParent.handleGetObject(key);
- if (result != null) {
+ /**
+ * Answers the names of the resources contained in this ResourceBundle.
+ *
+ * @return an Enumeration of the resource names
+ */
+ public abstract Enumeration<String> getKeys();
+
+ /**
+ * Gets the Locale of this ResourceBundle.
+ *
+ * @return the Locale of this ResourceBundle
+ */
+ public Locale getLocale() {
+ return locale;
+ }
+
+ /**
+ * Answers the named resource from this ResourceBundle.
+ *
+ * @param key
+ * the name of the resource
+ * @return the resource object
+ *
+ * @exception MissingResourceException
+ * when the resource is not found
+ */
+ public final Object getObject(String key) {
+ ResourceBundle last, theParent = this;
+ do {
+ Object result = theParent.handleGetObject(key);
+ if (result != null) {
return result;
}
- last = theParent;
- theParent = theParent.parent;
- } while (theParent != null);
- throw new MissingResourceException(null, last.getClass().getName(), key);
- }
-
- /**
- * Answers the named resource from this ResourceBundle.
- *
- * @param key
- * the name of the resource
- * @return the resource string
- *
- * @exception MissingResourceException
- * when the resource is not found
- */
- public final String getString(String key) {
- return (String) getObject(key);
- }
-
- /**
- * Answers the named resource from this ResourceBundle.
- *
- * @param key
- * the name of the resource
- * @return the resource string array
- *
- * @exception MissingResourceException
- * when the resource is not found
- */
- public final String[] getStringArray(String key) {
- return (String[]) getObject(key);
- }
-
- private static ResourceBundle handleGetBundle(String base, String locale,
- boolean loadBase, final ClassLoader loader) {
- ResourceBundle bundle = null;
- String bundleName = base + locale;
- Object cacheKey = loader != null ? (Object) loader : (Object) "null"; //$NON-NLS-1$
- Hashtable<String,ResourceBundle> loaderCache;
- synchronized (cache) {
- loaderCache = cache.get(cacheKey);
- if (loaderCache == null) {
- loaderCache = new Hashtable<String,ResourceBundle>(13);
- cache.put(cacheKey, loaderCache);
- }
- }
- ResourceBundle result = loaderCache.get(bundleName);
- if (result != null) {
- if (result == MISSINGBASE) {
+ last = theParent;
+ theParent = theParent.parent;
+ } while (theParent != null);
+ throw new MissingResourceException(null, last.getClass().getName(), key);
+ }
+
+ /**
+ * Answers the named resource from this ResourceBundle.
+ *
+ * @param key
+ * the name of the resource
+ * @return the resource string
+ *
+ * @exception MissingResourceException
+ * when the resource is not found
+ */
+ public final String getString(String key) {
+ return (String) getObject(key);
+ }
+
+ /**
+ * Answers the named resource from this ResourceBundle.
+ *
+ * @param key
+ * the name of the resource
+ * @return the resource string array
+ *
+ * @exception MissingResourceException
+ * when the resource is not found
+ */
+ public final String[] getStringArray(String key) {
+ return (String[]) getObject(key);
+ }
+
+ private static ResourceBundle handleGetBundle(String base, String locale,
+ boolean loadBase, final ClassLoader loader) {
+ ResourceBundle bundle = null;
+ String bundleName = base + locale;
+ Object cacheKey = loader != null ? (Object) loader : (Object) "null"; //$NON-NLS-1$
+ Hashtable<String, ResourceBundle> loaderCache;
+ synchronized (cache) {
+ loaderCache = cache.get(cacheKey);
+ if (loaderCache == null) {
+ loaderCache = new Hashtable<String, ResourceBundle>(13);
+ cache.put(cacheKey, loaderCache);
+ }
+ }
+ ResourceBundle result = loaderCache.get(bundleName);
+ if (result != null) {
+ if (result == MISSINGBASE) {
return null;
}
- if (result == MISSING) {
- if (!loadBase) {
+ if (result == MISSING) {
+ if (!loadBase) {
return null;
}
- String extension = strip(locale);
- if (extension == null) {
+ String extension = strip(locale);
+ if (extension == null) {
return null;
}
- return handleGetBundle(base, extension, loadBase, loader);
- }
- return result;
- }
-
- try {
- Class<?> bundleClass = Class.forName(bundleName, true, loader);
- bundle = (ResourceBundle) bundleClass.newInstance();
- bundle.setLocale(locale);
- } catch (LinkageError e) {
- } catch (Exception e) {
- }
-
- if (bundle == null) {
- final String fileName = bundleName.replace('.', '/');
- InputStream stream = AccessController.doPrivileged(new PrivilegedAction<InputStream>() {
- public InputStream run() {
- return loader == null ? ClassLoader
- .getSystemResourceAsStream(fileName
- + ".properties") : loader //$NON-NLS-1$
- .getResourceAsStream(fileName
- + ".properties"); //$NON-NLS-1$
- }
- });
- if (stream != null) {
- try {
- bundle = new PropertyResourceBundle(stream);
- bundle.setLocale(locale);
- stream.close();
- } catch (IOException e) {
- }
- }
- }
-
- String extension = strip(locale);
- if (bundle != null) {
- if (extension != null) {
- ResourceBundle parent = handleGetBundle(base, extension, true,
- loader);
- if (parent != null) {
+ return handleGetBundle(base, extension, loadBase, loader);
+ }
+ return result;
+ }
+
+ try {
+ Class<?> bundleClass = Class.forName(bundleName, true, loader);
+ bundle = (ResourceBundle) bundleClass.newInstance();
+ bundle.setLocale(locale);
+ } catch (LinkageError e) {
+ } catch (Exception e) {
+ }
+
+ if (bundle == null) {
+ final String fileName = bundleName.replace('.', '/');
+ InputStream stream = AccessController
+ .doPrivileged(new PrivilegedAction<InputStream>() {
+ public InputStream run() {
+ return loader == null ? ClassLoader
+ .getSystemResourceAsStream(fileName
+ + ".properties") : loader //$NON-NLS-1$
+ .getResourceAsStream(fileName
+ + ".properties"); //$NON-NLS-1$
+ }
+ });
+ if (stream != null) {
+ try {
+ bundle = new PropertyResourceBundle(stream);
+ bundle.setLocale(locale);
+ stream.close();
+ } catch (IOException e) {
+ }
+ }
+ }
+
+ String extension = strip(locale);
+ if (bundle != null) {
+ if (extension != null) {
+ ResourceBundle parent = handleGetBundle(base, extension, true,
+ loader);
+ if (parent != null) {
bundle.setParent(parent);
}
- }
- loaderCache.put(bundleName, bundle);
- return bundle;
- }
-
- if (extension != null && (loadBase || extension.length() > 0)) {
- bundle = handleGetBundle(base, extension, loadBase, loader);
- if (bundle != null) {
- loaderCache.put(bundleName, bundle);
- return bundle;
- }
- }
- loaderCache.put(bundleName, loadBase ? MISSINGBASE : MISSING);
- return null;
- }
-
- /**
- * Answers the named resource from this ResourceBundle, or null if the
- * resource is not found.
- *
- * @param key
- * the name of the resource
- * @return the resource object
- */
- protected abstract Object handleGetObject(String key);
-
- /**
- * Sets the parent resource bundle of this ResourceBundle. The parent is
- * searched for resources which are not found in this resource bundle.
- *
- * @param bundle
- * the parent resource bundle
- */
- protected void setParent(ResourceBundle bundle) {
- parent = bundle;
- }
-
- private static String strip(String name) {
- int index = name.lastIndexOf('_');
- if (index != -1) {
+ }
+ loaderCache.put(bundleName, bundle);
+ return bundle;
+ }
+
+ if (extension != null && (loadBase || extension.length() > 0)) {
+ bundle = handleGetBundle(base, extension, loadBase, loader);
+ if (bundle != null) {
+ loaderCache.put(bundleName, bundle);
+ return bundle;
+ }
+ }
+ loaderCache.put(bundleName, loadBase ? MISSINGBASE : MISSING);
+ return null;
+ }
+
+ /**
+ * Answers the named resource from this ResourceBundle, or null if the
+ * resource is not found.
+ *
+ * @param key
+ * the name of the resource
+ * @return the resource object
+ */
+ protected abstract Object handleGetObject(String key);
+
+ /**
+ * Sets the parent resource bundle of this ResourceBundle. The parent is
+ * searched for resources which are not found in this resource bundle.
+ *
+ * @param bundle
+ * the parent resource bundle
+ */
+ protected void setParent(ResourceBundle bundle) {
+ parent = bundle;
+ }
+
+ private static String strip(String name) {
+ int index = name.lastIndexOf('_');
+ if (index != -1) {
return name.substring(0, index);
}
- return null;
- }
+ return null;
+ }
- private void setLocale(String name) {
- String language = "", country = "", variant = ""; //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
- if (name.length() > 1) {
- int nextIndex = name.indexOf('_', 1);
- if (nextIndex == -1) {
+ private void setLocale(String name) {
+ String language = "", country = "", variant = ""; //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
+ if (name.length() > 1) {
+ int nextIndex = name.indexOf('_', 1);
+ if (nextIndex == -1) {
nextIndex = name.length();
}
- language = name.substring(1, nextIndex);
- if (nextIndex + 1 < name.length()) {
- int index = nextIndex;
- nextIndex = name.indexOf('_', nextIndex + 1);
- if (nextIndex == -1) {
+ language = name.substring(1, nextIndex);
+ if (nextIndex + 1 < name.length()) {
+ int index = nextIndex;
+ nextIndex = name.indexOf('_', nextIndex + 1);
+ if (nextIndex == -1) {
nextIndex = name.length();
}
- country = name.substring(index + 1, nextIndex);
- if (nextIndex + 1 < name.length()) {
+ country = name.substring(index + 1, nextIndex);
+ if (nextIndex + 1 < name.length()) {
variant = name.substring(nextIndex + 1, name.length());
}
- }
- }
- locale = new Locale(language, country, variant);
- }
+ }
+ }
+ locale = new Locale(language, country, variant);
+ }
}
Modified: harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/UUID.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/UUID.java?view=diff&rev=491834&r1=491833&r2=491834
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/UUID.java (original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/UUID.java Tue Jan 2 08:22:05 2007
@@ -172,7 +172,7 @@
byte[] hash;
try {
- MessageDigest md = MessageDigest.getInstance("MD5");
+ MessageDigest md = MessageDigest.getInstance("MD5"); //$NON-NLS-1$
hash = md.digest(name);
} catch (NoSuchAlgorithmException e) {
throw new AssertionError(e);