Add since tags for 3.2

git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/collections/trunk@348013 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Stephen Colebourne 2005-11-21 23:24:45 +00:00
parent 2724728c2c
commit 6c9fa119f5
9 changed files with 106 additions and 89 deletions

View File

@ -97,6 +97,7 @@ public class BufferUtils {
* @param buffer the buffer to synchronize, must not be null
* @return a blocking buffer backed by that buffer
* @throws IllegalArgumentException if the Buffer is null
* @since Commons Collections 3.2
*/
public static Buffer timeoutBuffer(Buffer buffer, long timeout) {
return TimeoutBuffer.decorate(buffer, timeout);

View File

@ -643,6 +643,7 @@ public class CollectionUtils {
* @param object the object to add, if null it will not be added
* @return true if the collection changed
* @throws NullPointerException if the collection is null
* @since Commons Collections 3.2
*/
public static boolean addIgnoreNull(Collection collection, Object object) {
return (object == null ? false : collection.add(object));
@ -1080,6 +1081,46 @@ public class CollectionUtils {
}
}
//-----------------------------------------------------------------------
/**
* Returns a collection containing all the elements in <code>collection</code>
* that are also in <code>retain</code>. The cardinality of an element <code>e</code>
* in the returned collection is the same as the cardinality of <code>e</code>
* in <code>collection</code> unless <code>retain</code> does not contain <code>e</code>, in which
* case the cardinality is zero. This method is useful if you do not wish to modify
* the collection <code>c</code> and thus cannot call <code>c.retainAll(retain);</code>.
*
* @param collection the collection whose contents are the target of the #retailAll operation
* @param retain the collection containing the elements to be retained in the returned collection
* @return a <code>Collection</code> containing all the elements of <code>collection</code>
* that occur at least once in <code>retain</code>.
* @throws NullPointerException if either parameter is null
* @since Commons Collections 3.2
*/
public static Collection retainAll(Collection collection, Collection retain) {
return ListUtils.retainAll(collection, retain);
}
/**
* Removes the elements in <code>remove</code> from <code>collection</code>. That is, this
* method returns a collection containing all the elements in <code>c</code>
* that are not in <code>remove</code>. The cardinality of an element <code>e</code>
* in the returned collection is the same as the cardinality of <code>e</code>
* in <code>collection</code> unless <code>remove</code> contains <code>e</code>, in which
* case the cardinality is zero. This method is useful if you do not wish to modify
* the collection <code>c</code> and thus cannot call <code>collection.removeAll(remove);</code>.
*
* @param collection the collection from which items are removed (in the returned collection)
* @param remove the items to be removed from the returned <code>collection</code>
* @return a <code>Collection</code> containing all the elements of <code>collection</code> except
* any elements that also occur in <code>remove</code>.
* @throws NullPointerException if either parameter is null
* @since Commons Collections 3.2
*/
public static Collection removeAll(Collection collection, Collection remove) {
return ListUtils.retainAll(collection, remove);
}
//-----------------------------------------------------------------------
/**
* Returns a synchronized collection backed by the given collection.
@ -1166,41 +1207,4 @@ public class CollectionUtils {
return TransformedCollection.decorate(collection, transformer);
}
/**
* Returns a collection containing all the elements in <code>collection</code>
* that are also in <code>retain</code>. The cardinality of an element <code>e</code>
* in the returned collection is the same as the cardinality of <code>e</code>
* in <code>collection</code> unless <code>retain</code> does not contain <code>e</code>, in which
* case the cardinality is zero. This method is useful if you do not wish to modify
* the collection <code>c</code> and thus cannot call <code>c.retainAll(retain);</code>.
*
* @param collection the collection whose contents are the target of the #retailAll operation
* @param retain the collection containing the elements to be retained in the returned collection
* @return a <code>Collection</code> containing all the elements of <code>collection</code>
* that occur at least once in <code>retain</code>.
* @throws NullPointerException if either parameter is null
*/
public static Collection retainAll(Collection collection, Collection retain) {
return ListUtils.retainAll(collection, retain);
}
/**
* Removes the elements in <code>remove</code> from <code>collection</code>. That is, this
* method returns a collection containing all the elements in <code>c</code>
* that are not in <code>remove</code>. The cardinality of an element <code>e</code>
* in the returned collection is the same as the cardinality of <code>e</code>
* in <code>collection</code> unless <code>remove</code> contains <code>e</code>, in which
* case the cardinality is zero. This method is useful if you do not wish to modify
* the collection <code>c</code> and thus cannot call <code>collection.removeAll(remove);</code>.
*
* @param collection the collection from which items are removed (in the returned collection)
* @param remove the items to be removed from the returned <code>collection</code>
* @return a <code>Collection</code> containing all the elements of <code>collection</code> except
* any elements that also occur in <code>remove</code>.
* @throws NullPointerException if either parameter is null
*/
public static Collection removeAll(Collection collection, Collection remove) {
return ListUtils.retainAll(collection, remove);
}
}

View File

@ -1082,6 +1082,7 @@ public class ExtendedProperties extends Hashtable {
* @return The associated List object.
* @throws ClassCastException is thrown if the key maps to an
* object that is not a List.
* @since Commons Collections 3.2
*/
public List getList(String key) {
return getList(key, null);
@ -1098,6 +1099,7 @@ public class ExtendedProperties extends Hashtable {
* @return The associated List.
* @throws ClassCastException is thrown if the key maps to an
* object that is not a List.
* @since Commons Collections 3.2
*/
public List getList(String key, List defaultValue) {
Object value = get(key);

View File

@ -695,6 +695,7 @@ public class IteratorUtils {
* @param list the list to iterate over, not null
* @return a new looping iterator
* @throws NullPointerException if the list is null
* @since Commons Collections 3.2
*/
public static ResettableIterator loopingListIterator(List list) {
if (list == null) {

View File

@ -218,6 +218,61 @@ public class ListUtils {
return hashCode;
}
//-----------------------------------------------------------------------
/**
* Returns a List containing all the elements in <code>collection</code>
* that are also in <code>retain</code>. The cardinality of an element <code>e</code>
* in the returned list is the same as the cardinality of <code>e</code>
* in <code>collection</code> unless <code>retain</code> does not contain <code>e</code>, in which
* case the cardinality is zero. This method is useful if you do not wish to modify
* the collection <code>c</code> and thus cannot call <code>collection.retainAll(retain);</code>.
*
* @param collection the collection whose contents are the target of the #retailAll operation
* @param retain the collection containing the elements to be retained in the returned collection
* @return a <code>List</code> containing all the elements of <code>c</code>
* that occur at least once in <code>retain</code>.
* @throws NullPointerException if either parameter is null
* @since Commons Collections 3.2
*/
public static List retainAll(Collection collection, Collection retain) {
List list = new ArrayList(Math.min(collection.size(), retain.size()));
for (Iterator iter = collection.iterator(); iter.hasNext();) {
Object obj = iter.next();
if (retain.contains(obj)) {
list.add(obj);
}
}
return list;
}
/**
* Removes the elements in <code>remove</code> from <code>collection</code>. That is, this
* method returns a list containing all the elements in <code>c</code>
* that are not in <code>remove</code>. The cardinality of an element <code>e</code>
* in the returned collection is the same as the cardinality of <code>e</code>
* in <code>collection</code> unless <code>remove</code> contains <code>e</code>, in which
* case the cardinality is zero. This method is useful if you do not wish to modify
* <code>collection</code> and thus cannot call <code>collection.removeAll(remove);</code>.
*
* @param collection the collection from which items are removed (in the returned collection)
* @param remove the items to be removed from the returned <code>collection</code>
* @return a <code>List</code> containing all the elements of <code>c</code> except
* any elements that also occur in <code>remove</code>.
* @throws NullPointerException if either parameter is null
* @since Commons Collections 3.2
*/
public static List removeAll(Collection collection, Collection remove) {
List list = new ArrayList();
for (Iterator iter = collection.iterator(); iter.hasNext();) {
Object obj = iter.next();
if (remove.contains(obj) == false) {
list.add(obj);
}
}
return list;
}
//-----------------------------------------------------------------------
/**
* Returns a synchronized list backed by the given list.
@ -351,56 +406,4 @@ public class ListUtils {
return FixedSizeList.decorate(list);
}
/**
* Returns a List containing all the elements in <code>collection</code>
* that are also in <code>retain</code>. The cardinality of an element <code>e</code>
* in the returned list is the same as the cardinality of <code>e</code>
* in <code>collection</code> unless <code>retain</code> does not contain <code>e</code>, in which
* case the cardinality is zero. This method is useful if you do not wish to modify
* the collection <code>c</code> and thus cannot call <code>collection.retainAll(retain);</code>.
*
* @param collection the collection whose contents are the target of the #retailAll operation
* @param retain the collection containing the elements to be retained in the returned collection
* @return a <code>List</code> containing all the elements of <code>c</code>
* that occur at least once in <code>retain</code>.
* @throws NullPointerException if either parameter is null
*/
public static List retainAll(Collection collection, Collection retain) {
List list = new ArrayList(Math.min(collection.size(), retain.size()));
for (Iterator iter = collection.iterator(); iter.hasNext();) {
Object obj = iter.next();
if (retain.contains(obj)) {
list.add(obj);
}
}
return list;
}
/**
* Removes the elements in <code>remove</code> from <code>collection</code>. That is, this
* method returns a list containing all the elements in <code>c</code>
* that are not in <code>remove</code>. The cardinality of an element <code>e</code>
* in the returned collection is the same as the cardinality of <code>e</code>
* in <code>collection</code> unless <code>remove</code> contains <code>e</code>, in which
* case the cardinality is zero. This method is useful if you do not wish to modify
* <code>collection</code> and thus cannot call <code>collection.removeAll(remove);</code>.
*
* @param collection the collection from which items are removed (in the returned collection)
* @param remove the items to be removed from the returned <code>collection</code>
* @return a <code>List</code> containing all the elements of <code>c</code> except
* any elements that also occur in <code>remove</code>.
* @throws NullPointerException if either parameter is null
*/
public static List removeAll(Collection collection, Collection remove) {
List list = new ArrayList();
for (Iterator iter = collection.iterator(); iter.hasNext();) {
Object obj = iter.next();
if (remove.contains(obj) == false) {
list.add(obj);
}
}
return list;
}
}

View File

@ -117,6 +117,7 @@ public class BlockingBuffer extends SynchronizedBuffer {
* @param timeout the timeout value in milliseconds
* @throws BufferUnderflowException if an interrupt is received
* @throws BufferUnderflowException if the timeout expires
* @since Commons Collections 3.2
*/
public Object get(final long timeout) {
synchronized (lock) {
@ -167,6 +168,7 @@ public class BlockingBuffer extends SynchronizedBuffer {
* @param timeout the timeout value in milliseconds
* @throws BufferUnderflowException if an interrupt is received
* @throws BufferUnderflowException if the timeout expires
* @since Commons Collections 3.2
*/
public Object remove(final long timeout) {
synchronized (lock) {

View File

@ -558,6 +558,8 @@ public class CursorableLinkedList extends AbstractLinkedList implements Serializ
//-----------------------------------------------------------------------
/**
* A cursor for the sublist based on LinkedSubListIterator.
*
* @since Commons Collections 3.2
*/
protected static class SubCursor extends Cursor {

View File

@ -85,6 +85,7 @@ public class TransformedMap
* @param keyTransformer the transformer to use for key conversion, null means no transformation
* @param valueTransformer the transformer to use for value conversion, null means no transformation
* @throws IllegalArgumentException if map is null
* @since Commons Collections 3.2
*/
public static Map decorateTransform(Map map, Transformer keyTransformer, Transformer valueTransformer) {
TransformedMap decorated = new TransformedMap(map, keyTransformer, valueTransformer);

View File

@ -77,6 +77,7 @@ public class TransformedSortedMap
* @param keyTransformer the transformer to use for key conversion, null means no transformation
* @param valueTransformer the transformer to use for value conversion, null means no transformation
* @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);