commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From scolebou...@apache.org
Subject cvs commit: jakarta-commons/collections/src/java/org/apache/commons/collections/map TransformedMap.java AbstractInputCheckedMapDecorator.java PredicatedMap.java
Date Fri, 21 May 2004 22:01:04 GMT
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.
        * <p>
  
  
  
  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.
  + * <p>
  + * 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
  -     * <code>put</code> or <code>putAll</code>.
  -     * <p>
  -     * 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.
  -     * <p>
  -     * 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
  -     * <code>put</code> or <code>putAll</code>.
  -     * <p>
  -     * An implementation may validate the value and throw an exception
  -     * or it may transform the value into another object.
  -     * <p>
  -     * 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 <code>setValue</code>.
        * <p>
        * 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 <code>checkSetValue</code> has any
effect.
  @@ -132,43 +94,7 @@
           return true;
       }
   
  -    /**
  -     * Checks each element in the specified map, creating a new map.
  -     * <p>
  -     * This method is used by <code>putAll</code> to check all the elements
  -     * before adding them to the map.
  -     * <p>
  -     * This implementation builds a <code>LinkedMap</code> 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


Mime
View raw message