Return-Path: Delivered-To: apmail-jakarta-commons-dev-archive@www.apache.org Received: (qmail 46779 invoked from network); 21 May 2004 22:01:10 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur-2.apache.org with SMTP; 21 May 2004 22:01:10 -0000 Received: (qmail 69677 invoked by uid 500); 21 May 2004 22:01:28 -0000 Delivered-To: apmail-jakarta-commons-dev-archive@jakarta.apache.org Received: (qmail 69576 invoked by uid 500); 21 May 2004 22:01:27 -0000 Mailing-List: contact commons-dev-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Jakarta Commons Developers List" Reply-To: "Jakarta Commons Developers List" Delivered-To: mailing list commons-dev@jakarta.apache.org Received: (qmail 69555 invoked by uid 500); 21 May 2004 22:01:27 -0000 Received: (qmail 69543 invoked by uid 98); 21 May 2004 22:01:27 -0000 Received: from scolebourne@apache.org by hermes.apache.org by uid 82 with qmail-scanner-1.20 (clamuko: 0.70. Clear:RC:0(209.237.227.194):. Processed in 0.068303 secs); 21 May 2004 22:01:27 -0000 X-Qmail-Scanner-Mail-From: scolebourne@apache.org via hermes.apache.org X-Qmail-Scanner: 1.20 (Clear:RC:0(209.237.227.194):. Processed in 0.068303 secs) Received: from unknown (HELO minotaur.apache.org) (209.237.227.194) by hermes.apache.org with SMTP; 21 May 2004 22:01:27 -0000 Received: (qmail 46704 invoked by uid 1529); 21 May 2004 22:01:04 -0000 Date: 21 May 2004 22:01:04 -0000 Message-ID: <20040521220104.46703.qmail@minotaur.apache.org> From: scolebourne@apache.org To: jakarta-commons-cvs@apache.org Subject: cvs commit: jakarta-commons/collections/src/java/org/apache/commons/collections/map TransformedMap.java AbstractInputCheckedMapDecorator.java PredicatedMap.java X-Spam-Rating: hermes.apache.org 1.6.2 0/1000/N X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N scolebourne 2004/05/21 15:01:04 Modified: collections/src/java/org/apache/commons/collections/map TransformedMap.java AbstractInputCheckedMapDecorator.java PredicatedMap.java Log: Reduce scope of AbstractInputCheckedMapDecorator for v3.1 Revision Changes Path 1.10 +1 -5 jakarta-commons/collections/src/java/org/apache/commons/collections/map/TransformedMap.java Index: TransformedMap.java =================================================================== RCS file: /home/cvs/jakarta-commons/collections/src/java/org/apache/commons/collections/map/TransformedMap.java,v retrieving revision 1.9 retrieving revision 1.10 diff -u -r1.9 -r1.10 --- TransformedMap.java 3 May 2004 21:48:49 -0000 1.9 +++ TransformedMap.java 21 May 2004 22:01:04 -0000 1.10 @@ -111,10 +111,6 @@ } //----------------------------------------------------------------------- - // The transformKey/transformValue/transformMap methods exist for backwards - // compatability - in an ideal world, they wouldn't and the superclass - // methods checkPutKey/checkPutValue would be overridden instead - /** * Transforms a key. *

1.2 +6 -80 jakarta-commons/collections/src/java/org/apache/commons/collections/map/AbstractInputCheckedMapDecorator.java Index: AbstractInputCheckedMapDecorator.java =================================================================== RCS file: /home/cvs/jakarta-commons/collections/src/java/org/apache/commons/collections/map/AbstractInputCheckedMapDecorator.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- AbstractInputCheckedMapDecorator.java 3 May 2004 21:48:49 -0000 1.1 +++ AbstractInputCheckedMapDecorator.java 21 May 2004 22:01:04 -0000 1.2 @@ -34,13 +34,16 @@ * the map. By overriding these methods, the input can be validated or manipulated. * In addition to the main map methods, the entrySet is also affected, which is * the hardest part of writing map implementations. + *

