scolebourne 2003/12/29 07:08:16 Modified: collections/src/java/org/apache/commons/collections/map StaticBucketMap.java UnmodifiableEntrySet.java ReferenceMap.java PredicatedMap.java Log: Change to standard variable naming and braces style Revision Changes Path 1.5 +16 -16 jakarta-commons/collections/src/java/org/apache/commons/collections/map/StaticBucketMap.java Index: StaticBucketMap.java =================================================================== RCS file: /home/cvs/jakarta-commons/collections/src/java/org/apache/commons/collections/map/StaticBucketMap.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- StaticBucketMap.java 28 Dec 2003 16:36:48 -0000 1.4 +++ StaticBucketMap.java 29 Dec 2003 15:08:15 -0000 1.5 @@ -498,23 +498,23 @@ (value == null ? 0 : value.hashCode())); } - public boolean equals(Object o) { - if (o == this) { + public boolean equals(Object obj) { + if (obj == this) { return true; } - if (o instanceof Map.Entry == false) { + if (obj instanceof Map.Entry == false) { return false; } - Map.Entry e2 = (Map.Entry) o; + Map.Entry e2 = (Map.Entry) obj; return ( (key == null ? e2.getKey() == null : key.equals(e2.getKey())) && (value == null ? e2.getValue() == null : value.equals(e2.getValue()))); } - public Object setValue(Object val) { + public Object setValue(Object obj) { Object retVal = value; - value = val; + value = obj; return retVal; } } @@ -600,8 +600,8 @@ return new EntryIterator(); } - public boolean contains(Object o) { - Map.Entry entry = (Map.Entry)o; + public boolean contains(Object obj) { + Map.Entry entry = (Map.Entry) obj; int hash = getHash(entry.getKey()); synchronized (m_locks[hash]) { for (Node n = m_buckets[hash]; n != null; n = n.next) { @@ -615,7 +615,7 @@ if (obj instanceof Map.Entry == false) { return false; } - Map.Entry entry = (Map.Entry)obj; + Map.Entry entry = (Map.Entry) obj; int hash = getHash(entry.getKey()); synchronized (m_locks[hash]) { for (Node n = m_buckets[hash]; n != null; n = n.next) { @@ -645,16 +645,16 @@ return new KeyIterator(); } - public boolean contains(Object o) { - return StaticBucketMap.this.containsKey(o); + public boolean contains(Object obj) { + return StaticBucketMap.this.containsKey(obj); } - public boolean remove(Object o) { - int hash = getHash(o); + public boolean remove(Object obj) { + int hash = getHash(obj); synchronized (m_locks[hash]) { for (Node n = m_buckets[hash]; n != null; n = n.next) { Object k = n.getKey(); - if ((k == o) || ((k != null) && k.equals(o))) { + if ((k == obj) || ((k != null) && k.equals(obj))) { StaticBucketMap.this.remove(k); return true; } 1.3 +3 -3 jakarta-commons/collections/src/java/org/apache/commons/collections/map/UnmodifiableEntrySet.java Index: UnmodifiableEntrySet.java =================================================================== RCS file: /home/cvs/jakarta-commons/collections/src/java/org/apache/commons/collections/map/UnmodifiableEntrySet.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- UnmodifiableEntrySet.java 5 Dec 2003 20:23:57 -0000 1.2 +++ UnmodifiableEntrySet.java 29 Dec 2003 15:08:15 -0000 1.3 @@ -195,7 +195,7 @@ super(entry); } - public Object setValue(Object o) { + public Object setValue(Object obj) { throw new UnsupportedOperationException(); } } 1.6 +55 -31 jakarta-commons/collections/src/java/org/apache/commons/collections/map/ReferenceMap.java Index: ReferenceMap.java =================================================================== RCS file: /home/cvs/jakarta-commons/collections/src/java/org/apache/commons/collections/map/ReferenceMap.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- ReferenceMap.java 29 Dec 2003 14:54:58 -0000 1.5 +++ ReferenceMap.java 29 Dec 2003 15:08:15 -0000 1.6 @@ -373,16 +373,16 @@ * @throws IOException if the stream raises it * @throws ClassNotFoundException if the stream raises it */ - private void readObject(ObjectInputStream inp) throws IOException, ClassNotFoundException { - inp.defaultReadObject(); - table = new Entry[inp.readInt()]; + private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { + in.defaultReadObject(); + table = new Entry[in.readInt()]; threshold = (int)(table.length * loadFactor); queue = new ReferenceQueue(); - Object key = inp.readObject(); + Object key = in.readObject(); while (key != null) { - Object value = inp.readObject(); + Object value = in.readObject(); put(key, value); - key = inp.readObject(); + key = in.readObject(); } } @@ -416,7 +416,9 @@ * if the key is not in this map */ private Entry getEntry(Object key) { - if (key == null) return null; + if (key == null) { + return null; + } int hash = key.hashCode(); int index = indexFor(hash); for (Entry entry = table[index]; entry != null; entry = entry.next) { @@ -502,8 +504,11 @@ Entry entry = table[index]; while (entry != null) { if (entry.purge(ref)) { - if (previous == null) table[index] = entry.next; - else previous.next = entry.next; + if (previous == null) { + table[index] = entry.next; + } else { + previous.next = entry.next; + } this.size--; return; } @@ -544,7 +549,9 @@ public boolean containsKey(Object key) { purge(); Entry entry = getEntry(key); - if (entry == null) return false; + if (entry == null) { + return false; + } return entry.getValue() != null; } @@ -558,7 +565,9 @@ public Object get(Object key) { purge(); Entry entry = getEntry(key); - if (entry == null) return null; + if (entry == null) { + return null; + } return entry.getValue(); } @@ -575,11 +584,17 @@ * is null */ public Object put(Object key, Object value) { - if (key == null) throw new NullPointerException("null keys not allowed"); - if (value == null) throw new NullPointerException("null values not allowed"); + if (key == null) { + throw new NullPointerException("null keys not allowed"); + } + if (value == null) { + throw new NullPointerException("null values not allowed"); + } purge(); - if (size + 1 > threshold) resize(); + if (size + 1 > threshold) { + resize(); + } int hash = key.hashCode(); int index = indexFor(hash); @@ -609,7 +624,9 @@ * the key was not in the map */ public Object remove(Object key) { - if (key == null) return null; + if (key == null) { + return null; + } purge(); int hash = key.hashCode(); int index = indexFor(hash); @@ -617,8 +634,11 @@ Entry entry = table[index]; while (entry != null) { if ((hash == entry.hash) && key.equals(entry.getKey())) { - if (previous == null) table[index] = entry.next; - else previous.next = entry.next; + if (previous == null) { + table[index] = entry.next; + } else { + previous.next = entry.next; + } this.size--; modCount++; return entry.getValue(); @@ -636,7 +656,7 @@ public void clear() { Arrays.fill(table, null); size = 0; - while (queue.poll() != null); // drain the queue + while (queue.poll() != null) {}; // drain the queue } @@ -658,18 +678,22 @@ ReferenceMap.this.clear(); } - public boolean contains(Object o) { - if (o == null) return false; - if (!(o instanceof Map.Entry)) return false; - Map.Entry e = (Map.Entry)o; + public boolean contains(Object obj) { + if (obj == null) { + return false; + } + if (obj instanceof Map.Entry == false) { + return false; + } + Map.Entry e = (Map.Entry) obj; Entry e2 = getEntry(e.getKey()); return (e2 != null) && e.equals(e2); } - public boolean remove(Object o) { - boolean r = contains(o); + public boolean remove(Object obj) { + boolean r = contains(obj); if (r) { - Map.Entry e = (Map.Entry)o; + Map.Entry e = (Map.Entry) obj; ReferenceMap.this.remove(e.getKey()); } return r; @@ -713,13 +737,13 @@ return new KeyIterator(); } - public boolean contains(Object o) { - return containsKey(o); + public boolean contains(Object obj) { + return containsKey(obj); } - public boolean remove(Object o) { - Object r = ReferenceMap.this.remove(o); + public boolean remove(Object obj) { + Object r = ReferenceMap.this.remove(obj); return r != null; } 1.4 +5 -5 jakarta-commons/collections/src/java/org/apache/commons/collections/map/PredicatedMap.java Index: PredicatedMap.java =================================================================== RCS file: /home/cvs/jakarta-commons/collections/src/java/org/apache/commons/collections/map/PredicatedMap.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- PredicatedMap.java 25 Dec 2003 00:49:14 -0000 1.3 +++ PredicatedMap.java 29 Dec 2003 15:08:15 -0000 1.4 @@ -243,11 +243,11 @@ this.predicate = valuePredicate; } - public Object setValue(Object o) { - if (predicate != null && predicate.evaluate(o) == false) { + public Object setValue(Object obj) { + if (predicate != null && predicate.evaluate(obj) == false) { throw new IllegalArgumentException("Cannot set value - Predicate rejected it"); } - return entry.setValue(o); + return entry.setValue(obj); } }
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]