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/bidimap AbstractDualBidiMap.java
Date Mon, 29 Dec 2003 01:28:20 GMT
scolebourne    2003/12/28 17:28:20

  Modified:    collections/src/java/org/apache/commons/collections/bidimap
                        AbstractDualBidiMap.java
  Log:
  Increase flexibility by adding factories for view iterators
  
  Revision  Changes    Path
  1.7       +73 -5     jakarta-commons/collections/src/java/org/apache/commons/collections/bidimap/AbstractDualBidiMap.java
  
  Index: AbstractDualBidiMap.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/collections/src/java/org/apache/commons/collections/bidimap/AbstractDualBidiMap.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- AbstractDualBidiMap.java	29 Dec 2003 00:38:08 -0000	1.6
  +++ AbstractDualBidiMap.java	29 Dec 2003 01:28:20 -0000	1.7
  @@ -258,6 +258,13 @@
       
       // Map views
       //-----------------------------------------------------------------------
  +    /**
  +     * Gets a keySet view of the map.
  +     * Changes made on the view are reflected in the map.
  +     * The set supports remove and clear but not add.
  +     * 
  +     * @return the keySet view
  +     */
       public Set keySet() {
           if (keySet == null) {
               keySet = new KeySet(this);
  @@ -265,6 +272,24 @@
           return keySet;
       }
   
  +    /**
  +     * Creates a key set iterator.
  +     * Subclasses can override this to return iterators with different properties.
  +     * 
  +     * @param iterator  the iterator to decorate
  +     * @return the keySet iterator
  +     */
  +    protected Iterator createKeySetIterator(Iterator iterator) {
  +        return new KeySetIterator(iterator, this);
  +    }
  +
  +    /**
  +     * Gets a values view of the map.
  +     * Changes made on the view are reflected in the map.
  +     * The set supports remove and clear but not add.
  +     * 
  +     * @return the values view
  +     */
       public Collection values() {
           if (values == null) {
               values = new Values(this);
  @@ -273,6 +298,17 @@
       }
   
       /**
  +     * Creates a values iterator.
  +     * Subclasses can override this to return iterators with different properties.
  +     * 
  +     * @param iterator  the iterator to decorate
  +     * @return the values iterator
  +     */
  +    protected Iterator createValuesIterator(Iterator iterator) {
  +        return new ValuesIterator(iterator, this);
  +    }
  +
  +    /**
        * Gets an entrySet view of the map.
        * Changes made on the set are reflected in the map.
        * The set supports remove and clear but not add.
  @@ -290,6 +326,17 @@
           return entrySet;
       }
       
  +    /**
  +     * Creates an entry set iterator.
  +     * Subclasses can override this to return iterators with different properties.
  +     * 
  +     * @param iterator  the iterator to decorate
  +     * @return the entrySet iterator
  +     */
  +    protected Iterator createEntrySetIterator(Iterator iterator) {
  +        return new EntrySetIterator(iterator, this);
  +    }
  +
       //-----------------------------------------------------------------------
       /**
        * Inner class View.
  @@ -299,6 +346,12 @@
           /** The parent map */
           protected final AbstractDualBidiMap parent;
           
  +        /**
  +         * Constructs a new view of the BidiMap.
  +         * 
  +         * @param coll  the collection view being decorated
  +         * @param parent  the parent BidiMap
  +         */
           protected View(Collection coll, AbstractDualBidiMap parent) {
               super(coll);
               this.parent = parent;
  @@ -349,12 +402,17 @@
        */
       protected static class KeySet extends View implements Set {
           
  +        /**
  +         * Constructs a new view of the BidiMap.
  +         * 
  +         * @param parent  the parent BidiMap
  +         */
           protected KeySet(AbstractDualBidiMap parent) {
               super(parent.maps[0].keySet(), parent);
           }
   
           public Iterator iterator() {
  -            return new KeySetIterator(super.iterator(), parent);
  +            return parent.createKeySetIterator(super.iterator());
           }
           
           public boolean contains(Object key) {
  @@ -412,12 +470,17 @@
        */
       protected static class Values extends View implements Set {
           
  +        /**
  +         * Constructs a new view of the BidiMap.
  +         * 
  +         * @param parent  the parent BidiMap
  +         */
           protected Values(AbstractDualBidiMap parent) {
               super(parent.maps[0].values(), parent);
           }
   
           public Iterator iterator() {
  -            return new ValuesIterator(super.iterator(), parent);
  +            return parent.createValuesIterator(super.iterator());
           }
           
           public boolean contains(Object value) {
  @@ -474,12 +537,17 @@
        */
       protected static class EntrySet extends View implements Set {
           
  +        /**
  +         * Constructs a new view of the BidiMap.
  +         * 
  +         * @param parent  the parent BidiMap
  +         */
           protected EntrySet(AbstractDualBidiMap parent) {
               super(parent.maps[0].entrySet(), parent);
           }
   
           public Iterator iterator() {
  -            return new EntrySetIterator(super.iterator(), parent);
  +            return parent.createEntrySetIterator(super.iterator());
           }
           
           public boolean remove(Object obj) {
  
  
  

---------------------------------------------------------------------
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