+ * This class is package-scoped, and may be withdrawn or replaced in future + * versions of Commons Collections. * * @since Commons Collections 3.1 * @version $Revision$ $Date$ * * @author Stephen Colebourne */ -public class AbstractInputCheckedMapDecorator +abstract class AbstractInputCheckedMapDecorator extends AbstractMapDecorator { /** @@ -62,45 +65,6 @@ //----------------------------------------------------------------------- /** - * Hook method called when a key is being added to the map using - * put or putAll. - *

- * An implementation may validate the key and throw an exception - * or it may transform the key into another object. - * The key may already exist in the map. - *

- * This implementation returns the input key. - * - * @param key the key to check - * @throws UnsupportedOperationException if the map may not be changed by put/putAll - * @throws IllegalArgumentException if the specified key is invalid - * @throws ClassCastException if the class of the specified key is invalid - * @throws NullPointerException if the specified key is null and nulls are invalid - */ - protected Object checkPutKey(Object key) { - return key; - } - - /** - * Hook method called when a new value is being added to the map using - * put or putAll. - *

- * An implementation may validate the value and throw an exception - * or it may transform the value into another object. - *

- * This implementation returns the input value. - * - * @param value the value to check - * @throws UnsupportedOperationException if the map may not be changed by put/putAll - * @throws IllegalArgumentException if the specified value is invalid - * @throws ClassCastException if the class of the specified value is invalid - * @throws NullPointerException if the specified value is null and nulls are invalid - */ - protected Object checkPutValue(Object value) { - return value; - } - - /** * Hook method called when a value is being set using setValue. *

* An implementation may validate the value and throw an exception @@ -114,9 +78,7 @@ * @throws ClassCastException if the class of the specified value is invalid * @throws NullPointerException if the specified value is null and nulls are invalid */ - protected Object checkSetValue(Object value) { - return value; - } + protected abstract Object checkSetValue(Object value); /** * Hook method called to determine if checkSetValue has any effect. @@ -132,43 +94,7 @@ return true; } - /** - * Checks each element in the specified map, creating a new map. - *

- * This method is used by putAll to check all the elements - * before adding them to the map. - *

- * This implementation builds a LinkedMap to preserve the order - * of the input map. - * - * @param map the map to transform - * @throws the transformed object - */ - protected Map checkMap(Map map) { - Map result = new LinkedMap(map.size()); - for (Iterator it = map.entrySet().iterator(); it.hasNext(); ) { - Map.Entry entry = (Map.Entry) it.next(); - result.put(checkPutKey(entry.getKey()), checkPutValue(entry.getValue())); - } - return result; - } - //----------------------------------------------------------------------- - public Object put(Object key, Object value) { - key = checkPutKey(key); - value = checkPutValue(value); - return getMap().put(key, value); - } - - public void putAll(Map mapToCopy) { - if (mapToCopy.size() == 0) { - return; - } else { - mapToCopy = checkMap(mapToCopy); - getMap().putAll(mapToCopy); - } - } - public Set entrySet() { if (isSetValueChecking()) { return new EntrySet(map.entrySet(), this); 1.13 +1 -4 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.12 retrieving revision 1.13 diff -u -r1.12 -r1.13 --- PredicatedMap.java 21 May 2004 21:38:49 -0000 1.12 +++ PredicatedMap.java 21 May 2004 22:01:04 -0000 1.13 @@ -120,9 +120,6 @@ } //----------------------------------------------------------------------- - // The validate method exists for backwards compatability - in an ideal - // world, it wouldn't and the superclass methods checkPutKey/checkPutValue - // would be overridden instead /** * Validates a key value pair. * --------------------------------------------------------------------- To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org For additional commands, e-mail: commons-dev-help@jakarta.apache.org