svn commit: r751739 - /commons/sandbox/compress/trunk/NOTICE.txt
Author: bodewig Date: Mon Mar 9 16:45:54 2009 New Revision: 751739 URL: http://svn.apache.org/viewvc?rev=751739view=rev Log: bump copyright Modified: commons/sandbox/compress/trunk/NOTICE.txt Modified: commons/sandbox/compress/trunk/NOTICE.txt URL: http://svn.apache.org/viewvc/commons/sandbox/compress/trunk/NOTICE.txt?rev=751739r1=751738r2=751739view=diff == --- commons/sandbox/compress/trunk/NOTICE.txt (original) +++ commons/sandbox/compress/trunk/NOTICE.txt Mon Mar 9 16:45:54 2009 @@ -1,5 +1,5 @@ Apache Commons Compress -Copyright 2002-2004 The Apache Software Foundation +Copyright 2002-2009 The Apache Software Foundation This product includes software developed by The Apache Software Foundation (http://www.apache.org/). @@ -7,4 +7,4 @@ Original BZip2 classes contributed by Keiron Liddle kei...@aftexsw.com, Aftex Software to the Apache Ant project Original Tar classes from contributors of the Apache Ant project Original Zip classes from contributors of the Apache Ant project -Original CPIO classes contributed by Markus Kuss and the jRPM project (jrpm.sourceforge.net) \ No newline at end of file +Original CPIO classes contributed by Markus Kuss and the jRPM project (jrpm.sourceforge.net)
svn commit: r751797 - /commons/proper/configuration/branches/configuration2_experimental/
Author: joehni Date: Mon Mar 9 19:26:32 2009 New Revision: 751797 URL: http://svn.apache.org/viewvc?rev=751797view=rev Log: Ignore all files and folders starting with dot. Modified: commons/proper/configuration/branches/configuration2_experimental/ (props changed) Propchange: commons/proper/configuration/branches/configuration2_experimental/ -- --- svn:ignore (original) +++ svn:ignore Mon Mar 9 19:26:32 2009 @@ -2,7 +2,7 @@ *.iws *.ipr *.iml -.nbattrs +.* docs target test-reports @@ -10,12 +10,7 @@ maven.log STRING0 lib -.classpath -.project *.ser junit*.properties *.patch - -.externalToolBuilders - maven-eclipse.xml
svn commit: r751850 - in /commons/proper/collections/branches/collections_jdk5_branch/src: java/org/apache/commons/collections/IteratorUtils.java test/org/apache/commons/collections/TestIteratorUtils.
Author: mbenson Date: Mon Mar 9 21:34:44 2009 New Revision: 751850 URL: http://svn.apache.org/viewvc?rev=751850view=rev Log: add iterable(Iterator) Modified: commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/IteratorUtils.java commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/TestIteratorUtils.java Modified: commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/IteratorUtils.java URL: http://svn.apache.org/viewvc/commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/IteratorUtils.java?rev=751850r1=751849r2=751850view=diff == --- commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/IteratorUtils.java (original) +++ commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/IteratorUtils.java Mon Mar 9 21:34:44 2009 @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the License); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an AS IS BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -55,7 +55,7 @@ import org.apache.commons.collections.iterators.UnmodifiableMapIterator; /** - * Provides static utility methods and decorators for {...@link Iterator} + * Provides static utility methods and decorators for {...@link Iterator} * instances. The implementations are provided in the iterators subpackage. * p * WARNING: Due to human error certain binary incompatabilities were introduced @@ -67,7 +67,7 @@ * * @since Commons Collections 2.1 * @version $Revision$ $Date$ - * + * * @author Stephen Colebourne * @author Phil Steitz */ @@ -93,17 +93,17 @@ /** * An ordered iterator over no elements. - */ + */ public static final OrderedIteratorObject EMPTY_ORDERED_ITERATOR = EmptyOrderedIterator.INSTANCE; /** * A map iterator over no elements. - */ + */ public static final MapIteratorObject, Object EMPTY_MAP_ITERATOR = EmptyMapIterator.INSTANCE; /** * An ordered map iterator over no elements. - */ + */ public static final OrderedMapIteratorObject, Object EMPTY_ORDERED_MAP_ITERATOR = EmptyOrderedMapIterator.INSTANCE; /** @@ -132,7 +132,7 @@ /** * Gets an empty list iterator. * p - * This iterator is a valid list iterator object that will iterate + * This iterator is a valid list iterator object that will iterate * over nothing. * p * WARNING: This method is binary incompatible with Commons Collections 2.1 and 2.1.1. @@ -147,7 +147,7 @@ /** * Gets an empty ordered iterator. * p - * This iterator is a valid iterator object that will iterate + * This iterator is a valid iterator object that will iterate * over nothing. * * @return an ordered iterator over nothing @@ -159,7 +159,7 @@ /** * Gets an empty map iterator. * p - * This iterator is a valid map iterator object that will iterate + * This iterator is a valid map iterator object that will iterate * over nothing. * * @return a map iterator over nothing @@ -171,7 +171,7 @@ /** * Gets an empty ordered map iterator. * p - * This iterator is a valid map iterator object that will iterate + * This iterator is a valid map iterator object that will iterate * over nothing. * * @return a map iterator over nothing @@ -385,7 +385,7 @@ public static E ResettableListIteratorE arrayListIterator(E[] array, int start, int end) { return new ObjectArrayListIteratorE(array, start, end); } - + /** * Gets a list iterator over part of an object or primitive array. * p @@ -404,7 +404,7 @@ public static E ResettableListIteratorE arrayListIterator(Object array, int start, int end) { return new ArrayListIteratorE(array, start, end); } - + // Unmodifiable //--- /** @@ -418,7 +418,7 @@ public static E IteratorE unmodifiableIterator(IteratorE iterator) { return UnmodifiableIterator.decorate(iterator); } - + /** * Gets an immutable version of a {...@link ListIterator}. The returned object * will always throw an {...@link UnsupportedOperationException} for @@ -447,7 +447,7 @@ // Chained
svn commit: r751852 - /commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/map/TransformedMap.java
Author: mbenson Date: Mon Mar 9 21:37:19 2009 New Revision: 751852 URL: http://svn.apache.org/viewvc?rev=751852view=rev Log: comments Modified: commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/map/TransformedMap.java Modified: commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/map/TransformedMap.java URL: http://svn.apache.org/viewvc/commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/map/TransformedMap.java?rev=751852r1=751851r2=751852view=diff == --- commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/map/TransformedMap.java (original) +++ commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/map/TransformedMap.java Mon Mar 9 21:37:19 2009 @@ -63,7 +63,7 @@ * p * If there are any elements already in the map being decorated, they * are NOT transformed. - * Constrast this with {...@link #decorateTransform}. + * Contrast this with {...@link #decorateTransform}. * * @param map the map to decorate, must not be null * @param keyTransformer the transformer to use for key conversion, null means no transformation @@ -82,7 +82,7 @@ * p * If there are any elements already in the map being decorated, they * will be transformed by this method. - * Constrast this with {...@link #decorate}. + * Contrast this with {...@link #decorate}. * * @param map the map to decorate, must not be null * @param keyTransformer the transformer to use for key conversion, null means no transformation
svn commit: r751857 - in /commons/proper/collections/branches/collections_jdk5_branch/src: java/org/apache/commons/collections/iterators/ test/org/apache/commons/collections/iterators/
Author: mbenson Date: Mon Mar 9 21:43:53 2009 New Revision: 751857 URL: http://svn.apache.org/viewvc?rev=751857view=rev Log: handle more ListIterator functionality when possible Added: commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/iterators/TestListIteratorWrapper2.java (with props) Modified: commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/iterators/ListIteratorWrapper.java commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/iterators/TestListIteratorWrapper.java Modified: commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/iterators/ListIteratorWrapper.java URL: http://svn.apache.org/viewvc/commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/iterators/ListIteratorWrapper.java?rev=751857r1=751856r2=751857view=diff == --- commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/iterators/ListIteratorWrapper.java (original) +++ commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/iterators/ListIteratorWrapper.java Mon Mar 9 21:43:53 2009 @@ -16,15 +16,21 @@ */ package org.apache.commons.collections.iterators; +import java.text.MessageFormat; import java.util.ArrayList; import java.util.Iterator; import java.util.List; +import java.util.ListIterator; import java.util.NoSuchElementException; +import org.apache.commons.collections.ResettableIterator; import org.apache.commons.collections.ResettableListIterator; /** - * Converts an iterator into a list iterator by caching the returned entries. + * Converts an {...@link Iterator} into a {...@link ResettableListIterator}. + * For plain codeIterator/codes this is accomplished by caching the returned + * elements. This class can also be used to simply add {...@link ResettableIterator} + * functionality to a given {...@link ListIterator}. * p * The codeListIterator/code interface has additional useful methods * for navigation - codeprevious()/code and the index methods. @@ -32,7 +38,7 @@ * codeListIterator/code. It achieves this by building a list internally * of as the underlying iterator is traversed. * p - * The optional operations of codeListIterator/code are not supported. + * The optional operations of codeListIterator/code are not supported for plain codeIterator/codes. * p * This class implements ResettableListIterator from Commons Collections 3.2. * @@ -41,13 +47,17 @@ * * @author Morgan Delagrange * @author Stephen Colebourne + * @author Matt Benson */ public class ListIteratorWrapperE implements ResettableListIteratorE { -/** Message used when remove, set or add are called. */ +/** Message used when set or add are called. */ private static final String UNSUPPORTED_OPERATION_MESSAGE = ListIteratorWrapper does not support optional operations of ListIterator.; +/** Message used when set or add are called. */ +private static final String CANNOT_REMOVE_MESSAGE = Cannot remove element at index {0}.; + /** The underlying iterator being decorated. */ private final Iterator? extends E iterator; /** The list being used to cache the iterator. */ @@ -57,6 +67,8 @@ private int currentIndex = 0; /** The current index of the wrapped iterator. */ private int wrappedIteratorIndex = 0; +/** recall whether the wrapped iterator's cursor is in such a state as to allow remove() to be called */ +private boolean removeState; // Constructor //- @@ -78,12 +90,19 @@ // ListIterator interface //- /** - * Throws {...@link UnsupportedOperationException}. + * Throws {...@link UnsupportedOperationException} + * unless the underlying codeIterator/code is a codeListIterator/code. * - * @param obj the object to add, ignored - * @throws UnsupportedOperationException always + * @param obj the object to add + * @throws UnsupportedOperationException */ public void add(E obj) throws UnsupportedOperationException { +if (iterator instanceof ListIterator) { +@SuppressWarnings(unchecked) +ListIteratorE li = (ListIteratorE) iterator; +li.add(obj); +return; +} throw new UnsupportedOperationException(UNSUPPORTED_OPERATION_MESSAGE); } @@ -93,7 +112,7 @@ * @return true if there are more elements */ public boolean hasNext() { -if (currentIndex == wrappedIteratorIndex) { +if (currentIndex == wrappedIteratorIndex || iterator
svn commit: r751858 - /commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/map/TestTransformedMap.java
Author: mbenson Date: Mon Mar 9 21:45:53 2009 New Revision: 751858 URL: http://svn.apache.org/viewvc?rev=751858view=rev Log: generics Modified: commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/map/TestTransformedMap.java Modified: commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/map/TestTransformedMap.java URL: http://svn.apache.org/viewvc/commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/map/TestTransformedMap.java?rev=751858r1=751857r2=751858view=diff == --- commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/map/TestTransformedMap.java (original) +++ commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/map/TestTransformedMap.java Mon Mar 9 21:45:53 2009 @@ -94,9 +94,9 @@ assertEquals(new Integer((String) els[0]), map.remove(els[0])); -Set entrySet = map.entrySet(); -Map.Entry[] array = (Map.Entry[]) entrySet.toArray(new Map.Entry[0]); -array[0].setValue(66); +SetMap.EntryK, V entrySet = map.entrySet(); +Map.EntryK, V[] array = entrySet.toArray(new Map.Entry[0]); +array[0].setValue((V) 66); assertEquals(new Integer(66), array[0].getValue()); assertEquals(new Integer(66), map.get(array[0].getKey()));
svn commit: r751865 - /commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/map/EntrySetToMapIteratorAdapter.java
Author: mbenson Date: Mon Mar 9 22:06:27 2009 New Revision: 751865 URL: http://svn.apache.org/viewvc?rev=751865view=rev Log: javadoc + extension point Modified: commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/map/EntrySetToMapIteratorAdapter.java Modified: commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/map/EntrySetToMapIteratorAdapter.java URL: http://svn.apache.org/viewvc/commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/map/EntrySetToMapIteratorAdapter.java?rev=751865r1=751864r2=751865view=diff == --- commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/map/EntrySetToMapIteratorAdapter.java (original) +++ commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/map/EntrySetToMapIteratorAdapter.java Mon Mar 9 22:06:27 2009 @@ -33,10 +33,14 @@ * @author Matt Benson */ public class EntrySetToMapIteratorAdapterK, V implements MapIteratorK, V, ResettableIteratorK { -private SetMap.EntryK, V entrySet; +/** The adapted Map entry Set. */ +protected SetMap.EntryK, V entrySet; -private transient IteratorMap.EntryK, V iterator; -private transient Map.EntryK, V entry; +/** The resettable iterator in use. */ +protected transient IteratorMap.EntryK, V iterator; + +/** The currently positioned Map entry. */ +protected transient Map.EntryK, V entry; /** * Create a new EntrySetToMapIteratorAdapter. @@ -97,7 +101,11 @@ entry = null; } -private synchronized Map.EntryK, V current() { +/** + * Get the currently active entry. + * @return Map.EntryK, V + */ +protected synchronized Map.EntryK, V current() { if (entry == null) { throw new IllegalStateException(); }
svn commit: r751869 - /commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/set/ListOrderedSet.java
Author: mbenson Date: Mon Mar 9 22:10:00 2009 New Revision: 751869 URL: http://svn.apache.org/viewvc?rev=751869view=rev Log: return type narrowing Modified: commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/set/ListOrderedSet.java Modified: commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/set/ListOrderedSet.java URL: http://svn.apache.org/viewvc/commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/set/ListOrderedSet.java?rev=751869r1=751868r2=751869view=diff == --- commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/set/ListOrderedSet.java (original) +++ commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/set/ListOrderedSet.java Mon Mar 9 22:10:00 2009 @@ -21,8 +21,10 @@ import java.util.HashSet; import java.util.Iterator; import java.util.List; +import java.util.ListIterator; import java.util.Set; +import org.apache.commons.collections.OrderedIterator; import org.apache.commons.collections.iterators.AbstractIteratorDecorator; import org.apache.commons.collections.list.UnmodifiableList; @@ -171,8 +173,8 @@ setOrder.clear(); } -public IteratorE iterator() { -return new OrderedSetIteratorE(setOrder.iterator(), collection); +public OrderedIteratorE iterator() { +return new OrderedSetIteratorE(setOrder.listIterator(), collection); } public boolean add(E object) { @@ -279,14 +281,15 @@ /** * Internal iterator handle remove. */ -static class OrderedSetIteratorE extends AbstractIteratorDecoratorE { +static class OrderedSetIteratorE extends AbstractIteratorDecoratorE implements OrderedIteratorE { /** Object we iterate on */ protected final CollectionE set; + /** Last object retrieved */ protected E last; -private OrderedSetIterator(IteratorE iterator, CollectionE set) { +private OrderedSetIterator(ListIteratorE iterator, CollectionE set) { super(iterator); this.set = set; } @@ -301,6 +304,15 @@ iterator.remove(); last = null; } + +public boolean hasPrevious() { +return ((ListIteratorE) iterator).hasPrevious(); +} + +public E previous() { +last = ((ListIteratorE) iterator).previous(); +return last; +} } }
svn commit: r751871 - in /commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections: IterableSortedMap.java bidimap/DualTreeBidiMap.java map/AbstractSortedMap
Author: mbenson Date: Mon Mar 9 22:13:34 2009 New Revision: 751871 URL: http://svn.apache.org/viewvc?rev=751871view=rev Log: Add OrderedMap to our SortedMap implementations Added: commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/IterableSortedMap.java (with props) Modified: commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/bidimap/DualTreeBidiMap.java commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/map/AbstractSortedMapDecorator.java Added: commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/IterableSortedMap.java URL: http://svn.apache.org/viewvc/commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/IterableSortedMap.java?rev=751871view=auto == --- commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/IterableSortedMap.java (added) +++ commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/IterableSortedMap.java Mon Mar 9 22:13:34 2009 @@ -0,0 +1,33 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the License); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.commons.collections; + +import java.util.SortedMap; + +/** + * {...@link SortedMap} + {...@link OrderedMap}. + * + * @param K the type of the keys in the map + * @param V the type of the values in the map + * @since Commons Collections 5 + * @TODO fix version + * @version $Revision$ $Date$ + * + * @author Matt Benson + */ +public interface IterableSortedMapK, V extends SortedMapK, V, OrderedMapK, V { +} Propchange: commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/IterableSortedMap.java -- svn:eol-style = native Propchange: commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/IterableSortedMap.java -- svn:keywords = Date Author Id Revision HeadURL Modified: commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/bidimap/DualTreeBidiMap.java URL: http://svn.apache.org/viewvc/commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/bidimap/DualTreeBidiMap.java?rev=751871r1=751870r2=751871view=diff == --- commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/bidimap/DualTreeBidiMap.java (original) +++ commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/bidimap/DualTreeBidiMap.java Mon Mar 9 22:13:34 2009 @@ -269,6 +269,14 @@ protected DualTreeBidiMapK, V decorated() { return (DualTreeBidiMapK, V) super.decorated(); } + +public K previousKey(K key) { +return decorated().previousKey(key); +}; + +public K nextKey(K key) { +return decorated().nextKey(key); +}; } //--- Modified: commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/map/AbstractSortedMapDecorator.java URL: http://svn.apache.org/viewvc/commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/map/AbstractSortedMapDecorator.java?rev=751871r1=751870r2=751871view=diff == --- commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/map/AbstractSortedMapDecorator.java (original) +++ commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/map/AbstractSortedMapDecorator.java Mon Mar 9 22:13:34 2009 @@ -17,8 +17,16 @@
svn commit: r751887 - in /commons/proper/collections/branches/collections_jdk5_branch/src: java/org/apache/commons/collections/MapUtils.java test/org/apache/commons/collections/TestMapUtils.java
Author: mbenson Date: Mon Mar 9 22:40:01 2009 New Revision: 751887 URL: http://svn.apache.org/viewvc?rev=751887view=rev Log: add methods to wrap Maps and SortedMaps not based on Commons Collections classes to their Iterable*Map counterparts Modified: commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/MapUtils.java commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/TestMapUtils.java Modified: commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/MapUtils.java URL: http://svn.apache.org/viewvc/commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/MapUtils.java?rev=751887r1=751886r2=751887view=diff == --- commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/MapUtils.java (original) +++ commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/MapUtils.java Mon Mar 9 22:40:01 2009 @@ -30,6 +30,8 @@ import java.util.SortedMap; import java.util.TreeMap; +import org.apache.commons.collections.map.AbstractMapDecorator; +import org.apache.commons.collections.map.AbstractSortedMapDecorator; import org.apache.commons.collections.map.FixedSizeMap; import org.apache.commons.collections.map.FixedSizeSortedMap; import org.apache.commons.collections.map.LazyMap; @@ -1397,7 +1399,7 @@ * @return an ordered map backed by the given map * @throws IllegalArgumentException if the Map is null */ -public static K, V IterableMapK, V orderedMap(MapK, V map) { +public static K, V OrderedMapK, V orderedMap(MapK, V map) { return ListOrderedMap.decorate(map); } @@ -1621,4 +1623,40 @@ return LazySortedMap.getLazySortedMap(map, transformerFactory); } +/** + * Get the specified {...@link Map} as an {...@link IterableMap}. + * @param K + * @param V + * @param map to wrap if necessary. + * @return IterableMapK, V + * @since Commons Collections 5 + * @TODO fix version + */ +public static K, V IterableMapK, V iterableMap(MapK, V map) { +if (map == null) { +throw new IllegalArgumentException(Map must not be null); +} +return map instanceof IterableMap ? (IterableMapK, V) map +: new AbstractMapDecoratorK, V(map) { +}; +} + +/** + * Get the specified {...@link SortedMap} as an {...@link IterableSortedMap}. + * @param K + * @param V + * @param sortedMap to wrap if necessary + * @return {...@link IterableSortedMap}K, V + * @since Commons Collections 5 + * @TODO fix version + */ +public static K, V IterableSortedMapK, V iterableSortedMap(SortedMapK, V sortedMap) { +if (sortedMap == null) { +throw new IllegalArgumentException(Map must not be null); +} +return sortedMap instanceof IterableSortedMap ? (IterableSortedMapK, V) sortedMap +: new AbstractSortedMapDecoratorK, V(sortedMap) { +}; +} + } Modified: commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/TestMapUtils.java URL: http://svn.apache.org/viewvc/commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/TestMapUtils.java?rev=751887r1=751886r2=751887view=diff == --- commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/TestMapUtils.java (original) +++ commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/TestMapUtils.java Mon Mar 9 22:40:01 2009 @@ -31,6 +31,7 @@ import org.apache.commons.collections.keyvalue.DefaultKeyValue; import org.apache.commons.collections.keyvalue.DefaultMapEntry; +import org.apache.commons.collections.map.HashedMap; import org.apache.commons.collections.map.LazyMap; import org.apache.commons.collections.map.PredicatedMap; @@ -737,4 +738,37 @@ assertEquals(false, MapUtils.isNotEmpty(map)); } +public void testIterableMap() { +try { +MapUtils.iterableMap(null); +fail(Should throw IllegalArgumentException); +} catch (IllegalArgumentException e) { +} +HashMapString, String map = new HashMapString, String(); +map.put(foo, foov); +map.put(bar, barv); +map.put(baz, bazv); +IterableMapString, String iMap = MapUtils.iterableMap(map); +assertEquals(map, iMap); +assertNotSame(map, iMap); +HashedMapString, String hMap = new HashedMapString, String(map); +assertSame(hMap, MapUtils.iterableMap(hMap)); +} + +
svn commit: r751888 - /commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/ResettableListIterator.java
Author: mbenson Date: Mon Mar 9 22:42:14 2009 New Revision: 751888 URL: http://svn.apache.org/viewvc?rev=751888view=rev Log: implement OrderedIterator (subset of ListIterator) Modified: commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/ResettableListIterator.java Modified: commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/ResettableListIterator.java URL: http://svn.apache.org/viewvc/commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/ResettableListIterator.java?rev=751888r1=751887r2=751888view=diff == --- commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/ResettableListIterator.java (original) +++ commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/ResettableListIterator.java Mon Mar 9 22:42:14 2009 @@ -29,6 +29,6 @@ * * @author Stephen Colebourne */ -public interface ResettableListIteratorE extends ListIteratorE, ResettableIteratorE { +public interface ResettableListIteratorE extends ListIteratorE, ResettableIteratorE, OrderedIteratorE { }
svn commit: r751890 - in /commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections: Get.java IterableGet.java IterableMap.java Put.java
Author: mbenson Date: Mon Mar 9 22:45:37 2009 New Revision: 751890 URL: http://svn.apache.org/viewvc?rev=751890view=rev Log: extract Put, Get, and IterableGet interfaces from IterableMap such that our Maps, which all implement IterableMap, can have their read/write functionality exposed separately. Added: commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/Get.java (with props) commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/IterableGet.java (with props) commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/Put.java (with props) Modified: commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/IterableMap.java Added: commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/Get.java URL: http://svn.apache.org/viewvc/commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/Get.java?rev=751890view=auto == --- commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/Get.java (added) +++ commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/Get.java Mon Mar 9 22:45:37 2009 @@ -0,0 +1,77 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the License); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.commons.collections; + +import java.util.Collection; +import java.util.Map; +import java.util.Set; + +/** + * The read subset of the {...@link Map} interface. + * @since Commons Collections 5 + * @TODO fix version + * @version $Revision$ $Date$ + * @see Put + * @author Matt Benson + */ +public interface GetK, V { + +/** + * @see Map#containsKey(Object) + */ +public boolean containsKey(Object key); + +/** + * @see Map#containsValue(Object) + */ +public boolean containsValue(Object value); + +/** + * @see Map#entrySet() + */ +public Setjava.util.Map.EntryK, V entrySet(); + +/** + * @see Map#get(Object) + */ +public V get(Object key); + +/** + * @see Map#remove(Object) + */ +public V remove(Object key); + +/** + * @see Map#isEmpty() + */ +public boolean isEmpty(); + +/** + * @see Map#keySet() + */ +public SetK keySet(); + +/** + * @see Map#size() + */ +public int size(); + +/** + * @see Map#values() + */ +public CollectionV values(); +} Propchange: commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/Get.java -- svn:eol-style = native Propchange: commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/Get.java -- svn:keywords = Date Author Id Revision HeadURL Added: commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/IterableGet.java URL: http://svn.apache.org/viewvc/commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/IterableGet.java?rev=751890view=auto == --- commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/IterableGet.java (added) +++ commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/IterableGet.java Mon Mar 9 22:45:37 2009 @@ -0,0 +1,49 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the License); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + *
svn commit: r751894 - in /commons/proper/collections/branches/collections_jdk5_branch/src: java/org/apache/commons/collections/splitmap/ test/org/apache/commons/collections/ test/org/apache/commons/co
Author: mbenson Date: Mon Mar 9 22:48:07 2009 New Revision: 751894 URL: http://svn.apache.org/viewvc?rev=751894view=rev Log: add splitmap package whose original goal is to provide a more versatile TransformedMap implementation Added: commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/splitmap/ commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/splitmap/AbstractIterableGetMapDecorator.java (with props) commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/splitmap/SplitMapUtils.java (with props) commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/splitmap/TransformedMap.java (with props) commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/splitmap/package.html (with props) commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/splitmap/ commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/splitmap/TestAll.java (with props) commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/splitmap/TestSplitMapUtils.java (with props) commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/splitmap/TestTransformedMap.java (with props) Modified: commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/TestAllPackages.java Added: commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/splitmap/AbstractIterableGetMapDecorator.java URL: http://svn.apache.org/viewvc/commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/splitmap/AbstractIterableGetMapDecorator.java?rev=751894view=auto == --- commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/splitmap/AbstractIterableGetMapDecorator.java (added) +++ commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/splitmap/AbstractIterableGetMapDecorator.java Mon Mar 9 22:48:07 2009 @@ -0,0 +1,161 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the License); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.commons.collections.splitmap; + +import java.util.Collection; +import java.util.Map; +import java.util.Set; + +import org.apache.commons.collections.Get; +import org.apache.commons.collections.IterableGet; +import org.apache.commons.collections.MapIterator; +import org.apache.commons.collections.map.EntrySetToMapIteratorAdapter; + +/** + * {...@link IterableGet} that uses a {...@link Map}K, V for the {...@link Get}K, V + * implementation. + * + * @since Commons Collections 5 + * @TODO fix version + * @version $Revision$ $Date$ + * + * @author Matt Benson + */ +public class AbstractIterableGetMapDecoratorK, V implements IterableGetK, V { +/** The map to decorate */ +protected transient MapK, V map; + +/** + * Create a new AbstractSplitMapDecorator. + * @param decorated the Map to decorate + */ +public AbstractIterableGetMapDecorator(MapK, V decorated) { +this.map = decorated; +} + +/** + * Gets the map being decorated. + * + * @return the decorated map + */ +protected MapK, V decorated() { +return map; +} + +/** + * {...@inheritdoc} + */ +public void clear() { +decorated().clear(); +} + +/** + * {...@inheritdoc} + */ +public boolean containsKey(Object key) { +return decorated().containsKey(key); +} + +/** + * {...@inheritdoc} + */ +public boolean containsValue(Object value) { +return decorated().containsValue(value); +} + +/** + * {...@inheritdoc} + */ +public SetMap.EntryK, V entrySet() { +return decorated().entrySet(); +} + +/** + * {...@inheritdoc} + */ +public V get(Object
svn commit: r751901 - /commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/splitmap/TransformedMap.java
Author: mbenson Date: Mon Mar 9 23:06:49 2009 New Revision: 751901 URL: http://svn.apache.org/viewvc?rev=751901view=rev Log: comments Modified: commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/splitmap/TransformedMap.java Modified: commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/splitmap/TransformedMap.java URL: http://svn.apache.org/viewvc/commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/splitmap/TransformedMap.java?rev=751901r1=751900r2=751901view=diff == --- commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/splitmap/TransformedMap.java (original) +++ commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/splitmap/TransformedMap.java Mon Mar 9 23:06:49 2009 @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the License); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an AS IS BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -22,6 +22,7 @@ import java.io.Serializable; import java.util.Map; +import org.apache.commons.collections.Get; import org.apache.commons.collections.Put; import org.apache.commons.collections.Transformer; import org.apache.commons.collections.map.LinkedMap; @@ -40,11 +41,22 @@ * is to wrap this map using {...@link java.util.Collections#synchronizedMap(Map)}. * This class may throw exceptions when accessed by concurrent threads without * synchronization. - * + * p + * The put and get type constraints of this class are mutually independent; + * contrast with {...@link org.apache.commons.collections.map.TransformedMap} which, + * by virtue of its implementing {...@link Map}lt;K, Vgt;, must be constructed in such + * a way that its read and write parameters are generalized to a common (super-)type. + * In practice this would often mean codegt;Object, Objectgt;/code, defeating + * much of the usefulness of having parameterized types. + * p + * On the downside, this class is not a drop-in replacement for {...@link java.util.Map} + * but is intended to be worked with either directly or by {...@link Put} and {...@link Get} + * generalizations. + * * @since Commons Collections 5 * @TODO fix version * @version $Revision$ $Date$ - * + * * @author Stephen Colebourne * @author Matt Benson */ @@ -66,7 +78,7 @@ * p * If there are any elements already in the map being decorated, they are * NOT transformed. - * + * * @param map the map to decorate, must not be null * @param keyTransformer the transformer to use for key conversion, null * means no transformation @@ -86,7 +98,7 @@ * p * If there are any elements already in the collection being decorated, they * are NOT transformed. - * + * * @param map the map to decorate, must not be null * @param keyTransformer the transformer to use for key conversion, null * means no conversion @@ -110,7 +122,7 @@ //--- /** * Write the map out using a custom routine. - * + * * @param out the output stream * @throws IOException */ @@ -121,7 +133,7 @@ /** * Read the map in using a custom routine. - * + * * @param in the input stream * @throws IOException * @throws ClassNotFoundException @@ -138,7 +150,7 @@ * Transforms a key. * p * The transformer itself may throw an exception if necessary. - * + * * @param object the object to transform * @throws the transformed object */ @@ -150,7 +162,7 @@ * Transforms a value. * p * The transformer itself may throw an exception if necessary. - * + * * @param object the object to transform * @throws the transformed object */ @@ -162,7 +174,7 @@ * Transforms a map. * p * The transformer itself may throw an exception if necessary. - * + * * @param map the map to transform * @throws the transformed object */ @@ -181,7 +193,7 @@ /** * Override to transform the value when using codesetValue/code. - * + * * @param value the value to transform * @return the transformed value */ @@ -204,5 +216,5 @@ decorated().putAll(transformMap(mapToCopy)); } - + }
svn commit: r751903 - /commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/map/TransformedMap.java
Author: mbenson Date: Mon Mar 9 23:10:21 2009 New Revision: 751903 URL: http://svn.apache.org/viewvc?rev=751903view=rev Log: comment Modified: commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/map/TransformedMap.java Modified: commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/map/TransformedMap.java URL: http://svn.apache.org/viewvc/commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/map/TransformedMap.java?rev=751903r1=751902r2=751903view=diff == --- commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/map/TransformedMap.java (original) +++ commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/map/TransformedMap.java Mon Mar 9 23:10:21 2009 @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the License); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an AS IS BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -36,14 +36,16 @@ * strongNote that TransformedMap is not synchronized and is not thread-safe./strong * If you wish to use this map from multiple threads concurrently, you must use * appropriate synchronization. The simplest approach is to wrap this map - * using {...@link java.util.Collections#synchronizedMap(Map)}. This class may throw + * using {...@link java.util.Collections#synchronizedMap(Map)}. This class may throw * exceptions when accessed by concurrent threads without synchronization. * p * This class is Serializable from Commons Collections 3.1. + * p + * @see org.apache.commons.collections.splitmap.TransformedMap * * @since Commons Collections 3.0 * @version $Revision$ $Date$ - * + * * @author Stephen Colebourne */ public class TransformedMapK, V @@ -64,7 +66,7 @@ * If there are any elements already in the map being decorated, they * are NOT transformed. * Contrast this with {...@link #decorateTransform}. - * + * * @param map the map to decorate, must not be null * @param keyTransformer the transformer to use for key conversion, null means no transformation * @param valueTransformer the transformer to use for value conversion, null means no transformation @@ -83,7 +85,7 @@ * If there are any elements already in the map being decorated, they * will be transformed by this method. * Contrast this with {...@link #decorate}. - * + * * @param map the map to decorate, must not be null * @param keyTransformer the transformer to use for key conversion, null means no transformation * @param valueTransformer the transformer to use for value conversion, null means no transformation @@ -108,7 +110,7 @@ * p * If there are any elements already in the collection being decorated, they * are NOT transformed. - * + * * @param map the map to decorate, must not be null * @param keyTransformer the transformer to use for key conversion, null means no conversion * @param valueTransformer the transformer to use for value conversion, null means no conversion @@ -124,7 +126,7 @@ //--- /** * Write the map out using a custom routine. - * + * * @param out the output stream * @throws IOException * @since Commons Collections 3.1 @@ -136,7 +138,7 @@ /** * Read the map in using a custom routine. - * + * * @param in the input stream * @throws IOException * @throws ClassNotFoundException @@ -153,7 +155,7 @@ * Transforms a key. * p * The transformer itself may throw an exception if necessary. - * + * * @param object the object to transform * @throws the transformed object */ @@ -168,7 +170,7 @@ * Transforms a value. * p * The transformer itself may throw an exception if necessary. - * + * * @param object the object to transform * @throws the transformed object */ @@ -183,7 +185,7 @@ * Transforms a map. * p * The transformer itself may throw an exception if necessary. - * + * * @param map the map to transform * @throws the transformed object */ @@ -202,7 +204,7 @@ /** * Override to transform the value when using codesetValue/code. - * + * * @param value the value to transform