svn commit: r815062 - /commons/proper/collections/trunk/src/java/org/apache/commons/collections/list/AbstractListDecorator.java
Author: bayard Date: Tue Sep 15 05:55:35 2009 New Revision: 815062 URL: http://svn.apache.org/viewvc?rev=815062view=rev Log: Merging from -r468106:814127 of collections_jdk5_branch - namely where this code was generified; mostly in r738956. Also see the following revisions: r471192 | scolebourne | 2006-11-04 06:04:46 -0800 (Sat, 04 Nov 2006) | 1 line Remove getList() - use decorated() r471173 | scolebourne | 2006-11-04 04:07:39 -0800 (Sat, 04 Nov 2006) | 1 line Abstract*Decorator - Generify and use covariant return types Modified: commons/proper/collections/trunk/src/java/org/apache/commons/collections/list/AbstractListDecorator.java Modified: commons/proper/collections/trunk/src/java/org/apache/commons/collections/list/AbstractListDecorator.java URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/java/org/apache/commons/collections/list/AbstractListDecorator.java?rev=815062r1=815061r2=815062view=diff == --- commons/proper/collections/trunk/src/java/org/apache/commons/collections/list/AbstractListDecorator.java (original) +++ commons/proper/collections/trunk/src/java/org/apache/commons/collections/list/AbstractListDecorator.java Tue Sep 15 05:55:35 2009 @@ -27,12 +27,17 @@ * p * Methods are forwarded directly to the decorated list. * + * @param E the type of the elements in the list * @since Commons Collections 3.0 * @version $Revision$ $Date$ * * @author Stephen Colebourne */ -public abstract class AbstractListDecorator extends AbstractCollectionDecorator implements List { +public abstract class AbstractListDecoratorE extends AbstractCollectionDecoratorE implements +ListE { + +/** Serialization version--necessary in an abstract class? */ +private static final long serialVersionUID = 4500739654952315623L; /** * Constructor only used in deserialization, do not use otherwise. @@ -48,7 +53,7 @@ * @param list the list to decorate, must not be null * @throws IllegalArgumentException if list is null */ -protected AbstractListDecorator(List list) { +protected AbstractListDecorator(ListE list) { super(list); } @@ -57,49 +62,49 @@ * * @return the decorated list */ -protected List getList() { -return (List) getCollection(); +protected ListE decorated() { +return (ListE) super.decorated(); } //--- -public void add(int index, Object object) { -getList().add(index, object); +public void add(int index, E object) { +decorated().add(index, object); } -public boolean addAll(int index, Collection coll) { -return getList().addAll(index, coll); +public boolean addAll(int index, Collection? extends E coll) { +return decorated().addAll(index, coll); } -public Object get(int index) { -return getList().get(index); +public E get(int index) { +return decorated().get(index); } public int indexOf(Object object) { -return getList().indexOf(object); +return decorated().indexOf(object); } public int lastIndexOf(Object object) { -return getList().lastIndexOf(object); +return decorated().lastIndexOf(object); } -public ListIterator listIterator() { -return getList().listIterator(); +public ListIteratorE listIterator() { +return decorated().listIterator(); } -public ListIterator listIterator(int index) { -return getList().listIterator(index); +public ListIteratorE listIterator(int index) { +return decorated().listIterator(index); } -public Object remove(int index) { -return getList().remove(index); +public E remove(int index) { +return decorated().remove(index); } -public Object set(int index, Object object) { -return getList().set(index, object); +public E set(int index, E object) { +return decorated().set(index, object); } -public List subList(int fromIndex, int toIndex) { -return getList().subList(fromIndex, toIndex); +public ListE subList(int fromIndex, int toIndex) { +return decorated().subList(fromIndex, toIndex); } }
svn commit: r815061 - /commons/proper/collections/trunk/src/java/org/apache/commons/collections/IteratorUtils.java
Author: bayard Date: Tue Sep 15 05:55:33 2009 New Revision: 815061 URL: http://svn.apache.org/viewvc?rev=815061view=rev Log: Merging from -r468106:814127 of collections_jdk5_branch - namely where this code was generified; mostly in r738956. Also see the following revisions: r753392 | mbenson | 2009-03-13 13:39:53 -0700 (Fri, 13 Mar 2009) | 1 line revert IteratorUtils stuff; toList() works fine for this--duh r751850 | mbenson | 2009-03-09 14:34:44 -0700 (Mon, 09 Mar 2009) | 1 line add iterable(Iterator) Modified: commons/proper/collections/trunk/src/java/org/apache/commons/collections/IteratorUtils.java Modified: commons/proper/collections/trunk/src/java/org/apache/commons/collections/IteratorUtils.java URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/java/org/apache/commons/collections/IteratorUtils.java?rev=815061r1=815060r2=815061view=diff == --- commons/proper/collections/trunk/src/java/org/apache/commons/collections/IteratorUtils.java (original) +++ commons/proper/collections/trunk/src/java/org/apache/commons/collections/IteratorUtils.java Tue Sep 15 05:55:33 2009 @@ -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 @@ -81,26 +81,30 @@ * WARNING: This constant is binary incompatible with Commons Collections 2.1 and 2.1.1. * Use codeEmptyIterator.INSTANCE/code for compatability with Commons Collections 2.1.1. */ -public static final ResettableIterator EMPTY_ITERATOR = EmptyIterator.RESETTABLE_INSTANCE; +public static final ResettableIteratorObject EMPTY_ITERATOR = EmptyIterator.RESETTABLE_INSTANCE; + /** * A list iterator over no elements. * p * WARNING: This constant is binary incompatible with Commons Collections 2.1 and 2.1.1. * Use codeEmptyListIterator.INSTANCE/code for compatability with Commons Collections 2.1.1. */ -public static final ResettableListIterator EMPTY_LIST_ITERATOR = EmptyListIterator.RESETTABLE_INSTANCE; +public static final ResettableListIteratorObject EMPTY_LIST_ITERATOR = EmptyListIterator.RESETTABLE_INSTANCE; + /** * An ordered iterator over no elements. - */ -public static final OrderedIterator EMPTY_ORDERED_ITERATOR = EmptyOrderedIterator.INSTANCE; + */ +public static final OrderedIteratorObject EMPTY_ORDERED_ITERATOR = EmptyOrderedIterator.INSTANCE; + /** * A map iterator over no elements. - */ -public static final MapIterator EMPTY_MAP_ITERATOR = EmptyMapIterator.INSTANCE; + */ +public static final MapIteratorObject, Object EMPTY_MAP_ITERATOR = EmptyMapIterator.INSTANCE; + /** * An ordered map iterator over no elements. - */ -public static final OrderedMapIterator EMPTY_ORDERED_MAP_ITERATOR = EmptyOrderedMapIterator.INSTANCE; + */ +public static final OrderedMapIteratorObject, Object EMPTY_ORDERED_MAP_ITERATOR = EmptyOrderedMapIterator.INSTANCE; /** * IteratorUtils is not normally instantiated. @@ -121,14 +125,14 @@ * * @return an iterator over nothing */ -public static ResettableIterator emptyIterator() { -return EMPTY_ITERATOR; +public static E ResettableIteratorE emptyIterator() { +return EmptyIterator.EgetResettableInstance(); } /** * 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. @@ -136,44 +140,44 @@ * * @return a list iterator over nothing */ -public static ResettableListIterator emptyListIterator() { -return EMPTY_LIST_ITERATOR; +public static E ResettableListIteratorE emptyListIterator() { +return EmptyListIterator.EgetResettableInstance(); } /** * 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 */ -public static OrderedIterator emptyOrderedIterator() { -return
svn commit: r815064 - /commons/proper/collections/trunk/src/java/org/apache/commons/collections/list/GrowthList.java
Author: bayard Date: Tue Sep 15 05:55:39 2009 New Revision: 815064 URL: http://svn.apache.org/viewvc?rev=815064view=rev Log: Merging from -r468106:814127 of collections_jdk5_branch - namely where this code was generified; mostly in r738956. Also see the following revisions: r471192 | scolebourne | 2006-11-04 06:04:46 -0800 (Sat, 04 Nov 2006) | 1 line Remove getList() - use decorated() Modified: commons/proper/collections/trunk/src/java/org/apache/commons/collections/list/GrowthList.java Modified: commons/proper/collections/trunk/src/java/org/apache/commons/collections/list/GrowthList.java URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/java/org/apache/commons/collections/list/GrowthList.java?rev=815064r1=815063r2=815064view=diff == --- commons/proper/collections/trunk/src/java/org/apache/commons/collections/list/GrowthList.java (original) +++ commons/proper/collections/trunk/src/java/org/apache/commons/collections/list/GrowthList.java Tue Sep 15 05:55:39 2009 @@ -55,7 +55,7 @@ * @author Stephen Colebourne * @author Paul Legato */ -public class GrowthList extends AbstractSerializableListDecorator { +public class GrowthListE extends AbstractSerializableListDecoratorE { /** Serialization version */ private static final long serialVersionUID = -3620001881672L; @@ -66,8 +66,8 @@ * @param list the list to decorate, must not be null * @throws IllegalArgumentException if list is null */ -public static List decorate(List list) { -return new GrowthList(list); +public static E ListE decorate(ListE list) { +return new GrowthListE(list); } //--- @@ -75,7 +75,7 @@ * Constructor that uses an ArrayList internally. */ public GrowthList() { -super(new ArrayList()); +super(new ArrayListE()); } /** @@ -85,7 +85,7 @@ * @throws IllegalArgumentException if initial size is invalid */ public GrowthList(int initialSize) { -super(new ArrayList(initialSize)); +super(new ArrayListE(initialSize)); } /** @@ -94,7 +94,7 @@ * @param list the list to decorate, must not be null * @throws IllegalArgumentException if list is null */ -protected GrowthList(List list) { +protected GrowthList(ListE list) { super(list); } @@ -117,12 +117,12 @@ * @throws ClassCastException if the underlying list rejects the element * @throws IllegalArgumentException if the underlying list rejects the element */ -public void add(int index, Object element) { -int size = getList().size(); +public void add(int index, E element) { +int size = decorated().size(); if (index size) { -getList().addAll(Collections.nCopies(index - size, null)); +decorated().addAll(Collections.EnCopies(index - size, null)); } -getList().add(index, element); +decorated().add(index, element); } //--- @@ -145,14 +145,14 @@ * @throws ClassCastException if the underlying list rejects the element * @throws IllegalArgumentException if the underlying list rejects the element */ -public boolean addAll(int index, Collection coll) { -int size = getList().size(); +public boolean addAll(int index, Collection? extends E coll) { +int size = decorated().size(); boolean result = false; if (index size) { -getList().addAll(Collections.nCopies(index - size, null)); +decorated().addAll(Collections.EnCopies(index - size, null)); result = true; } -return (getList().addAll(index, coll) | result); +return (decorated().addAll(index, coll) | result); } //--- @@ -175,12 +175,12 @@ * @throws ClassCastException if the underlying list rejects the element * @throws IllegalArgumentException if the underlying list rejects the element */ -public Object set(int index, Object element) { -int size = getList().size(); +public E set(int index, E element) { +int size = decorated().size(); if (index = size) { -getList().addAll(Collections.nCopies((index - size) + 1, null)); +decorated().addAll(Collections.EnCopies((index - size) + 1, null)); } -return getList().set(index, element); +return decorated().set(index, element); } }
svn commit: r815063 - /commons/proper/collections/trunk/src/java/org/apache/commons/collections/list/FixedSizeList.java
Author: bayard Date: Tue Sep 15 05:55:37 2009 New Revision: 815063 URL: http://svn.apache.org/viewvc?rev=815063view=rev Log: Merging from -r468106:814127 of collections_jdk5_branch - namely where this code was generified; mostly in r738956. Also see the following revisions: r471192 | scolebourne | 2006-11-04 06:04:46 -0800 (Sat, 04 Nov 2006) | 1 line Remove getList() - use decorated() Modified: commons/proper/collections/trunk/src/java/org/apache/commons/collections/list/FixedSizeList.java Modified: commons/proper/collections/trunk/src/java/org/apache/commons/collections/list/FixedSizeList.java URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/java/org/apache/commons/collections/list/FixedSizeList.java?rev=815063r1=815062r2=815063view=diff == --- commons/proper/collections/trunk/src/java/org/apache/commons/collections/list/FixedSizeList.java (original) +++ commons/proper/collections/trunk/src/java/org/apache/commons/collections/list/FixedSizeList.java Tue Sep 15 05:55:37 2009 @@ -39,9 +39,9 @@ * @author Stephen Colebourne * @author Paul Jack */ -public class FixedSizeList -extends AbstractSerializableListDecorator -implements BoundedCollection { +public class FixedSizeListE +extends AbstractSerializableListDecoratorE +implements BoundedCollectionE { /** Serialization version */ private static final long serialVersionUID = -2218010673611160319L; @@ -52,8 +52,8 @@ * @param list the list to decorate, must not be null * @throws IllegalArgumentException if list is null */ -public static List decorate(List list) { -return new FixedSizeList(list); +public static E ListE decorate(ListE list) { +return new FixedSizeListE(list); } //--- @@ -63,24 +63,24 @@ * @param list the list to decorate, must not be null * @throws IllegalArgumentException if list is null */ -protected FixedSizeList(List list) { +protected FixedSizeList(ListE list) { super(list); } //--- -public boolean add(Object object) { +public boolean add(E object) { throw new UnsupportedOperationException(List is fixed size); } -public void add(int index, Object object) { +public void add(int index, E object) { throw new UnsupportedOperationException(List is fixed size); } -public boolean addAll(Collection coll) { +public boolean addAll(Collection? extends E coll) { throw new UnsupportedOperationException(List is fixed size); } -public boolean addAll(int index, Collection coll) { +public boolean addAll(int index, Collection? extends E coll) { throw new UnsupportedOperationException(List is fixed size); } @@ -88,31 +88,31 @@ throw new UnsupportedOperationException(List is fixed size); } -public Object get(int index) { -return getList().get(index); +public E get(int index) { +return decorated().get(index); } public int indexOf(Object object) { -return getList().indexOf(object); +return decorated().indexOf(object); } -public Iterator iterator() { -return UnmodifiableIterator.decorate(getCollection().iterator()); +public IteratorE iterator() { +return UnmodifiableIterator.decorate(decorated().iterator()); } public int lastIndexOf(Object object) { -return getList().lastIndexOf(object); +return decorated().lastIndexOf(object); } -public ListIterator listIterator() { -return new FixedSizeListIterator(getList().listIterator(0)); +public ListIteratorE listIterator() { +return new FixedSizeListIterator(decorated().listIterator(0)); } -public ListIterator listIterator(int index) { -return new FixedSizeListIterator(getList().listIterator(index)); +public ListIteratorE listIterator(int index) { +return new FixedSizeListIterator(decorated().listIterator(index)); } -public Object remove(int index) { +public E remove(int index) { throw new UnsupportedOperationException(List is fixed size); } @@ -120,28 +120,28 @@ throw new UnsupportedOperationException(List is fixed size); } -public boolean removeAll(Collection coll) { +public boolean removeAll(Collection? coll) { throw new UnsupportedOperationException(List is fixed size); } -public boolean retainAll(Collection coll) { +public boolean retainAll(Collection? coll) { throw new
svn commit: r815065 - /commons/proper/collections/trunk/src/java/org/apache/commons/collections/list/LazyList.java
Author: bayard Date: Tue Sep 15 05:55:41 2009 New Revision: 815065 URL: http://svn.apache.org/viewvc?rev=815065view=rev Log: Merging from -r468106:814127 of collections_jdk5_branch - namely where this code was generified; mostly in r738956. Also see the following revisions: r471192 | scolebourne | 2006-11-04 06:04:46 -0800 (Sat, 04 Nov 2006) | 1 line Remove getList() - use decorated() Modified: commons/proper/collections/trunk/src/java/org/apache/commons/collections/list/LazyList.java Modified: commons/proper/collections/trunk/src/java/org/apache/commons/collections/list/LazyList.java URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/java/org/apache/commons/collections/list/LazyList.java?rev=815065r1=815064r2=815065view=diff == --- commons/proper/collections/trunk/src/java/org/apache/commons/collections/list/LazyList.java (original) +++ commons/proper/collections/trunk/src/java/org/apache/commons/collections/list/LazyList.java Tue Sep 15 05:55:41 2009 @@ -61,13 +61,13 @@ * @author Arron Bates * @author Paul Jack */ -public class LazyList extends AbstractSerializableListDecorator { +public class LazyListE extends AbstractSerializableListDecoratorE { /** Serialization version */ private static final long serialVersionUID = -1708388017160694542L; /** The factory to use to lazily instantiate the objects */ -protected final Factory factory; +protected final Factory? extends E factory; /** * Factory method to create a lazily instantiating list. @@ -76,8 +76,8 @@ * @param factory the factory to use for creation, must not be null * @throws IllegalArgumentException if list or factory is null */ -public static List decorate(List list, Factory factory) { -return new LazyList(list, factory); +public static E ListE decorate(ListE list, Factory? extends E factory) { +return new LazyListE(list, factory); } //--- @@ -88,7 +88,7 @@ * @param factory the factory to use for creation, must not be null * @throws IllegalArgumentException if list or factory is null */ -protected LazyList(List list, Factory factory) { +protected LazyList(ListE list, Factory? extends E factory) { super(list); if (factory == null) { throw new IllegalArgumentException(Factory must not be null); @@ -107,36 +107,33 @@ * * @param index the index to retrieve */ -public Object get(int index) { -int size = getList().size(); +public E get(int index) { +int size = decorated().size(); if (index size) { // within bounds, get the object -Object object = getList().get(index); +E object = decorated().get(index); if (object == null) { // item is a place holder, create new one, set and return object = factory.create(); -getList().set(index, object); +decorated().set(index, object); return object; -} else { -// good and ready to go -return object; -} -} else { -// we have to grow the list -for (int i = size; i index; i++) { -getList().add(null); } -// create our last object, set and return -Object object = factory.create(); -getList().add(object); +// good and ready to go return object; } +// we have to grow the list +for (int i = size; i index; i++) { +decorated().add(null); +} +// create our last object, set and return +E object = factory.create(); +decorated().add(object); +return object; } - -public List subList(int fromIndex, int toIndex) { -List sub = getList().subList(fromIndex, toIndex); -return new LazyList(sub, factory); +public ListE subList(int fromIndex, int toIndex) { +ListE sub = decorated().subList(fromIndex, toIndex); +return new LazyListE(sub, factory); } }
svn commit: r815066 - /commons/proper/collections/trunk/src/java/org/apache/commons/collections/list/PredicatedList.java
Author: bayard Date: Tue Sep 15 05:55:43 2009 New Revision: 815066 URL: http://svn.apache.org/viewvc?rev=815066view=rev Log: Merging from -r468106:814127 of collections_jdk5_branch - namely where this code was generified; mostly in r738956. Also see the following revisions: r555925 | skestle | 2007-07-13 03:39:24 -0700 (Fri, 13 Jul 2007) | 2 lines Added Edwin Tellman's patch for COLLECTIONS-243. It all seems pretty reasonable, and it should all be checked again as the project is worked through r471202 | scolebourne | 2006-11-04 06:21:44 -0800 (Sat, 04 Nov 2006) | 1 line Remove getCollection() - use covariant decorated() Modified: commons/proper/collections/trunk/src/java/org/apache/commons/collections/list/PredicatedList.java Modified: commons/proper/collections/trunk/src/java/org/apache/commons/collections/list/PredicatedList.java URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/java/org/apache/commons/collections/list/PredicatedList.java?rev=815066r1=815065r2=815066view=diff == --- commons/proper/collections/trunk/src/java/org/apache/commons/collections/list/PredicatedList.java (original) +++ commons/proper/collections/trunk/src/java/org/apache/commons/collections/list/PredicatedList.java Tue Sep 15 05:55:43 2009 @@ -16,15 +16,14 @@ */ package org.apache.commons.collections.list; -import java.util.Collection; -import java.util.Iterator; -import java.util.List; -import java.util.ListIterator; - import org.apache.commons.collections.Predicate; import org.apache.commons.collections.collection.PredicatedCollection; import org.apache.commons.collections.iterators.AbstractListIteratorDecorator; +import java.util.Collection; +import java.util.List; +import java.util.ListIterator; + /** * Decorates another codeList/code to validate that all additions * match a specified predicate. @@ -44,7 +43,7 @@ * @author Stephen Colebourne * @author Paul Jack */ -public class PredicatedList extends PredicatedCollection implements List { +public class PredicatedListE extends PredicatedCollectionE implements ListE { /** Serialization version */ private static final long serialVersionUID = -5722039223898659102L; @@ -57,11 +56,12 @@ * * @param list the list to decorate, must not be null * @param predicate the predicate to use for validation, must not be null + * @return the decorated list * @throws IllegalArgumentException if list or predicate is null * @throws IllegalArgumentException if the list contains invalid elements */ -public static List decorate(List list, Predicate predicate) { -return new PredicatedList(list, predicate); +public static T ListT decorate(ListT list, Predicate? super T predicate) { +return new PredicatedListT(list, predicate); } //--- @@ -76,7 +76,7 @@ * @throws IllegalArgumentException if list or predicate is null * @throws IllegalArgumentException if the list contains invalid elements */ -protected PredicatedList(List list, Predicate predicate) { +protected PredicatedList(ListE list, Predicate? super E predicate) { super(list, predicate); } @@ -85,73 +85,73 @@ * * @return the decorated list */ -protected List getList() { -return (List) getCollection(); +protected ListE decorated() { +return (ListE) super.decorated(); } //--- -public Object get(int index) { -return getList().get(index); +public E get(int index) { +return decorated().get(index); } public int indexOf(Object object) { -return getList().indexOf(object); +return decorated().indexOf(object); } public int lastIndexOf(Object object) { -return getList().lastIndexOf(object); +return decorated().lastIndexOf(object); } -public Object remove(int index) { -return getList().remove(index); +public E remove(int index) { +return decorated().remove(index); } //--- -public void add(int index, Object object) { +public void add(int index, E object) { validate(object); -getList().add(index, object); +decorated().add(index, object); } -public boolean addAll(int index, Collection coll) { -for (Iterator it = coll.iterator(); it.hasNext(); ) { -validate(it.next()); +public boolean addAll(int
svn commit: r815067 - /commons/proper/collections/trunk/src/java/org/apache/commons/collections/list/SynchronizedList.java
Author: bayard Date: Tue Sep 15 05:55:45 2009 New Revision: 815067 URL: http://svn.apache.org/viewvc?rev=815067view=rev Log: Merging from -r468106:814127 of collections_jdk5_branch - namely where this code was generified; mostly in r738956. Also see the following revisions: r555925 | skestle | 2007-07-13 03:39:24 -0700 (Fri, 13 Jul 2007) | 2 lines Added Edwin Tellman's patch for COLLECTIONS-243. It all seems pretty reasonable, and it should all be checked again as the project is worked through Modified: commons/proper/collections/trunk/src/java/org/apache/commons/collections/list/SynchronizedList.java Modified: commons/proper/collections/trunk/src/java/org/apache/commons/collections/list/SynchronizedList.java URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/java/org/apache/commons/collections/list/SynchronizedList.java?rev=815067r1=815066r2=815067view=diff == --- commons/proper/collections/trunk/src/java/org/apache/commons/collections/list/SynchronizedList.java (original) +++ commons/proper/collections/trunk/src/java/org/apache/commons/collections/list/SynchronizedList.java Tue Sep 15 05:55:45 2009 @@ -35,7 +35,7 @@ * * @author Stephen Colebourne */ -public class SynchronizedList extends SynchronizedCollection implements List { +public class SynchronizedListE extends SynchronizedCollectionE implements ListE { /** Serialization version */ private static final long serialVersionUID = -1403835447328619437L; @@ -46,8 +46,8 @@ * @param list the list to decorate, must not be null * @throws IllegalArgumentException if list is null */ -public static List decorate(List list) { -return new SynchronizedList(list); +public static T ListT decorate(ListT list) { +return new SynchronizedListT(list); } //--- @@ -57,7 +57,7 @@ * @param list the list to decorate, must not be null * @throws IllegalArgumentException if list is null */ -protected SynchronizedList(List list) { +protected SynchronizedList(ListE list) { super(list); } @@ -68,7 +68,7 @@ * @param lock the lock to use, must not be null * @throws IllegalArgumentException if list is null */ -protected SynchronizedList(List list, Object lock) { +protected SynchronizedList(ListE list, Object lock) { super(list, lock); } @@ -77,24 +77,24 @@ * * @return the decorated list */ -protected List getList() { -return (List) collection; +protected ListE getList() { +return (ListE) collection; } //--- -public void add(int index, Object object) { +public void add(int index, E object) { synchronized (lock) { getList().add(index, object); } } -public boolean addAll(int index, Collection coll) { +public boolean addAll(int index, Collection? extends E coll) { synchronized (lock) { return getList().addAll(index, coll); } } -public Object get(int index) { +public E get(int index) { synchronized (lock) { return getList().get(index); } @@ -122,7 +122,7 @@ * * @return an iterator that must be manually synchronized on the collection */ -public ListIterator listIterator() { +public ListIteratorE listIterator() { return getList().listIterator(); } @@ -136,28 +136,28 @@ * * @return an iterator that must be manually synchronized on the collection */ -public ListIterator listIterator(int index) { +public ListIteratorE listIterator(int index) { return getList().listIterator(index); } -public Object remove(int index) { +public E remove(int index) { synchronized (lock) { return getList().remove(index); } } -public Object set(int index, Object object) { +public E set(int index, E object) { synchronized (lock) { return getList().set(index, object); } } -public List subList(int fromIndex, int toIndex) { +public ListE subList(int fromIndex, int toIndex) { synchronized (lock) { -List list = getList().subList(fromIndex, toIndex); +ListE list = getList().subList(fromIndex, toIndex); // the lock is passed into the constructor here to ensure that the sublist is // synchronized on the same lock as the parent list -return new SynchronizedList(list, lock); +return new
svn commit: r815069 - /commons/proper/collections/trunk/src/java/org/apache/commons/collections/ListUtils.java
Author: bayard Date: Tue Sep 15 05:55:49 2009 New Revision: 815069 URL: http://svn.apache.org/viewvc?rev=815069view=rev Log: Merging from -r468106:814127 of collections_jdk5_branch - namely where this code was generified; mostly in r738956. Also see the following revisions: r555925 | skestle | 2007-07-13 03:39:24 -0700 (Fri, 13 Jul 2007) | 2 lines Added Edwin Tellman's patch for COLLECTIONS-243. It all seems pretty reasonable, and it should all be checked again as the project is worked through r471166 | scolebourne | 2006-11-04 03:33:22 -0800 (Sat, 04 Nov 2006) | 1 line Removed Typed* containers such as TypedList and TypedMap as generics now provides type safety Modified: commons/proper/collections/trunk/src/java/org/apache/commons/collections/ListUtils.java Modified: commons/proper/collections/trunk/src/java/org/apache/commons/collections/ListUtils.java URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/java/org/apache/commons/collections/ListUtils.java?rev=815069r1=815068r2=815069view=diff == --- commons/proper/collections/trunk/src/java/org/apache/commons/collections/ListUtils.java (original) +++ commons/proper/collections/trunk/src/java/org/apache/commons/collections/ListUtils.java Tue Sep 15 05:55:49 2009 @@ -27,7 +27,6 @@ import org.apache.commons.collections.list.PredicatedList; import org.apache.commons.collections.list.SynchronizedList; import org.apache.commons.collections.list.TransformedList; -import org.apache.commons.collections.list.TypedList; import org.apache.commons.collections.list.UnmodifiableList; /** @@ -51,8 +50,8 @@ * This uses the {...@link Collections Collections} implementation * and is provided for completeness. */ -public static final List EMPTY_LIST = Collections.EMPTY_LIST; - +public static final ListObject EMPTY_LIST = Collections.ObjectemptyList(); + /** * codeListUtils/code should not normally be instantiated. */ @@ -69,18 +68,14 @@ * @return the intersection of those two lists * @throws NullPointerException if either list is null */ -public static List intersection(final List list1, final List list2) { -final ArrayList result = new ArrayList(); -final Iterator iterator = list2.iterator(); - -while (iterator.hasNext()) { -final Object o = iterator.next(); +public static E ListE intersection(final List? extends E list1, final List? extends E list2) { +final ListE result = new ArrayListE(); -if (list1.contains(o)) { -result.add(o); +for (E e : list2) { +if (list1.contains(e)) { +result.add(e); } } - return result; } @@ -99,14 +94,11 @@ * @return a new list containing the results * @throws NullPointerException if either list is null */ -public static List subtract(final List list1, final List list2) { -final ArrayList result = new ArrayList(list1); -final Iterator iterator = list2.iterator(); - -while (iterator.hasNext()) { -result.remove(iterator.next()); +public static E ListE subtract(final ListE list1, final List? extends E list2) { +final ArrayListE result = new ArrayListE(list1); +for (E e : list2) { +result.remove(e); } - return result; } @@ -119,7 +111,7 @@ * @return a new list containing the sum of those lists * @throws NullPointerException if either list is null */ -public static List sum(final List list1, final List list2) { +public static E ListE sum(final List? extends E list1, final List? extends E list2) { return subtract(union(list1, list2), intersection(list1, list2)); } @@ -133,8 +125,8 @@ * @return a new list containing the union of those lists * @throws NullPointerException if either list is null */ -public static List union(final List list1, final List list2) { -final ArrayList result = new ArrayList(list1); +public static E ListE union(final List? extends E list1, final List? extends E list2) { +final ArrayListE result = new ArrayListE(list1); result.addAll(list2); return result; } @@ -168,7 +160,7 @@ * @param list2 the second list, may be null * @return whether the lists are equal by value comparison */ -public static boolean isEqualList(final Collection list1, final Collection list2) { +public static boolean isEqualList(final Collection? list1, final Collection? list2) { if (list1 == list2
svn commit: r815070 - /commons/proper/collections/trunk/src/java/org/apache/commons/collections/map/AbstractIterableMap.java
Author: bayard Date: Tue Sep 15 05:55:51 2009 New Revision: 815070 URL: http://svn.apache.org/viewvc?rev=815070view=rev Log: Merging from -r468106:814127 of collections_jdk5_branch - namely where this code was generified; mostly in r738956. Also see the following revisions: r740150 | mbenson | 2009-02-02 15:24:00 -0800 (Mon, 02 Feb 2009) | 1 line make all [collections] maps implement IterableMap Added: commons/proper/collections/trunk/src/java/org/apache/commons/collections/map/AbstractIterableMap.java - copied unchanged from r814127, commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/map/AbstractIterableMap.java
svn commit: r815075 - /commons/proper/collections/trunk/src/java/org/apache/commons/collections/map/DefaultedMap.java
Author: bayard Date: Tue Sep 15 05:56:01 2009 New Revision: 815075 URL: http://svn.apache.org/viewvc?rev=815075view=rev Log: Merging from -r468106:814127 of collections_jdk5_branch - namely where this code was generified; mostly in r738956. Also see the following revisions: r740150 | mbenson | 2009-02-02 15:24:00 -0800 (Mon, 02 Feb 2009) | 1 line make all [collections] maps implement IterableMap Modified: commons/proper/collections/trunk/src/java/org/apache/commons/collections/map/DefaultedMap.java Modified: commons/proper/collections/trunk/src/java/org/apache/commons/collections/map/DefaultedMap.java URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/java/org/apache/commons/collections/map/DefaultedMap.java?rev=815075r1=815074r2=815075view=diff == --- commons/proper/collections/trunk/src/java/org/apache/commons/collections/map/DefaultedMap.java (original) +++ commons/proper/collections/trunk/src/java/org/apache/commons/collections/map/DefaultedMap.java Tue Sep 15 05:56:01 2009 @@ -24,6 +24,7 @@ import java.util.Map; import org.apache.commons.collections.Factory; +import org.apache.commons.collections.IterableMap; import org.apache.commons.collections.Transformer; import org.apache.commons.collections.functors.ConstantTransformer; import org.apache.commons.collections.functors.FactoryTransformer; @@ -63,15 +64,13 @@ * @author Rafael U.C. Afonso * @see LazyMap */ -public class DefaultedMap -extends AbstractMapDecorator -implements Map, Serializable { +public class DefaultedMapK, V extends AbstractMapDecoratorK, V implements Serializable { /** Serialization version */ private static final long serialVersionUID = 19698628745827L; /** The transformer to use if the map does not contain a key */ -protected final Object value; +private final Transformer? super K, ? extends V value; //--- /** @@ -83,11 +82,8 @@ * @param defaultValue the default value to return when the key is not found * @throws IllegalArgumentException if map is null */ -public static Map decorate(Map map, Object defaultValue) { -if (defaultValue instanceof Transformer) { -defaultValue = ConstantTransformer.getInstance(defaultValue); -} -return new DefaultedMap(map, defaultValue); +public static K, V MapK, V decorate(MapK, V map, V defaultValue) { +return new DefaultedMapK, V(map, ConstantTransformer.getInstance(defaultValue)); } /** @@ -100,11 +96,11 @@ * @param factory the factory to use to create entries, must not be null * @throws IllegalArgumentException if map or factory is null */ -public static Map decorate(Map map, Factory factory) { +public static K, V IterableMapK, V decorate(MapK, V map, Factory? extends V factory) { if (factory == null) { throw new IllegalArgumentException(Factory must not be null); } -return new DefaultedMap(map, FactoryTransformer.getInstance(factory)); +return new DefaultedMapK, V(map, FactoryTransformer.getInstance(factory)); } /** @@ -118,11 +114,11 @@ * @param transformer the transformer to use as a factory to create entries, must not be null * @throws IllegalArgumentException if map or factory is null */ -public static Map decorate(Map map, Transformer transformer) { +public static K, V MapK, V decorate(MapK, V map, Transformer? super K, ? extends V transformer) { if (transformer == null) { throw new IllegalArgumentException(Transformer must not be null); } - return new DefaultedMap(map, transformer); + return new DefaultedMapK, V(map, transformer); } //--- @@ -135,12 +131,18 @@ * * @param defaultValue the default value to return when the key is not found */ -public DefaultedMap(Object defaultValue) { -super(new HashMap()); -if (defaultValue instanceof Transformer) { -defaultValue = ConstantTransformer.getInstance(defaultValue); -} -this.value = defaultValue; +public DefaultedMap(V defaultValue) { +this(ConstantTransformer.getInstance(defaultValue)); +} + +/** + * Constructs a new empty codeDefaultedMap/code that decorates + * a codeHashMap/code. + * p + * @param defaultValueTransformer transformer to use to generate missing values. + */ +public DefaultedMap(Transformer? super K, ? extends V defaultValueTransformer) { +this(new HashMapK, V
svn commit: r815074 - /commons/proper/collections/trunk/src/java/org/apache/commons/collections/map/CompositeMap.java
Author: bayard Date: Tue Sep 15 05:55:59 2009 New Revision: 815074 URL: http://svn.apache.org/viewvc?rev=815074view=rev Log: Merging from -r468106:814127 of collections_jdk5_branch - namely where this code was generified; mostly in r738956. Also see the following revisions: r740150 | mbenson | 2009-02-02 15:24:00 -0800 (Mon, 02 Feb 2009) | 1 line make all [collections] maps implement IterableMap Modified: commons/proper/collections/trunk/src/java/org/apache/commons/collections/map/CompositeMap.java Modified: commons/proper/collections/trunk/src/java/org/apache/commons/collections/map/CompositeMap.java URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/java/org/apache/commons/collections/map/CompositeMap.java?rev=815074r1=815073r2=815074view=diff == --- commons/proper/collections/trunk/src/java/org/apache/commons/collections/map/CompositeMap.java (original) +++ commons/proper/collections/trunk/src/java/org/apache/commons/collections/map/CompositeMap.java Tue Sep 15 05:55:59 2009 @@ -19,7 +19,6 @@ import java.io.Serializable; import java.util.Collection; -import java.util.Iterator; import java.util.Map; import java.util.Set; @@ -37,7 +36,7 @@ * strongNote that CompositeMap 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. * * @since Commons Collections 3.0 @@ -45,62 +44,69 @@ * * @author Brian McCallister */ -public class CompositeMap implements Map, Serializable { +public class CompositeMapK, V extends AbstractIterableMapK, V implements Serializable { + +/** Serialization version */ +private static final long serialVersionUID = -6096931280583808322L; /** Array of all maps in the composite */ -private Map[] composite; +private MapK, V[] composite; /** Handle mutation operations */ -private MapMutator mutator; +private MapMutatorK, V mutator; /** * Create a new, empty, CompositeMap. */ +@SuppressWarnings(unchecked) public CompositeMap() { -this(new Map[]{}, null); +this(new Map[] {}, null); } /** * Create a new CompositeMap with two composited Map instances. - * + * * @param one the first Map to be composited * @param two the second Map to be composited * @throws IllegalArgumentException if there is a key collision */ -public CompositeMap(Map one, Map two) { -this(new Map[]{one, two}, null); +@SuppressWarnings(unchecked) +public CompositeMap(MapK, V one, MapK, V two) { +this(new Map[] { one, two }, null); } /** * Create a new CompositeMap with two composited Map instances. - * + * * @param one the first Map to be composited * @param two the second Map to be composited * @param mutator MapMutator to be used for mutation operations */ -public CompositeMap(Map one, Map two, MapMutator mutator) { -this(new Map[]{one, two}, mutator); +@SuppressWarnings(unchecked) +public CompositeMap(MapK, V one, MapK, V two, MapMutatorK, V mutator) { +this(new Map[] { one, two }, mutator); } /** * Create a new CompositeMap which composites all of the Map instances in the * argument. It copies the argument array, it does not use it directly. - * + * * @param composite the Maps to be composited * @throws IllegalArgumentException if there is a key collision */ -public CompositeMap(Map[] composite) { +public CompositeMap(MapK, V[] composite) { this(composite, null); } /** * Create a new CompositeMap which composites all of the Map instances in the * argument. It copies the argument array, it does not use it directly. - * + * * @param composite Maps to be composited * @param mutator MapMutator to be used for mutation operations */ -public CompositeMap(Map[] composite, MapMutator mutator) { +@SuppressWarnings(unchecked) +public CompositeMap(MapK, V[] composite, MapMutatorK, V mutator) { this.mutator = mutator; this.composite = new Map[0]; for (int i = composite.length - 1; i = 0; --i) { @@ -111,13 +117,13 @@ //--- /** * Specify the MapMutator to be used
svn commit: r815083 - /commons/proper/collections/trunk/src/java/org/apache/commons/collections/map/StaticBucketMap.java
Author: bayard Date: Tue Sep 15 05:56:15 2009 New Revision: 815083 URL: http://svn.apache.org/viewvc?rev=815083view=rev Log: Merging from -r468106:814127 of collections_jdk5_branch - namely where this code was generified; mostly in r738956. Also see the following revisions: r813954 | sebb | 2009-09-11 10:50:42 -0700 (Fri, 11 Sep 2009) | 2 lines Make private immutable variables final Add missing @Override markers and fix some raw types r740150 | mbenson | 2009-02-02 15:24:00 -0800 (Mon, 02 Feb 2009) | 1 line make all [collections] maps implement IterableMap Modified: commons/proper/collections/trunk/src/java/org/apache/commons/collections/map/StaticBucketMap.java Modified: commons/proper/collections/trunk/src/java/org/apache/commons/collections/map/StaticBucketMap.java URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/java/org/apache/commons/collections/map/StaticBucketMap.java?rev=815083r1=815082r2=815083view=diff == --- commons/proper/collections/trunk/src/java/org/apache/commons/collections/map/StaticBucketMap.java (original) +++ commons/proper/collections/trunk/src/java/org/apache/commons/collections/map/StaticBucketMap.java Tue Sep 15 05:56:15 2009 @@ -101,14 +101,14 @@ * @author Janek Bogucki * @author Kazuya Ujihara */ -public final class StaticBucketMap implements Map { +public final class StaticBucketMapK, V extends AbstractIterableMapK, V { /** The default number of buckets to use */ private static final int DEFAULT_BUCKETS = 255; /** The array of buckets, where the actual data is held */ -private Node[] buckets; +private final NodeK, V[] buckets; /** The matching array of locks */ -private Lock[] locks; +private final Lock[] locks; /** * Initializes the map with the default number of buckets (255). @@ -127,6 +127,7 @@ * * @param numBuckets the number of buckets for this map */ +@SuppressWarnings(unchecked) public StaticBucketMap(int numBuckets) { int size = Math.max(17, numBuckets); @@ -202,11 +203,11 @@ * @param key the key to retrieve * @return the associated value */ -public Object get(final Object key) { +public V get(final Object key) { int hash = getHash(key); synchronized (locks[hash]) { -Node n = buckets[hash]; +NodeK, V n = buckets[hash]; while (n != null) { if (n.key == key || (n.key != null n.key.equals(key))) { @@ -229,7 +230,7 @@ int hash = getHash(key); synchronized (locks[hash]) { -Node n = buckets[hash]; +NodeK, V n = buckets[hash]; while (n != null) { if (n.key == key || (n.key != null n.key.equals(key))) { @@ -251,7 +252,7 @@ public boolean containsValue(final Object value) { for (int i = 0; i buckets.length; i++) { synchronized (locks[i]) { -Node n = buckets[i]; +NodeK, V n = buckets[i]; while (n != null) { if (n.value == value || (n.value != null n.value.equals(value))) { @@ -273,14 +274,14 @@ * @param value the value to use * @return the previous mapping for the key */ -public Object put(final Object key, final Object value) { +public V put(final K key, final V value) { int hash = getHash(key); synchronized (locks[hash]) { -Node n = buckets[hash]; +NodeK, V n = buckets[hash]; if (n == null) { -n = new Node(); +n = new NodeK, V(); n.key = key; n.value = value; buckets[hash] = n; @@ -291,11 +292,11 @@ // Set n to the last node in the linked list. Check each key along the way // If the key is found, then change the value of that node and return // the old value. -for (Node next = n; next != null; next = next.next) { +for (NodeK, V next = n; next != null; next = next.next) { n = next; if (n.key == key || (n.key != null n.key.equals(key))) { -Object returnVal = n.value; +V returnVal = n.value; n.value = value; return returnVal; } @@ -303,7 +304,7 @@ // The key was not found in the current list of nodes, add it to the end // in a new node. -Node newNode = new Node(); +NodeK, V newNode = new NodeK, V
svn commit: r815085 - /commons/proper/collections/trunk/src/java/org/apache/commons/collections/map/TransformedSortedMap.java
Author: bayard Date: Tue Sep 15 05:56:18 2009 New Revision: 815085 URL: http://svn.apache.org/viewvc?rev=815085view=rev Log: Merging from -r468106:814127 of collections_jdk5_branch - namely where this code was generified; mostly in r738956. Also see the following revisions: r471189 | scolebourne | 2006-11-04 05:57:57 -0800 (Sat, 04 Nov 2006) | 1 line Remove getMap(), getOrderedMap() and getSortedMap() - use decorated() Modified: commons/proper/collections/trunk/src/java/org/apache/commons/collections/map/TransformedSortedMap.java Modified: commons/proper/collections/trunk/src/java/org/apache/commons/collections/map/TransformedSortedMap.java URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/java/org/apache/commons/collections/map/TransformedSortedMap.java?rev=815085r1=815084r2=815085view=diff == --- commons/proper/collections/trunk/src/java/org/apache/commons/collections/map/TransformedSortedMap.java (original) +++ commons/proper/collections/trunk/src/java/org/apache/commons/collections/map/TransformedSortedMap.java Tue Sep 15 05:56:18 2009 @@ -43,9 +43,9 @@ * * @author Stephen Colebourne */ -public class TransformedSortedMap -extends TransformedMap -implements SortedMap { +public class TransformedSortedMapK, V +extends TransformedMapK, V +implements SortedMapK, V { /** Serialization version */ private static final long serialVersionUID = -8751771676410385778L; @@ -62,8 +62,10 @@ * @param valueTransformer the predicate to validate to values, null means no transformation * @throws IllegalArgumentException if the map is null */ -public static SortedMap decorate(SortedMap map, Transformer keyTransformer, Transformer valueTransformer) { -return new TransformedSortedMap(map, keyTransformer, valueTransformer); +public static K, V SortedMapK, V decorate(SortedMapK, V map, +Transformer? super K, ? extends K keyTransformer, +Transformer? super V, ? extends V valueTransformer) { +return new TransformedSortedMapK, V(map, keyTransformer, valueTransformer); } /** @@ -80,12 +82,14 @@ * @throws IllegalArgumentException if map is null * @since Commons Collections 3.2 */ -public static SortedMap decorateTransform(SortedMap map, Transformer keyTransformer, Transformer valueTransformer) { -TransformedSortedMap decorated = new TransformedSortedMap(map, keyTransformer, valueTransformer); +public static K, V SortedMapK, V decorateTransform(SortedMapK, V map, +Transformer? super K, ? extends K keyTransformer, +Transformer? super V, ? extends V valueTransformer) { +TransformedSortedMapK, V decorated = new TransformedSortedMapK, V(map, keyTransformer, valueTransformer); if (map.size() 0) { -Map transformed = decorated.transformMap(map); +MapK, V transformed = decorated.transformMap(map); decorated.clear(); -decorated.getMap().putAll(transformed); // avoids double transformation +decorated.decorated().putAll(transformed); // avoids double transformation } return decorated; } @@ -102,7 +106,9 @@ * @param valueTransformer the predicate to validate to values, null means no transformation * @throws IllegalArgumentException if the map is null */ -protected TransformedSortedMap(SortedMap map, Transformer keyTransformer, Transformer valueTransformer) { +protected TransformedSortedMap(SortedMapK, V map, +Transformer? super K, ? extends K keyTransformer, +Transformer? super V, ? extends V valueTransformer) { super(map, keyTransformer, valueTransformer); } @@ -112,36 +118,36 @@ * * @return the decorated map */ -protected SortedMap getSortedMap() { -return (SortedMap) map; +protected SortedMapK, V getSortedMap() { +return (SortedMapK, V) map; } //--- -public Object firstKey() { +public K firstKey() { return getSortedMap().firstKey(); } -public Object lastKey() { +public K lastKey() { return getSortedMap().lastKey(); } -public Comparator comparator() { +public Comparator? super K comparator() { return getSortedMap().comparator(); } -public SortedMap subMap(Object fromKey, Object toKey) { -SortedMap map = getSortedMap().subMap(fromKey, toKey); -return new TransformedSortedMap(map, keyTransformer, valueTransformer); +public SortedMapK, V subMap(K fromKey, K toKey) { +SortedMapK, V map
svn commit: r815086 - /commons/proper/collections/trunk/src/java/org/apache/commons/collections/map/UnmodifiableOrderedMap.java
Author: bayard Date: Tue Sep 15 05:56:20 2009 New Revision: 815086 URL: http://svn.apache.org/viewvc?rev=815086view=rev Log: Merging from -r468106:814127 of collections_jdk5_branch - namely where this code was generified; mostly in r738956. Also see the following revisions: r471189 | scolebourne | 2006-11-04 05:57:57 -0800 (Sat, 04 Nov 2006) | 1 line Remove getMap(), getOrderedMap() and getSortedMap() - use decorated() Modified: commons/proper/collections/trunk/src/java/org/apache/commons/collections/map/UnmodifiableOrderedMap.java Modified: commons/proper/collections/trunk/src/java/org/apache/commons/collections/map/UnmodifiableOrderedMap.java URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/java/org/apache/commons/collections/map/UnmodifiableOrderedMap.java?rev=815086r1=815085r2=815086view=diff == --- commons/proper/collections/trunk/src/java/org/apache/commons/collections/map/UnmodifiableOrderedMap.java (original) +++ commons/proper/collections/trunk/src/java/org/apache/commons/collections/map/UnmodifiableOrderedMap.java Tue Sep 15 05:56:20 2009 @@ -24,12 +24,10 @@ import java.util.Map; import java.util.Set; -import org.apache.commons.collections.MapIterator; import org.apache.commons.collections.OrderedMap; import org.apache.commons.collections.OrderedMapIterator; import org.apache.commons.collections.Unmodifiable; import org.apache.commons.collections.collection.UnmodifiableCollection; -import org.apache.commons.collections.iterators.UnmodifiableMapIterator; import org.apache.commons.collections.iterators.UnmodifiableOrderedMapIterator; import org.apache.commons.collections.set.UnmodifiableSet; @@ -45,9 +43,8 @@ * * @author Stephen Colebourne */ -public final class UnmodifiableOrderedMap -extends AbstractOrderedMapDecorator -implements Unmodifiable, Serializable { +public final class UnmodifiableOrderedMapK, V extends AbstractOrderedMapDecoratorK, V implements +Unmodifiable, Serializable { /** Serialization version */ private static final long serialVersionUID = 8136428161720526266L; @@ -58,11 +55,11 @@ * @param map the map to decorate, must not be null * @throws IllegalArgumentException if map is null */ -public static OrderedMap decorate(OrderedMap map) { +public static K, V OrderedMapK, V decorate(OrderedMapK, V map) { if (map instanceof Unmodifiable) { return map; } -return new UnmodifiableOrderedMap(map); +return new UnmodifiableOrderedMapK, V(map); } //--- @@ -72,7 +69,7 @@ * @param map the map to decorate, must not be null * @throws IllegalArgumentException if map is null */ -private UnmodifiableOrderedMap(OrderedMap map) { +private UnmodifiableOrderedMap(OrderedMapK, V map) { super(map); } @@ -97,19 +94,15 @@ * @throws ClassNotFoundException * @since Commons Collections 3.1 */ +@SuppressWarnings(unchecked) private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { in.defaultReadObject(); map = (Map) in.readObject(); } //--- -public MapIterator mapIterator() { -MapIterator it = getOrderedMap().mapIterator(); -return UnmodifiableMapIterator.decorate(it); -} - -public OrderedMapIterator orderedMapIterator() { -OrderedMapIterator it = getOrderedMap().orderedMapIterator(); +public OrderedMapIteratorK, V mapIterator() { +OrderedMapIteratorK, V it = decorated().mapIterator(); return UnmodifiableOrderedMapIterator.decorate(it); } @@ -117,30 +110,30 @@ throw new UnsupportedOperationException(); } -public Object put(Object key, Object value) { +public V put(K key, V value) { throw new UnsupportedOperationException(); } -public void putAll(Map mapToCopy) { +public void putAll(Map? extends K, ? extends V mapToCopy) { throw new UnsupportedOperationException(); } -public Object remove(Object key) { +public V remove(Object key) { throw new UnsupportedOperationException(); } -public Set entrySet() { -Set set = super.entrySet(); +public SetMap.EntryK, V entrySet() { +SetMap.EntryK, V set = super.entrySet(); return UnmodifiableEntrySet.decorate(set); } -public Set keySet() { -Set set = super.keySet(); +public SetK keySet() { +SetK set = super.keySet(); return UnmodifiableSet.decorate(set); } -public
svn commit: r815088 - /commons/proper/collections/trunk/src/java/org/apache/commons/collections/MapIterator.java
Author: bayard Date: Tue Sep 15 05:56:23 2009 New Revision: 815088 URL: http://svn.apache.org/viewvc?rev=815088view=rev Log: Merging from -r468106:814127 of collections_jdk5_branch - namely where this code was generified; mostly in r738956. Also see the following revisions: r468709 | scolebourne | 2006-10-28 10:49:04 -0700 (Sat, 28 Oct 2006) | 1 line Convert to generics Modified: commons/proper/collections/trunk/src/java/org/apache/commons/collections/MapIterator.java Modified: commons/proper/collections/trunk/src/java/org/apache/commons/collections/MapIterator.java URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/java/org/apache/commons/collections/MapIterator.java?rev=815088r1=815087r2=815088view=diff == --- commons/proper/collections/trunk/src/java/org/apache/commons/collections/MapIterator.java (original) +++ commons/proper/collections/trunk/src/java/org/apache/commons/collections/MapIterator.java Tue Sep 15 05:56:23 2009 @@ -17,6 +17,7 @@ package org.apache.commons.collections; import java.util.Iterator; +import java.util.NoSuchElementException; /** * Defines an iterator that operates over a codeMap/code. @@ -32,21 +33,23 @@ * to codenext()/code, the codegetValue()/code method provides direct * access to the value. The value can also be set using codesetValue()/code. * pre - * MapIterator it = map.mapIterator(); + * MapIteratorString,Integer it = map.mapIterator(); * while (it.hasNext()) { - * Object key = it.next(); - * Object value = it.getValue(); - * it.setValue(newValue); + * String key = it.next(); + * Integer value = it.getValue(); + * it.setValue(value + 1); * } * /pre - * + * + * @param K the type of the keys in the map + * @param V the type of the values in the map * @since Commons Collections 3.0 * @version $Revision$ $Date$ * * @author Stephen Colebourne */ -public interface MapIterator extends Iterator { - +public interface MapIteratorK, V extends IteratorK { + /** * Checks to see if there are more entries still to be iterated. * @@ -58,9 +61,9 @@ * Gets the next emkey/em from the codeMap/code. * * @return the next key in the iteration - * @throws java.util.NoSuchElementException if the iteration is finished + * @throws NoSuchElementException if the iteration is finished */ -Object next(); +K next(); //--- /** @@ -70,7 +73,7 @@ * @return the current key * @throws IllegalStateException if codenext()/code has not yet been called */ -Object getKey(); +K getKey(); /** * Gets the current value, which is the value associated with the last key @@ -79,7 +82,7 @@ * @return the current value * @throws IllegalStateException if codenext()/code has not yet been called */ -Object getValue(); +V getValue(); //--- /** @@ -93,7 +96,7 @@ * since the last call to codenext()/code */ void remove(); - + /** * Sets the value associated with the current key (optional operation). * @@ -104,6 +107,6 @@ * @throws IllegalStateException if coderemove()/code has been called since the * last call to codenext()/code */ -Object setValue(Object value); +V setValue(V value); }
svn commit: r815090 - /commons/proper/collections/trunk/src/java/org/apache/commons/collections/MultiMap.java
Author: bayard Date: Tue Sep 15 05:56:27 2009 New Revision: 815090 URL: http://svn.apache.org/viewvc?rev=815090view=rev Log: Merging from -r468106:814127 of collections_jdk5_branch - namely where this code was generified; mostly in r738956. Also see the following revisions: r740150 | mbenson | 2009-02-02 15:24:00 -0800 (Mon, 02 Feb 2009) | 1 line make all [collections] maps implement IterableMap Modified: commons/proper/collections/trunk/src/java/org/apache/commons/collections/MultiMap.java Modified: commons/proper/collections/trunk/src/java/org/apache/commons/collections/MultiMap.java URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/java/org/apache/commons/collections/MultiMap.java?rev=815090r1=815089r2=815090view=diff == --- commons/proper/collections/trunk/src/java/org/apache/commons/collections/MultiMap.java (original) +++ commons/proper/collections/trunk/src/java/org/apache/commons/collections/MultiMap.java Tue Sep 15 05:56:27 2009 @@ -17,7 +17,6 @@ package org.apache.commons.collections; import java.util.Collection; -import java.util.Map; /** * Defines a map that holds a collection of values against each key. @@ -47,7 +46,7 @@ * @author James Strachan * @author Stephen Colebourne */ -public interface MultiMap extends Map { +public interface MultiMapK, V extends IterableMapK, Object { /** * Removes a specific value from map. @@ -66,7 +65,7 @@ * @throws ClassCastException if the key or value is of an invalid type * @throws NullPointerException if the key or value is null and null is invalid */ -public Object remove(Object key, Object item); +public V remove(K key, V item); //--- /** @@ -98,7 +97,7 @@ * @throws ClassCastException if the key is of an invalid type * @throws NullPointerException if the key is null and null keys are invalid */ -Object get(Object key); +Object get(K key); /** * Checks whether the map contains the value specified. @@ -129,7 +128,7 @@ * @throws NullPointerException if the key or value is null and null is invalid * @throws IllegalArgumentException if the key or value is invalid */ -Object put(Object key, Object value); +Object put(K key, Object value); /** * Removes all values associated with the specified key. @@ -144,7 +143,7 @@ * @throws ClassCastException if the key is of an invalid type * @throws NullPointerException if the key is null and null keys are invalid */ -Object remove(Object key); +Object remove(K key); /** * Gets a collection containing all the values in the map. @@ -155,6 +154,6 @@ * * @return a collection view of the values contained in this map */ -Collection values(); +CollectionObject values(); }
svn commit: r815091 - /commons/proper/collections/trunk/src/java/org/apache/commons/collections/OrderedIterator.java
Author: bayard Date: Tue Sep 15 05:56:29 2009 New Revision: 815091 URL: http://svn.apache.org/viewvc?rev=815091view=rev Log: Merging from -r468106:814127 of collections_jdk5_branch - namely where this code was generified; mostly in r738956. Also see the following revisions: r751849 | mbenson | 2009-03-09 14:32:22 -0700 (Mon, 09 Mar 2009) | 1 line comment Modified: commons/proper/collections/trunk/src/java/org/apache/commons/collections/OrderedIterator.java Modified: commons/proper/collections/trunk/src/java/org/apache/commons/collections/OrderedIterator.java URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/java/org/apache/commons/collections/OrderedIterator.java?rev=815091r1=815090r2=815091view=diff == --- commons/proper/collections/trunk/src/java/org/apache/commons/collections/OrderedIterator.java (original) +++ commons/proper/collections/trunk/src/java/org/apache/commons/collections/OrderedIterator.java Tue Sep 15 05:56:29 2009 @@ -17,18 +17,21 @@ package org.apache.commons.collections; import java.util.Iterator; +import java.util.ListIterator; +import java.util.NoSuchElementException; /** - * Defines an iterator that operates over an ordered collection. + * Defines an iterator that operates over an ordered container. Subset of {...@link ListIterator}. * p - * This iterator allows both forward and reverse iteration through the collection. - * + * This iterator allows both forward and reverse iteration through the container. + * + * @param E the type to iterate over * @since Commons Collections 3.0 * @version $Revision$ $Date$ * * @author Stephen Colebourne */ -public interface OrderedIterator extends Iterator { +public interface OrderedIteratorE extends IteratorE { /** * Checks to see if there is a previous element that can be iterated to. @@ -38,11 +41,11 @@ boolean hasPrevious(); /** - * Gets the previous element from the collection. + * Gets the previous element from the container. * * @return the previous element in the iteration - * @throws java.util.NoSuchElementException if the iteration is finished + * @throws NoSuchElementException if the iteration is finished */ -Object previous(); +E previous(); }
svn commit: r815089 - /commons/proper/collections/trunk/src/java/org/apache/commons/collections/MapUtils.java
Author: bayard Date: Tue Sep 15 05:56:25 2009 New Revision: 815089 URL: http://svn.apache.org/viewvc?rev=815089view=rev Log: Merging from -r468106:814127 of collections_jdk5_branch - namely where this code was generified; mostly in r738956. Also see the following revisions: r751887 | mbenson | 2009-03-09 15:40:01 -0700 (Mon, 09 Mar 2009) | 1 line add methods to wrap Maps and SortedMaps not based on Commons Collections classes to their Iterable*Map counterparts r740457 | mbenson | 2009-02-03 13:23:15 -0800 (Tue, 03 Feb 2009) | 1 line ws r740150 | mbenson | 2009-02-02 15:24:00 -0800 (Mon, 02 Feb 2009) | 1 line make all [collections] maps implement IterableMap r471166 | scolebourne | 2006-11-04 03:33:22 -0800 (Sat, 04 Nov 2006) | 1 line Removed Typed* containers such as TypedList and TypedMap as generics now provides type safety Modified: commons/proper/collections/trunk/src/java/org/apache/commons/collections/MapUtils.java Modified: commons/proper/collections/trunk/src/java/org/apache/commons/collections/MapUtils.java URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/java/org/apache/commons/collections/MapUtils.java?rev=815089r1=815088r2=815089view=diff == --- commons/proper/collections/trunk/src/java/org/apache/commons/collections/MapUtils.java (original) +++ commons/proper/collections/trunk/src/java/org/apache/commons/collections/MapUtils.java Tue Sep 15 05:56:25 2009 @@ -19,6 +19,7 @@ import java.io.PrintStream; import java.text.NumberFormat; import java.text.ParseException; +import java.util.Collection; import java.util.Collections; import java.util.Enumeration; import java.util.HashMap; @@ -30,6 +31,8 @@ import java.util.TreeMap; import java.util.Collection; +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; @@ -40,12 +43,10 @@ import org.apache.commons.collections.map.PredicatedSortedMap; import org.apache.commons.collections.map.TransformedMap; import org.apache.commons.collections.map.TransformedSortedMap; -import org.apache.commons.collections.map.TypedMap; -import org.apache.commons.collections.map.TypedSortedMap; import org.apache.commons.collections.map.UnmodifiableMap; import org.apache.commons.collections.map.UnmodifiableSortedMap; -/** +/** * Provides utility methods and decorators for * {...@link Map} and {...@link SortedMap} instances. * p @@ -89,17 +90,19 @@ * @author Neil O'Toole */ public class MapUtils { - + /** * An empty unmodifiable map. * This was not provided in JDK1.2. */ -public static final Map EMPTY_MAP = UnmodifiableMap.decorate(new HashMap(1)); +public static final MapObject, Object EMPTY_MAP = UnmodifiableMap.decorate(new HashMapObject, Object(1)); + /** * An empty unmodifiable sorted map. * This is not provided in the JDK. */ -public static final SortedMap EMPTY_SORTED_MAP = UnmodifiableSortedMap.decorate(new TreeMap()); +public static final SortedMapObject, Object EMPTY_SORTED_MAP = UnmodifiableSortedMap.decorate(new TreeMapObject, Object()); + /** * String used to indent the verbose and debug Map prints. */ @@ -109,8 +112,8 @@ * codeMapUtils/code should not normally be instantiated. */ public MapUtils() { -} - +} + // Type safe getters //- /** @@ -120,7 +123,7 @@ * @param key the key to look up * @return the value in the Map, codenull/code if null map input */ -public static Object getObject(final Map map, final Object key) { +public static K, V V getObject(final Map? super K, V map, final K key) { if (map != null) { return map.get(key); } @@ -136,7 +139,7 @@ * @param key the key to look up * @return the value in the Map as a String, codenull/code if null map input */ -public static String getString(final Map map, final Object key) { +public static K String getString(final Map? super K, ? map, final K key) { if (map != null) { Object answer = map.get(key); if (answer != null) { @@ -160,17 +163,17 @@ * @param key
svn commit: r815093 - /commons/proper/collections/trunk/src/java/org/apache/commons/collections/Put.java
Author: bayard Date: Tue Sep 15 05:56:32 2009 New Revision: 815093 URL: http://svn.apache.org/viewvc?rev=815093view=rev Log: Merging from -r468106:814127 of collections_jdk5_branch - namely where this code was generified; mostly in r738956. Also see the following revisions: r751890 | mbenson | 2009-03-09 15:45:37 -0700 (Mon, 09 Mar 2009) | 1 line 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/trunk/src/java/org/apache/commons/collections/Put.java - copied unchanged from r814127, commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/Put.java
svn commit: r815094 - /commons/proper/collections/trunk/src/java/org/apache/commons/collections/ResettableListIterator.java
Author: bayard Date: Tue Sep 15 05:56:34 2009 New Revision: 815094 URL: http://svn.apache.org/viewvc?rev=815094view=rev Log: Merging from -r468106:814127 of collections_jdk5_branch - namely where this code was generified; mostly in r738956. Also see the following revisions: r751888 | mbenson | 2009-03-09 15:42:14 -0700 (Mon, 09 Mar 2009) | 1 line implement OrderedIterator (subset of ListIterator) Modified: commons/proper/collections/trunk/src/java/org/apache/commons/collections/ResettableListIterator.java Modified: commons/proper/collections/trunk/src/java/org/apache/commons/collections/ResettableListIterator.java URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/java/org/apache/commons/collections/ResettableListIterator.java?rev=815094r1=815093r2=815094view=diff == --- commons/proper/collections/trunk/src/java/org/apache/commons/collections/ResettableListIterator.java (original) +++ commons/proper/collections/trunk/src/java/org/apache/commons/collections/ResettableListIterator.java Tue Sep 15 05:56:34 2009 @@ -23,17 +23,12 @@ * p * This interface allows an iterator to be repeatedly reused. * + * @param E the type to iterate over * @since Commons Collections 3.0 * @version $Revision$ $Date$ * * @author Stephen Colebourne */ -public interface ResettableListIterator extends ListIterator, ResettableIterator { - -/** - * Resets the iterator back to the position at which the iterator - * was created. - */ -public void reset(); +public interface ResettableListIteratorE extends ListIteratorE, ResettableIteratorE, OrderedIteratorE { }
svn commit: r815092 - /commons/proper/collections/trunk/src/java/org/apache/commons/collections/PredicateUtils.java
Author: bayard Date: Tue Sep 15 05:56:30 2009 New Revision: 815092 URL: http://svn.apache.org/viewvc?rev=815092view=rev Log: Merging from -r468106:814127 of collections_jdk5_branch - namely where this code was generified; mostly in r738956. Also see the following revisions: r814050 | sebb | 2009-09-11 15:01:25 -0700 (Fri, 11 Sep 2009) | 1 line Some minor Javadoc fixes r643795 | skestle | 2008-04-02 01:49:57 -0700 (Wed, 02 Apr 2008) | 5 lines Generified EqualPredicate and created individual test class moved from TestPredicateUtils Added assertFalse() and assertTrue to BasicPredicateTestBase with (Predicate, Object) parameters Issues: COLLECTIONS-243, COLLECTIONS-253, COLLECTIONS-293 r643782 | skestle | 2008-04-02 01:00:00 -0700 (Wed, 02 Apr 2008) | 5 lines Generified NullPredicate and created individual test class moved on TestPredicateUtils Renamed PredicateTestBase to MockPredicateTestBase to reduce confusion and added BasicPredicateTestBase. Issues: COLLECTIONS-243, COLLECTIONS-253, COLLECTIONS-293 r643606 | skestle | 2008-04-01 14:52:12 -0700 (Tue, 01 Apr 2008) | 1 line Fixed (another) compilation error in PredicateUtils and added method deprecations for new call-through static constructors. r643593 | skestle | 2008-04-01 14:39:01 -0700 (Tue, 01 Apr 2008) | 1 line Fixed compilation error in PredicateUtils r641231 | skestle | 2008-03-26 02:58:51 -0700 (Wed, 26 Mar 2008) | 1 line Started incorporating Edwin's patch for COLLECTIONS-253, in preparation for COLLECTIONS-290. Modified: commons/proper/collections/trunk/src/java/org/apache/commons/collections/PredicateUtils.java Modified: commons/proper/collections/trunk/src/java/org/apache/commons/collections/PredicateUtils.java URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/java/org/apache/commons/collections/PredicateUtils.java?rev=815092r1=815091r2=815092view=diff == --- commons/proper/collections/trunk/src/java/org/apache/commons/collections/PredicateUtils.java (original) +++ commons/proper/collections/trunk/src/java/org/apache/commons/collections/PredicateUtils.java Tue Sep 15 05:56:30 2009 @@ -84,154 +84,161 @@ // Simple predicates //- -/** +/** * Gets a Predicate that always throws an exception. * This could be useful during testing as a placeholder. * * @see org.apache.commons.collections.functors.ExceptionPredicate - * + * * @return the predicate */ -public static Predicate exceptionPredicate() { -return ExceptionPredicate.INSTANCE; +public static T PredicateT exceptionPredicate() { +return ExceptionPredicate.TgetInstance(); } /** * Gets a Predicate that always returns true. - * + * * @see org.apache.commons.collections.functors.TruePredicate - * + * * @return the predicate + * @deprecated use {...@link TruePredicate#truePredicate()} instead. */ -public static Predicate truePredicate() { -return TruePredicate.INSTANCE; +@Deprecated +public static T PredicateT truePredicate() { +return TruePredicate.truePredicate(); } /** * Gets a Predicate that always returns false. - * + * * @see org.apache.commons.collections.functors.FalsePredicate - * + * * @return the predicate + * @deprecated use {...@link FalsePredicate#()} instead. */ -public static Predicate falsePredicate() { -return FalsePredicate.INSTANCE; +public static T PredicateT falsePredicate() { +return FalsePredicate.TgetInstance(); } /** * Gets a Predicate that checks if the input object passed in is null. - * + * * @see org.apache.commons.collections.functors.NullPredicate - * + * * @return the predicate + * @deprecated use {...@link NullPredicate#nullPredicate()} instead */ -public static Predicate nullPredicate() { -return NullPredicate.INSTANCE; +@Deprecated +public static T PredicateT nullPredicate() { +return NullPredicate.nullPredicate(); } /** * Gets a Predicate that checks if the input object
svn commit: r815098 - /commons/proper/collections/trunk/src/java/org/apache/commons/collections/set/PredicatedSet.java
Author: bayard Date: Tue Sep 15 05:56:41 2009 New Revision: 815098 URL: http://svn.apache.org/viewvc?rev=815098view=rev Log: Merging from -r468106:814127 of collections_jdk5_branch - namely where this code was generified; mostly in r738956. Also see the following revisions: r555925 | skestle | 2007-07-13 03:39:24 -0700 (Fri, 13 Jul 2007) | 2 lines Added Edwin Tellman's patch for COLLECTIONS-243. It all seems pretty reasonable, and it should all be checked again as the project is worked through r471202 | scolebourne | 2006-11-04 06:21:44 -0800 (Sat, 04 Nov 2006) | 1 line Remove getCollection() - use covariant decorated() Modified: commons/proper/collections/trunk/src/java/org/apache/commons/collections/set/PredicatedSet.java Modified: commons/proper/collections/trunk/src/java/org/apache/commons/collections/set/PredicatedSet.java URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/java/org/apache/commons/collections/set/PredicatedSet.java?rev=815098r1=815097r2=815098view=diff == --- commons/proper/collections/trunk/src/java/org/apache/commons/collections/set/PredicatedSet.java (original) +++ commons/proper/collections/trunk/src/java/org/apache/commons/collections/set/PredicatedSet.java Tue Sep 15 05:56:41 2009 @@ -40,7 +40,7 @@ * @author Stephen Colebourne * @author Paul Jack */ -public class PredicatedSet extends PredicatedCollection implements Set { +public class PredicatedSetE extends PredicatedCollectionE implements SetE { /** Serialization version */ private static final long serialVersionUID = -684521469108685117L; @@ -53,11 +53,12 @@ * * @param set the set to decorate, must not be null * @param predicate the predicate to use for validation, must not be null + * @return a decorated set * @throws IllegalArgumentException if set or predicate is null * @throws IllegalArgumentException if the set contains invalid elements */ -public static Set decorate(Set set, Predicate predicate) { -return new PredicatedSet(set, predicate); +public static T SetT decorate(SetT set, Predicate? super T predicate) { +return new PredicatedSetT(set, predicate); } //--- @@ -72,7 +73,7 @@ * @throws IllegalArgumentException if set or predicate is null * @throws IllegalArgumentException if the set contains invalid elements */ -protected PredicatedSet(Set set, Predicate predicate) { +protected PredicatedSet(SetE set, Predicate? super E predicate) { super(set, predicate); } @@ -81,8 +82,8 @@ * * @return the decorated set */ -protected Set getSet() { -return (Set) getCollection(); +protected SetE decorated() { +return (SetE) super.decorated(); } }
svn commit: r815097 - /commons/proper/collections/trunk/src/java/org/apache/commons/collections/set/ListOrderedSet.java
Author: bayard Date: Tue Sep 15 05:56:40 2009 New Revision: 815097 URL: http://svn.apache.org/viewvc?rev=815097view=rev Log: Merging from -r468106:814127 of collections_jdk5_branch - namely where this code was generified; mostly in r738956. Also see the following revisions: r751869 | mbenson | 2009-03-09 15:10:00 -0700 (Mon, 09 Mar 2009) | 1 line return type narrowing Modified: commons/proper/collections/trunk/src/java/org/apache/commons/collections/set/ListOrderedSet.java Modified: commons/proper/collections/trunk/src/java/org/apache/commons/collections/set/ListOrderedSet.java URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/java/org/apache/commons/collections/set/ListOrderedSet.java?rev=815097r1=815096r2=815097view=diff == --- commons/proper/collections/trunk/src/java/org/apache/commons/collections/set/ListOrderedSet.java (original) +++ commons/proper/collections/trunk/src/java/org/apache/commons/collections/set/ListOrderedSet.java Tue Sep 15 05:56:40 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; @@ -36,7 +38,7 @@ * p * The ListOrderedSet also has various useful direct methods. These include many * from codeList/code, such as codeget(int)/code, coderemove(int)/code - * and codeindexOf(int)/code. An unmodifiable codeList/code view of + * and codeindexOf(int)/code. An unmodifiable codeList/code view of * the set can be obtained via codeasList()/code. * p * This class cannot implement the codeList/code interface directly as @@ -50,26 +52,26 @@ * @author Stephen Colebourne * @author Henning P. Schmiedehausen */ -public class ListOrderedSet extends AbstractSerializableSetDecorator implements Set { +public class ListOrderedSetE extends AbstractSerializableSetDecoratorE implements SetE { /** Serialization version */ private static final long serialVersionUID = -228664372470420141L; /** Internal list to hold the sequence of objects */ -protected final List setOrder; +protected final ListE setOrder; /** * Factory method to create an ordered set specifying the list and set to use. * p * The list and set must both be empty. - * + * * @param set the set to decorate, must be empty and not null * @param list the list to decorate, must be empty and not null * @throws IllegalArgumentException if set or list is null * @throws IllegalArgumentException if either the set or list is not empty * @since Commons Collections 3.1 */ -public static ListOrderedSet decorate(Set set, List list) { +public static E ListOrderedSetE decorate(SetE set, ListE list) { if (set == null) { throw new IllegalArgumentException(Set must not be null); } @@ -79,19 +81,19 @@ if (set.size() 0 || list.size() 0) { throw new IllegalArgumentException(Set and List must be empty); } -return new ListOrderedSet(set, list); +return new ListOrderedSetE(set, list); } /** * Factory method to create an ordered set. * p * An codeArrayList/code is used to retain order. - * + * * @param set the set to decorate, must not be null * @throws IllegalArgumentException if set is null */ -public static ListOrderedSet decorate(Set set) { -return new ListOrderedSet(set); +public static E ListOrderedSetE decorate(SetE set) { +return new ListOrderedSetE(set); } /** @@ -101,53 +103,53 @@ * p * NOTE: If the list contains duplicates, the duplicates are removed, * altering the specified list. - * + * * @param list the list to decorate, must not be null * @throws IllegalArgumentException if list is null */ -public static ListOrderedSet decorate(List list) { +public static E ListOrderedSetE decorate(ListE list) { if (list == null) { throw new IllegalArgumentException(List must not be null); } -Set set = new HashSet(list); +SetE set = new HashSetE(list); list.retainAll(set); - -return new ListOrderedSet(set, list); + +return new ListOrderedSetE(set, list); } //--- /** * Constructs a new empty codeListOrderedSet/code using * a codeHashSet/code and an codeArrayList/code internally
svn commit: r815104 - /commons/proper/collections/trunk/src/java/org/apache/commons/collections/SetUtils.java
Author: bayard Date: Tue Sep 15 05:56:47 2009 New Revision: 815104 URL: http://svn.apache.org/viewvc?rev=815104view=rev Log: Merging from -r468106:814127 of collections_jdk5_branch - namely where this code was generified; mostly in r738956. Also see the following revisions: r555925 | skestle | 2007-07-13 03:39:24 -0700 (Fri, 13 Jul 2007) | 2 lines Added Edwin Tellman's patch for COLLECTIONS-243. It all seems pretty reasonable, and it should all be checked again as the project is worked through r471166 | scolebourne | 2006-11-04 03:33:22 -0800 (Sat, 04 Nov 2006) | 1 line Removed Typed* containers such as TypedList and TypedMap as generics now provides type safety Modified: commons/proper/collections/trunk/src/java/org/apache/commons/collections/SetUtils.java Modified: commons/proper/collections/trunk/src/java/org/apache/commons/collections/SetUtils.java URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/java/org/apache/commons/collections/SetUtils.java?rev=815104r1=815103r2=815104view=diff == --- commons/proper/collections/trunk/src/java/org/apache/commons/collections/SetUtils.java (original) +++ commons/proper/collections/trunk/src/java/org/apache/commons/collections/SetUtils.java Tue Sep 15 05:56:47 2009 @@ -18,7 +18,6 @@ import java.util.Collection; import java.util.Collections; -import java.util.Iterator; import java.util.Set; import java.util.SortedSet; import java.util.TreeSet; @@ -30,8 +29,6 @@ import org.apache.commons.collections.set.SynchronizedSortedSet; import org.apache.commons.collections.set.TransformedSet; import org.apache.commons.collections.set.TransformedSortedSet; -import org.apache.commons.collections.set.TypedSet; -import org.apache.commons.collections.set.TypedSortedSet; import org.apache.commons.collections.set.UnmodifiableSet; import org.apache.commons.collections.set.UnmodifiableSortedSet; @@ -54,12 +51,32 @@ * This uses the {...@link Collections} implementation * and is provided for completeness. */ -public static final Set EMPTY_SET = Collections.EMPTY_SET; +public static final Set? EMPTY_SET = Collections.EMPTY_SET; + +/** + * Get a typed empty unmodifiable Set. + * @param E + * @return SetE + */ +public static E SetE emptySet() { +return Collections.EemptySet(); +} + /** * An empty unmodifiable sorted set. * This is not provided in the JDK. */ -public static final SortedSet EMPTY_SORTED_SET = UnmodifiableSortedSet.decorate(new TreeSet()); +public static final SortedSet? EMPTY_SORTED_SET = UnmodifiableSortedSet.decorate(new TreeSetObject()); + +/** + * Get a typed empty unmodifiable sorted set. + * @param E + * @return SortedSetE + */ +@SuppressWarnings(unchecked) +public static E SortedSetE emptySortedSet() { +return (SortedSetE) EMPTY_SORTED_SET; +} /** * codeSetUtils/code should not normally be instantiated. @@ -96,7 +113,7 @@ * @param set2 the second set, may be null * @return whether the sets are equal by value comparison */ -public static boolean isEqualSet(final Collection set1, final Collection set2) { +public static boolean isEqualSet(final Collection? set1, final Collection? set2) { if (set1 == set2) { return true; } @@ -119,16 +136,13 @@ * @param set the set to calculate the hash code for, may be null * @return the hash code */ -public static int hashCodeForSet(final Collection set) { +public static T int hashCodeForSet(final CollectionT set) { if (set == null) { return 0; } -int hashCode = 0; -Iterator it = set.iterator(); -Object obj = null; -while (it.hasNext()) { -obj = it.next(); +int hashCode = 0; +for (T obj : set) { if (obj != null) { hashCode += obj.hashCode(); } @@ -159,7 +173,7 @@ * @return a synchronized set backed by the given set * @throws IllegalArgumentException if the set is null */ -public static Set synchronizedSet(Set set) { +public static T SetT synchronizedSet(SetT set) { return SynchronizedSet.decorate(set); } @@ -172,7 +186,7 @@ * @return an unmodifiable set backed by the given set * @throws IllegalArgumentException if the set is null */ -public static Set unmodifiableSet(Set set) { +public static E SetE unmodifiableSet(SetE set) { return UnmodifiableSet.decorate(set); } @@ -189,24 +203,11 @@ * @return
svn commit: r815107 - /commons/proper/collections/trunk/src/test/org/apache/commons/collections/AbstractDecoratedCollectionTest.java
Author: bayard Date: Tue Sep 15 05:56:53 2009 New Revision: 815107 URL: http://svn.apache.org/viewvc?rev=815107view=rev Log: Merging from -r468106:814127 of collections_jdk5_branch - namely where this code was generified; mostly in r738956. Also see the following revisions: r593347 | skestle | 2007-11-08 14:49:02 -0800 (Thu, 08 Nov 2007) | 3 lines Added initial IndexedCollection - still needs quite a bit of work - see TODO comments JIRA: COLLECTIONS-275 Added: commons/proper/collections/trunk/src/test/org/apache/commons/collections/AbstractDecoratedCollectionTest.java - copied unchanged from r814127, commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/AbstractDecoratedCollectionTest.java
svn commit: r815108 - /commons/proper/collections/trunk/src/test/org/apache/commons/collections/bag/AbstractTestBag.java
Author: bayard Date: Tue Sep 15 05:56:55 2009 New Revision: 815108 URL: http://svn.apache.org/viewvc?rev=815108view=rev Log: Merging from -r468106:814127 of collections_jdk5_branch - namely where this code was generified; mostly in r738956. Also see the following revisions: r557435 | skestle | 2007-07-18 17:35:50 -0700 (Wed, 18 Jul 2007) | 1 line Skipped failing SerializedCanonicalTests. Marked code to be revisited through collections re-work. Modified: commons/proper/collections/trunk/src/test/org/apache/commons/collections/bag/AbstractTestBag.java Modified: commons/proper/collections/trunk/src/test/org/apache/commons/collections/bag/AbstractTestBag.java URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/test/org/apache/commons/collections/bag/AbstractTestBag.java?rev=815108r1=815107r2=815108view=diff == --- commons/proper/collections/trunk/src/test/org/apache/commons/collections/bag/AbstractTestBag.java (original) +++ commons/proper/collections/trunk/src/test/org/apache/commons/collections/bag/AbstractTestBag.java Tue Sep 15 05:56:55 2009 @@ -42,7 +42,7 @@ * @author Chuck Burdick * @author Stephen Colebourne */ -public abstract class AbstractTestBag extends AbstractTestObject { +public abstract class AbstractTestBagT extends AbstractTestObject { // TODO: this class should really extend from TestCollection, but the bag // implementations currently do not conform to the Collection interface. Once // those are fixed or at least a strategy is made for resolving the issue, this @@ -63,52 +63,46 @@ * * @return the bag to be tested */ -public abstract Bag makeBag(); - -/** - * Implements the superclass method to return the Bag. - * - * @return the bag to be tested - */ -public Object makeObject() { -return makeBag(); -} +public abstract BagT makeObject(); //--- +@SuppressWarnings(unchecked) public void testBagAdd() { -Bag bag = makeBag(); -bag.add(A); +BagT bag = makeObject(); +bag.add((T) A); assertTrue(Should contain 'A', bag.contains(A)); assertEquals(Should have count of 1, 1, bag.getCount(A)); -bag.add(A); +bag.add((T) A); assertTrue(Should contain 'A', bag.contains(A)); assertEquals(Should have count of 2, 2, bag.getCount(A)); -bag.add(B); +bag.add((T) B); assertTrue(bag.contains(A)); assertTrue(bag.contains(B)); } +@SuppressWarnings(unchecked) public void testBagEqualsSelf() { -Bag bag = makeBag(); +BagT bag = makeObject(); assertTrue(bag.equals(bag)); -bag.add(elt); +bag.add((T) elt); assertTrue(bag.equals(bag)); -bag.add(elt); // again +bag.add((T) elt); // again assertTrue(bag.equals(bag)); -bag.add(elt2); +bag.add((T) elt2); assertTrue(bag.equals(bag)); } +@SuppressWarnings(unchecked) public void testRemove() { -Bag bag = makeBag(); -bag.add(A); +BagT bag = makeObject(); +bag.add((T) A); assertEquals(Should have count of 1, 1, bag.getCount(A)); bag.remove(A); assertEquals(Should have count of 0, 0, bag.getCount(A)); -bag.add(A); -bag.add(A); -bag.add(A); -bag.add(A); +bag.add((T) A); +bag.add((T) A); +bag.add((T) A); +bag.add((T) A); assertEquals(Should have count of 4, 4, bag.getCount(A)); bag.remove(A, 0); assertEquals(Should have count of 4, 4, bag.getCount(A)); @@ -118,14 +112,15 @@ assertEquals(Should have count of 0, 0, bag.getCount(A)); } +@SuppressWarnings(unchecked) public void testRemoveAll() { -Bag bag = makeBag(); -bag.add(A, 2); +BagT bag = makeObject(); +bag.add((T) A, 2); assertEquals(Should have count of 2, 2, bag.getCount(A)); -bag.add(B); -bag.add(C); +bag.add((T) B); +bag.add((T) C); assertEquals(Should have count of 4, 4, bag.size()); -List delete = new ArrayList(); +ListString delete = new ArrayListString(); delete.add(A); delete.add(B); bag.removeAll(delete); @@ -135,36 +130,38 @@ assertEquals(Should have count of 2, 2, bag.size()); } +@SuppressWarnings(unchecked) public void testContains() { -Bag bag = makeBag(); +BagT bag = makeObject(); assertEquals(Bag does not have at least 1 'A', false, bag.contains(A)); assertEquals(Bag
svn commit: r815109 - /commons/proper/collections/trunk/src/test/org/apache/commons/collections/bag/TestAll.java
Author: bayard Date: Tue Sep 15 05:56:57 2009 New Revision: 815109 URL: http://svn.apache.org/viewvc?rev=815109view=rev Log: Merging from -r468106:814127 of collections_jdk5_branch - namely where this code was generified; mostly in r738956. Also see the following revisions: r471166 | scolebourne | 2006-11-04 03:33:22 -0800 (Sat, 04 Nov 2006) | 1 line Removed Typed* containers such as TypedList and TypedMap as generics now provides type safety Modified: commons/proper/collections/trunk/src/test/org/apache/commons/collections/bag/TestAll.java Modified: commons/proper/collections/trunk/src/test/org/apache/commons/collections/bag/TestAll.java URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/test/org/apache/commons/collections/bag/TestAll.java?rev=815109r1=815108r2=815109view=diff == --- commons/proper/collections/trunk/src/test/org/apache/commons/collections/bag/TestAll.java (original) +++ commons/proper/collections/trunk/src/test/org/apache/commons/collections/bag/TestAll.java Tue Sep 15 05:56:57 2009 @@ -48,8 +48,6 @@ suite.addTest(TestTransformedBag.suite()); suite.addTest(TestTransformedSortedBag.suite()); suite.addTest(TestTreeBag.suite()); -suite.addTest(TestTypedBag.suite()); -suite.addTest(TestTypedSortedBag.suite()); return suite; }
svn commit: r815110 - /commons/proper/collections/trunk/src/test/org/apache/commons/collections/bag/TestPredicatedSortedBag.java
Author: bayard Date: Tue Sep 15 05:56:58 2009 New Revision: 815110 URL: http://svn.apache.org/viewvc?rev=815110view=rev Log: Merging from -r468106:814127 of collections_jdk5_branch - namely where this code was generified; mostly in r738956. Also see the following revisions: r471201 | scolebourne | 2006-11-04 06:17:26 -0800 (Sat, 04 Nov 2006) | 1 line Remove getBag() - use covariant decorated() Modified: commons/proper/collections/trunk/src/test/org/apache/commons/collections/bag/TestPredicatedSortedBag.java Modified: commons/proper/collections/trunk/src/test/org/apache/commons/collections/bag/TestPredicatedSortedBag.java URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/test/org/apache/commons/collections/bag/TestPredicatedSortedBag.java?rev=815110r1=815109r2=815110view=diff == --- commons/proper/collections/trunk/src/test/org/apache/commons/collections/bag/TestPredicatedSortedBag.java (original) +++ commons/proper/collections/trunk/src/test/org/apache/commons/collections/bag/TestPredicatedSortedBag.java Tue Sep 15 05:56:58 2009 @@ -21,10 +21,9 @@ import junit.framework.Test; import junit.framework.TestSuite; -import org.apache.commons.collections.Bag; import org.apache.commons.collections.Predicate; -import org.apache.commons.collections.PredicateUtils; import org.apache.commons.collections.SortedBag; +import org.apache.commons.collections.functors.TruePredicate; /** * Extension of {...@link AbstractTestSortedBag} for exercising the {...@link PredicatedSortedBag} @@ -35,73 +34,74 @@ * * @author Phil Steitz */ -public class TestPredicatedSortedBag extends AbstractTestSortedBag { - -private SortedBag nullBag = null; - +public class TestPredicatedSortedBagT extends AbstractTestSortedBagT { + +private SortedBagT nullBag = null; + public TestPredicatedSortedBag(String testName) { super(testName); } - + public static Test suite() { return new TestSuite(TestPredicatedSortedBag.class); } - + public static void main(String args[]) { String[] testCaseName = { TestPredicatedSortedBag.class.getName()}; junit.textui.TestRunner.main(testCaseName); } - + //-- - -protected Predicate stringPredicate() { -return new Predicate() { -public boolean evaluate(Object o) { + +protected PredicateT stringPredicate() { +return new PredicateT() { +public boolean evaluate(T o) { return o instanceof String; } }; -} - -protected Predicate truePredicate = PredicateUtils.truePredicate(); - -protected SortedBag decorateBag(SortedBag bag, Predicate predicate) { +} + +protected PredicateT truePredicate = TruePredicate.TtruePredicate(); + +protected SortedBagT decorateBag(SortedBagT bag, PredicateT predicate) { return PredicatedSortedBag.decorate(bag, predicate); } - -public Bag makeBag() { -return decorateBag(new TreeBag(), truePredicate); -} - -protected Bag makeTestBag() { -return decorateBag(new TreeBag(), stringPredicate()); + +public SortedBagT makeObject() { +return decorateBag(new TreeBagT(), truePredicate); +} + +protected SortedBagT makeTestBag() { +return decorateBag(new TreeBagT(), stringPredicate()); } - + //-- - + public void testDecorate() { -SortedBag bag = decorateBag(new TreeBag(), stringPredicate()); -SortedBag bag2 = ((PredicatedSortedBag) bag).getSortedBag(); +SortedBagT bag = decorateBag(new TreeBagT(), stringPredicate()); +((PredicatedSortedBagT) bag).decorated(); try { -SortedBag bag3 = decorateBag(new TreeBag(), null); +decorateBag(new TreeBagT(), null); fail(Expecting IllegalArgumentException for null predicate); } catch (IllegalArgumentException e) {} try { -SortedBag bag4 = decorateBag(nullBag, stringPredicate()); +decorateBag(nullBag, stringPredicate()); fail(Expecting IllegalArgumentException for null bag); } catch (IllegalArgumentException e) {} } - + +@SuppressWarnings(unchecked) public void testSortOrder() { -SortedBag bag = decorateBag(new TreeBag(), stringPredicate()); +SortedBagT bag = decorateBag(new TreeBagT(), stringPredicate()); String one = one; String two = two; String three = three; -bag.add(one); -bag.add(two
svn commit: r815111 - /commons/proper/collections/trunk/src/test/org/apache/commons/collections/bidimap/AbstractTestBidiMap.java
Author: bayard Date: Tue Sep 15 05:56:59 2009 New Revision: 815111 URL: http://svn.apache.org/viewvc?rev=815111view=rev Log: Merging from -r468106:814127 of collections_jdk5_branch - namely where this code was generified; mostly in r738956. Also see the following revisions: r740150 | mbenson | 2009-02-02 15:24:00 -0800 (Mon, 02 Feb 2009) | 1 line make all [collections] maps implement IterableMap Modified: commons/proper/collections/trunk/src/test/org/apache/commons/collections/bidimap/AbstractTestBidiMap.java Modified: commons/proper/collections/trunk/src/test/org/apache/commons/collections/bidimap/AbstractTestBidiMap.java URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/test/org/apache/commons/collections/bidimap/AbstractTestBidiMap.java?rev=815111r1=815110r2=815111view=diff == --- commons/proper/collections/trunk/src/test/org/apache/commons/collections/bidimap/AbstractTestBidiMap.java (original) +++ commons/proper/collections/trunk/src/test/org/apache/commons/collections/bidimap/AbstractTestBidiMap.java Tue Sep 15 05:56:59 2009 @@ -26,7 +26,7 @@ import org.apache.commons.collections.BulkTest; import org.apache.commons.collections.MapIterator; import org.apache.commons.collections.iterators.AbstractTestMapIterator; -import org.apache.commons.collections.map.AbstractTestMap; +import org.apache.commons.collections.map.AbstractTestIterableMap; /** * Abstract test class for {...@link BidiMap} methods and contracts. @@ -36,60 +36,31 @@ * @author Matthew Hawthorne * @author Stephen Colebourne */ -public abstract class AbstractTestBidiMap extends AbstractTestMap { - -// Test data. -private static final Object[][] entriesKV = -new Object[][] { -new Object[] { key1, value1 }, -new Object[] { key2, value2 }, -new Object[] { key3, value3 } -}; -private static final Object[][] entriesVK = -new Object[][] { -new Object[] { value1, key1 }, -new Object[] { value2, key2 }, -new Object[] { value3, key3 } -}; -protected final Object[][] entries; +public abstract class AbstractTestBidiMapK, V extends AbstractTestIterableMapK, V { public AbstractTestBidiMap(String testName) { super(testName); -entries = entriesKV; } public AbstractTestBidiMap() { super(Inverse); -entries = entriesVK; } //--- /** - * Implement to create an empty codeBidiMap/code. - * - * @return an empty codeBidiMap/code implementation. - */ -public abstract BidiMap makeEmptyBidiMap(); - -/** * Override to create a full codeBidiMap/code other than the default. - * + * * @return a full codeBidiMap/code implementation. */ -public BidiMap makeFullBidiMap() { -final BidiMap map = makeEmptyBidiMap(); -for (int i = 0; i entries.length; i++) { -map.put(entries[i][0], entries[i][1]); -} -return map; +@Override +public BidiMapK, V makeFullMap() { +return (BidiMapK, V) super.makeFullMap(); } /** * Override to return the empty BidiMap. */ -public final Map makeEmptyMap() { -return makeEmptyBidiMap(); -} +public abstract BidiMapK, V makeObject(); /** * Override to indicate to AbstractTestMap this is a BidiMap. @@ -97,7 +68,7 @@ public boolean isAllowDuplicateValues() { return false; } - + /** * Override as DualHashBidiMap didn't exist until version 3. */ @@ -107,33 +78,34 @@ // BidiPut //--- +@SuppressWarnings(unchecked) public void testBidiPut() { if (isPutAddSupported() == false || isPutChangeSupported() == false) return; -BidiMap map = makeEmptyBidiMap(); -BidiMap inverse = map.inverseBidiMap(); +BidiMapK, V map = makeObject(); +BidiMapV, K inverse = map.inverseBidiMap(); assertEquals(0, map.size()); assertEquals(map.size(), inverse.size()); - -map.put(A, B); + +map.put((K) A, (V) B); assertEquals(1, map.size()); assertEquals(map.size(), inverse.size()); assertEquals(B, map.get(A)); assertEquals(A, inverse.get(B)); - -map.put(A, C); + +map.put((K) A, (V) C); assertEquals(1, map.size()); assertEquals(map.size(), inverse.size()); assertEquals(C, map.get(A)); assertEquals(A, inverse.get(C)); - -map.put(B, C); + +map.put((K) B, (V) C
svn commit: r815112 - /commons/proper/collections/trunk/src/test/org/apache/commons/collections/collection/TestCompositeCollection.java
Author: bayard Date: Tue Sep 15 05:57:01 2009 New Revision: 815112 URL: http://svn.apache.org/viewvc?rev=815112view=rev Log: Merging from -r468106:814127 of collections_jdk5_branch - namely where this code was generified; mostly in r738956. Also see the following revisions: r471580 | scolebourne | 2006-11-05 16:22:53 -0800 (Sun, 05 Nov 2006) | 1 line Generify CompositeCollection Modified: commons/proper/collections/trunk/src/test/org/apache/commons/collections/collection/TestCompositeCollection.java Modified: commons/proper/collections/trunk/src/test/org/apache/commons/collections/collection/TestCompositeCollection.java URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/test/org/apache/commons/collections/collection/TestCompositeCollection.java?rev=815112r1=815111r2=815112view=diff == --- commons/proper/collections/trunk/src/test/org/apache/commons/collections/collection/TestCompositeCollection.java (original) +++ commons/proper/collections/trunk/src/test/org/apache/commons/collections/collection/TestCompositeCollection.java Tue Sep 15 05:57:01 2009 @@ -16,16 +16,18 @@ */ package org.apache.commons.collections.collection; +import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.HashSet; import java.util.Iterator; +import java.util.List; import junit.framework.Test; import junit.framework.TestSuite; /** - * Extension of {...@link AbstractTestCollection} for exercising the + * Extension of {...@link AbstractTestCollection} for exercising the * {...@link CompositeCollection} implementation. * * @since Commons Collections 3.0 @@ -34,12 +36,12 @@ * @author Brian McCallister * @author Phil Steitz */ -public class TestCompositeCollection extends AbstractTestCollection { - +public class TestCompositeCollectionE extends AbstractTestCollectionE { + public TestCompositeCollection(String name) { super(name); } - + public static Test suite() { return new TestSuite(TestCompositeCollection.class); } @@ -48,7 +50,7 @@ String[] testCaseName = { TestCompositeCollection.class.getName()}; junit.textui.TestRunner.main(testCaseName); } - + //- /** * Run stock collection tests without Mutator, so turn off add, remove @@ -56,145 +58,150 @@ public boolean isAddSupported() { return false; } - + public boolean isRemoveSupported() { return false; } - + /** * Empty collection is empty composite */ -public Collection makeCollection() { -return new CompositeCollection(); +public CollectionE makeObject() { +return new CompositeCollectionE(); } - -public Collection makeConfirmedCollection() { -return new HashSet(); -} - -public Object[] getFullElements() { -return new Object[] {1, 2, 3, 4}; + +public CollectionE makeConfirmedCollection() { +return new HashSetE(); +} + +@SuppressWarnings(unchecked) +public E[] getFullElements() { +return (E[]) new Object[] { 1, 2, 3, 4 }; } - + /** * Full collection consists of 4 collections, each with one element */ -public Collection makeFullCollection() { -CompositeCollection compositeCollection = new CompositeCollection(); -Object[] elements = getFullElements(); +public CollectionE makeFullCollection() { +CompositeCollectionE compositeCollection = new CompositeCollectionE(); +E[] elements = getFullElements(); for (int i = 0; i elements.length; i++) { -Collection summand = new HashSet(); +CollectionE summand = new HashSetE(); summand.add(elements[i]); compositeCollection.addComposited(summand); } return compositeCollection; } - + /** * Full collection should look like a collection with 4 elements */ -public Collection makeConfirmedFullCollection() { -Collection collection = new HashSet(); +public CollectionE makeConfirmedFullCollection() { +CollectionE collection = new HashSetE(); collection.addAll(Arrays.asList(getFullElements())); return collection; } - + /** * Override testUnsupportedRemove, since the default impl expects removeAll, * retainAll and iterator().remove to throw */ -public void testUnsupportedRemove() { +public void testUnsupportedRemove() { resetFull(); try { -collection.remove(null); +getCollection().remove(null
svn commit: r815114 - /commons/proper/collections/trunk/src/test/org/apache/commons/collections/iterators/TestAll.java
Author: bayard Date: Tue Sep 15 05:57:06 2009 New Revision: 815114 URL: http://svn.apache.org/viewvc?rev=815114view=rev Log: Merging from -r468106:814127 of collections_jdk5_branch - namely where this code was generified; mostly in r738956. Also see the following revisions: r751862 | mbenson | 2009-03-09 14:56:41 -0700 (Mon, 09 Mar 2009) | 1 line add new test to suite Modified: commons/proper/collections/trunk/src/test/org/apache/commons/collections/iterators/TestAll.java Modified: commons/proper/collections/trunk/src/test/org/apache/commons/collections/iterators/TestAll.java URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/test/org/apache/commons/collections/iterators/TestAll.java?rev=815114r1=815113r2=815114view=diff == --- commons/proper/collections/trunk/src/test/org/apache/commons/collections/iterators/TestAll.java (original) +++ commons/proper/collections/trunk/src/test/org/apache/commons/collections/iterators/TestAll.java Tue Sep 15 05:57:06 2009 @@ -47,6 +47,7 @@ suite.addTest(TestFilterListIterator.suite()); suite.addTest(TestIteratorChain.suite()); suite.addTest(TestListIteratorWrapper.suite()); +suite.addTest(TestListIteratorWrapper2.suite()); suite.addTest(TestLoopingIterator.suite()); suite.addTest(TestLoopingListIterator.suite()); suite.addTest(TestReverseListIterator.suite());
svn commit: r815113 - /commons/proper/collections/trunk/src/test/org/apache/commons/collections/functors/
Author: bayard Date: Tue Sep 15 05:57:05 2009 New Revision: 815113 URL: http://svn.apache.org/viewvc?rev=815113view=rev Log: Merging from -r468106:814127 of collections_jdk5_branch - namely where this code was generified; mostly in r738956. Also see the following revisions: r644140 | skestle | 2008-04-02 19:42:30 -0700 (Wed, 02 Apr 2008) | 1 line Fixed javac complier generic issues r644138 | skestle | 2008-04-02 19:34:09 -0700 (Wed, 02 Apr 2008) | 1 line Fixed javac complier generic issues r643795 | skestle | 2008-04-02 01:49:57 -0700 (Wed, 02 Apr 2008) | 5 lines Generified EqualPredicate and created individual test class moved from TestPredicateUtils Added assertFalse() and assertTrue to BasicPredicateTestBase with (Predicate, Object) parameters Issues: COLLECTIONS-243, COLLECTIONS-253, COLLECTIONS-293 r643782 | skestle | 2008-04-02 01:00:00 -0700 (Wed, 02 Apr 2008) | 5 lines Generified NullPredicate and created individual test class moved on TestPredicateUtils Renamed PredicateTestBase to MockPredicateTestBase to reduce confusion and added BasicPredicateTestBase. Issues: COLLECTIONS-243, COLLECTIONS-253, COLLECTIONS-293 r641231 | skestle | 2008-03-26 02:58:51 -0700 (Wed, 26 Mar 2008) | 1 line Started incorporating Edwin's patch for COLLECTIONS-253, in preparation for COLLECTIONS-290. Added: commons/proper/collections/trunk/src/test/org/apache/commons/collections/functors/ commons/proper/collections/trunk/src/test/org/apache/commons/collections/functors/BasicPredicateTestBase.java (with props) commons/proper/collections/trunk/src/test/org/apache/commons/collections/functors/MockPredicateTestBase.java (with props) commons/proper/collections/trunk/src/test/org/apache/commons/collections/functors/TestAll.java (with props) commons/proper/collections/trunk/src/test/org/apache/commons/collections/functors/TestAllPredicate.java (with props) commons/proper/collections/trunk/src/test/org/apache/commons/collections/functors/TestAnyAllOnePredicate.java (with props) commons/proper/collections/trunk/src/test/org/apache/commons/collections/functors/TestCompositePredicate.java (with props) commons/proper/collections/trunk/src/test/org/apache/commons/collections/functors/TestEqualPredicate.java (with props) commons/proper/collections/trunk/src/test/org/apache/commons/collections/functors/TestNullPredicate.java (with props) Added: commons/proper/collections/trunk/src/test/org/apache/commons/collections/functors/BasicPredicateTestBase.java URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/test/org/apache/commons/collections/functors/BasicPredicateTestBase.java?rev=815113view=auto == --- commons/proper/collections/trunk/src/test/org/apache/commons/collections/functors/BasicPredicateTestBase.java (added) +++ commons/proper/collections/trunk/src/test/org/apache/commons/collections/functors/BasicPredicateTestBase.java Tue Sep 15 05:57:05 2009 @@ -0,0 +1,38 @@ +package org.apache.commons.collections.functors; + +import org.apache.commons.collections.Predicate; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + +public abstract class BasicPredicateTestBase { +protected Object cObject; +protected String cString; +protected Integer cInteger; + +@Before +public void initialiseTestObjects() throws Exception { +cObject = new Object(); +cString = Hello; +cInteger = new Integer(6); +} + +@Test +public void predicateSanityTests() throws Exception { +Predicate? predicate = generatePredicate(); +Assert.assertNotNull(predicate); +} + +/** + * @return a predicate for general sanity tests. + */ +protected abstract Predicate? generatePredicate(); + +protected T void assertFalse(PredicateT predicate, T testObject) { +Assert.assertFalse(predicate.evaluate(testObject)); +} + +protected T void assertTrue(PredicateT predicate, T testObject) { +Assert.assertTrue(predicate.evaluate(testObject)); +} +} Propchange: commons/proper/collections/trunk/src/test/org/apache/commons/collections/functors/BasicPredicateTestBase.java -- svn:eol-style = native Added: commons/proper/collections
svn commit: r815115 - /commons/proper/collections/trunk/src/test/org/apache/commons/collections/iterators/TestFilterIterator.java
Author: bayard Date: Tue Sep 15 05:57:07 2009 New Revision: 815115 URL: http://svn.apache.org/viewvc?rev=815115view=rev Log: Merging from -r468106:814127 of collections_jdk5_branch - namely where this code was generified; mostly in r738956. Also see the following revisions: r641231 | skestle | 2008-03-26 02:58:51 -0700 (Wed, 26 Mar 2008) | 1 line Started incorporating Edwin's patch for COLLECTIONS-253, in preparation for COLLECTIONS-290. Modified: commons/proper/collections/trunk/src/test/org/apache/commons/collections/iterators/TestFilterIterator.java Modified: commons/proper/collections/trunk/src/test/org/apache/commons/collections/iterators/TestFilterIterator.java URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/test/org/apache/commons/collections/iterators/TestFilterIterator.java?rev=815115r1=815114r2=815115view=diff == --- commons/proper/collections/trunk/src/test/org/apache/commons/collections/iterators/TestFilterIterator.java (original) +++ commons/proper/collections/trunk/src/test/org/apache/commons/collections/iterators/TestFilterIterator.java Tue Sep 15 05:57:07 2009 @@ -16,6 +16,8 @@ */ package org.apache.commons.collections.iterators; +import static org.apache.commons.collections.functors.TruePredicate.truePredicate; + import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; @@ -28,7 +30,6 @@ import org.apache.commons.collections.Predicate; import org.apache.commons.collections.functors.NotNullPredicate; -import org.apache.commons.collections.functors.TruePredicate; /** * Test the filter iterator. @@ -39,7 +40,7 @@ * @author Ralph Wagner * @author Huw Roberts */ -public class TestFilterIterator extends AbstractTestIterator { +public class TestFilterIteratorE extends AbstractTestIteratorE { /** Creates new TestFilterIterator */ public TestFilterIterator(String name) { @@ -47,8 +48,9 @@ } private String[] array; -private List list; -private FilterIterator iterator; +private ListE list; +private FilterIteratorE iterator; + /** * Set up instance variables required by this test case. */ @@ -74,11 +76,11 @@ /** * Returns an full iterator wrapped in a * FilterIterator that blocks all the elements - * + * * @return empty FilterIterator */ -public Iterator makeEmptyIterator() { -return makeBlockAllFilter(new ArrayIterator(array)); +public FilterIteratorE makeEmptyIterator() { +return makeBlockAllFilter(new ArrayIteratorE(array)); } /** @@ -87,9 +89,9 @@ * * @return a filtered iterator */ -public Iterator makeFullIterator() { -array = new String[] { a, b, c }; -list = new ArrayList(Arrays.asList(array)); +@SuppressWarnings(unchecked) +public FilterIteratorE makeObject() { +list = new ArrayListE(Arrays.asList((E[]) array)); return makePassThroughFilter(list.iterator()); } @@ -100,8 +102,9 @@ } public void testRepeatedNext() { -for (int i = 0; i array.length; i++) +for (int i = 0; i array.length; i++) { iterator.next(); +} verifyNoMoreElements(); } @@ -120,15 +123,16 @@ * Test that when the iterator is changed, the hasNext method returns the * correct response for the new iterator. */ +@SuppressWarnings(unchecked) public void testSetIterator() { -Iterator iter1 = Collections.singleton(new Object()).iterator(); -Iterator iter2 = Collections.EMPTY_LIST.iterator(); - -FilterIterator filterIterator = new FilterIterator(iter1); -filterIterator.setPredicate(TruePredicate.getInstance()); +IteratorE iter1 = Collections.singleton((E) new Object()).iterator(); +IteratorE iter2 = Collections.EemptyList().iterator(); + +FilterIteratorE filterIterator = new FilterIteratorE(iter1); +filterIterator.setPredicate(truePredicate()); // this iterator has elements assertEquals(true, filterIterator.hasNext()); - + // this iterator has no elements filterIterator.setIterator(iter2); assertEquals(false, filterIterator.hasNext()); @@ -139,13 +143,13 @@ * correct response for the new predicate. */ public void testSetPredicate() { -Iterator iter = Collections.singleton(null).iterator(); +IteratorE iter = Collections.singleton((E) null).iterator(); -FilterIterator filterIterator = new FilterIterator(iter); -filterIterator.setPredicate(TruePredicate.getInstance()); +FilterIteratorE filterIterator = new FilterIteratorE(iter
svn commit: r815096 - /commons/proper/collections/trunk/src/java/org/apache/commons/collections/set/AbstractSortedSetDecorator.java
Author: bayard Date: Tue Sep 15 05:56:38 2009 New Revision: 815096 URL: http://svn.apache.org/viewvc?rev=815096view=rev Log: Merging from -r468106:814127 of collections_jdk5_branch - namely where this code was generified; mostly in r738956. Also see the following revisions: r471186 | scolebourne | 2006-11-04 05:47:51 -0800 (Sat, 04 Nov 2006) | 1 line Remove getSet() and getSortedSet() - use decorated() r471173 | scolebourne | 2006-11-04 04:07:39 -0800 (Sat, 04 Nov 2006) | 1 line Abstract*Decorator - Generify and use covariant return types Modified: commons/proper/collections/trunk/src/java/org/apache/commons/collections/set/AbstractSortedSetDecorator.java Modified: commons/proper/collections/trunk/src/java/org/apache/commons/collections/set/AbstractSortedSetDecorator.java URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/java/org/apache/commons/collections/set/AbstractSortedSetDecorator.java?rev=815096r1=815095r2=815096view=diff == --- commons/proper/collections/trunk/src/java/org/apache/commons/collections/set/AbstractSortedSetDecorator.java (original) +++ commons/proper/collections/trunk/src/java/org/apache/commons/collections/set/AbstractSortedSetDecorator.java Tue Sep 15 05:56:38 2009 @@ -25,12 +25,18 @@ * p * Methods are forwarded directly to the decorated set. * + * @param E the type of the elements in the sorted set * @since Commons Collections 3.0 * @version $Revision$ $Date$ * * @author Stephen Colebourne */ -public abstract class AbstractSortedSetDecorator extends AbstractSetDecorator implements SortedSet { +public abstract class AbstractSortedSetDecoratorE +extends AbstractSetDecoratorE +implements SortedSetE { + +/** Serialization version */ +private static final long serialVersionUID = -3462240946294214398L; /** * Constructor only used in deserialization, do not use otherwise. @@ -46,42 +52,42 @@ * @param set the set to decorate, must not be null * @throws IllegalArgumentException if set is null */ -protected AbstractSortedSetDecorator(Set set) { +protected AbstractSortedSetDecorator(SetE set) { super(set); } /** - * Gets the sorted set being decorated. + * Gets the set being decorated. * * @return the decorated set */ -protected SortedSet getSortedSet() { -return (SortedSet) getCollection(); +protected SortedSetE decorated() { +return (SortedSetE) super.decorated(); } - + //--- -public SortedSet subSet(Object fromElement, Object toElement) { -return getSortedSet().subSet(fromElement, toElement); +public SortedSetE subSet(E fromElement, E toElement) { +return decorated().subSet(fromElement, toElement); } -public SortedSet headSet(Object toElement) { -return getSortedSet().headSet(toElement); +public SortedSetE headSet(E toElement) { +return decorated().headSet(toElement); } -public SortedSet tailSet(Object fromElement) { -return getSortedSet().tailSet(fromElement); +public SortedSetE tailSet(E fromElement) { +return decorated().tailSet(fromElement); } -public Object first() { -return getSortedSet().first(); +public E first() { +return decorated().first(); } -public Object last() { -return getSortedSet().last(); +public E last() { +return decorated().last(); } -public Comparator comparator() { -return getSortedSet().comparator(); +public Comparator? super E comparator() { +return decorated().comparator(); } }
svn commit: r815099 - /commons/proper/collections/trunk/src/java/org/apache/commons/collections/set/PredicatedSortedSet.java
Author: bayard Date: Tue Sep 15 05:56:42 2009 New Revision: 815099 URL: http://svn.apache.org/viewvc?rev=815099view=rev Log: Merging from -r468106:814127 of collections_jdk5_branch - namely where this code was generified; mostly in r738956. Also see the following revisions: r555925 | skestle | 2007-07-13 03:39:24 -0700 (Fri, 13 Jul 2007) | 2 lines Added Edwin Tellman's patch for COLLECTIONS-243. It all seems pretty reasonable, and it should all be checked again as the project is worked through r471202 | scolebourne | 2006-11-04 06:21:44 -0800 (Sat, 04 Nov 2006) | 1 line Remove getCollection() - use covariant decorated() Modified: commons/proper/collections/trunk/src/java/org/apache/commons/collections/set/PredicatedSortedSet.java Modified: commons/proper/collections/trunk/src/java/org/apache/commons/collections/set/PredicatedSortedSet.java URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/java/org/apache/commons/collections/set/PredicatedSortedSet.java?rev=815099r1=815098r2=815099view=diff == --- commons/proper/collections/trunk/src/java/org/apache/commons/collections/set/PredicatedSortedSet.java (original) +++ commons/proper/collections/trunk/src/java/org/apache/commons/collections/set/PredicatedSortedSet.java Tue Sep 15 05:56:42 2009 @@ -40,7 +40,7 @@ * @author Stephen Colebourne * @author Paul Jack */ -public class PredicatedSortedSet extends PredicatedSet implements SortedSet { +public class PredicatedSortedSetE extends PredicatedSetE implements SortedSetE { /** Serialization version */ private static final long serialVersionUID = -9110948148132275052L; @@ -53,11 +53,12 @@ * * @param set the set to decorate, must not be null * @param predicate the predicate to use for validation, must not be null + * @return a new predicated sorted set. * @throws IllegalArgumentException if set or predicate is null * @throws IllegalArgumentException if the set contains invalid elements */ -public static SortedSet decorate(SortedSet set, Predicate predicate) { -return new PredicatedSortedSet(set, predicate); +public static T SortedSetT decorate(SortedSetT set, Predicate? super T predicate) { +return new PredicatedSortedSetT(set, predicate); } //--- @@ -72,7 +73,7 @@ * @throws IllegalArgumentException if set or predicate is null * @throws IllegalArgumentException if the set contains invalid elements */ -protected PredicatedSortedSet(SortedSet set, Predicate predicate) { +protected PredicatedSortedSet(SortedSetE set, Predicate? super E predicate) { super(set, predicate); } @@ -81,36 +82,36 @@ * * @return the decorated sorted set */ -private SortedSet getSortedSet() { -return (SortedSet) getCollection(); +protected SortedSetE decorated() { +return (SortedSetE) super.decorated(); } //--- -public SortedSet subSet(Object fromElement, Object toElement) { -SortedSet sub = getSortedSet().subSet(fromElement, toElement); -return new PredicatedSortedSet(sub, predicate); +public Comparator? super E comparator() { +return decorated().comparator(); } -public SortedSet headSet(Object toElement) { -SortedSet sub = getSortedSet().headSet(toElement); -return new PredicatedSortedSet(sub, predicate); +public E first() { +return decorated().first(); } -public SortedSet tailSet(Object fromElement) { -SortedSet sub = getSortedSet().tailSet(fromElement); -return new PredicatedSortedSet(sub, predicate); +public E last() { +return decorated().last(); } -public Object first() { -return getSortedSet().first(); +public SortedSetE subSet(E fromElement, E toElement) { +SortedSetE sub = decorated().subSet(fromElement, toElement); +return new PredicatedSortedSetE(sub, predicate); } -public Object last() { -return getSortedSet().last(); +public SortedSetE headSet(E toElement) { +SortedSetE sub = decorated().headSet(toElement); +return new PredicatedSortedSetE(sub, predicate); } -public Comparator comparator() { -return getSortedSet().comparator(); +public SortedSetE tailSet(E fromElement) { +SortedSetE sub = decorated().tailSet(fromElement); +return new PredicatedSortedSetE(sub, predicate); } }
svn commit: r815105 - in /commons/proper/collections/trunk/src/java/org/apache/commons/collections/splitmap: ./ AbstractIterableGetMapDecorator.java SplitMapUtils.java TransformedMap.java package.html
Author: bayard Date: Tue Sep 15 05:56:50 2009 New Revision: 815105 URL: http://svn.apache.org/viewvc?rev=815105view=rev Log: Merging from -r468106:814127 of collections_jdk5_branch - namely where this code was generified; mostly in r738956. Also see the following revisions: r814061 | mbenson | 2009-09-11 15:22:41 -0700 (Fri, 11 Sep 2009) | 1 line finish extraction of abstract class r814060 | mbenson | 2009-09-11 15:21:50 -0700 (Fri, 11 Sep 2009) | 1 line Get does not clear() r814050 | sebb | 2009-09-11 15:01:25 -0700 (Fri, 11 Sep 2009) | 1 line Some minor Javadoc fixes r751901 | mbenson | 2009-03-09 16:06:49 -0700 (Mon, 09 Mar 2009) | 1 line comments r751894 | mbenson | 2009-03-09 15:48:07 -0700 (Mon, 09 Mar 2009) | 1 line add splitmap package whose original goal is to provide a more versatile TransformedMap implementation Added: commons/proper/collections/trunk/src/java/org/apache/commons/collections/splitmap/ - copied from r814127, commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/splitmap/ commons/proper/collections/trunk/src/java/org/apache/commons/collections/splitmap/AbstractIterableGetMapDecorator.java - copied unchanged from r814127, commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/splitmap/AbstractIterableGetMapDecorator.java commons/proper/collections/trunk/src/java/org/apache/commons/collections/splitmap/SplitMapUtils.java - copied unchanged from r814127, commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/splitmap/SplitMapUtils.java commons/proper/collections/trunk/src/java/org/apache/commons/collections/splitmap/TransformedMap.java - copied unchanged from r814127, commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/splitmap/TransformedMap.java commons/proper/collections/trunk/src/java/org/apache/commons/collections/splitmap/package.html - copied unchanged from r814127, commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/splitmap/package.html
svn commit: r815119 - /commons/proper/collections/trunk/src/test/org/apache/commons/collections/list/AbstractTestList.java
Author: bayard Date: Tue Sep 15 05:57:17 2009 New Revision: 815119 URL: http://svn.apache.org/viewvc?rev=815119view=rev Log: Merging from -r468106:814127 of collections_jdk5_branch - namely where this code was generified; mostly in r738956. Also see the following revisions: r557435 | skestle | 2007-07-18 17:35:50 -0700 (Wed, 18 Jul 2007) | 1 line Skipped failing SerializedCanonicalTests. Marked code to be revisited through collections re-work. Modified: commons/proper/collections/trunk/src/test/org/apache/commons/collections/list/AbstractTestList.java Modified: commons/proper/collections/trunk/src/test/org/apache/commons/collections/list/AbstractTestList.java URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/test/org/apache/commons/collections/list/AbstractTestList.java?rev=815119r1=815118r2=815119view=diff == --- commons/proper/collections/trunk/src/test/org/apache/commons/collections/list/AbstractTestList.java (original) +++ commons/proper/collections/trunk/src/test/org/apache/commons/collections/list/AbstractTestList.java Tue Sep 15 05:57:17 2009 @@ -53,11 +53,11 @@ * @author Stephen Colebourne * @author Neil O'Toole */ -public abstract class AbstractTestList extends AbstractTestCollection { +public abstract class AbstractTestListE extends AbstractTestCollectionE { /** * JUnit constructor. - * + * * @param testName the test class name */ public AbstractTestList(String testName) { @@ -66,7 +66,7 @@ //--- /** - * Returns true if the collections produced by + * Returns true if the collections produced by * {...@link #makeCollection()} and {...@link #makeFullCollection()} * support the codeset operation.p * Default implementation returns true. Override if your collection @@ -81,11 +81,12 @@ * Verifies that the test list implementation matches the confirmed list * implementation. */ +@SuppressWarnings(unchecked) public void verify() { super.verify(); -List list1 = getList(); -List list2 = getConfirmedList(); +ListE list1 = getCollection(); +ListE list2 = getConfirmed(); assertEquals(List should equal confirmed, list1, list2); assertEquals(Confirmed should equal list, list2, list1); @@ -93,9 +94,9 @@ assertEquals(Hash codes should be equal, list1.hashCode(), list2.hashCode()); int i = 0; -Iterator iterator1 = list1.iterator(); -Iterator iterator2 = list2.iterator(); -Object[] array = list1.toArray(); +IteratorE iterator1 = list1.iterator(); +IteratorE iterator2 = list2.iterator(); +E[] array = (E[]) list1.toArray(); while (iterator2.hasNext()) { assertTrue(List iterator should have next, iterator1.hasNext()); Object o1 = iterator1.next(); @@ -120,35 +121,16 @@ /** * Returns an empty {...@link ArrayList}. */ -public Collection makeConfirmedCollection() { -ArrayList list = new ArrayList(); +public CollectionE makeConfirmedCollection() { +ArrayListE list = new ArrayListE(); return list; } /** * Returns a full {...@link ArrayList}. */ -public Collection makeConfirmedFullCollection() { -ArrayList list = new ArrayList(); -list.addAll(Arrays.asList(getFullElements())); -return list; -} - -/** - * Return a new, empty {...@link List} to be used for testing. - * - * @return an empty list for testing. - */ -public abstract List makeEmptyList(); - -/** - * Return a new, full {...@link List} to be used for testing. - * - * @return a full list for testing - */ -public List makeFullList() { -// only works if list supports optional addAll(Collection) -List list = makeEmptyList(); +public CollectionE makeConfirmedFullCollection() { +ArrayListE list = new ArrayListE(); list.addAll(Arrays.asList(getFullElements())); return list; } @@ -158,17 +140,16 @@ * * @return an empty list to be used for testing */ -public final Collection makeCollection() { -return makeEmptyList(); -} +public abstract ListE makeObject(); /** - * Returns {...@link #makeFullList()}. - * - * @return a full list to be used for testing + * {...@inheritdoc} */ -public final Collection makeFullCollection() { -return makeFullList(); +public ListE makeFullCollection() { +// only works if list supports optional addAll(Collection) +ListE
svn commit: r815125 - /commons/proper/collections/trunk/src/test/org/apache/commons/collections/map/TestCompositeMap.java
Author: bayard Date: Tue Sep 15 05:57:24 2009 New Revision: 815125 URL: http://svn.apache.org/viewvc?rev=815125view=rev Log: Merging from -r468106:814127 of collections_jdk5_branch - namely where this code was generified; mostly in r738956. Also see the following revisions: r740150 | mbenson | 2009-02-02 15:24:00 -0800 (Mon, 02 Feb 2009) | 1 line make all [collections] maps implement IterableMap Modified: commons/proper/collections/trunk/src/test/org/apache/commons/collections/map/TestCompositeMap.java Modified: commons/proper/collections/trunk/src/test/org/apache/commons/collections/map/TestCompositeMap.java URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/test/org/apache/commons/collections/map/TestCompositeMap.java?rev=815125r1=815124r2=815125view=diff == --- commons/proper/collections/trunk/src/test/org/apache/commons/collections/map/TestCompositeMap.java (original) +++ commons/proper/collections/trunk/src/test/org/apache/commons/collections/map/TestCompositeMap.java Tue Sep 15 05:57:24 2009 @@ -33,7 +33,7 @@ * * @author Brian McCallister */ -public class TestCompositeMap extends AbstractTestMap { +public class TestCompositeMapK, V extends AbstractTestIterableMapK, V { /** used as a flag in MapMutator tests */ private boolean pass = false; @@ -55,37 +55,40 @@ junit.textui.TestRunner.main(testCaseName); } -public Map makeEmptyMap() { -CompositeMap map = new CompositeMap(); -map.addComposited(new HashMap()); +public CompositeMapK, V makeObject() { +CompositeMapK, V map = new CompositeMapK, V(); +map.addComposited(new HashMapK, V()); map.setMutator( new EmptyMapMutator() ); return map; } -private Map buildOne() { -HashMap map = new HashMap(); -map.put(1, one); -map.put(2, two); +@SuppressWarnings(unchecked) +private MapK, V buildOne() { +HashMapK, V map = new HashMapK, V(); +map.put((K) 1, (V) one); +map.put((K) 2, (V) two); return map; } -public Map buildTwo() { -HashMap map = new HashMap(); -map.put(3, three); -map.put(4, four); +@SuppressWarnings(unchecked) +public MapK, V buildTwo() { +HashMapK, V map = new HashMapK, V(); +map.put((K) 3, (V) three); +map.put((K) 4, (V) four); return map; } public void testGet() { -CompositeMap map = new CompositeMap(buildOne(), buildTwo()); +CompositeMapK, V map = new CompositeMapK, V(buildOne(), buildTwo()); Assert.assertEquals(one, map.get(1)); Assert.assertEquals(four, map.get(4)); } +@SuppressWarnings(unchecked) public void testAddComposited() { -CompositeMap map = new CompositeMap(buildOne(), buildTwo()); -HashMap three = new HashMap(); -three.put(5, five); +CompositeMapK, V map = new CompositeMapK, V(buildOne(), buildTwo()); +HashMapK, V three = new HashMapK, V(); +three.put((K) 5, (V) five); map.addComposited(three); assertTrue(map.containsKey(5)); try { @@ -96,10 +99,11 @@ } } +@SuppressWarnings(unchecked) public void testRemoveComposited() { -CompositeMap map = new CompositeMap(buildOne(), buildTwo()); -HashMap three = new HashMap(); -three.put(5, five); +CompositeMapK, V map = new CompositeMapK, V(buildOne(), buildTwo()); +HashMapK, V three = new HashMapK, V(); +three.put((K) 5, (V) five); map.addComposited(three); assertTrue(map.containsKey(5)); @@ -111,10 +115,11 @@ } +@SuppressWarnings(unchecked) public void testRemoveFromUnderlying() { -CompositeMap map = new CompositeMap(buildOne(), buildTwo()); -HashMap three = new HashMap(); -three.put(5, five); +CompositeMapK, V map = new CompositeMapK, V(buildOne(), buildTwo()); +HashMapK, V three = new HashMapK, V(); +three.put((K) 5, (V) five); map.addComposited(three); assertTrue(map.containsKey(5)); @@ -123,10 +128,11 @@ assertFalse(map.containsKey(5)); } +@SuppressWarnings(unchecked) public void testRemoveFromComposited() { -CompositeMap map = new CompositeMap(buildOne(), buildTwo()); -HashMap three = new HashMap(); -three.put(5, five); +CompositeMapK, V map = new CompositeMapK, V(buildOne(), buildTwo()); +HashMapK, V three = new HashMapK, V(); +three.put((K) 5, (V) five); map.addComposited(three); assertTrue(map.containsKey(5
svn commit: r815127 - /commons/proper/collections/trunk/src/test/org/apache/commons/collections/map/TestFixedSizeMap.java
Author: bayard Date: Tue Sep 15 05:57:29 2009 New Revision: 815127 URL: http://svn.apache.org/viewvc?rev=815127view=rev Log: Merging from -r468106:814127 of collections_jdk5_branch - namely where this code was generified; mostly in r738956. Also see the following revisions: r740150 | mbenson | 2009-02-02 15:24:00 -0800 (Mon, 02 Feb 2009) | 1 line make all [collections] maps implement IterableMap Modified: commons/proper/collections/trunk/src/test/org/apache/commons/collections/map/TestFixedSizeMap.java Modified: commons/proper/collections/trunk/src/test/org/apache/commons/collections/map/TestFixedSizeMap.java URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/test/org/apache/commons/collections/map/TestFixedSizeMap.java?rev=815127r1=815126r2=815127view=diff == --- commons/proper/collections/trunk/src/test/org/apache/commons/collections/map/TestFixedSizeMap.java (original) +++ commons/proper/collections/trunk/src/test/org/apache/commons/collections/map/TestFixedSizeMap.java Tue Sep 15 05:57:29 2009 @@ -19,6 +19,8 @@ import java.util.HashMap; import java.util.Map; +import org.apache.commons.collections.IterableMap; + import junit.framework.Test; import junit.framework.TestSuite; @@ -31,7 +33,7 @@ * * @author Stephen Colebourne */ -public class TestFixedSizeMap extends AbstractTestMap { +public class TestFixedSizeMapK, V extends AbstractTestIterableMapK, V { public TestFixedSizeMap(String testName) { super(testName); @@ -46,16 +48,16 @@ junit.textui.TestRunner.main(testCaseName); } -public Map makeEmptyMap() { -return FixedSizeMap.decorate(new HashMap()); +public IterableMapK, V makeObject() { +return FixedSizeMap.decorate(new HashMapK, V()); } -public Map makeFullMap() { -Map map = new HashMap(); +public IterableMapK, V makeFullMap() { +MapK, V map = new HashMapK, V(); addSampleMappings(map); return FixedSizeMap.decorate(map); } - + public boolean isPutAddSupported() { return false; }
svn commit: r815128 - /commons/proper/collections/trunk/src/test/org/apache/commons/collections/map/TestLazyMap.java
Author: bayard Date: Tue Sep 15 05:57:30 2009 New Revision: 815128 URL: http://svn.apache.org/viewvc?rev=815128view=rev Log: Merging from -r468106:814127 of collections_jdk5_branch - namely where this code was generified; mostly in r738956. Also see the following revisions: r740150 | mbenson | 2009-02-02 15:24:00 -0800 (Mon, 02 Feb 2009) | 1 line make all [collections] maps implement IterableMap r572176 | skestle | 2007-09-02 15:04:41 -0700 (Sun, 02 Sep 2007) | 1 line Generified LazySortedMap to fix build errors r571381 | skestle | 2007-08-30 22:13:56 -0700 (Thu, 30 Aug 2007) | 1 line Generified LazyMap Modified: commons/proper/collections/trunk/src/test/org/apache/commons/collections/map/TestLazyMap.java Modified: commons/proper/collections/trunk/src/test/org/apache/commons/collections/map/TestLazyMap.java URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/test/org/apache/commons/collections/map/TestLazyMap.java?rev=815128r1=815127r2=815128view=diff == --- commons/proper/collections/trunk/src/test/org/apache/commons/collections/map/TestLazyMap.java (original) +++ commons/proper/collections/trunk/src/test/org/apache/commons/collections/map/TestLazyMap.java Tue Sep 15 05:57:30 2009 @@ -16,14 +16,15 @@ */ package org.apache.commons.collections.map; +import static org.apache.commons.collections.map.LazyMap.getLazyMap; + import java.util.HashMap; import java.util.Map; -import junit.framework.Test; -import junit.framework.TestSuite; - import org.apache.commons.collections.Factory; import org.apache.commons.collections.FactoryUtils; +import org.apache.commons.collections.Transformer; +import org.junit.Test; /** * Extension of {...@link AbstractTestMap} for exercising the @@ -34,56 +35,64 @@ * * @author Phil Steitz */ -public class TestLazyMap extends AbstractTestMap { - -protected static final Factory oneFactory = FactoryUtils.constantFactory(One); -protected static final Factory nullFactory = FactoryUtils.nullFactory(); - +public class TestLazyMapK, V extends AbstractTestIterableMapK, V { + +private static final FactoryInteger oneFactory = FactoryUtils.constantFactory(1); + public TestLazyMap(String testName) { super(testName); } - -public static Test suite() { -return new TestSuite(TestLazyMap.class); -} - + public static void main(String args[]) { String[] testCaseName = { TestLazyMap.class.getName()}; junit.textui.TestRunner.main(testCaseName); } -//--- -protected Map decorateMap(Map map, Factory factory) { -return LazyMap.decorate(map, factory); -} - -public Map makeEmptyMap() { -return decorateMap(new HashMap(), nullFactory); -} - -protected Map makeTestMap(Factory factory) { -return decorateMap(new HashMap(), factory); +@Override +public LazyMapK,V makeObject() { +return getLazyMap(new HashMapK,V(), FactoryUtils.VnullFactory()); } -//--- +//--- +@Override public void testMapGet() { -Map map = makeTestMap(oneFactory); +//TODO eliminate need for this via superclass - see svn history. +} + +@Test +public void mapGetWithFactory() { +MapInteger, Number map = getLazyMap(new HashMapInteger,Number(), oneFactory); assertEquals(0, map.size()); -String s1 = (String) map.get(Five); -assertEquals(One, s1); +Number i1 = map.get(Five); +assertEquals(1, i1); assertEquals(1, map.size()); -String s2 = (String) map.get(new String(new char[] {'F','i','v','e'})); -assertEquals(One, s2); +Number i2 = map.get(new String(new char[] {'F','i','v','e'})); +assertEquals(1, i2); assertEquals(1, map.size()); -assertSame(s1, s2); - -map = makeTestMap(nullFactory); +assertSame(i1, i2); + +map = getLazyMap(new HashMapInteger,Number(), FactoryUtils.LongnullFactory()); Object o = map.get(Five); assertEquals(null,o); assertEquals(1, map.size()); - } - + +@Test +public void mapGetWithTransformer() { +TransformerNumber, Integer intConverter = new TransformerNumber, Integer(){ +public Integer transform(Number input
svn commit: r815130 - /commons/proper/collections/trunk/src/test/org/apache/commons/collections/map/TestMultiValueMap.java
Author: bayard Date: Tue Sep 15 05:57:34 2009 New Revision: 815130 URL: http://svn.apache.org/viewvc?rev=815130view=rev Log: Merging from -r468106:814127 of collections_jdk5_branch - namely where this code was generified; mostly in r738956. Also see the following revisions: r468685 | scolebourne | 2006-10-28 05:30:27 -0700 (Sat, 28 Oct 2006) | 1 line COLLECTIONS-228 - MultiValueMap put and putAll do not return the correct values Modified: commons/proper/collections/trunk/src/test/org/apache/commons/collections/map/TestMultiValueMap.java Modified: commons/proper/collections/trunk/src/test/org/apache/commons/collections/map/TestMultiValueMap.java URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/test/org/apache/commons/collections/map/TestMultiValueMap.java?rev=815130r1=815129r2=815130view=diff == --- commons/proper/collections/trunk/src/test/org/apache/commons/collections/map/TestMultiValueMap.java (original) +++ commons/proper/collections/trunk/src/test/org/apache/commons/collections/map/TestMultiValueMap.java Tue Sep 15 05:57:34 2009 @@ -26,6 +26,7 @@ import java.util.Map; import junit.framework.Test; +import junit.framework.TestCase; import junit.framework.TestSuite; import org.apache.commons.collections.IteratorUtils; @@ -40,7 +41,7 @@ * @author Stephen Colebourne * @since Commons Collections 3.2 */ -public class TestMultiValueMap extends AbstractTestObject { +public class TestMultiValueMapK, V extends AbstractTestObject { public TestMultiValueMap(String testName) { super(testName); @@ -56,25 +57,28 @@ } public void testNoMappingReturnsNull() { -final MultiValueMap map = createTestMap(); +final MultiValueMapK, V map = createTestMap(); assertNull(map.get(whatever)); } +@SuppressWarnings(unchecked) public void testValueCollectionType() { -final MultiValueMap map = createTestMap(LinkedList.class); +final MultiValueMapK, V map = createTestMap(LinkedList.class); assertTrue(map.get(one) instanceof LinkedList); } +@SuppressWarnings(unchecked) public void testMultipleValues() { -final MultiValueMap map = createTestMap(HashSet.class); -final HashSet expected = new HashSet(); -expected.add(uno); -expected.add(un); +final MultiValueMapK, V map = createTestMap(HashSet.class); +final HashSetV expected = new HashSetV(); +expected.add((V) uno); +expected.add((V) un); assertEquals(expected, map.get(one)); } +@SuppressWarnings(unchecked) public void testContainsValue() { -final MultiValueMap map = createTestMap(HashSet.class); +final MultiValueMapK, V map = createTestMap(HashSet.class); assertTrue(map.containsValue(uno)); assertTrue(map.containsValue(un)); assertTrue(map.containsValue(dos)); @@ -84,56 +88,60 @@ assertFalse(map.containsValue(quatro)); } +@SuppressWarnings(unchecked) public void testKeyContainsValue() { -final MultiValueMap map = createTestMap(HashSet.class); -assertTrue(map.containsValue(one, uno)); -assertTrue(map.containsValue(one, un)); -assertTrue(map.containsValue(two, dos)); -assertTrue(map.containsValue(two, deux)); -assertTrue(map.containsValue(three, tres)); -assertTrue(map.containsValue(three, trois)); -assertFalse(map.containsValue(four, quatro)); +final MultiValueMapK, V map = createTestMap(HashSet.class); +assertTrue(map.containsValue((K) one, uno)); +assertTrue(map.containsValue((K) one, un)); +assertTrue(map.containsValue((K) two, dos)); +assertTrue(map.containsValue((K) two, deux)); +assertTrue(map.containsValue((K) three, tres)); +assertTrue(map.containsValue((K) three, trois)); +assertFalse(map.containsValue((K) four, quatro)); } +@SuppressWarnings(unchecked) public void testValues() { -final MultiValueMap map = createTestMap(HashSet.class); -final HashSet expected = new HashSet(); -expected.add(uno); -expected.add(dos); -expected.add(tres); -expected.add(un); -expected.add(deux); -expected.add(trois); -final Collection c = map.values(); +final MultiValueMapK, V map = createTestMap(HashSet.class); +final HashSetV expected = new HashSetV(); +expected.add((V) uno); +expected.add((V) dos); +expected.add((V) tres); +expected.add((V) un); +expected.add((V) deux); +expected.add((V) trois); +final CollectionObject c = map.values(); assertEquals(6
svn commit: r815134 - /commons/proper/collections/trunk/src/test/org/apache/commons/collections/MapPerformance.java
Author: bayard Date: Tue Sep 15 05:57:41 2009 New Revision: 815134 URL: http://svn.apache.org/viewvc?rev=815134view=rev Log: Merging from -r468106:814127 of collections_jdk5_branch - namely where this code was generified; mostly in r738956. Also see the following revisions: r471163 | scolebourne | 2006-11-04 02:56:39 -0800 (Sat, 04 Nov 2006) | 1 line Remove FastArrayList, FastHashMap, FastTreeMap r468687 | scolebourne | 2006-10-28 05:53:28 -0700 (Sat, 28 Oct 2006) | 1 line COLLECTIONS-229 - Remove deprecated classes and code Modified: commons/proper/collections/trunk/src/test/org/apache/commons/collections/MapPerformance.java Modified: commons/proper/collections/trunk/src/test/org/apache/commons/collections/MapPerformance.java URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/test/org/apache/commons/collections/MapPerformance.java?rev=815134r1=815133r2=815134view=diff == --- commons/proper/collections/trunk/src/test/org/apache/commons/collections/MapPerformance.java (original) +++ commons/proper/collections/trunk/src/test/org/apache/commons/collections/MapPerformance.java Tue Sep 15 05:57:41 2009 @@ -17,11 +17,11 @@ package org.apache.commons.collections; import java.util.Collection; -import java.util.Collections; +//import java.util.Collections; import java.util.HashMap; import java.util.Map; import java.util.Set; -import java.util.TreeMap; +//import java.util.TreeMap; import org.apache.commons.collections.map.Flat3Map; @@ -43,18 +43,17 @@ } private static void testAll() { -Map dummyMap = new DummyMap(); -Map hashMap = new HashMap(); +MapString, String dummyMap = new DummyMapString, String(); +MapString, String hashMap = new HashMapString, String(); //hashMap.put(Alpha, A); //hashMap.put(Beta, B); //hashMap.put(Gamma, C); //hashMap.put(Delta, D); -Map flatMap = new Flat3Map(hashMap); +MapString, String flatMap = new Flat3MapString, String(hashMap); System.out.println(flatMap); -Map unmodHashMap = Collections.unmodifiableMap(new HashMap(hashMap)); -Map fastHashMap = new FastHashMap(hashMap); -Map treeMap = new TreeMap(hashMap); -Map seqMap = new SequencedHashMap(hashMap); +//MapString, String unmodHashMap = Collections.unmodifiableMap(new HashMapString, String(hashMap)); +//Map fastHashMap = new FastHashMap(hashMap); +//MapString, String treeMap = new TreeMapString, String(hashMap); //Map linkedMap = new LinkedHashMap(hashMap); //Map syncMap = Collections.unmodifiableMap(new HashMap(hashMap)); //Map bucketMap = new StaticBucketMap(); @@ -110,9 +109,9 @@ //test(doubleMap, DoubleMap ); } -private static void test(Map map, String name) { +private static void test(MapString, String map, String name) { long start = 0, end = 0; -int total = 0; +//int total = 0; start = System.currentTimeMillis(); for (int i = RUNS; i 0; i--) { //if (map.get(Alpha) != null) total++; @@ -134,7 +133,7 @@ // -- -private static class DummyMap implements Map { +private static class DummyMapK, V implements MapK, V { public void clear() { } public boolean containsKey(Object key) { @@ -143,30 +142,30 @@ public boolean containsValue(Object value) { return false; } -public Set entrySet() { +public SetMap.EntryK, V entrySet() { return null; } -public Object get(Object key) { +public V get(Object key) { return null; } public boolean isEmpty() { return false; } -public Set keySet() { +public SetK keySet() { return null; } -public Object put(Object key, Object value) { +public V put(K key, V value) { return null; } -public void putAll(Map t) { +public void putAll(Map? extends K, ? extends V t) { } -public Object remove(Object key) { +public V remove(Object key) { return null; } public int size() { return 0; } -public Collection values() { +public CollectionV values() { return null; } }
svn commit: r815135 - /commons/proper/collections/trunk/src/test/org/apache/commons/collections/MockTestCase.java
Author: bayard Date: Tue Sep 15 05:57:42 2009 New Revision: 815135 URL: http://svn.apache.org/viewvc?rev=815135view=rev Log: Merging from -r468106:814127 of collections_jdk5_branch - namely where this code was generified; mostly in r738956. Also see the following revisions: r593144 | skestle | 2007-11-08 04:21:55 -0800 (Thu, 08 Nov 2007) | 3 lines Updated CollectionUtils and test. Probably 80-90% complete for generics. Very open to review / patches. Jira: COLLECTIONS-245 Added: commons/proper/collections/trunk/src/test/org/apache/commons/collections/MockTestCase.java - copied unchanged from r814127, commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/MockTestCase.java
svn commit: r815136 - /commons/proper/collections/trunk/src/test/org/apache/commons/collections/set/TestAll.java
Author: bayard Date: Tue Sep 15 05:57:43 2009 New Revision: 815136 URL: http://svn.apache.org/viewvc?rev=815136view=rev Log: Merging from -r468106:814127 of collections_jdk5_branch - namely where this code was generified; mostly in r738956. Also see the following revisions: r471166 | scolebourne | 2006-11-04 03:33:22 -0800 (Sat, 04 Nov 2006) | 1 line Removed Typed* containers such as TypedList and TypedMap as generics now provides type safety Modified: commons/proper/collections/trunk/src/test/org/apache/commons/collections/set/TestAll.java Modified: commons/proper/collections/trunk/src/test/org/apache/commons/collections/set/TestAll.java URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/test/org/apache/commons/collections/set/TestAll.java?rev=815136r1=815135r2=815136view=diff == --- commons/proper/collections/trunk/src/test/org/apache/commons/collections/set/TestAll.java (original) +++ commons/proper/collections/trunk/src/test/org/apache/commons/collections/set/TestAll.java Tue Sep 15 05:57:43 2009 @@ -53,8 +53,6 @@ suite.addTest(TestSynchronizedSortedSet.suite()); suite.addTest(TestTransformedSet.suite()); suite.addTest(TestTransformedSortedSet.suite()); -suite.addTest(TestTypedSet.suite()); -suite.addTest(TestTypedSortedSet.suite()); suite.addTest(TestUnmodifiableSet.suite()); suite.addTest(TestUnmodifiableSortedSet.suite());
svn commit: r815137 - /commons/proper/collections/trunk/src/test/org/apache/commons/collections/set/TestCompositeSet.java
Author: bayard Date: Tue Sep 15 05:57:45 2009 New Revision: 815137 URL: http://svn.apache.org/viewvc?rev=815137view=rev Log: Merging from -r468106:814127 of collections_jdk5_branch - namely where this code was generified; mostly in r738956. Also see the following revisions: r471580 | scolebourne | 2006-11-05 16:22:53 -0800 (Sun, 05 Nov 2006) | 1 line Generify CompositeCollection Modified: commons/proper/collections/trunk/src/test/org/apache/commons/collections/set/TestCompositeSet.java Modified: commons/proper/collections/trunk/src/test/org/apache/commons/collections/set/TestCompositeSet.java URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/test/org/apache/commons/collections/set/TestCompositeSet.java?rev=815137r1=815136r2=815137view=diff == --- commons/proper/collections/trunk/src/test/org/apache/commons/collections/set/TestCompositeSet.java (original) +++ commons/proper/collections/trunk/src/test/org/apache/commons/collections/set/TestCompositeSet.java Tue Sep 15 05:57:45 2009 @@ -16,17 +16,18 @@ */ package org.apache.commons.collections.set; +import java.util.Collection; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + import junit.framework.Test; import junit.framework.TestSuite; import org.apache.commons.collections.collection.CompositeCollection; -import java.util.Set; -import java.util.HashSet; -import java.util.Collection; - /** - * Extension of {...@link AbstractTestSet} for exercising the + * Extension of {...@link AbstractTestSet} for exercising the * {...@link CompositeSet} implementation. * * @since Commons Collections 3.0 @@ -36,90 +37,97 @@ * @author Phil Steitz */ -public class TestCompositeSet extends AbstractTestSet { +public class TestCompositeSetE extends AbstractTestSetE { public TestCompositeSet(String name) { super(name); } - + public static Test suite() { return new TestSuite(TestCompositeSet.class); } - -public Set makeEmptySet() { -final HashSet contained = new HashSet(); -CompositeSet set = new CompositeSet(contained); + +public CompositeSetE makeObject() { +final HashSetE contained = new HashSetE(); +CompositeSetE set = new CompositeSetE(contained); set.setMutator( new EmptySetMutator(contained) ); return set; } - -public Set buildOne() { -HashSet set = new HashSet(); -set.add(1); -set.add(2); + +@SuppressWarnings(unchecked) +public SetE buildOne() { +HashSetE set = new HashSetE(); +set.add((E) 1); +set.add((E) 2); return set; } - -public Set buildTwo() { -HashSet set = new HashSet(); -set.add(3); -set.add(4); + +@SuppressWarnings(unchecked) +public SetE buildTwo() { +HashSetE set = new HashSetE(); +set.add((E) 3); +set.add((E) 4); return set; } - + +@SuppressWarnings(unchecked) public void testContains() { -CompositeSet set = new CompositeSet(new Set[]{buildOne(), buildTwo()}); +CompositeSetE set = new CompositeSetE(new Set[]{ buildOne(), buildTwo() }); assertTrue(set.contains(1)); } - + +@SuppressWarnings(unchecked) public void testRemoveUnderlying() { -Set one = buildOne(); -Set two = buildTwo(); -CompositeSet set = new CompositeSet(new Set[]{one, two}); +SetE one = buildOne(); +SetE two = buildTwo(); +CompositeSetE set = new CompositeSetE(new Set[] { one, two }); one.remove(1); assertFalse(set.contains(1)); - + two.remove(3); assertFalse(set.contains(3)); } - + +@SuppressWarnings(unchecked) public void testRemoveComposited() { -Set one = buildOne(); -Set two = buildTwo(); -CompositeSet set = new CompositeSet(new Set[]{one, two}); +SetE one = buildOne(); +SetE two = buildTwo(); +CompositeSetE set = new CompositeSetE(new Set[] { one, two }); set.remove(1); assertFalse(one.contains(1)); - + set.remove(3); assertFalse(one.contains(3)); } - + +@SuppressWarnings(unchecked) public void testFailedCollisionResolution() { -Set one = buildOne(); -Set two = buildTwo(); -CompositeSet set = new CompositeSet(new Set[]{one, two}); -set.setMutator(new CompositeSet.SetMutator() { -public void resolveCollision(CompositeSet comp, Set existing, -Set added, Collection intersects) { +SetE one = buildOne(); +SetE two = buildTwo(); +CompositeSetE set
svn commit: r815143 - /commons/proper/collections/trunk/src/test/org/apache/commons/collections/TestAllPackages.java
Author: bayard Date: Tue Sep 15 05:57:56 2009 New Revision: 815143 URL: http://svn.apache.org/viewvc?rev=815143view=rev Log: Merging from -r468106:814127 of collections_jdk5_branch - namely where this code was generified; mostly in r738956. Also see the following revisions: r751894 | mbenson | 2009-03-09 15:48:07 -0700 (Mon, 09 Mar 2009) | 1 line add splitmap package whose original goal is to provide a more versatile TransformedMap implementation r643795 | skestle | 2008-04-02 01:49:57 -0700 (Wed, 02 Apr 2008) | 5 lines Generified EqualPredicate and created individual test class moved from TestPredicateUtils Added assertFalse() and assertTrue to BasicPredicateTestBase with (Predicate, Object) parameters Issues: COLLECTIONS-243, COLLECTIONS-253, COLLECTIONS-293 r572157 | skestle | 2007-09-02 14:12:28 -0700 (Sun, 02 Sep 2007) | 1 line Cleaned imports, formatting r570395 | skestle | 2007-08-28 05:08:29 -0700 (Tue, 28 Aug 2007) | 1 line Generified InstantiateFactory (missed -another;sorry- commit file!) Modified: commons/proper/collections/trunk/src/test/org/apache/commons/collections/TestAllPackages.java Modified: commons/proper/collections/trunk/src/test/org/apache/commons/collections/TestAllPackages.java URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/test/org/apache/commons/collections/TestAllPackages.java?rev=815143r1=815142r2=815143view=diff == --- commons/proper/collections/trunk/src/test/org/apache/commons/collections/TestAllPackages.java (original) +++ commons/proper/collections/trunk/src/test/org/apache/commons/collections/TestAllPackages.java Tue Sep 15 05:57:56 2009 @@ -16,9 +16,9 @@ */ package org.apache.commons.collections; -import junit.framework.Test; -import junit.framework.TestCase; -import junit.framework.TestSuite; +import org.junit.runner.RunWith; +import org.junit.runners.Suite; +import org.junit.runners.Suite.SuiteClasses; /** * Entry point for all Collections project tests. @@ -26,31 +26,23 @@ * @version $Revision$ $Date$ * * @author Stephen Colebourne + * @author Stephen Kestle */ -public class TestAllPackages extends TestCase { -public TestAllPackages(String testName) { -super(testName); -} - -public static Test suite() { -TestSuite suite = new TestSuite(); -suite.addTest(org.apache.commons.collections.TestAll.suite()); -suite.addTest(org.apache.commons.collections.bag.TestAll.suite()); -suite.addTest(org.apache.commons.collections.bidimap.TestAll.suite()); -suite.addTest(org.apache.commons.collections.buffer.TestAll.suite()); - suite.addTest(org.apache.commons.collections.collection.TestAll.suite()); - suite.addTest(org.apache.commons.collections.comparators.TestAll.suite()); - suite.addTest(org.apache.commons.collections.iterators.TestAll.suite()); -suite.addTest(org.apache.commons.collections.keyvalue.TestAll.suite()); -suite.addTest(org.apache.commons.collections.list.TestAll.suite()); -suite.addTest(org.apache.commons.collections.map.TestAll.suite()); -suite.addTest(org.apache.commons.collections.set.TestAll.suite()); -return suite; -} - -public static void main(String args[]) { -String[] testCaseName = { TestAllPackages.class.getName() }; -junit.textui.TestRunner.main(testCaseName); -} - +...@runwith(Suite.class) +...@suiteclasses({ +org.apache.commons.collections.TestAll.class, +org.apache.commons.collections.bag.TestAll.class, +org.apache.commons.collections.bidimap.TestAll.class, +org.apache.commons.collections.buffer.TestAll.class, +org.apache.commons.collections.collection.TestAll.class, +org.apache.commons.collections.comparators.TestAll.class, +org.apache.commons.collections.functors.TestAll.class, +org.apache.commons.collections.iterators.TestAll.class, +org.apache.commons.collections.keyvalue.TestAll.class, +org.apache.commons.collections.list.TestAll.class, +org.apache.commons.collections.map.TestAll.class, +org.apache.commons.collections.set.TestAll.class, +org.apache.commons.collections.splitmap.TestAll.class +}) +public class TestAllPackages { }
svn commit: r815150 - /commons/proper/collections/trunk/src/test/org/apache/commons/collections/TestIteratorUtils.java
Author: bayard Date: Tue Sep 15 05:58:07 2009 New Revision: 815150 URL: http://svn.apache.org/viewvc?rev=815150view=rev Log: Merging from -r468106:814127 of collections_jdk5_branch - namely where this code was generified; mostly in r738956. Also see the following revisions: r753392 | mbenson | 2009-03-13 13:39:53 -0700 (Fri, 13 Mar 2009) | 1 line revert IteratorUtils stuff; toList() works fine for this--duh r751850 | mbenson | 2009-03-09 14:34:44 -0700 (Mon, 09 Mar 2009) | 1 line add iterable(Iterator) Modified: commons/proper/collections/trunk/src/test/org/apache/commons/collections/TestIteratorUtils.java Modified: commons/proper/collections/trunk/src/test/org/apache/commons/collections/TestIteratorUtils.java URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/test/org/apache/commons/collections/TestIteratorUtils.java?rev=815150r1=815149r2=815150view=diff == --- commons/proper/collections/trunk/src/test/org/apache/commons/collections/TestIteratorUtils.java (original) +++ commons/proper/collections/trunk/src/test/org/apache/commons/collections/TestIteratorUtils.java Tue Sep 15 05:58:07 2009 @@ -53,16 +53,16 @@ } public void testToList() { -List list = new ArrayList(); +ListObject list = new ArrayListObject(); list.add(new Integer(1)); list.add(Two); list.add(null); -List result = IteratorUtils.toList(list.iterator()); +ListObject result = IteratorUtils.toList(list.iterator()); assertEquals(list, result); } public void testToArray() { -List list = new ArrayList(); +ListObject list = new ArrayListObject(); list.add(new Integer(1)); list.add(Two); list.add(null); @@ -71,137 +71,137 @@ } public void testToArray2() { -List list = new ArrayList(); +ListString list = new ArrayListString(); list.add(One); list.add(Two); list.add(null); String[] result = (String[]) IteratorUtils.toArray(list.iterator(), String.class); assertEquals(list, Arrays.asList(result)); } - + public void testArrayIterator() { Object[] objArray = {a, b, c}; -ResettableIterator iterator = IteratorUtils.arrayIterator(objArray); +ResettableIteratorObject iterator = IteratorUtils.arrayIterator(objArray); assertTrue(iterator.next().equals(a)); assertTrue(iterator.next().equals(b)); iterator.reset(); assertTrue(iterator.next().equals(a)); - + try { iterator = IteratorUtils.arrayIterator(new Integer(0)); fail(Expecting IllegalArgumentException); } catch (IllegalArgumentException ex) { // expected } - + try { iterator = IteratorUtils.arrayIterator(null); fail(Expecting NullPointerException); } catch (NullPointerException ex) { // expected } - + iterator = IteratorUtils.arrayIterator(objArray, 1); assertTrue(iterator.next().equals(b)); - + try { iterator = IteratorUtils.arrayIterator(objArray, -1); fail(Expecting IndexOutOfBoundsException); } catch (IndexOutOfBoundsException ex) { // expected } - + iterator = IteratorUtils.arrayIterator(objArray, 3); assertTrue(!iterator.hasNext()); iterator.reset(); - + try { iterator = IteratorUtils.arrayIterator(objArray, 4); fail(Expecting IndexOutOfBoundsException); } catch (IndexOutOfBoundsException ex) { // expected } - + iterator = IteratorUtils.arrayIterator(objArray, 2, 3); assertTrue(iterator.next().equals(c)); - + try { iterator = IteratorUtils.arrayIterator(objArray, 2, 4); fail(Expecting IndexOutOfBoundsException); } catch (IndexOutOfBoundsException ex) { // expected } - + try { iterator = IteratorUtils.arrayIterator(objArray, -1, 1); fail(Expecting IndexOutOfBoundsException); } catch (IndexOutOfBoundsException ex) { // expected } - + try { iterator = IteratorUtils.arrayIterator(objArray, 2, 1); fail(Expecting IllegalArgumentException); } catch (IllegalArgumentException ex) { // expected } - + int[] intArray = {0, 1, 2}; iterator
svn commit: r814127 [5/5] - in /commons/proper/collections/branches/collections_jdk5_branch/src: java/org/apache/commons/collections/ java/org/apache/commons/collections/bag/ java/org/apache/commons/c
Modified: commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/buffer/TestTransformedBuffer.java URL: http://svn.apache.org/viewvc/commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/buffer/TestTransformedBuffer.java?rev=814127r1=814126r2=814127view=diff == --- commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/buffer/TestTransformedBuffer.java (original) +++ commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/buffer/TestTransformedBuffer.java Sat Sep 12 09:45:33 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. @@ -30,7 +30,7 @@ * * @since Commons Collections 3.0 * @version $Revision$ $Date$ - * + * * @author Stephen Colebourne */ public class TestTransformedBuffer extends TestCase { Modified: commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/buffer/TestUnboundedFifoBuffer.java URL: http://svn.apache.org/viewvc/commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/buffer/TestUnboundedFifoBuffer.java?rev=814127r1=814126r2=814127view=diff == --- commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/buffer/TestUnboundedFifoBuffer.java (original) +++ commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/buffer/TestUnboundedFifoBuffer.java Sat Sep 12 09:45:33 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. @@ -28,9 +28,9 @@ /** * Test cases for UnboundedFifoBuffer. - * + * * @version $Revision$ $Date$ - * + * * @author Unknown */ public class TestUnboundedFifoBufferE extends AbstractTestCollectionE { Modified: commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/collection/TestAll.java URL: http://svn.apache.org/viewvc/commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/collection/TestAll.java?rev=814127r1=814126r2=814127view=diff == --- commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/collection/TestAll.java (original) +++ commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/collection/TestAll.java Sat Sep 12 09:45:33 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,10 +22,10 @@ /** * Entry point for tests. - * + * * @since Commons Collections 3.0 * @version $Revision$ $Date$ - * + * * @author Stephen Colebourne */ public class TestAll extends TestCase { Modified: commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/collection/TestTransformedCollection.java URL: http://svn.apache.org/viewvc/commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/collection/TestTransformedCollection.java?rev=814127r1=814126r2=814127view=diff == --- commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/collection/TestTransformedCollection.java (original) +++
svn commit: r814128 [5/5] - in /commons/proper/collections/trunk/src: java/org/apache/commons/collections/ java/org/apache/commons/collections/bag/ java/org/apache/commons/collections/bidimap/ java/or
Modified: commons/proper/collections/trunk/src/test/org/apache/commons/collections/map/AbstractTestMap.java URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/test/org/apache/commons/collections/map/AbstractTestMap.java?rev=814128r1=814127r2=814128view=diff == --- commons/proper/collections/trunk/src/test/org/apache/commons/collections/map/AbstractTestMap.java (original) +++ commons/proper/collections/trunk/src/test/org/apache/commons/collections/map/AbstractTestMap.java Sat Sep 12 09:46:44 2009 @@ -45,7 +45,7 @@ * bEntry Population Methods/b * p * Override these methods if your map requires special entries: - * + * * ul * li{...@link #getSampleKeys()} * li{...@link #getSampleValues()} Modified: commons/proper/collections/trunk/src/test/org/apache/commons/collections/map/AbstractTestOrderedMap.java URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/test/org/apache/commons/collections/map/AbstractTestOrderedMap.java?rev=814128r1=814127r2=814128view=diff == --- commons/proper/collections/trunk/src/test/org/apache/commons/collections/map/AbstractTestOrderedMap.java (original) +++ commons/proper/collections/trunk/src/test/org/apache/commons/collections/map/AbstractTestOrderedMap.java Sat Sep 12 09:46:44 2009 @@ -35,7 +35,7 @@ * Abstract test class for {...@link OrderedMap} methods and contracts. * * @version $Revision$ $Date$ - * + * * @author Stephen Colebourne */ public abstract class AbstractTestOrderedMap extends AbstractTestIterableMap { Modified: commons/proper/collections/trunk/src/test/org/apache/commons/collections/map/AbstractTestSortedMap.java URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/test/org/apache/commons/collections/map/AbstractTestSortedMap.java?rev=814128r1=814127r2=814128view=diff == --- commons/proper/collections/trunk/src/test/org/apache/commons/collections/map/AbstractTestSortedMap.java (original) +++ commons/proper/collections/trunk/src/test/org/apache/commons/collections/map/AbstractTestSortedMap.java Sat Sep 12 09:46:44 2009 @@ -30,7 +30,7 @@ * Abstract test class for {...@link java.util.SortedMap} methods and contracts. * * @version $Revision$ $Date$ - * + * * @author Stephen Colebourne */ public abstract class AbstractTestSortedMap extends AbstractTestMap { Modified: commons/proper/collections/trunk/src/test/org/apache/commons/collections/map/TestAll.java URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/test/org/apache/commons/collections/map/TestAll.java?rev=814128r1=814127r2=814128view=diff == --- commons/proper/collections/trunk/src/test/org/apache/commons/collections/map/TestAll.java (original) +++ commons/proper/collections/trunk/src/test/org/apache/commons/collections/map/TestAll.java Sat Sep 12 09:46:44 2009 @@ -22,10 +22,10 @@ /** * Entry point for tests. - * + * * @since Commons Collections 3.0 * @version $Revision$ $Date$ - * + * * @author Stephen Colebourne */ public class TestAll extends TestCase { Modified: commons/proper/collections/trunk/src/test/org/apache/commons/collections/map/TestCaseInsensitiveMap.java URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/test/org/apache/commons/collections/map/TestCaseInsensitiveMap.java?rev=814128r1=814127r2=814128view=diff == --- commons/proper/collections/trunk/src/test/org/apache/commons/collections/map/TestCaseInsensitiveMap.java (original) +++ commons/proper/collections/trunk/src/test/org/apache/commons/collections/map/TestCaseInsensitiveMap.java Sat Sep 12 09:46:44 2009 @@ -28,9 +28,9 @@ /** * Tests for the {...@link CaseInsensitiveMap} implementation. - * + * * @version $Revision$ $Date$ - * + * * @author Commons-Collections team */ public class TestCaseInsensitiveMap extends AbstractTestIterableMap { Modified: commons/proper/collections/trunk/src/test/org/apache/commons/collections/map/TestDefaultedMap.java URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/test/org/apache/commons/collections/map/TestDefaultedMap.java?rev=814128r1=814127r2=814128view=diff == --- commons/proper/collections/trunk/src/test/org/apache/commons/collections/map/TestDefaultedMap.java (original) +++ commons/proper/collections/trunk/src/test/org/apache/commons/collections/map/TestDefaultedMap.java Sat Sep 12 09:46:44 2009 @@ -33,7 +33,7 @@ * * @since Commons Collections 3.2 * @version $Revision: 155406 $ $Date$ - * + * * @author Stephen Colebourne */
svn commit: r814212 - /commons/proper/collections/branches/collections_jdk5_branch/NOTICE.txt
Author: bayard Date: Sat Sep 12 17:44:46 2009 New Revision: 814212 URL: http://svn.apache.org/viewvc?rev=814212view=rev Log: Updating NOTICE to match trunk Modified: commons/proper/collections/branches/collections_jdk5_branch/NOTICE.txt Modified: commons/proper/collections/branches/collections_jdk5_branch/NOTICE.txt URL: http://svn.apache.org/viewvc/commons/proper/collections/branches/collections_jdk5_branch/NOTICE.txt?rev=814212r1=814211r2=814212view=diff == --- commons/proper/collections/branches/collections_jdk5_branch/NOTICE.txt (original) +++ commons/proper/collections/branches/collections_jdk5_branch/NOTICE.txt Sat Sep 12 17:44:46 2009 @@ -1,4 +1,4 @@ -Apache Jakarta Commons Collections +Apache Commons Collections Copyright 2001-2009 The Apache Software Foundation This product includes software developed by
svn commit: r812235 - in /commons/proper/lang/trunk/src: java/org/apache/commons/lang/mutable/ test/org/apache/commons/lang/mutable/
Author: bayard Date: Mon Sep 7 17:52:53 2009 New Revision: 812235 URL: http://svn.apache.org/viewvc?rev=812235view=rev Log: Applying Ivan Bilenjkij's patch such that the Mutable classes implement an appropriately typed Mutable interface. LANG-528 Modified: commons/proper/lang/trunk/src/java/org/apache/commons/lang/mutable/MutableBoolean.java commons/proper/lang/trunk/src/java/org/apache/commons/lang/mutable/MutableByte.java commons/proper/lang/trunk/src/java/org/apache/commons/lang/mutable/MutableDouble.java commons/proper/lang/trunk/src/java/org/apache/commons/lang/mutable/MutableFloat.java commons/proper/lang/trunk/src/java/org/apache/commons/lang/mutable/MutableInt.java commons/proper/lang/trunk/src/java/org/apache/commons/lang/mutable/MutableLong.java commons/proper/lang/trunk/src/java/org/apache/commons/lang/mutable/MutableShort.java commons/proper/lang/trunk/src/test/org/apache/commons/lang/mutable/MutableBooleanTest.java commons/proper/lang/trunk/src/test/org/apache/commons/lang/mutable/MutableByteTest.java commons/proper/lang/trunk/src/test/org/apache/commons/lang/mutable/MutableDoubleTest.java commons/proper/lang/trunk/src/test/org/apache/commons/lang/mutable/MutableFloatTest.java commons/proper/lang/trunk/src/test/org/apache/commons/lang/mutable/MutableIntTest.java commons/proper/lang/trunk/src/test/org/apache/commons/lang/mutable/MutableLongTest.java commons/proper/lang/trunk/src/test/org/apache/commons/lang/mutable/MutableObjectTest.java commons/proper/lang/trunk/src/test/org/apache/commons/lang/mutable/MutableShortTest.java Modified: commons/proper/lang/trunk/src/java/org/apache/commons/lang/mutable/MutableBoolean.java URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/java/org/apache/commons/lang/mutable/MutableBoolean.java?rev=812235r1=812234r2=812235view=diff == --- commons/proper/lang/trunk/src/java/org/apache/commons/lang/mutable/MutableBoolean.java (original) +++ commons/proper/lang/trunk/src/java/org/apache/commons/lang/mutable/MutableBoolean.java Mon Sep 7 17:52:53 2009 @@ -27,7 +27,7 @@ * @author Apache Software Foundation * @version $Id$ */ -public class MutableBoolean implements Mutable, Serializable, ComparableMutableBoolean { +public class MutableBoolean implements MutableBoolean, Serializable, ComparableMutableBoolean { /** * Required for serialization support. @@ -88,8 +88,6 @@ * @return zero if this object represents the same boolean value as the argument; a positive value if this object * represents true and the argument represents false; and a negative value if this object represents false * and the argument represents true - * @throws ClassCastException - * if the argument is not a MutableInt */ public int compareTo(MutableBoolean other) { boolean anotherVal = other.value; @@ -120,7 +118,7 @@ * * @return the value as a Boolean */ -public Object getValue() { +public Boolean getValue() { return Boolean.valueOf(this.value); } @@ -152,11 +150,9 @@ *the value to set * @throws NullPointerException * if the object is null - * @throws ClassCastException - * if the type is not a {...@link Boolean} */ -public void setValue(Object value) { -setValue(((Boolean) value).booleanValue()); +public void setValue(Boolean value) { +this.value = value.booleanValue(); } /** Modified: commons/proper/lang/trunk/src/java/org/apache/commons/lang/mutable/MutableByte.java URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/java/org/apache/commons/lang/mutable/MutableByte.java?rev=812235r1=812234r2=812235view=diff == --- commons/proper/lang/trunk/src/java/org/apache/commons/lang/mutable/MutableByte.java (original) +++ commons/proper/lang/trunk/src/java/org/apache/commons/lang/mutable/MutableByte.java Mon Sep 7 17:52:53 2009 @@ -23,7 +23,7 @@ * @since 2.1 * @version $Id$ */ -public class MutableByte extends Number implements ComparableMutableByte, Mutable { +public class MutableByte extends Number implements ComparableMutableByte, MutableNumber { /** * Required for serialization support. @@ -72,7 +72,7 @@ * * @return the value as a Byte */ -public Object getValue() { +public Byte getValue() { return Byte.valueOf(this.value); } @@ -93,11 +93,9 @@ *the value to set * @throws NullPointerException * if the object is null - * @throws ClassCastException - * if the type is not a {...@link Number} */ -public void setValue(Object value) { -setValue(((Number) value
svn commit: r812236 - in /commons/proper/lang/trunk/src/java/org/apache/commons/lang/math: DoubleRange.java FloatRange.java IntRange.java LongRange.java NumberRange.java
Author: bayard Date: Mon Sep 7 17:56:30 2009 New Revision: 812236 URL: http://svn.apache.org/viewvc?rev=812236view=rev Log: Applying Boris' patch in LANG-481 to improve thread safety in the Range classes. The previous code's reuse of the hashCode variable for local operations means it is utterly non-thread-safe. Now uses a local variable so that the worst case should be the hashCode being calculated multiple times, but not ending up with different values. Modified: commons/proper/lang/trunk/src/java/org/apache/commons/lang/math/DoubleRange.java commons/proper/lang/trunk/src/java/org/apache/commons/lang/math/FloatRange.java commons/proper/lang/trunk/src/java/org/apache/commons/lang/math/IntRange.java commons/proper/lang/trunk/src/java/org/apache/commons/lang/math/LongRange.java commons/proper/lang/trunk/src/java/org/apache/commons/lang/math/NumberRange.java Modified: commons/proper/lang/trunk/src/java/org/apache/commons/lang/math/DoubleRange.java URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/java/org/apache/commons/lang/math/DoubleRange.java?rev=812236r1=812235r2=812236view=diff == --- commons/proper/lang/trunk/src/java/org/apache/commons/lang/math/DoubleRange.java (original) +++ commons/proper/lang/trunk/src/java/org/apache/commons/lang/math/DoubleRange.java Mon Sep 7 17:56:30 2009 @@ -398,13 +398,15 @@ */ @Override public int hashCode() { -if (hashCode == 0) { -hashCode = 17; -hashCode = 37 * hashCode + getClass().hashCode(); +int temp = hashCode; +if (temp == 0) { +temp = 17; +temp = 37 * temp + getClass().hashCode(); long lng = Double.doubleToLongBits(min); -hashCode = 37 * hashCode + ((int) (lng ^ (lng 32))); +temp = 37 * temp + ((int) (lng ^ (lng 32))); lng = Double.doubleToLongBits(max); -hashCode = 37 * hashCode + ((int) (lng ^ (lng 32))); +temp = 37 * temp + ((int) (lng ^ (lng 32))); +hashCode = temp; } return hashCode; } Modified: commons/proper/lang/trunk/src/java/org/apache/commons/lang/math/FloatRange.java URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/java/org/apache/commons/lang/math/FloatRange.java?rev=812236r1=812235r2=812236view=diff == --- commons/proper/lang/trunk/src/java/org/apache/commons/lang/math/FloatRange.java (original) +++ commons/proper/lang/trunk/src/java/org/apache/commons/lang/math/FloatRange.java Mon Sep 7 17:56:30 2009 @@ -394,11 +394,13 @@ */ @Override public int hashCode() { -if (hashCode == 0) { -hashCode = 17; -hashCode = 37 * hashCode + getClass().hashCode(); -hashCode = 37 * hashCode + Float.floatToIntBits(min); -hashCode = 37 * hashCode + Float.floatToIntBits(max); +int temp = hashCode; +if (temp == 0) { +temp = 17; +temp = 37 * temp + getClass().hashCode(); +temp = 37 * temp + Float.floatToIntBits(min); +temp = 37 * temp + Float.floatToIntBits(max); +hashCode = temp; } return hashCode; } Modified: commons/proper/lang/trunk/src/java/org/apache/commons/lang/math/IntRange.java URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/java/org/apache/commons/lang/math/IntRange.java?rev=812236r1=812235r2=812236view=diff == --- commons/proper/lang/trunk/src/java/org/apache/commons/lang/math/IntRange.java (original) +++ commons/proper/lang/trunk/src/java/org/apache/commons/lang/math/IntRange.java Mon Sep 7 17:56:30 2009 @@ -368,11 +368,13 @@ */ @Override public int hashCode() { -if (hashCode == 0) { -hashCode = 17; -hashCode = 37 * hashCode + getClass().hashCode(); -hashCode = 37 * hashCode + min; -hashCode = 37 * hashCode + max; +int temp = hashCode; +if (temp == 0) { +temp = 17; +temp = 37 * temp + getClass().hashCode(); +temp = 37 * temp + min; +temp = 37 * temp + max; +hashCode = temp; } return hashCode; } Modified: commons/proper/lang/trunk/src/java/org/apache/commons/lang/math/LongRange.java URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/java/org/apache/commons/lang/math/LongRange.java?rev=812236r1=812235r2=812236view=diff == --- commons/proper/lang/trunk/src/java/org/apache/commons/lang/math/LongRange.java (original) +++ commons/proper/lang/trunk/src/java/org/apache/commons/lang/math/LongRange.java Mon Sep 7 17
svn commit: r811944 - in /commons/proper/lang/trunk/src/java/org/apache/commons/lang: Validate.java text/StrBuilder.java
Author: bayard Date: Sun Sep 6 22:56:09 2009 New Revision: 811944 URL: http://svn.apache.org/viewvc?rev=811944view=rev Log: Applying Stefan Zeller's performance improvement to StrBuilder (LANG-523) by doubling the size of the String in ensureCapacity. Tests indicate a hundredhold improvement in appending speed, which seems worth the doubling of data size. Modified: commons/proper/lang/trunk/src/java/org/apache/commons/lang/Validate.java commons/proper/lang/trunk/src/java/org/apache/commons/lang/text/StrBuilder.java Modified: commons/proper/lang/trunk/src/java/org/apache/commons/lang/Validate.java URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/java/org/apache/commons/lang/Validate.java?rev=811944r1=811943r2=811944view=diff == --- commons/proper/lang/trunk/src/java/org/apache/commons/lang/Validate.java (original) +++ commons/proper/lang/trunk/src/java/org/apache/commons/lang/Validate.java Sun Sep 6 22:56:09 2009 @@ -16,6 +16,7 @@ */ package org.apache.commons.lang; +import java.text.MessageFormat; import java.util.Collection; import java.util.Iterator; import java.util.Map; @@ -31,10 +32,74 @@ * Validate.notNull( surname, The surname must not be null); * /pre * + * All validate functions exist in 4 variants: + * + * p1st function with only the validation option/p + * pre + * Validate.isNotNull(surName); + * /pre + * + * p2nd function with an additional String message parameter. This should + * be used only if no additional parameters have to be provided. Instead of using + * String operations to create the message String, the following 3rd variant + * should be used./p + * pre + * Validate.isNotNull(surName, surname must be set); + * /pre + * + * pSince commons-lang-3.0, for each validation function a similar 3rd validation function exists + * with a list of additional message parameters as Objects in ellipsis notation. + * This is used instead of simply passing a message String due to performance reasons! + * When using a message string, all parameters would have to be string concatenated + * before the call, even if no problem arises which would cost performance./br + * Instead of this, we will concatenate (with spaces) all given msgObjects.toString() + * only in case of a failed validation! If the first parameter of the msgObject is a + * String, it will be taken as the format string for {...@code MessageFormat}./p + * + * h3Examples:/h3 + * p + * Simply validating an Argument without further message: + * pre + * public void myFn(String argString, Integer argInt) { + * Validate.notNull(argString); + * Validate.notNull(argInt); + * Validate.isTrue(argInt.intValue 3); + * } + * /pre + * p + * + * p + * Validating an Argument and adding a message to the IllegalArgumentException: + * pre + * public void myFn(String argString, Integer argInt) { + * Validate.notNull(argInt, Integer parameter must be set); + * Validate.isTrue(argInt.intValue 3, Integer parameter must be =3!); + * } + * /pre + * p + * + * p + * If the first parameter of the msgObject is a String {...@code MessageFormat} will be used: + * pre + * Validate.isTrue(argInt1.intValue argInt2.intValue, param2 actually is {1} but must larger than param1 {0} !, argInt1, argInt2); + * /pre + * /p + * + * pThe same function sometimes exists multiple times in a 4th form with a single message String parameter + * and an additional value parameter. This is essentially the same like the 3rd form, but with fixed + * object values to preserve backward compatibility with Validate 2.0!p + * pIf the message String contains a codequot;{0}quot;/code, it will be passed to + * {...@code MessageFormat} with the value parameter as single Object parameter. If not, the value parameter + * will simply get concatenated to the message String separated with a space. + * /p + + * @see MessageFormat + * * @author a href=mailto:ola.b...@arkitema.se;Ola Berg/a * @author Stephen Colebourne * @author Gary Gregory * @author Norm Deane + * @author a href=mailto:strub...@yahoo.de;Mark Struberg/a * @since 2.0 * @version $Id$ */ @@ -74,7 +139,7 @@ */ public static void isTrue(boolean expression, String message, Object value) { if (expression == false) { -throw new IllegalArgumentException(message + value); +throw new IllegalArgumentException(getMessage(message, value)); } } @@ -100,7 +165,8 @@ */ public static void isTrue(boolean expression, String message, long value) { if (expression == false) { -throw new IllegalArgumentException(message + value); + +throw new IllegalArgumentException(getMessage(message, value)); } } @@ -127,7 +193,7 @@ */ public static void isTrue(boolean expression, String message, double value) { if (expression
svn commit: r811948 - /commons/proper/lang/trunk/src/java/org/apache/commons/lang/Validate.java
Author: bayard Date: Sun Sep 6 23:00:28 2009 New Revision: 811948 URL: http://svn.apache.org/viewvc?rev=811948view=rev Log: Reverting accidental commit in r811944. Modified: commons/proper/lang/trunk/src/java/org/apache/commons/lang/Validate.java Modified: commons/proper/lang/trunk/src/java/org/apache/commons/lang/Validate.java URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/java/org/apache/commons/lang/Validate.java?rev=811948r1=811947r2=811948view=diff == --- commons/proper/lang/trunk/src/java/org/apache/commons/lang/Validate.java (original) +++ commons/proper/lang/trunk/src/java/org/apache/commons/lang/Validate.java Sun Sep 6 23:00:28 2009 @@ -16,7 +16,6 @@ */ package org.apache.commons.lang; -import java.text.MessageFormat; import java.util.Collection; import java.util.Iterator; import java.util.Map; @@ -32,74 +31,10 @@ * Validate.notNull( surname, The surname must not be null); * /pre * - * All validate functions exist in 4 variants: - * - * p1st function with only the validation option/p - * pre - * Validate.isNotNull(surName); - * /pre - * - * p2nd function with an additional String message parameter. This should - * be used only if no additional parameters have to be provided. Instead of using - * String operations to create the message String, the following 3rd variant - * should be used./p - * pre - * Validate.isNotNull(surName, surname must be set); - * /pre - * - * pSince commons-lang-3.0, for each validation function a similar 3rd validation function exists - * with a list of additional message parameters as Objects in ellipsis notation. - * This is used instead of simply passing a message String due to performance reasons! - * When using a message string, all parameters would have to be string concatenated - * before the call, even if no problem arises which would cost performance./br - * Instead of this, we will concatenate (with spaces) all given msgObjects.toString() - * only in case of a failed validation! If the first parameter of the msgObject is a - * String, it will be taken as the format string for {...@code MessageFormat}./p - * - * h3Examples:/h3 - * p - * Simply validating an Argument without further message: - * pre - * public void myFn(String argString, Integer argInt) { - * Validate.notNull(argString); - * Validate.notNull(argInt); - * Validate.isTrue(argInt.intValue 3); - * } - * /pre - * p - * - * p - * Validating an Argument and adding a message to the IllegalArgumentException: - * pre - * public void myFn(String argString, Integer argInt) { - * Validate.notNull(argInt, Integer parameter must be set); - * Validate.isTrue(argInt.intValue 3, Integer parameter must be =3!); - * } - * /pre - * p - * - * p - * If the first parameter of the msgObject is a String {...@code MessageFormat} will be used: - * pre - * Validate.isTrue(argInt1.intValue argInt2.intValue, param2 actually is {1} but must larger than param1 {0} !, argInt1, argInt2); - * /pre - * /p - * - * pThe same function sometimes exists multiple times in a 4th form with a single message String parameter - * and an additional value parameter. This is essentially the same like the 3rd form, but with fixed - * object values to preserve backward compatibility with Validate 2.0!p - * pIf the message String contains a codequot;{0}quot;/code, it will be passed to - * {...@code MessageFormat} with the value parameter as single Object parameter. If not, the value parameter - * will simply get concatenated to the message String separated with a space. - * /p - - * @see MessageFormat - * * @author a href=mailto:ola.b...@arkitema.se;Ola Berg/a * @author Stephen Colebourne * @author Gary Gregory * @author Norm Deane - * @author a href=mailto:strub...@yahoo.de;Mark Struberg/a * @since 2.0 * @version $Id$ */ @@ -139,7 +74,7 @@ */ public static void isTrue(boolean expression, String message, Object value) { if (expression == false) { -throw new IllegalArgumentException(getMessage(message, value)); +throw new IllegalArgumentException(message + value); } } @@ -165,8 +100,7 @@ */ public static void isTrue(boolean expression, String message, long value) { if (expression == false) { - -throw new IllegalArgumentException(getMessage(message, value)); +throw new IllegalArgumentException(message + value); } } @@ -193,7 +127,7 @@ */ public static void isTrue(boolean expression, String message, double value) { if (expression == false) { -throw new IllegalArgumentException(getMessage(message, value)); +throw new IllegalArgumentException(message + value); } } @@ -248,32 +182,6 @@ } } -/** - * pValidate an argument, throwing
svn commit: r803006 - /commons/proper/lang/trunk/src/java/org/apache/commons/lang/text/StrMatcher.java
Author: bayard Date: Tue Aug 11 06:39:39 2009 New Revision: 803006 URL: http://svn.apache.org/viewvc?rev=803006view=rev Log: Making inner class private fields final per LANG-474 Modified: commons/proper/lang/trunk/src/java/org/apache/commons/lang/text/StrMatcher.java Modified: commons/proper/lang/trunk/src/java/org/apache/commons/lang/text/StrMatcher.java URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/java/org/apache/commons/lang/text/StrMatcher.java?rev=803006r1=803005r2=803006view=diff == --- commons/proper/lang/trunk/src/java/org/apache/commons/lang/text/StrMatcher.java (original) +++ commons/proper/lang/trunk/src/java/org/apache/commons/lang/text/StrMatcher.java Tue Aug 11 06:39:39 2009 @@ -273,7 +273,7 @@ */ static final class CharSetMatcher extends StrMatcher { /** The set of characters to match. */ -private char[] chars; +private final char[] chars; /** * Constructor that creates a matcher from a character array. @@ -307,7 +307,7 @@ */ static final class CharMatcher extends StrMatcher { /** The character to match. */ -private char ch; +private final char ch; /** * Constructor that creates a matcher that matches a single character. @@ -340,7 +340,7 @@ */ static final class StringMatcher extends StrMatcher { /** The string to match, as a character array. */ -private char[] chars; +private final char[] chars; /** * Constructor that creates a matcher from a String.
svn commit: r802477 - /commons/proper/lang/trunk/src/java/org/apache/commons/lang/ClassUtils.java
Author: bayard Date: Sun Aug 9 02:44:56 2009 New Revision: 802477 URL: http://svn.apache.org/viewvc?rev=802477view=rev Log: Improving performance of getAllInterfaces per LANG-500's patch from Pino Silvaggio Modified: commons/proper/lang/trunk/src/java/org/apache/commons/lang/ClassUtils.java Modified: commons/proper/lang/trunk/src/java/org/apache/commons/lang/ClassUtils.java URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/java/org/apache/commons/lang/ClassUtils.java?rev=802477r1=802476r2=802477view=diff == --- commons/proper/lang/trunk/src/java/org/apache/commons/lang/ClassUtils.java (original) +++ commons/proper/lang/trunk/src/java/org/apache/commons/lang/ClassUtils.java Sun Aug 9 02:44:56 2009 @@ -20,6 +20,8 @@ import java.lang.reflect.Modifier; import java.util.ArrayList; import java.util.HashMap; +import java.util.HashSet; +import java.util.LinkedHashSet; import java.util.List; import java.util.Map; @@ -284,24 +286,26 @@ if (cls == null) { return null; } -ListClass? list = new ArrayListClass?(); + +LinkedHashSetClass? interfacesFound = new LinkedHashSetClass?(); +getAllInterfaces(cls, interfacesFound); + +return new ArrayListClass?(interfacesFound); +} + +private static void getAllInterfaces(Class? cls, HashSetClass? interfacesFound) { while (cls != null) { Class?[] interfaces = cls.getInterfaces(); -for (Class? intface : interfaces) { -if (list.contains(intface) == false) { -list.add(intface); -} -ListClass? superInterfaces = getAllInterfaces(intface); -for (Class? superInterface : superInterfaces) { -if (list.contains(superInterface) == false) { -list.add(superInterface); -} + +for (Class? i : interfaces) { +if (interfacesFound.add(i)) { +getAllInterfaces(i, interfacesFound); } } + cls = cls.getSuperclass(); -} -return list; -} + } + } // Convert list // --
svn commit: r796065 - in /commons/proper/lang: lang-backcompat/src/java/org/apache/commons/lang/UnhandledException.java trunk/src/java/org/apache/commons/lang/UnhandledException.java
Author: bayard Date: Mon Jul 20 23:40:09 2009 New Revision: 796065 URL: http://svn.apache.org/viewvc?rev=796065view=rev Log: Moving UnhandledException to backcompat Added: commons/proper/lang/lang-backcompat/src/java/org/apache/commons/lang/UnhandledException.java - copied unchanged from r796064, commons/proper/lang/trunk/src/java/org/apache/commons/lang/UnhandledException.java Removed: commons/proper/lang/trunk/src/java/org/apache/commons/lang/UnhandledException.java
svn commit: r796066 - in /commons/proper/lang: lang-backcompat/src/java/org/apache/commons/lang/NotImplementedException.java trunk/src/java/org/apache/commons/lang/NotImplementedException.java
Author: bayard Date: Mon Jul 20 23:40:38 2009 New Revision: 796066 URL: http://svn.apache.org/viewvc?rev=796066view=rev Log: Moving NotImplementedException to backcompat Added: commons/proper/lang/lang-backcompat/src/java/org/apache/commons/lang/NotImplementedException.java - copied unchanged from r796065, commons/proper/lang/trunk/src/java/org/apache/commons/lang/NotImplementedException.java Removed: commons/proper/lang/trunk/src/java/org/apache/commons/lang/NotImplementedException.java
svn commit: r796067 - in /commons/proper/lang: lang-backcompat/src/java/org/apache/commons/lang/IllegalClassException.java trunk/src/java/org/apache/commons/lang/IllegalClassException.java
Author: bayard Date: Mon Jul 20 23:41:01 2009 New Revision: 796067 URL: http://svn.apache.org/viewvc?rev=796067view=rev Log: Moving IllegalClassException to backcompat Added: commons/proper/lang/lang-backcompat/src/java/org/apache/commons/lang/IllegalClassException.java - copied unchanged from r796066, commons/proper/lang/trunk/src/java/org/apache/commons/lang/IllegalClassException.java Removed: commons/proper/lang/trunk/src/java/org/apache/commons/lang/IllegalClassException.java
svn commit: r796068 - in /commons/proper/lang: lang-backcompat/src/java/org/apache/commons/lang/IncompleteArgumentException.java trunk/src/java/org/apache/commons/lang/IncompleteArgumentException.java
Author: bayard Date: Mon Jul 20 23:43:08 2009 New Revision: 796068 URL: http://svn.apache.org/viewvc?rev=796068view=rev Log: Moving IncompleteArgumentException to backcompat Added: commons/proper/lang/lang-backcompat/src/java/org/apache/commons/lang/IncompleteArgumentException.java - copied unchanged from r796067, commons/proper/lang/trunk/src/java/org/apache/commons/lang/IncompleteArgumentException.java Removed: commons/proper/lang/trunk/src/java/org/apache/commons/lang/IncompleteArgumentException.java
svn commit: r796070 - in /commons/proper/lang/trunk/src/java/org/apache/commons/lang: ClassUtils.java exception/ExceptionUtils.java
Author: bayard Date: Mon Jul 20 23:46:42 2009 New Revision: 796070 URL: http://svn.apache.org/viewvc?rev=796070view=rev Log: Fixing classes to not need NullArgumentException Modified: commons/proper/lang/trunk/src/java/org/apache/commons/lang/ClassUtils.java commons/proper/lang/trunk/src/java/org/apache/commons/lang/exception/ExceptionUtils.java Modified: commons/proper/lang/trunk/src/java/org/apache/commons/lang/ClassUtils.java URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/java/org/apache/commons/lang/ClassUtils.java?rev=796070r1=796069r2=796070view=diff == --- commons/proper/lang/trunk/src/java/org/apache/commons/lang/ClassUtils.java (original) +++ commons/proper/lang/trunk/src/java/org/apache/commons/lang/ClassUtils.java Mon Jul 20 23:46:42 2009 @@ -825,7 +825,7 @@ private static String toCanonicalName(String className) { className = StringUtils.deleteWhitespace(className); if (className == null) { -throw new NullArgumentException(className); +throw new NullPointerException(className must not be null.); } else if (className.endsWith([])) { StringBuffer classNameBuffer = new StringBuffer(); while (className.endsWith([])) { Modified: commons/proper/lang/trunk/src/java/org/apache/commons/lang/exception/ExceptionUtils.java URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/java/org/apache/commons/lang/exception/ExceptionUtils.java?rev=796070r1=796069r2=796070view=diff == --- commons/proper/lang/trunk/src/java/org/apache/commons/lang/exception/ExceptionUtils.java (original) +++ commons/proper/lang/trunk/src/java/org/apache/commons/lang/exception/ExceptionUtils.java Mon Jul 20 23:46:42 2009 @@ -33,7 +33,6 @@ import org.apache.commons.lang.ArrayUtils; import org.apache.commons.lang.ClassUtils; -import org.apache.commons.lang.NullArgumentException; import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.SystemUtils; @@ -187,7 +186,7 @@ */ public static boolean setCause(Throwable target, Throwable cause) { if (target == null) { -throw new NullArgumentException(target); +throw new NullPointerException(target must not be null.); } Object[] causeArgs = new Object[]{cause}; boolean modifiedTarget = false;
svn commit: r796071 - in /commons/proper/lang: lang-backcompat/src/test/org/apache/commons/lang/UnhandledExceptionTest.java trunk/src/test/org/apache/commons/lang/UnhandledExceptionTest.java
Author: bayard Date: Mon Jul 20 23:50:16 2009 New Revision: 796071 URL: http://svn.apache.org/viewvc?rev=796071view=rev Log: Moving UnhandledException to backcompat Added: commons/proper/lang/lang-backcompat/src/test/org/apache/commons/lang/UnhandledExceptionTest.java - copied unchanged from r796070, commons/proper/lang/trunk/src/test/org/apache/commons/lang/UnhandledExceptionTest.java Removed: commons/proper/lang/trunk/src/test/org/apache/commons/lang/UnhandledExceptionTest.java
svn commit: r796073 - in /commons/proper/lang: lang-backcompat/src/test/org/apache/commons/lang/IllegalClassExceptionTest.java trunk/src/test/org/apache/commons/lang/IllegalClassExceptionTest.java
Author: bayard Date: Mon Jul 20 23:50:42 2009 New Revision: 796073 URL: http://svn.apache.org/viewvc?rev=796073view=rev Log: Moving IllegalClassException to backcompat Added: commons/proper/lang/lang-backcompat/src/test/org/apache/commons/lang/IllegalClassExceptionTest.java - copied unchanged from r796072, commons/proper/lang/trunk/src/test/org/apache/commons/lang/IllegalClassExceptionTest.java Removed: commons/proper/lang/trunk/src/test/org/apache/commons/lang/IllegalClassExceptionTest.java
svn commit: r796074 - in /commons/proper/lang: lang-backcompat/src/test/org/apache/commons/lang/NotImplementedExceptionTest.java trunk/src/test/org/apache/commons/lang/NotImplementedExceptionTest.java
Author: bayard Date: Mon Jul 20 23:50:47 2009 New Revision: 796074 URL: http://svn.apache.org/viewvc?rev=796074view=rev Log: Moving NotImplementedException to backcompat Added: commons/proper/lang/lang-backcompat/src/test/org/apache/commons/lang/NotImplementedExceptionTest.java - copied unchanged from r796073, commons/proper/lang/trunk/src/test/org/apache/commons/lang/NotImplementedExceptionTest.java Removed: commons/proper/lang/trunk/src/test/org/apache/commons/lang/NotImplementedExceptionTest.java
svn commit: r796075 - in /commons/proper/lang: lang-backcompat/src/test/org/apache/commons/lang/NullArgumentExceptionTest.java trunk/src/test/org/apache/commons/lang/NullArgumentExceptionTest.java
Author: bayard Date: Mon Jul 20 23:50:56 2009 New Revision: 796075 URL: http://svn.apache.org/viewvc?rev=796075view=rev Log: Moving NullArgumentException to backcompat Added: commons/proper/lang/lang-backcompat/src/test/org/apache/commons/lang/NullArgumentExceptionTest.java - copied unchanged from r796074, commons/proper/lang/trunk/src/test/org/apache/commons/lang/NullArgumentExceptionTest.java Removed: commons/proper/lang/trunk/src/test/org/apache/commons/lang/NullArgumentExceptionTest.java
svn commit: r796076 - in /commons/proper/lang: lang-backcompat/src/test/org/apache/commons/lang/IncompleteArgumentExceptionTest.java trunk/src/test/org/apache/commons/lang/IncompleteArgumentExceptionT
Author: bayard Date: Mon Jul 20 23:51:04 2009 New Revision: 796076 URL: http://svn.apache.org/viewvc?rev=796076view=rev Log: Moving IncompleteArgumentException to backcompat Added: commons/proper/lang/lang-backcompat/src/test/org/apache/commons/lang/IncompleteArgumentExceptionTest.java - copied unchanged from r796075, commons/proper/lang/trunk/src/test/org/apache/commons/lang/IncompleteArgumentExceptionTest.java Removed: commons/proper/lang/trunk/src/test/org/apache/commons/lang/IncompleteArgumentExceptionTest.java
svn commit: r796078 - in /commons/proper/lang/trunk/src: java/org/apache/commons/lang/text/translate/CharSequenceTranslator.java java/org/apache/commons/lang/text/translate/UnicodeUnescaper.java test/
Author: bayard Date: Mon Jul 20 23:55:30 2009 New Revision: 796078 URL: http://svn.apache.org/viewvc?rev=796078view=rev Log: Fixing classes to not need UnhandledException and IllegalArgumentException Modified: commons/proper/lang/trunk/src/java/org/apache/commons/lang/text/translate/CharSequenceTranslator.java commons/proper/lang/trunk/src/java/org/apache/commons/lang/text/translate/UnicodeUnescaper.java commons/proper/lang/trunk/src/test/org/apache/commons/lang/ClassUtilsTest.java Modified: commons/proper/lang/trunk/src/java/org/apache/commons/lang/text/translate/CharSequenceTranslator.java URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/java/org/apache/commons/lang/text/translate/CharSequenceTranslator.java?rev=796078r1=796077r2=796078view=diff == --- commons/proper/lang/trunk/src/java/org/apache/commons/lang/text/translate/CharSequenceTranslator.java (original) +++ commons/proper/lang/trunk/src/java/org/apache/commons/lang/text/translate/CharSequenceTranslator.java Mon Jul 20 23:55:30 2009 @@ -21,8 +21,6 @@ import java.io.StringWriter; import java.util.Locale; -import org.apache.commons.lang.UnhandledException; - /** * An API for translating text. * Its core use is to escape and unescape text. Because escaping and unescaping @@ -60,7 +58,7 @@ return writer.toString(); } catch (IOException ioe) { // this should never ever happen while writing to a StringWriter -throw new UnhandledException(ioe); +throw new RuntimeException(ioe); } } Modified: commons/proper/lang/trunk/src/java/org/apache/commons/lang/text/translate/UnicodeUnescaper.java URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/java/org/apache/commons/lang/text/translate/UnicodeUnescaper.java?rev=796078r1=796077r2=796078view=diff == --- commons/proper/lang/trunk/src/java/org/apache/commons/lang/text/translate/UnicodeUnescaper.java (original) +++ commons/proper/lang/trunk/src/java/org/apache/commons/lang/text/translate/UnicodeUnescaper.java Mon Jul 20 23:55:30 2009 @@ -19,8 +19,6 @@ import java.io.IOException; import java.io.Writer; -import org.apache.commons.lang.UnhandledException; - /** * Translates escaped unicode values of the form \\u+\d\d\d\d back to * unicode. @@ -49,7 +47,7 @@ int value = Integer.parseInt(unicode.toString(), 16); out.write((char) value); } catch (NumberFormatException nfe) { -throw new UnhandledException(Unable to parse unicode value: + unicode, nfe); +throw new RuntimeException(Unable to parse unicode value: + unicode, nfe); } return i + 4; } else { Modified: commons/proper/lang/trunk/src/test/org/apache/commons/lang/ClassUtilsTest.java URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/test/org/apache/commons/lang/ClassUtilsTest.java?rev=796078r1=796077r2=796078view=diff == --- commons/proper/lang/trunk/src/test/org/apache/commons/lang/ClassUtilsTest.java (original) +++ commons/proper/lang/trunk/src/test/org/apache/commons/lang/ClassUtilsTest.java Mon Jul 20 23:55:30 2009 @@ -562,7 +562,7 @@ } public void testGetClassInvalidArguments() throws Exception { -assertGetClassThrowsIllegalArgument( null ); +assertGetClassThrowsNullPointerException( null ); assertGetClassThrowsClassNotFound( [][][] ); assertGetClassThrowsClassNotFound( [[] ); assertGetClassThrowsClassNotFound( [ ); @@ -651,8 +651,8 @@ } } -private void assertGetClassThrowsIllegalArgument( String className ) throws Exception { -assertGetClassThrowsException( className, IllegalArgumentException.class ); +private void assertGetClassThrowsNullPointerException( String className ) throws Exception { +assertGetClassThrowsException( className, NullPointerException.class ); } private void assertGetClassThrowsClassNotFound( String className ) throws Exception {
svn commit: r795482 - /commons/proper/lang/trunk/xdocs/changes.xml
Author: bayard Date: Sun Jul 19 06:44:37 2009 New Revision: 795482 URL: http://svn.apache.org/viewvc?rev=795482view=rev Log: 1.1-2.4 now in the changes report (LANG-484) Modified: commons/proper/lang/trunk/xdocs/changes.xml Modified: commons/proper/lang/trunk/xdocs/changes.xml URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/xdocs/changes.xml?rev=795482r1=795481r2=795482view=diff == --- commons/proper/lang/trunk/xdocs/changes.xml (original) +++ commons/proper/lang/trunk/xdocs/changes.xml Sun Jul 19 06:44:37 2009 @@ -25,18 +25,281 @@ /release release version=2.4 date=2008-03-18 description= +action type=add issue=LANG-322ClassUtils.getShortClassName(String) inefficient/action +action type=add issue=LANG-269Shouldn't Commons Lang's StringUtils have a common string method?/action +action type=fix issue=LANG-368FastDateFormat getDateInstance() and getDateTimeInstance() assume Locale.getDefault() won't change/action +action type=add issue=LANG-402OSGi-ify Lang/action +action type=fix issue=LANG-412StrBuilder appendFixedWidth does not handle nulls/action +action type=fix issue=LANG-380infinite loop in Fraction.reduce when numerator == 0/action +action type=fix issue=LANG-367FastDateFormat thread safety/action +action type=add issue=LANG-298ClassUtils.getShortClassName and ClassUtils.getPackageName and class of array/action +action type=fix issue=LANG-328LocaleUtils.toLocale() rejects strings with only language+variant/action +action type=fix issue=LANG-334Enum is not thread-safe/action +action type=fix issue=LANG-365BooleanUtils.toBoolean() - invalid drop-thru in case statement causes StringIndexOutOfBoundsException/action +action type=add issue=LANG-333ArrayUtils.toClass/action +action type=fix issue=LANG-360Why does appendIdentityToString return null?/action +action type=fix issue=LANG-381NumberUtils.min(floatArray) returns wrong value if floatArray[0] happens to be Float.NaN/action +action type=fix issue=LANG-346Dates.round() behaves incorrectly for minutes and seconds/action +action type=add issue=LANG-407StringUtils.length(String) returns null-safe length/action +action type=add issue=LANG-180adding a StringUtils.replace method that takes an array or List of replacement strings/action +action type=add issue=LANG-383Adding functionality to DateUtils to allow direct setting of various fields./action +action type=add issue=LANG-374Add escaping for CSV columns to StringEscapeUtils/action +action type=add issue=LANG-326StringUtils: startsWith / endsWith / startsWithIgnoreCase / endsWithIgnoreCase / removeStartIgnoreCase / removeEndIgnoreCase methods/action +action type=add issue=LANG-351Extension to ClassUtils: Obtain the primitive class from a wrapper/action +action type=fix issue=LANG-399Javadoc bugs - cannot find object/action +action type=add issue=LANG-345Optimize HashCodeBuilder.append(Object)/action +action type=fix issue=LANG-385http://commons.apache.org/lang/developerguide.html Building section is incorrect and incomplete/action +action type=fix issue=LANG-410Ambiguous / confusing names in StringUtils replace* methods/action +action type=add issue=LANG-257Add new splitByWholeSeparatorPreserveAllTokens() methods to StringUtils/action +action type=add issue=LANG-356Add getStartTime to StopWatch/action +action type=add issue=LANG-377Perhaps add containsAny() methods?/action +action type=fix issue=LANG-353Javadoc Example for EqualsBuilder is questionable/action +action type=fix issue=LANG-393EqualsBuilder don't compare BigDecimals correctly/action +action type=add issue=LANG-192Split camel case strings/action +action type=add issue=LANG-404Add Calendar flavour format methods to DateFormatUtils/action +action type=add issue=LANG-379Calculating A date fragment in any time-unit/action +action type=add issue=LANG-413Memory usage improvement for StringUtils#getLevenshteinDistance()/action +action type=add issue=LANG-362Add ExtendedMessageFormat to org.apache.commons.lang.text/action +action type=fix issue=LANG-363StringEscapeUtils.escapeJavaScript() method did not escape '/' into '\/', it will make IE render page uncorrectly/action +action type=add issue=LANG-321Add toArray() method to IntRange and LongRange classes/action +action type=add issue=LANG-375add SystemUtils.IS_OS_WINDOWS_VISTA field/action +action type=add issue=LANG-329Pointless synchronized in ThreadLocal.initialValue should be removed/action +action type=add issue=LANG-371ToStringStyle javadoc should show examples of styles/action +action type=fix issue=LANG-364Documentation bug for ignoreEmptyTokens accessors in StrTokenizer/action +action type=fix issue=LANG-361BooleanUtils toBooleanObject javadoc does not match implementation/action
svn commit: r794509 - /commons/proper/codec/trunk/xdocs/changes.xml
Author: bayard Date: Thu Jul 16 03:39:32 2009 New Revision: 794509 URL: http://svn.apache.org/viewvc?rev=794509view=rev Log: Converting 1.3 bugzilla ids to JIRA keys. Modified: commons/proper/codec/trunk/xdocs/changes.xml Modified: commons/proper/codec/trunk/xdocs/changes.xml URL: http://svn.apache.org/viewvc/commons/proper/codec/trunk/xdocs/changes.xml?rev=794509r1=794508r2=794509view=diff == --- commons/proper/codec/trunk/xdocs/changes.xml (original) +++ commons/proper/codec/trunk/xdocs/changes.xml Thu Jul 16 03:39:32 2009 @@ -76,27 +76,27 @@ /action /release release version=1.3 date=10 July 2004 description=Feature and fix release. - action dev=ggregory, tobrien type=add issue=27813 due-to=Alex Karasulu + action dev=ggregory, tobrien type=add issue=CODEC-21 due-to=Alex Karasulu BinaryCodec: Encodes and decodes binary to and from Strings of 0s and 1s. /action - action dev=ggregory type=add issue=26617 due-to=Oleg Kalnichevski due-to-email=ol...@apache.org + action dev=ggregory type=add issue=CODEC-41 due-to=Oleg Kalnichevski due-to-email=ol...@apache.org QuotedPrintableCodec: Codec for RFC 1521 MIME (Multipurpose Internet Mail Extensions) Part One. Rules #3, #4, and #5 of the quoted-printable spec are not implemented yet. See also issue 27789. /action - action dev=ggregory type=add issue=26617 due-to=Oleg Kalnichevski due-to-email=ol...@apache.org + action dev=ggregory type=add issue=CODEC-41 due-to=Oleg Kalnichevski due-to-email=ol...@apache.org BCodec: Identical to the Base64 encoding defined by RFC 1521 and allows a character set to be specified. /action - action dev=ggregory type=add issue=26617 due-to=Oleg Kalnichevski due-to-email=ol...@apache.org + action dev=ggregory type=add issue=CODEC-41 due-to=Oleg Kalnichevski due-to-email=ol...@apache.org QCodec: Similar to the Quoted-Printable content-transfer-encoding defined in RFC 1521 and designed to allow text containing mostly ASCII characters to be decipherable on an ASCII terminal without decoding. /action - action dev=ggregory type=add issue=25243 due-to=Matthew Inger due-to-email=mattin...@yahoo.com + action dev=ggregory type=add issue=CODEC-45 due-to=Matthew Inger due-to-email=mattin...@yahoo.com Soundex: Implemented the DIFFERENCE algorithm. /action - action dev=ggregory type=add issue=25243 due-to=Matthew Inger due-to-email=mattin...@yahoo.com + action dev=ggregory type=add issue=CODEC-45 due-to=Matthew Inger due-to-email=mattin...@yahoo.com RefinedSoundex: Implemented the DIFFERENCE algorithm. /action action dev=ggregory type=update @@ -109,16 +109,16 @@ The Board recommendation to remove Javadoc author tags has been implemented. All author tags are now Apache Software Foundation. /action - action dev=ggregory type=fix issue=25995 due-to=Oleg Kalnichevski due-to-email=ol...@apache.org + action dev=ggregory type=fix issue=CODEC-25 due-to=Oleg Kalnichevski due-to-email=ol...@apache.org The default URL encoding logic was broken. /action - action dev=ggregory type=fix issue=27781 due-to=Gary D. Gregory + action dev=ggregory type=fix issue=CODEC-31 due-to=Gary D. Gregory Base64 chunked encoding not compliant with RFC 2045 section 2.1 CRLF. /action - action dev=ggregory type=fix issue=28455 + action dev=ggregory type=fix issue=CODEC-5 Hex converts illegal characters to 255. /action - action dev=tobrien type=fix issue=28457 + action dev=tobrien type=fix issue=CODEC-17 Metaphone now correctly handles a silent B in a word that ends in MB. COMB is encoded as KM, before this fix COMB was encoded as KMB. /action
svn commit: r794512 - /commons/proper/codec/trunk/xdocs/changes.xml
Author: bayard Date: Thu Jul 16 03:45:24 2009 New Revision: 794512 URL: http://svn.apache.org/viewvc?rev=794512view=rev Log: Fixing remaining bugzilla ids to be JIRA keys to close out CODEC-76 Modified: commons/proper/codec/trunk/xdocs/changes.xml Modified: commons/proper/codec/trunk/xdocs/changes.xml URL: http://svn.apache.org/viewvc/commons/proper/codec/trunk/xdocs/changes.xml?rev=794512r1=794511r2=794512view=diff == --- commons/proper/codec/trunk/xdocs/changes.xml (original) +++ commons/proper/codec/trunk/xdocs/changes.xml Thu Jul 16 03:45:24 2009 @@ -82,7 +82,7 @@ action dev=ggregory type=add issue=CODEC-41 due-to=Oleg Kalnichevski due-to-email=ol...@apache.org QuotedPrintableCodec: Codec for RFC 1521 MIME (Multipurpose Internet Mail Extensions) Part One. Rules #3, #4, and #5 of the quoted-printable spec -are not implemented yet. See also issue 27789. +are not implemented yet. See also issue CODEC-46. /action action dev=ggregory type=add issue=CODEC-41 due-to=Oleg Kalnichevski due-to-email=ol...@apache.org BCodec: Identical to the Base64 encoding defined by RFC 1521 and allows a @@ -136,19 +136,19 @@ action dev=tobrien type=add due-to=Dave Dribin, David Graham DigestUtils: Calculates MD5 and SHA digests. /action - action dev=tobrien type=fix issue=19860 due-to=Brian Ewins + action dev=tobrien type=fix issue=CODEC-26 due-to=Brian Ewins Modified Base64 to remedy non-compliance with RFC 2045. Non-Base64 characters were not being discarded during the decode. RFC 2045 explicitly states that all characters outside of the base64 alphabet are to be ignored. /action - action dev=ggregory type=fix issue=24360 + action dev=ggregory type=fix issue=CODEC-4 Hex.decode(Object) throws a ClassCastException when a String argument is passed in. /action - action dev=ggregory type=fix issue=24471 + action dev=ggregory type=fix issue=CODEC-3 Soundex: The HW rule is not applied; hyphens and apostrophes are not ignored. /action - action dev=ggregory type=fix issue=24484 + action dev=ggregory type=fix issue=CODEC-29 Soundex.setMaxLength causes bugs and is not needed. Calling Soundex.setMaxLength() with a value of 2 or less causes the wrong answer to be returned. Since the encoding returned by Soundex is always
svn commit: r794525 - in /commons/proper/codec/trunk/src/test/org/apache/commons/codec: digest/DigestUtilsTest.java language/CaverphoneTest.java language/SoundexTest.java
Author: bayard Date: Thu Jul 16 04:58:08 2009 New Revision: 794525 URL: http://svn.apache.org/viewvc?rev=794525view=rev Log: Improving code coverage Modified: commons/proper/codec/trunk/src/test/org/apache/commons/codec/digest/DigestUtilsTest.java commons/proper/codec/trunk/src/test/org/apache/commons/codec/language/CaverphoneTest.java commons/proper/codec/trunk/src/test/org/apache/commons/codec/language/SoundexTest.java Modified: commons/proper/codec/trunk/src/test/org/apache/commons/codec/digest/DigestUtilsTest.java URL: http://svn.apache.org/viewvc/commons/proper/codec/trunk/src/test/org/apache/commons/codec/digest/DigestUtilsTest.java?rev=794525r1=794524r2=794525view=diff == --- commons/proper/codec/trunk/src/test/org/apache/commons/codec/digest/DigestUtilsTest.java (original) +++ commons/proper/codec/trunk/src/test/org/apache/commons/codec/digest/DigestUtilsTest.java Thu Jul 16 04:58:08 2009 @@ -157,4 +157,8 @@ DigestUtils.shaHex(new ByteArrayInputStream(testData))); } + +public void testConstructable() { +new DigestUtils(); +} } Modified: commons/proper/codec/trunk/src/test/org/apache/commons/codec/language/CaverphoneTest.java URL: http://svn.apache.org/viewvc/commons/proper/codec/trunk/src/test/org/apache/commons/codec/language/CaverphoneTest.java?rev=794525r1=794524r2=794525view=diff == --- commons/proper/codec/trunk/src/test/org/apache/commons/codec/language/CaverphoneTest.java (original) +++ commons/proper/codec/trunk/src/test/org/apache/commons/codec/language/CaverphoneTest.java Thu Jul 16 04:58:08 2009 @@ -59,4 +59,10 @@ } } +public void testIsCaverphoneEquals() { +Caverphone caverphone = new Caverphone(); +assertFalse(Caverphone encodings should not be equal, caverphone.isCaverphoneEqual(Peter, Stevenson)); +assertTrue(Caverphone encodings should be equal, caverphone.isCaverphoneEqual(Peter, Peady)); +} + } Modified: commons/proper/codec/trunk/src/test/org/apache/commons/codec/language/SoundexTest.java URL: http://svn.apache.org/viewvc/commons/proper/codec/trunk/src/test/org/apache/commons/codec/language/SoundexTest.java?rev=794525r1=794524r2=794525view=diff == --- commons/proper/codec/trunk/src/test/org/apache/commons/codec/language/SoundexTest.java (original) +++ commons/proper/codec/trunk/src/test/org/apache/commons/codec/language/SoundexTest.java Thu Jul 16 04:58:08 2009 @@ -400,4 +400,14 @@ public void testNewInstance3() { assertEquals(W452, new Soundex(Soundex.US_ENGLISH_MAPPING_STRING).soundex(Williams)); } + +public void testSoundexUtilsNullBehaviour() { +assertEquals(null, SoundexUtils.clean(null)); +assertEquals(, SoundexUtils.clean()); +assertEquals(0, SoundexUtils.differenceEncoded(null, )); +assertEquals(0, SoundexUtils.differenceEncoded(, null)); +} +public void testSoundexUtilsConstructable() { +new SoundexUtils(); +} }
svn commit: r794528 - /commons/proper/codec/trunk/src/java/org/apache/commons/codec/language/Metaphone.java
Author: bayard Date: Thu Jul 16 05:09:20 2009 New Revision: 794528 URL: http://svn.apache.org/viewvc?rev=794528view=rev Log: Adding note on unexecutable code Modified: commons/proper/codec/trunk/src/java/org/apache/commons/codec/language/Metaphone.java Modified: commons/proper/codec/trunk/src/java/org/apache/commons/codec/language/Metaphone.java URL: http://svn.apache.org/viewvc/commons/proper/codec/trunk/src/java/org/apache/commons/codec/language/Metaphone.java?rev=794528r1=794527r2=794528view=diff == --- commons/proper/codec/trunk/src/java/org/apache/commons/codec/language/Metaphone.java (original) +++ commons/proper/codec/trunk/src/java/org/apache/commons/codec/language/Metaphone.java Thu Jul 16 05:09:20 2009 @@ -212,6 +212,7 @@ break; // silent G } if (isPreviousChar(local, n, 'G')) { +// NOTE: Given that duplicated chars are removed, I don't see how this can ever be true hard = true ; } else { hard = false ;
svn commit: r794532 - /commons/proper/codec/trunk/src/test/org/apache/commons/codec/language/MetaphoneTest.java
Author: bayard Date: Thu Jul 16 05:22:45 2009 New Revision: 794532 URL: http://svn.apache.org/viewvc?rev=794532view=rev Log: Adding a pair of notes Modified: commons/proper/codec/trunk/src/test/org/apache/commons/codec/language/MetaphoneTest.java Modified: commons/proper/codec/trunk/src/test/org/apache/commons/codec/language/MetaphoneTest.java URL: http://svn.apache.org/viewvc/commons/proper/codec/trunk/src/test/org/apache/commons/codec/language/MetaphoneTest.java?rev=794532r1=794531r2=794532view=diff == --- commons/proper/codec/trunk/src/test/org/apache/commons/codec/language/MetaphoneTest.java (original) +++ commons/proper/codec/trunk/src/test/org/apache/commons/codec/language/MetaphoneTest.java Thu Jul 16 05:22:45 2009 @@ -434,7 +434,10 @@ } public void testDiscardOfSilentGN() { +// NOTE: This does not test for silent GN, but for starting with GN assertEquals( N, this.getMetaphone().metaphone(GNU) ); + +// NOTE: Trying to test for GNED, but expected code does not appear to execute assertEquals( SNT, this.getMetaphone().metaphone(SIGNED) ); }
svn commit: r792049 - /commons/proper/lang/trunk/src/java/org/apache/commons/lang/LocaleUtils.java
Author: bayard Date: Wed Jul 8 06:30:04 2009 New Revision: 792049 URL: http://svn.apache.org/viewvc?rev=792049view=rev Log: synchronized removed from availableLocaleSet per LANG-488 Modified: commons/proper/lang/trunk/src/java/org/apache/commons/lang/LocaleUtils.java Modified: commons/proper/lang/trunk/src/java/org/apache/commons/lang/LocaleUtils.java URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/java/org/apache/commons/lang/LocaleUtils.java?rev=792049r1=792048r2=792049view=diff == --- commons/proper/lang/trunk/src/java/org/apache/commons/lang/LocaleUtils.java (original) +++ commons/proper/lang/trunk/src/java/org/apache/commons/lang/LocaleUtils.java Wed Jul 8 06:30:04 2009 @@ -221,7 +221,7 @@ * * @return the unmodifiable set of available locales */ -public static synchronized SetLocale availableLocaleSet() { +public static SetLocale availableLocaleSet() { if(cAvailableLocaleSet == null) { initAvailableLocaleSet(); }
svn commit: r792050 - /commons/proper/lang/trunk/src/java/org/apache/commons/lang/EnumUtils.java
Author: bayard Date: Wed Jul 8 06:35:53 2009 New Revision: 792050 URL: http://svn.apache.org/viewvc?rev=792050view=rev Log: Updating comment to explain why a public constructor exists Modified: commons/proper/lang/trunk/src/java/org/apache/commons/lang/EnumUtils.java Modified: commons/proper/lang/trunk/src/java/org/apache/commons/lang/EnumUtils.java URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/java/org/apache/commons/lang/EnumUtils.java?rev=792050r1=792049r2=792050view=diff == --- commons/proper/lang/trunk/src/java/org/apache/commons/lang/EnumUtils.java (original) +++ commons/proper/lang/trunk/src/java/org/apache/commons/lang/EnumUtils.java Wed Jul 8 06:35:53 2009 @@ -27,7 +27,8 @@ public class EnumUtils { /** - * Constructor. This class should not normally be instantiated. + * pThis constructor is public to permit tools that require a JavaBean + * instance to operate./p */ public EnumUtils() { }
svn commit: r791721 - /commons/proper/lang/trunk/src/java/org/apache/commons/lang/StringEscapeUtils.java
Author: bayard Date: Tue Jul 7 06:56:22 2009 New Revision: 791721 URL: http://svn.apache.org/viewvc?rev=791721view=rev Log: Deprecating StringEscapeUtils Modified: commons/proper/lang/trunk/src/java/org/apache/commons/lang/StringEscapeUtils.java Modified: commons/proper/lang/trunk/src/java/org/apache/commons/lang/StringEscapeUtils.java URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/java/org/apache/commons/lang/StringEscapeUtils.java?rev=791721r1=791720r2=791721view=diff == --- commons/proper/lang/trunk/src/java/org/apache/commons/lang/StringEscapeUtils.java (original) +++ commons/proper/lang/trunk/src/java/org/apache/commons/lang/StringEscapeUtils.java Tue Jul 7 06:56:22 2009 @@ -37,7 +37,10 @@ * @author Pete Gieser * @since 2.0 * @version $Id$ + * + * @deprecated Use text.translate.EscapeUtils and text.translate.UnescapeUtils instead */ +...@deprecated public class StringEscapeUtils { /**
svn commit: r791726 - /commons/proper/lang/trunk/src/java/org/apache/commons/lang/LocaleUtils.java
Author: bayard Date: Tue Jul 7 07:10:02 2009 New Revision: 791726 URL: http://svn.apache.org/viewvc?rev=791726view=rev Log: Moving availableLocaleSet and availableLocaleList to both lazily initialize in a separate synchronized method. This brings the two pieces of code into line with each other, allows availableLocaleSet() to be unsynchronized as desired in LANG-488 and removes the static initialization of availableLocaleList() as requested in LANG-511 Modified: commons/proper/lang/trunk/src/java/org/apache/commons/lang/LocaleUtils.java Modified: commons/proper/lang/trunk/src/java/org/apache/commons/lang/LocaleUtils.java URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/java/org/apache/commons/lang/LocaleUtils.java?rev=791726r1=791725r2=791726view=diff == --- commons/proper/lang/trunk/src/java/org/apache/commons/lang/LocaleUtils.java (original) +++ commons/proper/lang/trunk/src/java/org/apache/commons/lang/LocaleUtils.java Tue Jul 7 07:10:02 2009 @@ -40,18 +40,18 @@ public class LocaleUtils { /** Unmodifiable list of available locales. */ -private static final ListLocale cAvailableLocaleList; +//@GuardedBy(this) +private static ListLocale cAvailableLocaleList; // lazily created by availableLocaleList() + /** Unmodifiable set of available locales. */ //@GuardedBy(this) -private static SetLocale cAvailableLocaleSet; // lazily created by availableLocaleSet() +private static SetLocale cAvailableLocaleSet; // lazily created by availableLocaleSet() + /** Unmodifiable map of language locales by country. */ private static final MapString, ListLocale cLanguagesByCountry = Collections.synchronizedMap(new HashMapString, ListLocale()); + /** Unmodifiable map of country locales by language. */ private static final MapString, ListLocale cCountriesByLanguage = Collections.synchronizedMap(new HashMapString, ListLocale()); -static { -ListLocale list = Arrays.asList(Locale.getAvailableLocales()); -cAvailableLocaleList = Collections.unmodifiableList(list); -} /** * pcodeLocaleUtils/code instances should NOT be constructed in standard programming. @@ -193,9 +193,24 @@ * @return the unmodifiable list of available locales */ public static ListLocale availableLocaleList() { +if(cAvailableLocaleList == null) { +initAvailableLocaleList(); +} return cAvailableLocaleList; } +/** + * Initializes the availableLocaleList. It is separate from availableLocaleList() + * to avoid the synchronized block affecting normal use, yet synchronized and + * lazy loading to avoid a static block affecting other methods in this class. + */ +private static synchronized void initAvailableLocaleList() { +if(cAvailableLocaleList == null) { +ListLocale list = Arrays.asList(Locale.getAvailableLocales()); +cAvailableLocaleList = Collections.unmodifiableList(list); +} +} + //--- /** * pObtains an unmodifiable set of installed locales./p @@ -207,13 +222,21 @@ * @return the unmodifiable set of available locales */ public static synchronized SetLocale availableLocaleSet() { -SetLocale set = cAvailableLocaleSet; -if (set == null) { -set = new HashSetLocale(availableLocaleList()); -set = Collections.unmodifiableSet(set); -cAvailableLocaleSet = set; +if(cAvailableLocaleSet == null) { +initAvailableLocaleSet(); +} +return cAvailableLocaleSet; +} + +/** + * Initializes the availableLocaleSet. It is separate from availableLocaleSet() + * to avoid the synchronized block affecting normal use, yet synchronized and + * lazy loading to avoid a static block affecting other methods in this class. + */ +private static synchronized void initAvailableLocaleSet() { +if(cAvailableLocaleSet == null) { +cAvailableLocaleSet = Collections.unmodifiableSet( new HashSetLocale(availableLocaleList()) ); } -return set; } //---
svn commit: r789573 - in /commons/proper/lang/trunk/src: java/org/apache/commons/lang/StringUtils.java test/org/apache/commons/lang/StringUtilsTest.java
Author: bayard Date: Tue Jun 30 06:24:20 2009 New Revision: 789573 URL: http://svn.apache.org/viewvc?rev=789573view=rev Log: Applying Vincent Ricard's patch in LANG-471 (reported by Ivica Mikic) adding isAllUpperCase and isAllLowerCase to StringUtils Modified: commons/proper/lang/trunk/src/java/org/apache/commons/lang/StringUtils.java commons/proper/lang/trunk/src/test/org/apache/commons/lang/StringUtilsTest.java Modified: commons/proper/lang/trunk/src/java/org/apache/commons/lang/StringUtils.java URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/java/org/apache/commons/lang/StringUtils.java?rev=789573r1=789572r2=789573view=diff == --- commons/proper/lang/trunk/src/java/org/apache/commons/lang/StringUtils.java (original) +++ commons/proper/lang/trunk/src/java/org/apache/commons/lang/StringUtils.java Tue Jun 30 06:24:20 2009 @@ -4916,6 +4916,66 @@ return true; } +/** + * pChecks if the String contains only lowercase characters./p + * + * pcodenull/code will return codefalse/code. + * An empty String () will return codefalse/code./p + * + * pre + * StringUtils.isAllLowerCase(null) = false + * StringUtils.isAllLowerCase() = false + * StringUtils.isAllLowerCase( ) = false + * StringUtils.isAllLowerCase(abc) = true + * StringUtils.isAllLowerCase(abC) = false + * /pre + * + * @param str the String to check, may be null + * @return codetrue/code if only contains lowercase characters, and is non-null + */ +public static boolean isAllLowerCase(String str) { +if (str == null || isEmpty(str)) { +return false; +} +int sz = str.length(); +for (int i = 0; i sz; i++) { +if (Character.isLowerCase(str.charAt(i)) == false) { +return false; +} +} +return true; +} + +/** + * pChecks if the String contains only uppercase characters./p + * + * pcodenull/code will return codefalse/code. + * An empty String () will return codefalse/code./p + * + * pre + * StringUtils.isAllUpperCase(null) = false + * StringUtils.isAllUpperCase() = false + * StringUtils.isAllUpperCase( ) = false + * StringUtils.isAllUpperCase(ABC) = true + * StringUtils.isAllUpperCase(aBC) = false + * /pre + * + * @param str the String to check, may be null + * @return codetrue/code if only contains uppercase characters, and is non-null + */ +public static boolean isAllUpperCase(String str) { +if (str == null || isEmpty(str)) { +return false; +} +int sz = str.length(); +for (int i = 0; i sz; i++) { +if (Character.isUpperCase(str.charAt(i)) == false) { +return false; +} +} +return true; +} + // Defaults //--- /** Modified: commons/proper/lang/trunk/src/test/org/apache/commons/lang/StringUtilsTest.java URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/test/org/apache/commons/lang/StringUtilsTest.java?rev=789573r1=789572r2=789573view=diff == --- commons/proper/lang/trunk/src/test/org/apache/commons/lang/StringUtilsTest.java (original) +++ commons/proper/lang/trunk/src/test/org/apache/commons/lang/StringUtilsTest.java Tue Jun 30 06:24:20 2009 @@ -1541,7 +1541,29 @@ assertEquals(, StringUtils.EMPTY); assertEquals(0, StringUtils.EMPTY.length()); } - + +/** + * Test for {...@link StringUtils#isAllLowerCase(String)}. + */ +public void testIsAllLowerCase() { +assertFalse(StringUtils.isAllLowerCase(null)); +assertFalse(StringUtils.isAllLowerCase(StringUtils.EMPTY)); +assertTrue(StringUtils.isAllLowerCase(abc)); +assertFalse(StringUtils.isAllLowerCase(abc )); +assertFalse(StringUtils.isAllLowerCase(abC)); +} + +/** + * Test for {...@link StringUtils#isAllUpperCase(String)}. + */ +public void testIsAllUpperCase() { +assertFalse(StringUtils.isAllUpperCase(null)); +assertFalse(StringUtils.isAllUpperCase(StringUtils.EMPTY)); +assertTrue(StringUtils.isAllUpperCase(ABC)); +assertFalse(StringUtils.isAllUpperCase(ABC )); +assertFalse(StringUtils.isAllUpperCase(aBC)); +} + public void testRemoveStart() { // StringUtils.removeStart(, *)= assertNull(StringUtils.removeStart(null, null));
svn commit: r789575 - /commons/proper/lang/trunk/src/java/org/apache/commons/lang/StringUtils.java
Author: bayard Date: Tue Jun 30 06:34:01 2009 New Revision: 789575 URL: http://svn.apache.org/viewvc?rev=789575view=rev Log: Moving a few of the StringUtils methods over to accepting CharSequence instead of String as part of LANG-510 Modified: commons/proper/lang/trunk/src/java/org/apache/commons/lang/StringUtils.java Modified: commons/proper/lang/trunk/src/java/org/apache/commons/lang/StringUtils.java URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/java/org/apache/commons/lang/StringUtils.java?rev=789575r1=789574r2=789575view=diff == --- commons/proper/lang/trunk/src/java/org/apache/commons/lang/StringUtils.java (original) +++ commons/proper/lang/trunk/src/java/org/apache/commons/lang/StringUtils.java Tue Jun 30 06:34:01 2009 @@ -188,7 +188,7 @@ * @param str the String to check, may be null * @return codetrue/code if the String is empty or null */ -public static boolean isEmpty(String str) { +public static boolean isEmpty(CharSequence str) { return str == null || str.length() == 0; } @@ -206,7 +206,7 @@ * @param str the String to check, may be null * @return codetrue/code if the String is not empty and not null */ -public static boolean isNotEmpty(String str) { +public static boolean isNotEmpty(CharSequence str) { return !StringUtils.isEmpty(str); } @@ -225,7 +225,7 @@ * @return codetrue/code if the String is null, empty or whitespace * @since 2.0 */ -public static boolean isBlank(String str) { +public static boolean isBlank(CharSequence str) { int strLen; if (str == null || (strLen = str.length()) == 0) { return true; @@ -254,7 +254,7 @@ * not empty and not null and not whitespace * @since 2.0 */ -public static boolean isNotBlank(String str) { +public static boolean isNotBlank(CharSequence str) { return !StringUtils.isBlank(str); }
svn commit: r789584 - in /commons/proper/lang/trunk/src/java/org/apache/commons/lang/text/translate: EntityArrays.java EscapeUtils.java UnescapeUtils.java
Author: bayard Date: Tue Jun 30 06:47:18 2009 New Revision: 789584 URL: http://svn.apache.org/viewvc?rev=789584view=rev Log: Making the EntityArrays class public by cloning the arrays when they are accessed. API might need a sanity check as this is the old Entities stuff. Also changing the arrays to be private and the rest of the code to use the cloning methods. This does add performance overhead, but I think it'll be negligible and better to practice safe coding. Part of LANG-505 Modified: commons/proper/lang/trunk/src/java/org/apache/commons/lang/text/translate/EntityArrays.java commons/proper/lang/trunk/src/java/org/apache/commons/lang/text/translate/EscapeUtils.java commons/proper/lang/trunk/src/java/org/apache/commons/lang/text/translate/UnescapeUtils.java Modified: commons/proper/lang/trunk/src/java/org/apache/commons/lang/text/translate/EntityArrays.java URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/java/org/apache/commons/lang/text/translate/EntityArrays.java?rev=789584r1=789583r2=789584view=diff == --- commons/proper/lang/trunk/src/java/org/apache/commons/lang/text/translate/EntityArrays.java (original) +++ commons/proper/lang/trunk/src/java/org/apache/commons/lang/text/translate/EntityArrays.java Tue Jun 30 06:47:18 2009 @@ -17,15 +17,16 @@ package org.apache.commons.lang.text.translate; /** - * Package private class holding varius entity data for HTML and XML. + * Class holding various entity data for HTML and XML - generally for use with + * the LookupTranslator. * All arrays are of length [*][2]. * * @since 3.0 */ -// TODO: These need to be public - make methods to return them for security purposes? -class EntityArrays { +public class EntityArrays { -static final String[][] ISO8859_1_ESCAPE = { +public static String[][] ISO8859_1_ESCAPE() { return ISO8859_1_ESCAPE.clone(); } +private static final String[][] ISO8859_1_ESCAPE = { {\u00A0, nbsp;}, // non-breaking space {\u00A1, iexcl;}, // inverted exclamation mark {\u00A2, cent;}, // cent sign @@ -124,10 +125,12 @@ {\u00FF, yuml;}, // ÿ - lowercase y, umlaut }; -static final String[][] ISO8859_1_UNESCAPE = invert(ISO8859_1_ESCAPE); +public static String[][] ISO8859_1_UNESCAPE() { return ISO8859_1_UNESCAPE.clone(); } +private static final String[][] ISO8859_1_UNESCAPE = invert(ISO8859_1_ESCAPE); // http://www.w3.org/TR/REC-html40/sgml/entities.html -static final String[][] HTML40_EXTENDED_ESCAPE = { +public static String[][] HTML40_EXTENDED_ESCAPE() { return HTML40_EXTENDED_ESCAPE.clone(); } +private static final String[][] HTML40_EXTENDED_ESCAPE = { // !-- Latin Extended-B -- {\u0192, fnof;}, // latin small f with hook = function= florin, U+0192 ISOtech -- // !-- Greek -- @@ -324,29 +327,34 @@ {\u20AC, euro;}, // -- euro sign, U+20AC NEW -- }; -static final String[][] HTML40_EXTENDED_UNESCAPE = invert(HTML40_EXTENDED_ESCAPE); +public static String[][] HTML40_EXTENDED_UNESCAPE() { return HTML40_EXTENDED_UNESCAPE.clone(); } +private static final String[][] HTML40_EXTENDED_UNESCAPE = invert(HTML40_EXTENDED_ESCAPE); -static final String[][] BASIC_ESCAPE = { +public static String[][] BASIC_ESCAPE() { return BASIC_ESCAPE.clone(); } +private static final String[][] BASIC_ESCAPE = { {\, quot;}, // - double-quote {, amp;}, // - ampersand {, lt;},// - less-than {, gt;},// - greater-than }; -static final String[][] BASIC_UNESCAPE = invert(BASIC_ESCAPE); +public static String[][] BASIC_UNESCAPE() { return BASIC_UNESCAPE.clone(); } +private static final String[][] BASIC_UNESCAPE = invert(BASIC_ESCAPE); -static final String[][] APOS_ESCAPE = { +public static String[][] APOS_ESCAPE() { return APOS_ESCAPE.clone(); } +private static final String[][] APOS_ESCAPE = { {', apos;}, // XML apostrophe }; -static final String[][] APOS_UNESCAPE = invert(APOS_ESCAPE); +public static String[][] APOS_UNESCAPE() { return APOS_UNESCAPE.clone(); } +private static final String[][] APOS_UNESCAPE = invert(APOS_ESCAPE); /** * Used to invert an escape array into an unescape array * @param array String[][] to be inverted * @return String[][] inverted array */ -static String[][] invert(String[][] array) { +public static String[][] invert(String[][] array) { String[][] newarray = new String[array.length][2]; for(int i = 0; iarray.length; i++) { newarray[i][0] = array[i][1]; Modified: commons/proper/lang/trunk/src/java/org/apache/commons/lang/text/translate/EscapeUtils.java URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/java/org/apache/commons/lang/text/translate/EscapeUtils.java?rev
svn commit: r789589 - in /commons/proper/lang/trunk/src/java/org/apache/commons/lang/text/translate: EscapeUtils.java UnescapeUtils.java
Author: bayard Date: Tue Jun 30 07:04:06 2009 New Revision: 789589 URL: http://svn.apache.org/viewvc?rev=789589view=rev Log: Splitting out the \b \n \t \f \r Java ctrl chars as their own translator to help with the request in LANG-498 Modified: commons/proper/lang/trunk/src/java/org/apache/commons/lang/text/translate/EscapeUtils.java commons/proper/lang/trunk/src/java/org/apache/commons/lang/text/translate/UnescapeUtils.java Modified: commons/proper/lang/trunk/src/java/org/apache/commons/lang/text/translate/EscapeUtils.java URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/java/org/apache/commons/lang/text/translate/EscapeUtils.java?rev=789589r1=789588r2=789589view=diff == --- commons/proper/lang/trunk/src/java/org/apache/commons/lang/text/translate/EscapeUtils.java (original) +++ commons/proper/lang/trunk/src/java/org/apache/commons/lang/text/translate/EscapeUtils.java Tue Jun 30 07:04:06 2009 @@ -29,12 +29,7 @@ */ public class EscapeUtils { -public static final CharSequenceTranslator ESCAPE_JAVA = - new LookupTranslator( -new String[][] { - {\, \\\}, - {\\, }, - }).with( +public static final CharSequenceTranslator ESCAPE_JAVA_CTRL_CHARS = new LookupTranslator( new String[][] { {\b, \\b}, @@ -42,9 +37,18 @@ {\t, \\t}, {\f, \\f}, {\r, \\r} +}); + +public static final CharSequenceTranslator ESCAPE_JAVA = + new LookupTranslator( +new String[][] { + {\, \\\}, + {\\, }, }).with( - UnicodeEscaper.outsideOf(32, 0x7f) -)); +ESCAPE_JAVA_CTRL_CHARS + ).with( +UnicodeEscaper.outsideOf(32, 0x7f) +); public static final String escapeJava(String input) { return ESCAPE_JAVA.translate(input); @@ -59,14 +63,7 @@ {\\, }, {/, \\/} }), -new LookupTranslator( - new String[][] { -{\b, \\b}, -{\n, \\n}, -{\t, \\t}, -{\f, \\f}, -{\r, \\r} - }), +ESCAPE_JAVA_CTRL_CHARS, UnicodeEscaper.outsideOf(32, 0x7f) ); Modified: commons/proper/lang/trunk/src/java/org/apache/commons/lang/text/translate/UnescapeUtils.java URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/java/org/apache/commons/lang/text/translate/UnescapeUtils.java?rev=789589r1=789588r2=789589view=diff == --- commons/proper/lang/trunk/src/java/org/apache/commons/lang/text/translate/UnescapeUtils.java (original) +++ commons/proper/lang/trunk/src/java/org/apache/commons/lang/text/translate/UnescapeUtils.java Tue Jun 30 07:04:06 2009 @@ -29,20 +29,26 @@ */ public class UnescapeUtils { +public static final CharSequenceTranslator UNESCAPE_JAVA_CTRL_CHARS = +new LookupTranslator( + new String[][] { +{\\b, \b}, +{\\n, \n}, +{\\t, \t}, +{\\f, \f}, +{\\r, \r} + }); + // throw illegal character: \92 as an Exception if a \ on the end of the Java (as per the compiler)? public static final CharSequenceTranslator UNESCAPE_JAVA = new AggregateTranslator( new UnicodeUnescaper(), +UNESCAPE_JAVA_CTRL_CHARS, new LookupTranslator( new String[][] { {, \\}, {\\\, \}, {\\', '}, -{\\r, \r}, -{\\f, \f}, -{\\t, \t}, -{\\n, \n}, -{\\b, \b}, {\\, } }) );
svn commit: r789561 - /commons/proper/lang/trunk/src/java/org/apache/commons/lang/text/translate/EntityArrays.java
Author: bayard Date: Tue Jun 30 05:09:01 2009 New Revision: 789561 URL: http://svn.apache.org/viewvc?rev=789561view=rev Log: Added todo note Modified: commons/proper/lang/trunk/src/java/org/apache/commons/lang/text/translate/EntityArrays.java Modified: commons/proper/lang/trunk/src/java/org/apache/commons/lang/text/translate/EntityArrays.java URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/java/org/apache/commons/lang/text/translate/EntityArrays.java?rev=789561r1=789560r2=789561view=diff == --- commons/proper/lang/trunk/src/java/org/apache/commons/lang/text/translate/EntityArrays.java (original) +++ commons/proper/lang/trunk/src/java/org/apache/commons/lang/text/translate/EntityArrays.java Tue Jun 30 05:09:01 2009 @@ -22,6 +22,7 @@ * * @since 3.0 */ +// TODO: These need to be public - make methods to return them for security purposes? class EntityArrays { static final String[][] ISO8859_1_ESCAPE = {
svn commit: r789566 - in /commons/proper/lang/trunk/src/test/org/apache/commons/lang/text/translate: ./ LookupTranslatorTest.java
Author: bayard Date: Tue Jun 30 05:46:08 2009 New Revision: 789566 URL: http://svn.apache.org/viewvc?rev=789566view=rev Log: Adding a simple unit test for text translate. More needed, though StringEscapeUtils does do a good job of hitting a high level of coverage for these classes already. It's easier to debug when you have tighter testing. Added: commons/proper/lang/trunk/src/test/org/apache/commons/lang/text/translate/ commons/proper/lang/trunk/src/test/org/apache/commons/lang/text/translate/LookupTranslatorTest.java (with props) Added: commons/proper/lang/trunk/src/test/org/apache/commons/lang/text/translate/LookupTranslatorTest.java URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/test/org/apache/commons/lang/text/translate/LookupTranslatorTest.java?rev=789566view=auto == --- commons/proper/lang/trunk/src/test/org/apache/commons/lang/text/translate/LookupTranslatorTest.java (added) +++ commons/proper/lang/trunk/src/test/org/apache/commons/lang/text/translate/LookupTranslatorTest.java Tue Jun 30 05:46:08 2009 @@ -0,0 +1,39 @@ +/* + * 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.lang.text.translate; + +import junit.framework.TestCase; + +import java.io.StringWriter; +import java.io.IOException; + +/** + * Unit tests for {...@link org.apache.commons.lang.text.translate.LookupTranslator}. + */ +public class LookupTranslatorTest extends TestCase { + +public void testBasicLookup() throws IOException { +String input = one; +LookupTranslator lt = new LookupTranslator(new CharSequence[][] { { one, two } }); +StringWriter out = new StringWriter(); +int result = lt.translate(one, 0, out); +assertEquals(Incorrect codepoint consumption, 3, result); +assertEquals(Incorrect value, two, out.toString()); +} + +} Propchange: commons/proper/lang/trunk/src/test/org/apache/commons/lang/text/translate/LookupTranslatorTest.java -- svn:eol-style = native
svn commit: r789567 - /commons/proper/lang/trunk/src/java/org/apache/commons/lang/text/translate/LookupTranslator.java
Author: bayard Date: Tue Jun 30 05:47:39 2009 New Revision: 789567 URL: http://svn.apache.org/viewvc?rev=789567view=rev Log: Performance improvement. Switching from looping through a doubled array to using a Map. This probably costs more for simple cases like Java/EcmaScript/Xml, but makes up for it in the Html case. This gets performance of the testUnescapeHexCharsHtml method back down to near the same region as the original code Modified: commons/proper/lang/trunk/src/java/org/apache/commons/lang/text/translate/LookupTranslator.java Modified: commons/proper/lang/trunk/src/java/org/apache/commons/lang/text/translate/LookupTranslator.java URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/java/org/apache/commons/lang/text/translate/LookupTranslator.java?rev=789567r1=789566r2=789567view=diff == --- commons/proper/lang/trunk/src/java/org/apache/commons/lang/text/translate/LookupTranslator.java (original) +++ commons/proper/lang/trunk/src/java/org/apache/commons/lang/text/translate/LookupTranslator.java Tue Jun 30 05:47:39 2009 @@ -18,14 +18,18 @@ import java.io.IOException; import java.io.Writer; +import java.util.HashMap; /** * Translates a value using a lookup table. * @since 3.0 */ +// TODO: Replace with a RegexLookup? Performance test. public class LookupTranslator extends CharSequenceTranslator { -protected CharSequence[][] lookup; +private HashMapCharSequence, CharSequence lookupMap; +private int shortest = Integer.MAX_VALUE; +private int longest = 0; /** * Define the lookup table to be used in translation @@ -33,18 +37,34 @@ * @param CharSequence[][] Lookup table of size [*][2] */ public LookupTranslator(CharSequence[][] lookup) { -this.lookup = lookup; +lookupMap = new HashMapCharSequence, CharSequence(); +for(CharSequence[] seq : lookup) { +this.lookupMap.put(seq[0], seq[1]); +int sz = seq[0].length(); +if(sz shortest) { +shortest = sz; +} +if(sz longest) { +longest = sz; +} +} } /** * {...@inheritdoc} */ public int translate(CharSequence input, int index, Writer out) throws IOException { -CharSequence subsequence = input.subSequence(index, input.length()); -for(CharSequence[] seq : lookup) { -if( subsequence.toString().startsWith(seq[0].toString()) ) { -out.write(seq[1].toString()); -return seq[0].length(); +int max = longest; +if(index + longest input.length()) { +max = input.length() - index; +} +// descend so as to get a greedy algorithm +for(int i=max; i = shortest; i--) { +CharSequence subSeq = input.subSequence(index, index + i); +CharSequence result = lookupMap.get(subSeq); +if(result != null) { +out.write(result.toString()); +return i; } } return 0;
svn commit: r788275 - /commons/proper/lang/trunk/src/java/org/apache/commons/lang/Validate.java
Author: bayard Date: Thu Jun 25 06:58:11 2009 New Revision: 788275 URL: http://svn.apache.org/viewvc?rev=788275view=rev Log: Refactoring to avoid code duplication - LANG-458 Modified: commons/proper/lang/trunk/src/java/org/apache/commons/lang/Validate.java Modified: commons/proper/lang/trunk/src/java/org/apache/commons/lang/Validate.java URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/java/org/apache/commons/lang/Validate.java?rev=788275r1=788274r2=788275view=diff == --- commons/proper/lang/trunk/src/java/org/apache/commons/lang/Validate.java (original) +++ commons/proper/lang/trunk/src/java/org/apache/commons/lang/Validate.java Thu Jun 25 06:58:11 2009 @@ -218,9 +218,7 @@ * @throws IllegalArgumentException if the object is codenull/code */ public static void notNull(Object object) { -if (object == null) { -throw new IllegalArgumentException(The validated object is null); -} +notNull(object, The validated object is null); } // notEmpty array
svn commit: r788276 - in /commons/proper/lang/trunk/src: java/org/apache/commons/lang/math/NumberUtils.java test/org/apache/commons/lang/math/NumberUtilsTest.java
Author: bayard Date: Thu Jun 25 07:09:30 2009 New Revision: 788276 URL: http://svn.apache.org/viewvc?rev=788276view=rev Log: Applying patch from LANG-461 from Vincent Ricard to add toByte and toShort methods to NumberUtils Modified: commons/proper/lang/trunk/src/java/org/apache/commons/lang/math/NumberUtils.java commons/proper/lang/trunk/src/test/org/apache/commons/lang/math/NumberUtilsTest.java Modified: commons/proper/lang/trunk/src/java/org/apache/commons/lang/math/NumberUtils.java URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/java/org/apache/commons/lang/math/NumberUtils.java?rev=788276r1=788275r2=788276view=diff == --- commons/proper/lang/trunk/src/java/org/apache/commons/lang/math/NumberUtils.java (original) +++ commons/proper/lang/trunk/src/java/org/apache/commons/lang/math/NumberUtils.java Thu Jun 25 07:09:30 2009 @@ -288,6 +288,101 @@ } } + //--- + /** + * pConvert a codeString/code to a codebyte/code, returning + * codezero/code if the conversion fails./p + * + * pIf the string is codenull/code, codezero/code is returned./p + * + * pre + * NumberUtils.toByte(null) = 0 + * NumberUtils.toByte() = 0 + * NumberUtils.toByte(1) = 1 + * /pre + * + * @param str the string to convert, may be null + * @return the byte represented by the string, or codezero/code if + * conversion fails + */ +public static byte toByte(String str) { +return toByte(str, (byte) 0); +} + +/** + * pConvert a codeString/code to a codebyte/code, returning a + * default value if the conversion fails./p + * + * pIf the string is codenull/code, the default value is returned./p + * + * pre + * NumberUtils.toByte(null, 1) = 1 + * NumberUtils.toByte(, 1) = 1 + * NumberUtils.toByte(1, 0) = 1 + * /pre + * + * @param str the string to convert, may be null + * @param defaultValue the default value + * @return the byte represented by the string, or the default if conversion fails + */ +public static byte toByte(String str, byte defaultValue) { +if(str == null) { +return defaultValue; +} +try { +return Byte.parseByte(str); +} catch (NumberFormatException nfe) { +return defaultValue; +} +} + +/** + * pConvert a codeString/code to a codeshort/code, returning + * codezero/code if the conversion fails./p + * + * pIf the string is codenull/code, codezero/code is returned./p + * + * pre + * NumberUtils.toShort(null) = 0 + * NumberUtils.toShort() = 0 + * NumberUtils.toShort(1) = 1 + * /pre + * + * @param str the string to convert, may be null + * @return the short represented by the string, or codezero/code if + * conversion fails + */ +public static short toShort(String str) { +return toShort(str, (short) 0); +} + +/** + * pConvert a codeString/code to an codeshort/code, returning a + * default value if the conversion fails./p + * + * pIf the string is codenull/code, the default value is returned./p + * + * pre + * NumberUtils.toShort(null, 1) = 1 + * NumberUtils.toShort(, 1) = 1 + * NumberUtils.toShort(1, 0) = 1 + * /pre + * + * @param str the string to convert, may be null + * @param defaultValue the default value + * @return the short represented by the string, or the default if conversion fails + */ +public static short toShort(String str, short defaultValue) { +if(str == null) { +return defaultValue; +} +try { +return Short.parseShort(str); +} catch (NumberFormatException nfe) { +return defaultValue; +} +} + //--- // must handle Long, Float, Integer, Float, Short, // BigDecimal, BigInteger and Byte Modified: commons/proper/lang/trunk/src/test/org/apache/commons/lang/math/NumberUtilsTest.java URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/test/org/apache/commons/lang/math/NumberUtilsTest.java?rev=788276r1=788275r2=788276view=diff == --- commons/proper/lang/trunk/src/test/org/apache/commons/lang/math/NumberUtilsTest.java (original) +++ commons/proper/lang/trunk/src/test/org/apache/commons/lang/math/NumberUtilsTest.java Thu Jun 25 07:09:30 2009 @@ -150,6 +150,42 @@ assertTrue(toDouble(String,int) 2 failed, NumberUtils.toDouble(a, 5.0d) == 5.0d); } + /** + * Test for {...@link NumberUtils#toByte(String)}. + */ +public void
svn commit: r788564 - in /commons/proper/lang/trunk: pom.xml xdocs/changes.xml
Author: bayard Date: Fri Jun 26 03:42:27 2009 New Revision: 788564 URL: http://svn.apache.org/viewvc?rev=788564view=rev Log: Adding changes report and filling out v1.0.1 Modified: commons/proper/lang/trunk/pom.xml commons/proper/lang/trunk/xdocs/changes.xml Modified: commons/proper/lang/trunk/pom.xml URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/pom.xml?rev=788564r1=788563r2=788564view=diff == --- commons/proper/lang/trunk/pom.xml (original) +++ commons/proper/lang/trunk/pom.xml Fri Jun 26 03:42:27 2009 @@ -447,6 +447,22 @@ reporting plugins +plugin + groupIdorg.apache.maven.plugins/groupId + artifactIdmaven-changes-plugin/artifactId + version2.0/version + configuration +xmlPath${basedir}/xdocs/changes.xml/xmlPath +issueLinkTemplate%URL%/%ISSUE%/issueLinkTemplate + /configuration + reportSets +reportSet + reports + reportchanges-report/report + /reports +/reportSet + /reportSets +/plugin plugin artifactIdmaven-checkstyle-plugin/artifactId version2.1/version @@ -456,6 +472,7 @@ /configuration /plugin !-- Requires setting 'export MAVEN_OPTS=-Xmx512m ' -- + !-- plugin groupIdorg.codehaus.mojo/groupId artifactIdfindbugs-maven-plugin/artifactId @@ -466,6 +483,7 @@ excludeFilterFilefindbugs-exclude-filter.xml/excludeFilterFile /configuration /plugin + -- plugin groupIdorg.codehaus.mojo/groupId artifactIdcobertura-maven-plugin/artifactId Modified: commons/proper/lang/trunk/xdocs/changes.xml URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/xdocs/changes.xml?rev=788564r1=788563r2=788564view=diff == --- commons/proper/lang/trunk/xdocs/changes.xml (original) +++ commons/proper/lang/trunk/xdocs/changes.xml Fri Jun 26 03:42:27 2009 @@ -21,36 +21,33 @@ /properties body - release version=3.0 date=Unreleased - description=Backwards incompatible update of Commons Lang to Java 5 + release version=3.0 date=Unreleased description=Backwards incompatible update of Commons Lang to Java 5 /release - release version=2.4 date=2008-03-18 - description= + release version=2.4 date=2008-03-18 description= /release - release version=2.3 date=2007-02-13 - description= + release version=2.3 date=2007-02-13 description= /release - release version=2.2 date=2006-10-04 - description= + release version=2.2 date=2006-10-04 description= /release - release version=2.1 date=2005-06-13 - description= + release version=2.1 date=2005-06-13 description= /release - release version=2.0 date=2003-09-02 - description= + release version=2.0 date=2003-09-02 description= /release - release version=1.0.1 date=2002-11-25 - description=Quick bugfix to 1.0 + release version=1.0.1 date=2002-11-25 description=Quick bugfix to 1.0 +action type=fixNumberRange.getMaximum returns minimum/action +action type=fixEnum constructor validations/action +action type=fixNestableException/Delegate is not serializable/action +action type=fixsplit using null and max less than actual token count adds null/action +action type=addExceptionUtils cannot handle J2EE-Exception in a default way/action /release - release version=1.0 date=2002-10-04 - description=First release of Commons Lang + release version=1.0 date=2002-10-04 description=First release of Commons Lang /release /body
svn commit: r788243 - /commons/proper/lang/trunk/src/java/org/apache/commons/lang/text/translate/CharSequenceTranslator.java
Author: bayard Date: Thu Jun 25 03:54:03 2009 New Revision: 788243 URL: http://svn.apache.org/viewvc?rev=788243view=rev Log: Adding a method to chain translators together. I've gone back and forth on the name, currently with() is my preference. So you could say: BASIC_XML.with(HTML4_ENTITIES). cf LANG-505 Modified: commons/proper/lang/trunk/src/java/org/apache/commons/lang/text/translate/CharSequenceTranslator.java Modified: commons/proper/lang/trunk/src/java/org/apache/commons/lang/text/translate/CharSequenceTranslator.java URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/java/org/apache/commons/lang/text/translate/CharSequenceTranslator.java?rev=788243r1=788242r2=788243view=diff == --- commons/proper/lang/trunk/src/java/org/apache/commons/lang/text/translate/CharSequenceTranslator.java (original) +++ commons/proper/lang/trunk/src/java/org/apache/commons/lang/text/translate/CharSequenceTranslator.java Thu Jun 25 03:54:03 2009 @@ -104,6 +104,17 @@ } /** + * Helper method to create a merger of this translator with another set of + * translators. Useful in customizing the standard functionality. + */ +public final CharSequenceTranslator with(CharSequenceTranslator... translators) { +CharSequenceTranslator[] newArray = new CharSequenceTranslator[translators.length + 1]; +newArray[0] = this; +System.arraycopy(translators, 0, newArray, 1, translators.length); +return new AggregateTranslator(newArray); +} + +/** * pReturns an upper case hexadecimal codeString/code for the given * character./p *
svn commit: r788245 - /commons/proper/lang/trunk/src/java/org/apache/commons/lang/text/translate/EscapeUtils.java
Author: bayard Date: Thu Jun 25 03:55:18 2009 New Revision: 788245 URL: http://svn.apache.org/viewvc?rev=788245view=rev Log: Updating ESCAPE_JAVA to use the new .with() approach and to fold the two unicode escape methods into one. Modified: commons/proper/lang/trunk/src/java/org/apache/commons/lang/text/translate/EscapeUtils.java Modified: commons/proper/lang/trunk/src/java/org/apache/commons/lang/text/translate/EscapeUtils.java URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/java/org/apache/commons/lang/text/translate/EscapeUtils.java?rev=788245r1=788244r2=788245view=diff == --- commons/proper/lang/trunk/src/java/org/apache/commons/lang/text/translate/EscapeUtils.java (original) +++ commons/proper/lang/trunk/src/java/org/apache/commons/lang/text/translate/EscapeUtils.java Thu Jun 25 03:55:18 2009 @@ -30,15 +30,21 @@ public class EscapeUtils { public static final CharSequenceTranslator ESCAPE_JAVA = -new AggregateTranslator( -new LookupTranslator( - new String[][] { -{\, \\\}, -{\\, } - }), -new EscapeLowAsciiAsUnicode(), -new EscapeNonAsciiAsUnicode() -); + new LookupTranslator( +new String[][] { + {\, \\\}, + {\\, }, + }).with( + new LookupTranslator( +new String[][] { + {\b, \\b}, + {\n, \\n}, + {\t, \\t}, + {\f, \\f}, + {\r, \\r} + }).with( + UnicodeEscaper.outsideOf(32, 0x7f) +)); public static final String escapeJava(String input) { return ESCAPE_JAVA.translate(input);
svn commit: r788254 - /commons/proper/lang/trunk/src/test/org/apache/commons/lang/StringEscapeUtilsTest.java
Author: bayard Date: Thu Jun 25 04:52:32 2009 New Revision: 788254 URL: http://svn.apache.org/viewvc?rev=788254view=rev Log: Indentation fix Modified: commons/proper/lang/trunk/src/test/org/apache/commons/lang/StringEscapeUtilsTest.java Modified: commons/proper/lang/trunk/src/test/org/apache/commons/lang/StringEscapeUtilsTest.java URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/test/org/apache/commons/lang/StringEscapeUtilsTest.java?rev=788254r1=788253r2=788254view=diff == --- commons/proper/lang/trunk/src/test/org/apache/commons/lang/StringEscapeUtilsTest.java (original) +++ commons/proper/lang/trunk/src/test/org/apache/commons/lang/StringEscapeUtilsTest.java Thu Jun 25 04:52:32 2009 @@ -231,7 +231,7 @@ assertEquals(message, expected, StringEscapeUtils.escapeHtml(original)); StringWriter sw = new StringWriter(); try { -StringEscapeUtils.escapeHtml(sw, original); +StringEscapeUtils.escapeHtml(sw, original); } catch (IOException e) { } String actual = original == null ? null : sw.toString(); @@ -248,7 +248,7 @@ StringWriter sw = new StringWriter(); try { -StringEscapeUtils.unescapeHtml(sw, original); +StringEscapeUtils.unescapeHtml(sw, original); } catch (IOException e) { } String actual = original == null ? null : sw.toString();
svn commit: r788255 - /commons/proper/lang/trunk/src/java/org/apache/commons/lang/text/translate/UnicodeEscaper.java
Author: bayard Date: Thu Jun 25 04:54:48 2009 New Revision: 788255 URL: http://svn.apache.org/viewvc?rev=788255view=rev Log: Adding some todo notes Modified: commons/proper/lang/trunk/src/java/org/apache/commons/lang/text/translate/UnicodeEscaper.java Modified: commons/proper/lang/trunk/src/java/org/apache/commons/lang/text/translate/UnicodeEscaper.java URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/java/org/apache/commons/lang/text/translate/UnicodeEscaper.java?rev=788255r1=788254r2=788255view=diff == --- commons/proper/lang/trunk/src/java/org/apache/commons/lang/text/translate/UnicodeEscaper.java (original) +++ commons/proper/lang/trunk/src/java/org/apache/commons/lang/text/translate/UnicodeEscaper.java Thu Jun 25 04:54:48 2009 @@ -20,7 +20,7 @@ import java.io.Writer; /** - * Translates codepoints to their unicode escape value. + * Translates codepoints to their unicode escaped value. * @since 3.0 */ public class UnicodeEscaper extends CodePointTranslator { @@ -66,6 +66,8 @@ } } +// TODO: Handle multiple u's per Java spec +// TODO: Handle potential + sign per various unicode escape implementations if (codepoint 0x) { // TODO: Figure out what to do. Output as two unicodes? // Does this make this a Java-specific output class?
svn commit: r788256 - in /commons/proper/lang/trunk/src/java/org/apache/commons/lang/text/translate: EscapeNonAsciiAsNumericEntity.java EscapeUtils.java NumericEntityEscaper.java
Author: bayard Date: Thu Jun 25 04:56:18 2009 New Revision: 788256 URL: http://svn.apache.org/viewvc?rev=788256view=rev Log: Replacing the NonAsciiAsNumericEntity class with a more generic NumericEntityEscaper. cf LANG-505 Added: commons/proper/lang/trunk/src/java/org/apache/commons/lang/text/translate/NumericEntityEscaper.java (with props) Removed: commons/proper/lang/trunk/src/java/org/apache/commons/lang/text/translate/EscapeNonAsciiAsNumericEntity.java Modified: commons/proper/lang/trunk/src/java/org/apache/commons/lang/text/translate/EscapeUtils.java Modified: commons/proper/lang/trunk/src/java/org/apache/commons/lang/text/translate/EscapeUtils.java URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/java/org/apache/commons/lang/text/translate/EscapeUtils.java?rev=788256r1=788255r2=788256view=diff == --- commons/proper/lang/trunk/src/java/org/apache/commons/lang/text/translate/EscapeUtils.java (original) +++ commons/proper/lang/trunk/src/java/org/apache/commons/lang/text/translate/EscapeUtils.java Thu Jun 25 04:56:18 2009 @@ -71,7 +71,7 @@ new AggregateTranslator( new LookupTranslator(EntityArrays.BASIC_ESCAPE), new LookupTranslator(EntityArrays.APOS_ESCAPE), -new EscapeNonAsciiAsNumericEntity() +NumericEntityEscaper.above(0x7f) ); public static final String escapeXml(String input) { @@ -82,7 +82,7 @@ new AggregateTranslator( new LookupTranslator(EntityArrays.BASIC_ESCAPE), new LookupTranslator(EntityArrays.ISO8859_1_ESCAPE), -new EscapeNonAsciiAsNumericEntity() +NumericEntityEscaper.above(0x7f) ); public static final String escapeHtml3(String input) { @@ -94,7 +94,7 @@ new LookupTranslator(EntityArrays.BASIC_ESCAPE), new LookupTranslator(EntityArrays.ISO8859_1_ESCAPE), new LookupTranslator(EntityArrays.HTML40_EXTENDED_ESCAPE), -new EscapeNonAsciiAsNumericEntity() +NumericEntityEscaper.above(0x7f) ); public static final String escapeHtml4(String input) { Added: commons/proper/lang/trunk/src/java/org/apache/commons/lang/text/translate/NumericEntityEscaper.java URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/java/org/apache/commons/lang/text/translate/NumericEntityEscaper.java?rev=788256view=auto == --- commons/proper/lang/trunk/src/java/org/apache/commons/lang/text/translate/NumericEntityEscaper.java (added) +++ commons/proper/lang/trunk/src/java/org/apache/commons/lang/text/translate/NumericEntityEscaper.java Thu Jun 25 04:56:18 2009 @@ -0,0 +1,75 @@ +/* + * 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.lang.text.translate; + +import java.io.IOException; +import java.io.Writer; + +/** + * Translates codepoints to their XML numeric entity escaped value. + * @since 3.0 + */ +public class NumericEntityEscaper extends CodePointTranslator { + +private int below = 0; +private int above = Integer.MAX_VALUE; +private boolean between = true; + +public static NumericEntityEscaper below(int codepoint) { +return outsideOf(codepoint, Integer.MAX_VALUE); +} + +public static NumericEntityEscaper above(int codepoint) { +return outsideOf(0, codepoint); +} + +public static NumericEntityEscaper between(int codepointLow, int codepointHigh) { +NumericEntityEscaper escaper = new NumericEntityEscaper(); +escaper.above = codepointHigh; +escaper.below = codepointLow; +return escaper; +} + +public static NumericEntityEscaper outsideOf(int codepointLow, int codepointHigh) { +NumericEntityEscaper escaper = new NumericEntityEscaper(); +escaper.above = codepointHigh; +escaper.below = codepointLow; +escaper.between = false; +return escaper; +} + +/** + * {...@inheritdoc} + */ +public boolean translate(int codepoint, Writer out) throws IOException { +if(between
svn commit: r788257 - /commons/proper/lang/trunk/src/java/org/apache/commons/lang/text/translate/UnicodeEscaper.java
Author: bayard Date: Thu Jun 25 04:57:19 2009 New Revision: 788257 URL: http://svn.apache.org/viewvc?rev=788257view=rev Log: Fixing bug in below/above implementations found while implementing NumericEntityEscaper Modified: commons/proper/lang/trunk/src/java/org/apache/commons/lang/text/translate/UnicodeEscaper.java Modified: commons/proper/lang/trunk/src/java/org/apache/commons/lang/text/translate/UnicodeEscaper.java URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/java/org/apache/commons/lang/text/translate/UnicodeEscaper.java?rev=788257r1=788256r2=788257view=diff == --- commons/proper/lang/trunk/src/java/org/apache/commons/lang/text/translate/UnicodeEscaper.java (original) +++ commons/proper/lang/trunk/src/java/org/apache/commons/lang/text/translate/UnicodeEscaper.java Thu Jun 25 04:57:19 2009 @@ -30,11 +30,11 @@ private boolean between = true; public static UnicodeEscaper below(int codepoint) { -return between(0, codepoint); +return outsideOf(codepoint, Integer.MAX_VALUE); } public static UnicodeEscaper above(int codepoint) { -return between(codepoint, Integer.MAX_VALUE); +return outsideOf(0, codepoint); } public static UnicodeEscaper outsideOf(int codepointLow, int codepointHigh) {
svn commit: r788259 - in /commons/proper/lang/trunk/src/java/org/apache/commons/lang/text/translate: EscapeLowAsciiAsUnicode.java EscapeNonAsciiAsUnicode.java EscapeUtils.java
Author: bayard Date: Thu Jun 25 05:00:39 2009 New Revision: 788259 URL: http://svn.apache.org/viewvc?rev=788259view=rev Log: Removing unnecessary Escape*AsciiAsUnicode classes. UnicodeEscaper now handles the range concept directly and the ctrl character lookup table is now a direct LookupTranslator defined in EscapeUtils. cf LANG-505 Removed: commons/proper/lang/trunk/src/java/org/apache/commons/lang/text/translate/EscapeLowAsciiAsUnicode.java commons/proper/lang/trunk/src/java/org/apache/commons/lang/text/translate/EscapeNonAsciiAsUnicode.java Modified: commons/proper/lang/trunk/src/java/org/apache/commons/lang/text/translate/EscapeUtils.java Modified: commons/proper/lang/trunk/src/java/org/apache/commons/lang/text/translate/EscapeUtils.java URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/java/org/apache/commons/lang/text/translate/EscapeUtils.java?rev=788259r1=788258r2=788259view=diff == --- commons/proper/lang/trunk/src/java/org/apache/commons/lang/text/translate/EscapeUtils.java (original) +++ commons/proper/lang/trunk/src/java/org/apache/commons/lang/text/translate/EscapeUtils.java Thu Jun 25 05:00:39 2009 @@ -59,8 +59,15 @@ {\\, }, {/, \\/} }), -new EscapeLowAsciiAsUnicode(), -new EscapeNonAsciiAsUnicode() +new LookupTranslator( + new String[][] { +{\b, \\b}, +{\n, \\n}, +{\t, \\t}, +{\f, \\f}, +{\r, \\r} + }), +UnicodeEscaper.outsideOf(32, 0x7f) ); public static final String escapeEcmaScript(String input) {
svn commit: r788263 - in /commons/proper/lang/trunk/src/java/org/apache/commons/lang/mutable: Mutable.java MutableObject.java
Author: bayard Date: Thu Jun 25 05:25:23 2009 New Revision: 788263 URL: http://svn.apache.org/viewvc?rev=788263view=rev Log: Generifying the general Mutable, and the underlying MutableObject. This then allows for typed checking of a MutableBigDecimal for example as per LANG-276 Modified: commons/proper/lang/trunk/src/java/org/apache/commons/lang/mutable/Mutable.java commons/proper/lang/trunk/src/java/org/apache/commons/lang/mutable/MutableObject.java Modified: commons/proper/lang/trunk/src/java/org/apache/commons/lang/mutable/Mutable.java URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/java/org/apache/commons/lang/mutable/Mutable.java?rev=788263r1=788262r2=788263view=diff == --- commons/proper/lang/trunk/src/java/org/apache/commons/lang/mutable/Mutable.java (original) +++ commons/proper/lang/trunk/src/java/org/apache/commons/lang/mutable/Mutable.java Thu Jun 25 05:25:23 2009 @@ -30,14 +30,14 @@ * @since 2.1 * @version $Id$ */ -public interface Mutable { +public interface MutableT { /** * Gets the value of this mutable. * * @return the stored value */ -Object getValue(); +T getValue(); /** * Sets the value of this mutable. @@ -49,6 +49,6 @@ * @throws ClassCastException * if the type is invalid */ -void setValue(Object value); +void setValue(T value); } Modified: commons/proper/lang/trunk/src/java/org/apache/commons/lang/mutable/MutableObject.java URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/java/org/apache/commons/lang/mutable/MutableObject.java?rev=788263r1=788262r2=788263view=diff == --- commons/proper/lang/trunk/src/java/org/apache/commons/lang/mutable/MutableObject.java (original) +++ commons/proper/lang/trunk/src/java/org/apache/commons/lang/mutable/MutableObject.java Thu Jun 25 05:25:23 2009 @@ -25,7 +25,7 @@ * @since 2.1 * @version $Id$ */ -public class MutableObject implements Mutable, Serializable { +public class MutableObjectT implements MutableT, Serializable { /** * Required for serialization support. @@ -35,7 +35,7 @@ private static final long serialVersionUID = 86241875189L; /** The mutable value. */ -private Object value; +private T value; /** * Constructs a new MutableObject with the default value of codenull/code. @@ -50,7 +50,7 @@ * @param value *a value. */ -public MutableObject(Object value) { +public MutableObject(T value) { super(); this.value = value; } @@ -61,7 +61,7 @@ * * @return the value */ -public Object getValue() { +public T getValue() { return this.value; } @@ -71,27 +71,27 @@ * @param value *the value to set */ -public void setValue(Object value) { +public void setValue(T value) { this.value = value; } //--- /** * Compares this object against the specified object. The result is codetrue/code if and only if the argument - * is not codenull/code and is a codeMutableObject/code object that contains the same codeObject/code + * is not codenull/code and is a codeMutableObject/code object that contains the same codeT/code * value as this object. * * @param obj *the object to compare with. * @return codetrue/code if the objects are the same; codefalse/code otherwise. */ -@Override -public boolean equals(Object obj) { -if (obj instanceof MutableObject) { -Object other = ((MutableObject) obj).value; -return value == other || (value != null value.equals(other)); +public boolean equals(MutableObjectT obj) { +if(obj == null) { +return false; } -return false; + +T other = obj.value; +return value == other || (value != null value.equals(other)); } /**
svn commit: r787560 [2/2] - in /commons/proper/lang/trunk: ./ src/java/org/apache/commons/lang/ src/java/org/apache/commons/lang/text/translate/ src/test/org/apache/commons/lang/
Modified: commons/proper/lang/trunk/src/test/org/apache/commons/lang/StringEscapeUtilsTest.java URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/test/org/apache/commons/lang/StringEscapeUtilsTest.java?rev=787560r1=787559r2=787560view=diff == --- commons/proper/lang/trunk/src/test/org/apache/commons/lang/StringEscapeUtilsTest.java (original) +++ commons/proper/lang/trunk/src/test/org/apache/commons/lang/StringEscapeUtilsTest.java Tue Jun 23 06:15:50 2009 @@ -154,7 +154,7 @@ assertUnescapeJava(\ntest\b, \\ntest\\b); assertUnescapeJava(\u123425foo\ntest\b, \\u123425foo\\ntest\\b); assertUnescapeJava('\foo\teste\r, \\'\\foo\\teste\\r); -assertUnescapeJava(\\, \\); +assertUnescapeJava(, \\); //foo assertUnescapeJava(lowercase unicode, \uABCDx, \\uabcdx); assertUnescapeJava(uppercase unicode, \uABCDx, \\uABCDx);
svn commit: r787893 - in /commons/proper/lang/trunk/src/java/org/apache/commons/lang/reflect: ConstructorUtils.java FieldUtils.java MemberUtils.java MethodUtils.java package.html
Author: bayard Date: Wed Jun 24 03:59:23 2009 New Revision: 787893 URL: http://svn.apache.org/viewvc?rev=787893view=rev Log: Updating the @since as I don't expect a 2.5 Modified: commons/proper/lang/trunk/src/java/org/apache/commons/lang/reflect/ConstructorUtils.java commons/proper/lang/trunk/src/java/org/apache/commons/lang/reflect/FieldUtils.java commons/proper/lang/trunk/src/java/org/apache/commons/lang/reflect/MemberUtils.java commons/proper/lang/trunk/src/java/org/apache/commons/lang/reflect/MethodUtils.java commons/proper/lang/trunk/src/java/org/apache/commons/lang/reflect/package.html Modified: commons/proper/lang/trunk/src/java/org/apache/commons/lang/reflect/ConstructorUtils.java URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/java/org/apache/commons/lang/reflect/ConstructorUtils.java?rev=787893r1=787892r2=787893view=diff == --- commons/proper/lang/trunk/src/java/org/apache/commons/lang/reflect/ConstructorUtils.java (original) +++ commons/proper/lang/trunk/src/java/org/apache/commons/lang/reflect/ConstructorUtils.java Wed Jun 24 03:59:23 2009 @@ -46,7 +46,7 @@ * @author Jan Sorensen * @author Robert Burrell Donkin * @author Rodney Waldhoff - * @since 2.5 + * @since 3.0 * @version $Id$ */ public class ConstructorUtils { Modified: commons/proper/lang/trunk/src/java/org/apache/commons/lang/reflect/FieldUtils.java URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/java/org/apache/commons/lang/reflect/FieldUtils.java?rev=787893r1=787892r2=787893view=diff == --- commons/proper/lang/trunk/src/java/org/apache/commons/lang/reflect/FieldUtils.java (original) +++ commons/proper/lang/trunk/src/java/org/apache/commons/lang/reflect/FieldUtils.java Wed Jun 24 03:59:23 2009 @@ -32,7 +32,7 @@ * * @author Stephen Colebourne * @author Matt Benson - * @since 2.5 + * @since 3.0 * @version $Id$ */ public class FieldUtils { Modified: commons/proper/lang/trunk/src/java/org/apache/commons/lang/reflect/MemberUtils.java URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/java/org/apache/commons/lang/reflect/MemberUtils.java?rev=787893r1=787892r2=787893view=diff == --- commons/proper/lang/trunk/src/java/org/apache/commons/lang/reflect/MemberUtils.java (original) +++ commons/proper/lang/trunk/src/java/org/apache/commons/lang/reflect/MemberUtils.java Wed Jun 24 03:59:23 2009 @@ -31,7 +31,7 @@ * * @author Steve Cohen * @author Matt Benson - * @since 2.5 + * @since 3.0 * @version $Id$ */ abstract class MemberUtils { Modified: commons/proper/lang/trunk/src/java/org/apache/commons/lang/reflect/MethodUtils.java URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/java/org/apache/commons/lang/reflect/MethodUtils.java?rev=787893r1=787892r2=787893view=diff == --- commons/proper/lang/trunk/src/java/org/apache/commons/lang/reflect/MethodUtils.java (original) +++ commons/proper/lang/trunk/src/java/org/apache/commons/lang/reflect/MethodUtils.java Wed Jun 24 03:59:23 2009 @@ -50,7 +50,7 @@ * @author Robert Burrell Donkin * @author Niall Pemberton * @author Matt Benson - * @since 2.5 + * @since 3.0 * @version $Id$ */ public class MethodUtils { Modified: commons/proper/lang/trunk/src/java/org/apache/commons/lang/reflect/package.html URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/java/org/apache/commons/lang/reflect/package.html?rev=787893r1=787892r2=787893view=diff == --- commons/proper/lang/trunk/src/java/org/apache/commons/lang/reflect/package.html (original) +++ commons/proper/lang/trunk/src/java/org/apache/commons/lang/reflect/package.html Wed Jun 24 03:59:23 2009 @@ -23,6 +23,6 @@ /head body Accumulates common high-level uses of the codejava.lang.reflect/code APIs. -...@since 2.5 +...@since 3.0 /body /html
svn commit: r787895 - in /commons/proper/lang/trunk/src: java/org/apache/commons/lang/IntHashMap.java test/org/apache/commons/lang/IntHashMapTest.java test/org/apache/commons/lang/LangTestSuite.java
Author: bayard Date: Wed Jun 24 04:01:35 2009 New Revision: 787895 URL: http://svn.apache.org/viewvc?rev=787895view=rev Log: Removing IntHashMap. Without Entities it's not needed. Removed: commons/proper/lang/trunk/src/java/org/apache/commons/lang/IntHashMap.java commons/proper/lang/trunk/src/test/org/apache/commons/lang/IntHashMapTest.java Modified: commons/proper/lang/trunk/src/test/org/apache/commons/lang/LangTestSuite.java Modified: commons/proper/lang/trunk/src/test/org/apache/commons/lang/LangTestSuite.java URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/test/org/apache/commons/lang/LangTestSuite.java?rev=787895r1=787894r2=787895view=diff == --- commons/proper/lang/trunk/src/test/org/apache/commons/lang/LangTestSuite.java (original) +++ commons/proper/lang/trunk/src/test/org/apache/commons/lang/LangTestSuite.java Wed Jun 24 04:01:35 2009 @@ -65,7 +65,6 @@ suite.addTest(EnumUtilsTest.suite()); suite.addTest(IllegalClassExceptionTest.suite()); suite.addTest(IncompleteArgumentExceptionTest.suite()); -suite.addTest(IntHashMapTest.suite()); suite.addTest(LocaleUtilsTest.suite()); suite.addTest(NotImplementedExceptionTest.suite()); suite.addTest(NullArgumentExceptionTest.suite());
svn commit: r787896 - in /commons/proper/lang/trunk/src/test/org/apache/commons/lang: ./ builder/ exception/ math/ mutable/ reflect/ text/ time/
Author: bayard Date: Wed Jun 24 04:03:36 2009 New Revision: 787896 URL: http://svn.apache.org/viewvc?rev=787896view=rev Log: Removing Suite classes per agreement on mailing list back in March Removed: commons/proper/lang/trunk/src/test/org/apache/commons/lang/AllLangTestSuite.java commons/proper/lang/trunk/src/test/org/apache/commons/lang/LangTestSuite.java commons/proper/lang/trunk/src/test/org/apache/commons/lang/builder/BuilderTestSuite.java commons/proper/lang/trunk/src/test/org/apache/commons/lang/exception/ExceptionTestSuite.java commons/proper/lang/trunk/src/test/org/apache/commons/lang/math/MathTestSuite.java commons/proper/lang/trunk/src/test/org/apache/commons/lang/mutable/MutableTestSuite.java commons/proper/lang/trunk/src/test/org/apache/commons/lang/reflect/ReflectTestSuite.java commons/proper/lang/trunk/src/test/org/apache/commons/lang/text/TextTestSuite.java commons/proper/lang/trunk/src/test/org/apache/commons/lang/time/TimeTestSuite.java
svn commit: r787897 - in /commons/proper/lang/trunk: build.xml default.properties
Author: bayard Date: Wed Jun 24 04:04:15 2009 New Revision: 787897 URL: http://svn.apache.org/viewvc?rev=787897view=rev Log: Removing Ant build system. Already out of date, and broken with the suites gone Removed: commons/proper/lang/trunk/build.xml commons/proper/lang/trunk/default.properties