mirror of
https://github.com/apache/commons-collections.git
synced 2025-02-17 15:35:00 +00:00
Add ObservableSortedSet
Rename range to view git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/collections/trunk@131181 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
21cc633fde
commit
957094fb79
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/java/org/apache/commons/collections/observed/Attic/ModificationHandler.java,v 1.6 2003/09/21 16:00:28 scolebourne Exp $
|
||||
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/java/org/apache/commons/collections/observed/Attic/ModificationHandler.java,v 1.7 2003/09/21 20:01:53 scolebourne Exp $
|
||||
* ====================================================================
|
||||
*
|
||||
* The Apache Software License, Version 1.1
|
||||
@ -76,7 +76,7 @@ import java.util.Collection;
|
||||
* later collections release.
|
||||
*
|
||||
* @since Commons Collections 3.0
|
||||
* @version $Revision: 1.6 $ $Date: 2003/09/21 16:00:28 $
|
||||
* @version $Revision: 1.7 $ $Date: 2003/09/21 20:01:53 $
|
||||
*
|
||||
* @author Stephen Colebourne
|
||||
*/
|
||||
@ -91,8 +91,8 @@ public class ModificationHandler {
|
||||
private Collection baseCollection = null;
|
||||
/** The root handler */
|
||||
private final ModificationHandler rootHandler;
|
||||
/** The range offset, 0 if not a range */
|
||||
private final int rangeOffset;
|
||||
/** The view offset, 0 if not a view */
|
||||
private final int viewOffset;
|
||||
|
||||
// Constructors
|
||||
//-----------------------------------------------------------------------
|
||||
@ -102,19 +102,19 @@ public class ModificationHandler {
|
||||
protected ModificationHandler() {
|
||||
super();
|
||||
this.rootHandler = this;
|
||||
this.rangeOffset = 0;
|
||||
this.viewOffset = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param rootHandler the base underlying handler
|
||||
* @param rangeOffset the offset on the base collection
|
||||
* @param viewOffset the offset on the base collection
|
||||
*/
|
||||
protected ModificationHandler(ModificationHandler rootHandler, int rangeOffset) {
|
||||
protected ModificationHandler(ModificationHandler rootHandler, int viewOffset) {
|
||||
super();
|
||||
this.rootHandler = rootHandler;
|
||||
this.rangeOffset = rangeOffset;
|
||||
this.viewOffset = viewOffset;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -173,12 +173,12 @@ public class ModificationHandler {
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the range offset.
|
||||
* Gets the view offset.
|
||||
*
|
||||
* @return the range offset
|
||||
* @return the view offset
|
||||
*/
|
||||
protected int getRangeOffset() {
|
||||
return rangeOffset;
|
||||
protected int getViewOffset() {
|
||||
return viewOffset;
|
||||
}
|
||||
|
||||
// PreListeners
|
||||
@ -291,12 +291,12 @@ public class ModificationHandler {
|
||||
* @param object the object that will be added/removed/set, the method param or derived
|
||||
* @param repeat the number of repeats of the add/remove, the method param or derived
|
||||
* @param previous the previous value that will be removed/replaced, must exist in coll
|
||||
* @param range the range collection, null if no range
|
||||
* @param rangeOffset the offset of the range, -1 if unknown
|
||||
* @param view the view collection that the change was actioned on, null if no view
|
||||
* @param viewOffset the offset of the subList view, -1 if unknown
|
||||
*/
|
||||
protected boolean preEvent(
|
||||
int type, int index, Object object, int repeat,
|
||||
Object previous, ObservableCollection range, int rangeOffset) {
|
||||
Object previous, ObservableCollection view, int viewOffset) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -311,12 +311,12 @@ public class ModificationHandler {
|
||||
* @param object the object that was added/removed/set, the method param or derived
|
||||
* @param repeat the number of repeats of the add/remove, the method param or derived
|
||||
* @param previous the previous value that was removed/replace, must have existed in coll
|
||||
* @param range the range collection, null if no range
|
||||
* @param rangeOffset the offset of the range, -1 if unknown
|
||||
* @param view the view collection that the change was actioned on, null if no view
|
||||
* @param viewOffset the offset of the subList view, -1 if unknown
|
||||
*/
|
||||
protected void postEvent(
|
||||
boolean modified, int type, int index, Object object, int repeat,
|
||||
Object previous, ObservableCollection range, int rangeOffset) {
|
||||
Object previous, ObservableCollection view, int viewOffset) {
|
||||
}
|
||||
|
||||
// Event handling
|
||||
@ -358,7 +358,7 @@ public class ModificationHandler {
|
||||
* @return true to process modification
|
||||
*/
|
||||
protected boolean preAddIndexed(int index, Object object) {
|
||||
return preEvent(ModificationEventType.ADD_INDEXED, index + rangeOffset, object, 1, null, null, -1);
|
||||
return preEvent(ModificationEventType.ADD_INDEXED, index + viewOffset, object, 1, null, null, -1);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -370,7 +370,7 @@ public class ModificationHandler {
|
||||
* @param object the object being added
|
||||
*/
|
||||
protected void postAddIndexed(int index, Object object) {
|
||||
postEvent(true, ModificationEventType.ADD_INDEXED, index + rangeOffset, object, 1, null, null, -1);
|
||||
postEvent(true, ModificationEventType.ADD_INDEXED, index + viewOffset, object, 1, null, null, -1);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
@ -413,7 +413,7 @@ public class ModificationHandler {
|
||||
* @return true to process modification
|
||||
*/
|
||||
protected boolean preAddIterated(int index, Object object) {
|
||||
return preEvent(ModificationEventType.ADD_ITERATED, index + rangeOffset, object, 1, null, null, -1);
|
||||
return preEvent(ModificationEventType.ADD_ITERATED, index + viewOffset, object, 1, null, null, -1);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -426,7 +426,7 @@ public class ModificationHandler {
|
||||
*/
|
||||
protected void postAddIterated(int index, Object object) {
|
||||
// assume collection changed
|
||||
postEvent(true, ModificationEventType.ADD_ITERATED, index + rangeOffset, object, 1, null, null, -1);
|
||||
postEvent(true, ModificationEventType.ADD_ITERATED, index + viewOffset, object, 1, null, null, -1);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
@ -465,7 +465,7 @@ public class ModificationHandler {
|
||||
* @return true to process modification
|
||||
*/
|
||||
protected boolean preAddAllIndexed(int index, Collection coll) {
|
||||
return preEvent(ModificationEventType.ADD_ALL_INDEXED, index + rangeOffset, coll, 1, null, null, -1);
|
||||
return preEvent(ModificationEventType.ADD_ALL_INDEXED, index + viewOffset, coll, 1, null, null, -1);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -478,7 +478,7 @@ public class ModificationHandler {
|
||||
* @param collChanged the result from the addAll method
|
||||
*/
|
||||
protected void postAddAllIndexed(int index, Collection coll, boolean collChanged) {
|
||||
postEvent(collChanged, ModificationEventType.ADD_ALL_INDEXED, index + rangeOffset, coll, 1, null, null, -1);
|
||||
postEvent(collChanged, ModificationEventType.ADD_ALL_INDEXED, index + viewOffset, coll, 1, null, null, -1);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
@ -540,7 +540,7 @@ public class ModificationHandler {
|
||||
protected boolean preRemoveIndexed(int index) {
|
||||
// could do a get(index) to determine previousValue
|
||||
// we don't for performance, but subclass may override
|
||||
return preEvent(ModificationEventType.REMOVE_INDEXED, index + rangeOffset, null, 1, null, null, -1);
|
||||
return preEvent(ModificationEventType.REMOVE_INDEXED, index + viewOffset, null, 1, null, null, -1);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -552,7 +552,7 @@ public class ModificationHandler {
|
||||
* @param previousValue the result from the remove method
|
||||
*/
|
||||
protected void postRemoveIndexed(int index, Object previousValue) {
|
||||
postEvent(true, ModificationEventType.REMOVE_INDEXED, index + rangeOffset, null, 1, previousValue, null, -1);
|
||||
postEvent(true, ModificationEventType.REMOVE_INDEXED, index + viewOffset, null, 1, previousValue, null, -1);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
@ -617,7 +617,7 @@ public class ModificationHandler {
|
||||
* @return true to process modification
|
||||
*/
|
||||
protected boolean preRemoveIterated(int index, Object removedValue) {
|
||||
return preEvent(ModificationEventType.REMOVE_ITERATED, index + rangeOffset, removedValue, 1, removedValue, null, -1);
|
||||
return preEvent(ModificationEventType.REMOVE_ITERATED, index + viewOffset, removedValue, 1, removedValue, null, -1);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -630,7 +630,7 @@ public class ModificationHandler {
|
||||
*/
|
||||
protected void postRemoveIterated(int index, Object removedValue) {
|
||||
// assume collection changed
|
||||
postEvent(true, ModificationEventType.REMOVE_ITERATED, index + rangeOffset, removedValue, 1, removedValue, null, -1);
|
||||
postEvent(true, ModificationEventType.REMOVE_ITERATED, index + viewOffset, removedValue, 1, removedValue, null, -1);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
@ -696,7 +696,7 @@ public class ModificationHandler {
|
||||
protected boolean preSetIndexed(int index, Object object) {
|
||||
// could do a get(index) to determine previousValue
|
||||
// we don't for performance, but subclass may override
|
||||
return preEvent(ModificationEventType.SET_INDEXED, index + rangeOffset, object, 1, null, null, -1);
|
||||
return preEvent(ModificationEventType.SET_INDEXED, index + viewOffset, object, 1, null, null, -1);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -710,7 +710,7 @@ public class ModificationHandler {
|
||||
*/
|
||||
protected void postSetIndexed(int index, Object object, Object previousValue) {
|
||||
// reference check for modification, in case equals() has issues (eg. performance)
|
||||
postEvent((object != previousValue), ModificationEventType.SET_INDEXED, index + rangeOffset, object, 1, previousValue, null, -1);
|
||||
postEvent((object != previousValue), ModificationEventType.SET_INDEXED, index + viewOffset, object, 1, previousValue, null, -1);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
@ -725,7 +725,7 @@ public class ModificationHandler {
|
||||
* @return true to process modification
|
||||
*/
|
||||
protected boolean preSetIterated(int index, Object object, Object previousValue) {
|
||||
return preEvent(ModificationEventType.SET_ITERATED, index + rangeOffset, object, 1, previousValue, null, -1);
|
||||
return preEvent(ModificationEventType.SET_ITERATED, index + viewOffset, object, 1, previousValue, null, -1);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -739,10 +739,83 @@ public class ModificationHandler {
|
||||
*/
|
||||
protected void postSetIterated(int index, Object object, Object previousValue) {
|
||||
// reference check for modification, in case equals() has issues (eg. performance)
|
||||
postEvent((object != previousValue), ModificationEventType.SET_ITERATED, index + rangeOffset, object, 1, previousValue, null, -1);
|
||||
postEvent((object != previousValue), ModificationEventType.SET_ITERATED, index + viewOffset, object, 1, previousValue, null, -1);
|
||||
}
|
||||
|
||||
// Views
|
||||
// SortedSet Views
|
||||
//-----------------------------------------------------------------------
|
||||
/**
|
||||
* Creates a new handler for SortedSet subSet.
|
||||
*
|
||||
* @param fromElement the from element
|
||||
* @param toElement the to element
|
||||
*/
|
||||
protected ModificationHandler createSubSetHandler(Object fromElement, Object toElement) {
|
||||
return new SetViewHandler(rootHandler);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new handler for SortedSet headSet.
|
||||
*
|
||||
* @param toElement the to element
|
||||
*/
|
||||
protected ModificationHandler createHeadSetHandler(Object toElement) {
|
||||
return new SetViewHandler(rootHandler);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new handler for SortedSet tailSet.
|
||||
*
|
||||
* @param fromElement the from element
|
||||
*/
|
||||
protected ModificationHandler createTailSetHandler(Object fromElement) {
|
||||
return new SetViewHandler(rootHandler);
|
||||
}
|
||||
|
||||
/**
|
||||
* Inner class for views.
|
||||
*/
|
||||
protected static class SetViewHandler extends ModificationHandler {
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param rootHandler the base underlying handler
|
||||
*/
|
||||
protected SetViewHandler(ModificationHandler rootHandler) {
|
||||
super(rootHandler, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Override the preEvent method to forward all events to the
|
||||
* underlying handler. This method also inserts details of the view
|
||||
* that caused the event.
|
||||
*/
|
||||
protected boolean preEvent(
|
||||
int type, int index, Object object, int repeat,
|
||||
Object previous, ObservableCollection ignoredView, int offset) {
|
||||
|
||||
return getRootHandler().preEvent(
|
||||
type, index, object, repeat,
|
||||
previous, getObservedCollection(), offset);
|
||||
}
|
||||
|
||||
/**
|
||||
* Override the postEvent method to forward all events to the
|
||||
* underlying handler. This method also inserts details of the view
|
||||
* that caused the event.
|
||||
*/
|
||||
protected void postEvent(
|
||||
boolean modified, int type, int index, Object object, int repeat,
|
||||
Object previous, ObservableCollection ignoredView, int offset) {
|
||||
|
||||
getRootHandler().postEvent(
|
||||
modified, type, index, object, repeat,
|
||||
previous, getObservedCollection(), offset);
|
||||
}
|
||||
}
|
||||
|
||||
// List View
|
||||
//-----------------------------------------------------------------------
|
||||
/**
|
||||
* Creates a new handler for subLists that is aware of the offset.
|
||||
@ -751,47 +824,50 @@ public class ModificationHandler {
|
||||
* @param toIndex the sublist toIndex (exclusive)
|
||||
*/
|
||||
protected ModificationHandler createSubListHandler(int fromIndex, int toIndex) {
|
||||
return new SubListHandler(rootHandler, fromIndex + rangeOffset);
|
||||
return new SubListHandler(rootHandler, fromIndex + viewOffset);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Inner class for subLists.
|
||||
*/
|
||||
protected static class SubListHandler extends ModificationHandler {
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param rootHandler the base underlying handler
|
||||
* @param rangeOffset the offset on the base collection
|
||||
* @param viewOffset the offset on the base collection
|
||||
*/
|
||||
protected SubListHandler(ModificationHandler rootHandler, int rangeOffset) {
|
||||
super(rootHandler, rangeOffset);
|
||||
protected SubListHandler(ModificationHandler rootHandler, int viewOffset) {
|
||||
super(rootHandler, viewOffset);
|
||||
}
|
||||
|
||||
/**
|
||||
* Override the preEvent method to forward all events to the
|
||||
* underlying handler. This method also inserts details of the range
|
||||
* underlying handler. This method also inserts details of the view
|
||||
* that caused the event.
|
||||
*/
|
||||
protected boolean preEvent(
|
||||
int type, int index, Object object, int repeat,
|
||||
Object previous, ObservableCollection ignoredRange, int ignoredOffset) {
|
||||
Object previous, ObservableCollection ignoredView, int ignoredOffset) {
|
||||
|
||||
return getRootHandler().preEvent(
|
||||
type, index, object, repeat,
|
||||
previous, getObservedCollection(), getRangeOffset());
|
||||
previous, getObservedCollection(), getViewOffset());
|
||||
}
|
||||
|
||||
/**
|
||||
* Override the postEvent method to forward all events to the
|
||||
* underlying handler. This method also inserts details of the range
|
||||
* underlying handler. This method also inserts details of the view
|
||||
* that caused the event.
|
||||
*/
|
||||
protected void postEvent(
|
||||
boolean modified, int type, int index, Object object, int repeat,
|
||||
Object previous, ObservableCollection ignoredRange, int ignoredOffset) {
|
||||
Object previous, ObservableCollection ignoredView, int ignoredOffset) {
|
||||
|
||||
getRootHandler().postEvent(
|
||||
modified, type, index, object, repeat,
|
||||
previous, getObservedCollection(), getRangeOffset());
|
||||
previous, getObservedCollection(), getViewOffset());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,194 @@
|
||||
/*
|
||||
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/java/org/apache/commons/collections/observed/Attic/ObservableSortedSet.java,v 1.1 2003/09/21 20:01:53 scolebourne Exp $
|
||||
* ====================================================================
|
||||
*
|
||||
* The Apache Software License, Version 1.1
|
||||
*
|
||||
* Copyright (c) 2003 The Apache Software Foundation. All rights
|
||||
* reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* 3. The end-user documentation included with the redistribution, if
|
||||
* any, must include the following acknowledgement:
|
||||
* "This product includes software developed by the
|
||||
* Apache Software Foundation (http://www.apache.org/)."
|
||||
* Alternately, this acknowledgement may appear in the software itself,
|
||||
* if and wherever such third-party acknowledgements normally appear.
|
||||
*
|
||||
* 4. The names "The Jakarta Project", "Commons", and "Apache Software
|
||||
* Foundation" must not be used to endorse or promote products derived
|
||||
* from this software without prior written permission. For written
|
||||
* permission, please contact apache@apache.org.
|
||||
*
|
||||
* 5. Products derived from this software may not be called "Apache"
|
||||
* nor may "Apache" appear in their names without prior written
|
||||
* permission of the Apache Software Foundation.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
|
||||
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
||||
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
||||
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
* ====================================================================
|
||||
*
|
||||
* This software consists of voluntary contributions made by many
|
||||
* individuals on behalf of the Apache Software Foundation. For more
|
||||
* information on the Apache Software Foundation, please see
|
||||
* <http://www.apache.org/>.
|
||||
*
|
||||
*/
|
||||
package org.apache.commons.collections.observed;
|
||||
|
||||
import java.util.Comparator;
|
||||
import java.util.SortedSet;
|
||||
|
||||
/**
|
||||
* Decorates a <code>SortedSet</code> implementation to observe modifications.
|
||||
* <p>
|
||||
* Each modifying method call made on this <code>SortedSet</code> is forwarded to a
|
||||
* {@link ModificationHandler}.
|
||||
* The handler manages the event, notifying listeners and optionally vetoing changes.
|
||||
* The default handler is {@link StandardModificationHandler}.
|
||||
* See this class for details of configuration available.
|
||||
*
|
||||
* @since Commons Collections 3.0
|
||||
* @version $Revision: 1.1 $ $Date: 2003/09/21 20:01:53 $
|
||||
*
|
||||
* @author Stephen Colebourne
|
||||
*/
|
||||
public class ObservableSortedSet extends ObservableSet implements SortedSet {
|
||||
|
||||
// Factories
|
||||
//-----------------------------------------------------------------------
|
||||
/**
|
||||
* Factory method to create an observable set.
|
||||
* <p>
|
||||
* A {@link StandardModificationHandler} will be created.
|
||||
* This can be accessed by {@link #getHandler()} to add listeners.
|
||||
*
|
||||
* @param set the set to decorate, must not be null
|
||||
* @return the observed Set
|
||||
* @throws IllegalArgumentException if the collection is null
|
||||
*/
|
||||
public static ObservableSortedSet decorate(final SortedSet set) {
|
||||
return new ObservableSortedSet(set, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Factory method to create an observable set using a listener or a handler.
|
||||
* <p>
|
||||
* A lot of functionality is available through this method.
|
||||
* If you don't need the extra functionality, simply implement the
|
||||
* {@link org.apache.commons.collections.observed.standard.StandardModificationListener}
|
||||
* interface and pass it in as the second parameter.
|
||||
* <p>
|
||||
* Internally, an <code>ObservableSet</code> relies on a {@link ModificationHandler}.
|
||||
* The handler receives all the events and processes them, typically by
|
||||
* calling listeners. Different handler implementations can be plugged in
|
||||
* to provide a flexible event system.
|
||||
* <p>
|
||||
* The handler implementation is determined by the listener parameter via
|
||||
* the registered factories. The listener may be a manually configured
|
||||
* <code>ModificationHandler</code> instance.
|
||||
* <p>
|
||||
* The listener is defined as an Object for maximum flexibility.
|
||||
* It does not have to be a listener in the classic JavaBean sense.
|
||||
* It is entirely up to the factory and handler as to how the parameter
|
||||
* is interpretted. An IllegalArgumentException is thrown if no suitable
|
||||
* handler can be found for this listener.
|
||||
* <p>
|
||||
* A <code>null</code> listener will create a {@link StandardModificationHandler}.
|
||||
*
|
||||
* @param set the set to decorate, must not be null
|
||||
* @param listener set listener, may be null
|
||||
* @return the observed set
|
||||
* @throws IllegalArgumentException if the set is null
|
||||
* @throws IllegalArgumentException if there is no valid handler for the listener
|
||||
*/
|
||||
public static ObservableSortedSet decorate(
|
||||
final SortedSet set,
|
||||
final Object listener) {
|
||||
|
||||
if (set == null) {
|
||||
throw new IllegalArgumentException("Set must not be null");
|
||||
}
|
||||
return new ObservableSortedSet(set, listener);
|
||||
}
|
||||
|
||||
// Constructors
|
||||
//-----------------------------------------------------------------------
|
||||
/**
|
||||
* Constructor that wraps (not copies) and takes a handler.
|
||||
* <p>
|
||||
* The handler implementation is determined by the listener parameter via
|
||||
* the registered factories. The listener may be a manually configured
|
||||
* <code>ModificationHandler</code> instance.
|
||||
*
|
||||
* @param set the set to decorate, must not be null
|
||||
* @param listener the listener, may be null
|
||||
* @throws IllegalArgumentException if the set is null
|
||||
*/
|
||||
protected ObservableSortedSet(
|
||||
final SortedSet set,
|
||||
final Object listener) {
|
||||
super(set, listener);
|
||||
}
|
||||
|
||||
/**
|
||||
* Typecast the collection to a SortedSet.
|
||||
*
|
||||
* @return the wrapped collection as a SortedSet
|
||||
*/
|
||||
private SortedSet getSortedSet() {
|
||||
return (SortedSet) getCollection();
|
||||
}
|
||||
|
||||
// SortedSet API
|
||||
//-----------------------------------------------------------------------
|
||||
public Comparator comparator() {
|
||||
return getSortedSet().comparator();
|
||||
}
|
||||
|
||||
public Object first() {
|
||||
return getSortedSet().first();
|
||||
}
|
||||
|
||||
public Object last() {
|
||||
return getSortedSet().last();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
public SortedSet subSet(Object fromElement, Object toElement) {
|
||||
SortedSet subSet = getSortedSet().subSet(fromElement, toElement);
|
||||
return new ObservableSortedSet(subSet, getHandler().createSubSetHandler(fromElement, toElement));
|
||||
}
|
||||
|
||||
public SortedSet headSet(Object toElement) {
|
||||
SortedSet headSet = getSortedSet().headSet(toElement);
|
||||
return new ObservableSortedSet(headSet, getHandler().createHeadSetHandler(toElement));
|
||||
}
|
||||
|
||||
public SortedSet tailSet(Object fromElement) {
|
||||
SortedSet tailSet = getSortedSet().tailSet(fromElement);
|
||||
return new ObservableSortedSet(tailSet, getHandler().createTailSetHandler(fromElement));
|
||||
}
|
||||
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/test/org/apache/commons/collections/observed/Attic/ObservedTestHelper.java,v 1.8 2003/09/21 16:00:55 scolebourne Exp $
|
||||
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/test/org/apache/commons/collections/observed/Attic/ObservedTestHelper.java,v 1.9 2003/09/21 20:01:53 scolebourne Exp $
|
||||
* ====================================================================
|
||||
*
|
||||
* The Apache Software License, Version 1.1
|
||||
@ -61,6 +61,7 @@ import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.ListIterator;
|
||||
import java.util.SortedSet;
|
||||
|
||||
import junit.framework.Assert;
|
||||
|
||||
@ -76,7 +77,7 @@ import org.apache.commons.collections.observed.standard.StandardPreModificationL
|
||||
* {@link ObservedCollection} implementations.
|
||||
*
|
||||
* @since Commons Collections 3.0
|
||||
* @version $Revision: 1.8 $ $Date: 2003/09/21 16:00:55 $
|
||||
* @version $Revision: 1.9 $ $Date: 2003/09/21 20:01:53 $
|
||||
*
|
||||
* @author Stephen Colebourne
|
||||
*/
|
||||
@ -164,6 +165,15 @@ public class ObservedTestHelper {
|
||||
bulkTestObservedCollection(factory);
|
||||
}
|
||||
|
||||
public static void bulkTestObservedSortedSet(ObservedFactory factory) {
|
||||
Assert.assertTrue(factory.createObservedCollection() instanceof ObservableSortedSet);
|
||||
Assert.assertTrue(factory.createObservedCollection(LISTENER) instanceof ObservableSortedSet);
|
||||
Assert.assertTrue(factory.createObservedCollection(new StandardModificationHandler()) instanceof ObservableSortedSet);
|
||||
|
||||
bulkTestObservedCollection(factory);
|
||||
// TODO: subSet...
|
||||
}
|
||||
|
||||
public static void bulkTestObservedList(ObservedFactory factory) {
|
||||
Assert.assertTrue(factory.createObservedCollection() instanceof ObservableList);
|
||||
Assert.assertTrue(factory.createObservedCollection(LISTENER) instanceof ObservableList);
|
||||
@ -378,9 +388,9 @@ public class ObservedTestHelper {
|
||||
Assert.assertEquals(1, LISTENER.postEvent.getSizeChange());
|
||||
Assert.assertEquals(true, LISTENER.postEvent.isSizeChanged());
|
||||
|
||||
Assert.assertEquals(false, LISTENER.postEvent.isRange());
|
||||
Assert.assertEquals(-1, LISTENER.postEvent.getRangeOffset());
|
||||
Assert.assertEquals(null, LISTENER.postEvent.getRange());
|
||||
Assert.assertEquals(false, LISTENER.postEvent.isView());
|
||||
Assert.assertEquals(-1, LISTENER.postEvent.getViewOffset());
|
||||
Assert.assertEquals(null, LISTENER.postEvent.getView());
|
||||
Assert.assertEquals(true, LISTENER.postEvent.isTypeAdd());
|
||||
Assert.assertEquals(false, LISTENER.postEvent.isTypeReduce());
|
||||
Assert.assertEquals(false, LISTENER.postEvent.isTypeChange());
|
||||
@ -420,36 +430,38 @@ public class ObservedTestHelper {
|
||||
Assert.assertEquals(1, LISTENER.postEvent.getSizeChange());
|
||||
Assert.assertEquals(true, LISTENER.postEvent.isSizeChanged());
|
||||
|
||||
LISTENER.preEvent = null;
|
||||
LISTENER.postEvent = null;
|
||||
Assert.assertEquals(2, coll.size());
|
||||
coll.add(SIX_SEVEN_LIST);
|
||||
Assert.assertEquals(3, coll.size());
|
||||
// pre
|
||||
Assert.assertSame(coll, LISTENER.preEvent.getObservedCollection());
|
||||
Assert.assertSame(coll.getHandler(), LISTENER.preEvent.getHandler());
|
||||
Assert.assertEquals(ModificationEventType.ADD, LISTENER.preEvent.getType());
|
||||
Assert.assertEquals(-1, LISTENER.preEvent.getChangeIndex());
|
||||
Assert.assertSame(SIX_SEVEN_LIST, LISTENER.preEvent.getChangeObject());
|
||||
Assert.assertEquals(1, LISTENER.preEvent.getChangeCollection().size());
|
||||
Assert.assertSame(SIX_SEVEN_LIST, LISTENER.preEvent.getChangeCollection().iterator().next());
|
||||
Assert.assertEquals(1, LISTENER.preEvent.getChangeRepeat());
|
||||
Assert.assertSame(null, LISTENER.preEvent.getPrevious());
|
||||
Assert.assertEquals(2, LISTENER.preEvent.getPreSize());
|
||||
// post
|
||||
Assert.assertSame(coll, LISTENER.postEvent.getObservedCollection());
|
||||
Assert.assertSame(coll.getHandler(), LISTENER.postEvent.getHandler());
|
||||
Assert.assertEquals(ModificationEventType.ADD, LISTENER.postEvent.getType());
|
||||
Assert.assertEquals(-1, LISTENER.postEvent.getChangeIndex());
|
||||
Assert.assertSame(SIX_SEVEN_LIST, LISTENER.postEvent.getChangeObject());
|
||||
Assert.assertEquals(1, LISTENER.postEvent.getChangeCollection().size());
|
||||
Assert.assertSame(SIX_SEVEN_LIST, LISTENER.postEvent.getChangeCollection().iterator().next());
|
||||
Assert.assertEquals(1, LISTENER.postEvent.getChangeRepeat());
|
||||
Assert.assertSame(null, LISTENER.postEvent.getPrevious());
|
||||
Assert.assertEquals(2, LISTENER.postEvent.getPreSize());
|
||||
Assert.assertEquals(3, LISTENER.postEvent.getPostSize());
|
||||
Assert.assertEquals(1, LISTENER.postEvent.getSizeChange());
|
||||
Assert.assertEquals(true, LISTENER.postEvent.isSizeChanged());
|
||||
if (coll instanceof SortedSet == false) {
|
||||
LISTENER.preEvent = null;
|
||||
LISTENER.postEvent = null;
|
||||
Assert.assertEquals(2, coll.size());
|
||||
coll.add(SIX_SEVEN_LIST);
|
||||
Assert.assertEquals(3, coll.size());
|
||||
// pre
|
||||
Assert.assertSame(coll, LISTENER.preEvent.getObservedCollection());
|
||||
Assert.assertSame(coll.getHandler(), LISTENER.preEvent.getHandler());
|
||||
Assert.assertEquals(ModificationEventType.ADD, LISTENER.preEvent.getType());
|
||||
Assert.assertEquals(-1, LISTENER.preEvent.getChangeIndex());
|
||||
Assert.assertSame(SIX_SEVEN_LIST, LISTENER.preEvent.getChangeObject());
|
||||
Assert.assertEquals(1, LISTENER.preEvent.getChangeCollection().size());
|
||||
Assert.assertSame(SIX_SEVEN_LIST, LISTENER.preEvent.getChangeCollection().iterator().next());
|
||||
Assert.assertEquals(1, LISTENER.preEvent.getChangeRepeat());
|
||||
Assert.assertSame(null, LISTENER.preEvent.getPrevious());
|
||||
Assert.assertEquals(2, LISTENER.preEvent.getPreSize());
|
||||
// post
|
||||
Assert.assertSame(coll, LISTENER.postEvent.getObservedCollection());
|
||||
Assert.assertSame(coll.getHandler(), LISTENER.postEvent.getHandler());
|
||||
Assert.assertEquals(ModificationEventType.ADD, LISTENER.postEvent.getType());
|
||||
Assert.assertEquals(-1, LISTENER.postEvent.getChangeIndex());
|
||||
Assert.assertSame(SIX_SEVEN_LIST, LISTENER.postEvent.getChangeObject());
|
||||
Assert.assertEquals(1, LISTENER.postEvent.getChangeCollection().size());
|
||||
Assert.assertSame(SIX_SEVEN_LIST, LISTENER.postEvent.getChangeCollection().iterator().next());
|
||||
Assert.assertEquals(1, LISTENER.postEvent.getChangeRepeat());
|
||||
Assert.assertSame(null, LISTENER.postEvent.getPrevious());
|
||||
Assert.assertEquals(2, LISTENER.postEvent.getPreSize());
|
||||
Assert.assertEquals(3, LISTENER.postEvent.getPostSize());
|
||||
Assert.assertEquals(1, LISTENER.postEvent.getSizeChange());
|
||||
Assert.assertEquals(true, LISTENER.postEvent.isSizeChanged());
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
@ -488,9 +500,9 @@ public class ObservedTestHelper {
|
||||
Assert.assertEquals(1, LISTENER.postEvent.getSizeChange());
|
||||
Assert.assertEquals(true, LISTENER.postEvent.isSizeChanged());
|
||||
|
||||
Assert.assertEquals(false, LISTENER.postEvent.isRange());
|
||||
Assert.assertEquals(-1, LISTENER.postEvent.getRangeOffset());
|
||||
Assert.assertEquals(null, LISTENER.postEvent.getRange());
|
||||
Assert.assertEquals(false, LISTENER.postEvent.isView());
|
||||
Assert.assertEquals(-1, LISTENER.postEvent.getViewOffset());
|
||||
Assert.assertEquals(null, LISTENER.postEvent.getView());
|
||||
Assert.assertEquals(true, LISTENER.postEvent.isTypeAdd());
|
||||
Assert.assertEquals(false, LISTENER.postEvent.isTypeReduce());
|
||||
Assert.assertEquals(false, LISTENER.postEvent.isTypeChange());
|
||||
@ -533,9 +545,9 @@ public class ObservedTestHelper {
|
||||
Assert.assertEquals(3, LISTENER.postEvent.getSizeChange());
|
||||
Assert.assertEquals(true, LISTENER.postEvent.isSizeChanged());
|
||||
|
||||
Assert.assertEquals(false, LISTENER.postEvent.isRange());
|
||||
Assert.assertEquals(-1, LISTENER.postEvent.getRangeOffset());
|
||||
Assert.assertEquals(null, LISTENER.postEvent.getRange());
|
||||
Assert.assertEquals(false, LISTENER.postEvent.isView());
|
||||
Assert.assertEquals(-1, LISTENER.postEvent.getViewOffset());
|
||||
Assert.assertEquals(null, LISTENER.postEvent.getView());
|
||||
Assert.assertEquals(true, LISTENER.postEvent.isTypeAdd());
|
||||
Assert.assertEquals(false, LISTENER.postEvent.isTypeReduce());
|
||||
Assert.assertEquals(false, LISTENER.postEvent.isTypeChange());
|
||||
@ -580,9 +592,9 @@ public class ObservedTestHelper {
|
||||
Assert.assertEquals(1, LISTENER.postEvent.getSizeChange());
|
||||
Assert.assertEquals(true, LISTENER.postEvent.isSizeChanged());
|
||||
|
||||
Assert.assertEquals(false, LISTENER.postEvent.isRange());
|
||||
Assert.assertEquals(-1, LISTENER.postEvent.getRangeOffset());
|
||||
Assert.assertEquals(null, LISTENER.postEvent.getRange());
|
||||
Assert.assertEquals(false, LISTENER.postEvent.isView());
|
||||
Assert.assertEquals(-1, LISTENER.postEvent.getViewOffset());
|
||||
Assert.assertEquals(null, LISTENER.postEvent.getView());
|
||||
Assert.assertEquals(true, LISTENER.postEvent.isTypeAdd());
|
||||
Assert.assertEquals(false, LISTENER.postEvent.isTypeReduce());
|
||||
Assert.assertEquals(false, LISTENER.postEvent.isTypeChange());
|
||||
@ -622,9 +634,9 @@ public class ObservedTestHelper {
|
||||
Assert.assertEquals(2, LISTENER.postEvent.getSizeChange());
|
||||
Assert.assertEquals(true, LISTENER.postEvent.isSizeChanged());
|
||||
|
||||
Assert.assertEquals(false, LISTENER.postEvent.isRange());
|
||||
Assert.assertEquals(-1, LISTENER.postEvent.getRangeOffset());
|
||||
Assert.assertEquals(null, LISTENER.postEvent.getRange());
|
||||
Assert.assertEquals(false, LISTENER.postEvent.isView());
|
||||
Assert.assertEquals(-1, LISTENER.postEvent.getViewOffset());
|
||||
Assert.assertEquals(null, LISTENER.postEvent.getView());
|
||||
Assert.assertEquals(true, LISTENER.postEvent.isTypeAdd());
|
||||
Assert.assertEquals(false, LISTENER.postEvent.isTypeReduce());
|
||||
Assert.assertEquals(false, LISTENER.postEvent.isTypeChange());
|
||||
@ -665,9 +677,9 @@ public class ObservedTestHelper {
|
||||
Assert.assertEquals(2, LISTENER.postEvent.getSizeChange());
|
||||
Assert.assertEquals(true, LISTENER.postEvent.isSizeChanged());
|
||||
|
||||
Assert.assertEquals(false, LISTENER.postEvent.isRange());
|
||||
Assert.assertEquals(-1, LISTENER.postEvent.getRangeOffset());
|
||||
Assert.assertEquals(null, LISTENER.postEvent.getRange());
|
||||
Assert.assertEquals(false, LISTENER.postEvent.isView());
|
||||
Assert.assertEquals(-1, LISTENER.postEvent.getViewOffset());
|
||||
Assert.assertEquals(null, LISTENER.postEvent.getView());
|
||||
Assert.assertEquals(true, LISTENER.postEvent.isTypeAdd());
|
||||
Assert.assertEquals(false, LISTENER.postEvent.isTypeReduce());
|
||||
Assert.assertEquals(false, LISTENER.postEvent.isTypeChange());
|
||||
@ -708,9 +720,9 @@ public class ObservedTestHelper {
|
||||
Assert.assertEquals(-2, LISTENER.postEvent.getSizeChange());
|
||||
Assert.assertEquals(true, LISTENER.postEvent.isSizeChanged());
|
||||
|
||||
Assert.assertEquals(false, LISTENER.postEvent.isRange());
|
||||
Assert.assertEquals(-1, LISTENER.postEvent.getRangeOffset());
|
||||
Assert.assertEquals(null, LISTENER.postEvent.getRange());
|
||||
Assert.assertEquals(false, LISTENER.postEvent.isView());
|
||||
Assert.assertEquals(-1, LISTENER.postEvent.getViewOffset());
|
||||
Assert.assertEquals(null, LISTENER.postEvent.getView());
|
||||
Assert.assertEquals(false, LISTENER.postEvent.isTypeAdd());
|
||||
Assert.assertEquals(true, LISTENER.postEvent.isTypeReduce());
|
||||
Assert.assertEquals(false, LISTENER.postEvent.isTypeChange());
|
||||
@ -761,9 +773,9 @@ public class ObservedTestHelper {
|
||||
Assert.assertEquals(-1, LISTENER.postEvent.getSizeChange());
|
||||
Assert.assertEquals(true, LISTENER.postEvent.isSizeChanged());
|
||||
|
||||
Assert.assertEquals(false, LISTENER.postEvent.isRange());
|
||||
Assert.assertEquals(-1, LISTENER.postEvent.getRangeOffset());
|
||||
Assert.assertEquals(null, LISTENER.postEvent.getRange());
|
||||
Assert.assertEquals(false, LISTENER.postEvent.isView());
|
||||
Assert.assertEquals(-1, LISTENER.postEvent.getViewOffset());
|
||||
Assert.assertEquals(null, LISTENER.postEvent.getView());
|
||||
Assert.assertEquals(false, LISTENER.postEvent.isTypeAdd());
|
||||
Assert.assertEquals(true, LISTENER.postEvent.isTypeReduce());
|
||||
Assert.assertEquals(false, LISTENER.postEvent.isTypeChange());
|
||||
@ -812,9 +824,9 @@ public class ObservedTestHelper {
|
||||
Assert.assertEquals(-1, LISTENER.postEvent.getSizeChange());
|
||||
Assert.assertEquals(true, LISTENER.postEvent.isSizeChanged());
|
||||
|
||||
Assert.assertEquals(false, LISTENER.postEvent.isRange());
|
||||
Assert.assertEquals(-1, LISTENER.postEvent.getRangeOffset());
|
||||
Assert.assertEquals(null, LISTENER.postEvent.getRange());
|
||||
Assert.assertEquals(false, LISTENER.postEvent.isView());
|
||||
Assert.assertEquals(-1, LISTENER.postEvent.getViewOffset());
|
||||
Assert.assertEquals(null, LISTENER.postEvent.getView());
|
||||
Assert.assertEquals(false, LISTENER.postEvent.isTypeAdd());
|
||||
Assert.assertEquals(true, LISTENER.postEvent.isTypeReduce());
|
||||
Assert.assertEquals(false, LISTENER.postEvent.isTypeChange());
|
||||
@ -858,9 +870,9 @@ public class ObservedTestHelper {
|
||||
Assert.assertEquals(-3, LISTENER.postEvent.getSizeChange());
|
||||
Assert.assertEquals(true, LISTENER.postEvent.isSizeChanged());
|
||||
|
||||
Assert.assertEquals(false, LISTENER.postEvent.isRange());
|
||||
Assert.assertEquals(-1, LISTENER.postEvent.getRangeOffset());
|
||||
Assert.assertEquals(null, LISTENER.postEvent.getRange());
|
||||
Assert.assertEquals(false, LISTENER.postEvent.isView());
|
||||
Assert.assertEquals(-1, LISTENER.postEvent.getViewOffset());
|
||||
Assert.assertEquals(null, LISTENER.postEvent.getView());
|
||||
Assert.assertEquals(false, LISTENER.postEvent.isTypeAdd());
|
||||
Assert.assertEquals(true, LISTENER.postEvent.isTypeReduce());
|
||||
Assert.assertEquals(false, LISTENER.postEvent.isTypeChange());
|
||||
@ -903,9 +915,9 @@ public class ObservedTestHelper {
|
||||
Assert.assertEquals(-1, LISTENER.postEvent.getSizeChange());
|
||||
Assert.assertEquals(true, LISTENER.postEvent.isSizeChanged());
|
||||
|
||||
Assert.assertEquals(false, LISTENER.postEvent.isRange());
|
||||
Assert.assertEquals(-1, LISTENER.postEvent.getRangeOffset());
|
||||
Assert.assertEquals(null, LISTENER.postEvent.getRange());
|
||||
Assert.assertEquals(false, LISTENER.postEvent.isView());
|
||||
Assert.assertEquals(-1, LISTENER.postEvent.getViewOffset());
|
||||
Assert.assertEquals(null, LISTENER.postEvent.getView());
|
||||
Assert.assertEquals(false, LISTENER.postEvent.isTypeAdd());
|
||||
Assert.assertEquals(true, LISTENER.postEvent.isTypeReduce());
|
||||
Assert.assertEquals(false, LISTENER.postEvent.isTypeChange());
|
||||
@ -951,9 +963,9 @@ public class ObservedTestHelper {
|
||||
Assert.assertEquals(-1, LISTENER.postEvent.getSizeChange());
|
||||
Assert.assertEquals(true, LISTENER.postEvent.isSizeChanged());
|
||||
|
||||
Assert.assertEquals(false, LISTENER.postEvent.isRange());
|
||||
Assert.assertEquals(-1, LISTENER.postEvent.getRangeOffset());
|
||||
Assert.assertEquals(null, LISTENER.postEvent.getRange());
|
||||
Assert.assertEquals(false, LISTENER.postEvent.isView());
|
||||
Assert.assertEquals(-1, LISTENER.postEvent.getViewOffset());
|
||||
Assert.assertEquals(null, LISTENER.postEvent.getView());
|
||||
Assert.assertEquals(false, LISTENER.postEvent.isTypeAdd());
|
||||
Assert.assertEquals(true, LISTENER.postEvent.isTypeReduce());
|
||||
Assert.assertEquals(false, LISTENER.postEvent.isTypeChange());
|
||||
@ -1006,9 +1018,9 @@ public class ObservedTestHelper {
|
||||
Assert.assertEquals(-1, LISTENER.postEvent.getSizeChange());
|
||||
Assert.assertEquals(true, LISTENER.postEvent.isSizeChanged());
|
||||
|
||||
Assert.assertEquals(false, LISTENER.postEvent.isRange());
|
||||
Assert.assertEquals(-1, LISTENER.postEvent.getRangeOffset());
|
||||
Assert.assertEquals(null, LISTENER.postEvent.getRange());
|
||||
Assert.assertEquals(false, LISTENER.postEvent.isView());
|
||||
Assert.assertEquals(-1, LISTENER.postEvent.getViewOffset());
|
||||
Assert.assertEquals(null, LISTENER.postEvent.getView());
|
||||
Assert.assertEquals(false, LISTENER.postEvent.isTypeAdd());
|
||||
Assert.assertEquals(true, LISTENER.postEvent.isTypeReduce());
|
||||
Assert.assertEquals(false, LISTENER.postEvent.isTypeChange());
|
||||
@ -1058,9 +1070,9 @@ public class ObservedTestHelper {
|
||||
Assert.assertEquals(-2, LISTENER.postEvent.getSizeChange());
|
||||
Assert.assertEquals(true, LISTENER.postEvent.isSizeChanged());
|
||||
|
||||
Assert.assertEquals(false, LISTENER.postEvent.isRange());
|
||||
Assert.assertEquals(-1, LISTENER.postEvent.getRangeOffset());
|
||||
Assert.assertEquals(null, LISTENER.postEvent.getRange());
|
||||
Assert.assertEquals(false, LISTENER.postEvent.isView());
|
||||
Assert.assertEquals(-1, LISTENER.postEvent.getViewOffset());
|
||||
Assert.assertEquals(null, LISTENER.postEvent.getView());
|
||||
Assert.assertEquals(false, LISTENER.postEvent.isTypeAdd());
|
||||
Assert.assertEquals(true, LISTENER.postEvent.isTypeReduce());
|
||||
Assert.assertEquals(false, LISTENER.postEvent.isTypeChange());
|
||||
@ -1110,9 +1122,9 @@ public class ObservedTestHelper {
|
||||
Assert.assertEquals(-1, LISTENER.postEvent.getSizeChange());
|
||||
Assert.assertEquals(true, LISTENER.postEvent.isSizeChanged());
|
||||
|
||||
Assert.assertEquals(false, LISTENER.postEvent.isRange());
|
||||
Assert.assertEquals(-1, LISTENER.postEvent.getRangeOffset());
|
||||
Assert.assertEquals(null, LISTENER.postEvent.getRange());
|
||||
Assert.assertEquals(false, LISTENER.postEvent.isView());
|
||||
Assert.assertEquals(-1, LISTENER.postEvent.getViewOffset());
|
||||
Assert.assertEquals(null, LISTENER.postEvent.getView());
|
||||
Assert.assertEquals(false, LISTENER.postEvent.isTypeAdd());
|
||||
Assert.assertEquals(true, LISTENER.postEvent.isTypeReduce());
|
||||
Assert.assertEquals(false, LISTENER.postEvent.isTypeChange());
|
||||
@ -1163,9 +1175,9 @@ public class ObservedTestHelper {
|
||||
Assert.assertEquals(0, LISTENER.postEvent.getSizeChange());
|
||||
Assert.assertEquals(false, LISTENER.postEvent.isSizeChanged());
|
||||
|
||||
Assert.assertEquals(false, LISTENER.postEvent.isRange());
|
||||
Assert.assertEquals(-1, LISTENER.postEvent.getRangeOffset());
|
||||
Assert.assertEquals(null, LISTENER.postEvent.getRange());
|
||||
Assert.assertEquals(false, LISTENER.postEvent.isView());
|
||||
Assert.assertEquals(-1, LISTENER.postEvent.getViewOffset());
|
||||
Assert.assertEquals(null, LISTENER.postEvent.getView());
|
||||
Assert.assertEquals(false, LISTENER.postEvent.isTypeAdd());
|
||||
Assert.assertEquals(false, LISTENER.postEvent.isTypeReduce());
|
||||
Assert.assertEquals(true, LISTENER.postEvent.isTypeChange());
|
||||
@ -1211,9 +1223,9 @@ public class ObservedTestHelper {
|
||||
Assert.assertEquals(0, LISTENER.postEvent.getSizeChange());
|
||||
Assert.assertEquals(false, LISTENER.postEvent.isSizeChanged());
|
||||
|
||||
Assert.assertEquals(false, LISTENER.postEvent.isRange());
|
||||
Assert.assertEquals(-1, LISTENER.postEvent.getRangeOffset());
|
||||
Assert.assertEquals(null, LISTENER.postEvent.getRange());
|
||||
Assert.assertEquals(false, LISTENER.postEvent.isView());
|
||||
Assert.assertEquals(-1, LISTENER.postEvent.getViewOffset());
|
||||
Assert.assertEquals(null, LISTENER.postEvent.getView());
|
||||
Assert.assertEquals(false, LISTENER.postEvent.isTypeAdd());
|
||||
Assert.assertEquals(false, LISTENER.postEvent.isTypeReduce());
|
||||
Assert.assertEquals(true, LISTENER.postEvent.isTypeChange());
|
||||
@ -1242,9 +1254,9 @@ public class ObservedTestHelper {
|
||||
Assert.assertSame(EIGHT, LISTENER.postEvent.getChangeObject());
|
||||
Assert.assertEquals(5, LISTENER.postEvent.getPreSize());
|
||||
Assert.assertEquals(6, LISTENER.postEvent.getPostSize());
|
||||
Assert.assertEquals(true, LISTENER.postEvent.isRange());
|
||||
Assert.assertEquals(1, LISTENER.postEvent.getRangeOffset());
|
||||
Assert.assertSame(subList, LISTENER.postEvent.getRange());
|
||||
Assert.assertEquals(true, LISTENER.postEvent.isView());
|
||||
Assert.assertEquals(1, LISTENER.postEvent.getViewOffset());
|
||||
Assert.assertSame(subList, LISTENER.postEvent.getView());
|
||||
|
||||
LISTENER.preEvent = null;
|
||||
LISTENER.postEvent = null;
|
||||
@ -1259,9 +1271,9 @@ public class ObservedTestHelper {
|
||||
Assert.assertSame(EIGHT, LISTENER.postEvent.getChangeObject());
|
||||
Assert.assertEquals(6, LISTENER.postEvent.getPreSize());
|
||||
Assert.assertEquals(7, LISTENER.postEvent.getPostSize());
|
||||
Assert.assertEquals(true, LISTENER.postEvent.isRange());
|
||||
Assert.assertEquals(1, LISTENER.postEvent.getRangeOffset());
|
||||
Assert.assertSame(subList, LISTENER.postEvent.getRange());
|
||||
Assert.assertEquals(true, LISTENER.postEvent.isView());
|
||||
Assert.assertEquals(1, LISTENER.postEvent.getViewOffset());
|
||||
Assert.assertSame(subList, LISTENER.postEvent.getView());
|
||||
|
||||
LISTENER.preEvent = null;
|
||||
LISTENER.postEvent = null;
|
||||
@ -1277,9 +1289,9 @@ public class ObservedTestHelper {
|
||||
Assert.assertSame(SIX, LISTENER.postEvent.getPrevious());
|
||||
Assert.assertEquals(7, LISTENER.postEvent.getPreSize());
|
||||
Assert.assertEquals(7, LISTENER.postEvent.getPostSize());
|
||||
Assert.assertEquals(true, LISTENER.postEvent.isRange());
|
||||
Assert.assertEquals(1, LISTENER.postEvent.getRangeOffset());
|
||||
Assert.assertSame(subList, LISTENER.postEvent.getRange());
|
||||
Assert.assertEquals(true, LISTENER.postEvent.isView());
|
||||
Assert.assertEquals(1, LISTENER.postEvent.getViewOffset());
|
||||
Assert.assertSame(subList, LISTENER.postEvent.getView());
|
||||
|
||||
LISTENER.preEvent = null;
|
||||
LISTENER.postEvent = null;
|
||||
@ -1297,9 +1309,9 @@ public class ObservedTestHelper {
|
||||
Assert.assertSame(SEVEN, LISTENER.postEvent.getPrevious());
|
||||
Assert.assertEquals(7, LISTENER.postEvent.getPreSize());
|
||||
Assert.assertEquals(6, LISTENER.postEvent.getPostSize());
|
||||
Assert.assertEquals(true, LISTENER.postEvent.isRange());
|
||||
Assert.assertEquals(1, LISTENER.postEvent.getRangeOffset());
|
||||
Assert.assertSame(subList, LISTENER.postEvent.getRange());
|
||||
Assert.assertEquals(true, LISTENER.postEvent.isView());
|
||||
Assert.assertEquals(1, LISTENER.postEvent.getViewOffset());
|
||||
Assert.assertSame(subList, LISTENER.postEvent.getView());
|
||||
|
||||
LISTENER.preEvent = null;
|
||||
LISTENER.postEvent = null;
|
||||
@ -1319,9 +1331,9 @@ public class ObservedTestHelper {
|
||||
Assert.assertSame(SEVEN, LISTENER.postEvent.getPrevious());
|
||||
Assert.assertEquals(6, LISTENER.postEvent.getPreSize());
|
||||
Assert.assertEquals(6, LISTENER.postEvent.getPostSize());
|
||||
Assert.assertEquals(true, LISTENER.postEvent.isRange());
|
||||
Assert.assertEquals(1, LISTENER.postEvent.getRangeOffset());
|
||||
Assert.assertSame(subList, LISTENER.postEvent.getRange());
|
||||
Assert.assertEquals(true, LISTENER.postEvent.isView());
|
||||
Assert.assertEquals(1, LISTENER.postEvent.getViewOffset());
|
||||
Assert.assertSame(subList, LISTENER.postEvent.getView());
|
||||
|
||||
LISTENER.preEvent = null;
|
||||
LISTENER.postEvent = null;
|
||||
@ -1337,9 +1349,9 @@ public class ObservedTestHelper {
|
||||
Assert.assertSame(null, LISTENER.postEvent.getPrevious());
|
||||
Assert.assertEquals(6, LISTENER.postEvent.getPreSize());
|
||||
Assert.assertEquals(2, LISTENER.postEvent.getPostSize());
|
||||
Assert.assertEquals(true, LISTENER.postEvent.isRange());
|
||||
Assert.assertEquals(1, LISTENER.postEvent.getRangeOffset());
|
||||
Assert.assertSame(subList, LISTENER.postEvent.getRange());
|
||||
Assert.assertEquals(true, LISTENER.postEvent.isView());
|
||||
Assert.assertEquals(1, LISTENER.postEvent.getViewOffset());
|
||||
Assert.assertSame(subList, LISTENER.postEvent.getView());
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/test/org/apache/commons/collections/observed/Attic/TestAll.java,v 1.2 2003/09/07 16:50:59 scolebourne Exp $
|
||||
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/test/org/apache/commons/collections/observed/Attic/TestAll.java,v 1.3 2003/09/21 20:01:53 scolebourne Exp $
|
||||
* ====================================================================
|
||||
*
|
||||
* The Apache Software License, Version 1.1
|
||||
@ -65,7 +65,7 @@ import junit.framework.TestSuite;
|
||||
* Entry point for all collections observed tests.
|
||||
*
|
||||
* @since Commons Collections 3.0
|
||||
* @version $Revision: 1.2 $ $Date: 2003/09/07 16:50:59 $
|
||||
* @version $Revision: 1.3 $ $Date: 2003/09/21 20:01:53 $
|
||||
*
|
||||
* @author Stephen Colebourne
|
||||
*/
|
||||
@ -83,11 +83,12 @@ public class TestAll extends TestCase {
|
||||
public static Test suite() {
|
||||
TestSuite suite = new TestSuite();
|
||||
|
||||
suite.addTest(TestObservedBag.suite());
|
||||
suite.addTest(TestObservedBuffer.suite());
|
||||
suite.addTest(TestObservedCollection.suite());
|
||||
suite.addTest(TestObservedList.suite());
|
||||
suite.addTest(TestObservedSet.suite());
|
||||
suite.addTest(TestObservableBag.suite());
|
||||
suite.addTest(TestObservableBuffer.suite());
|
||||
suite.addTest(TestObservableCollection.suite());
|
||||
suite.addTest(TestObservableList.suite());
|
||||
suite.addTest(TestObservableSet.suite());
|
||||
suite.addTest(TestObservableSortedSet.suite());
|
||||
|
||||
return suite;
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/test/org/apache/commons/collections/observed/Attic/TestObservedBag.java,v 1.2 2003/09/21 16:00:55 scolebourne Exp $
|
||||
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/test/org/apache/commons/collections/observed/Attic/TestObservableBag.java,v 1.1 2003/09/21 20:01:53 scolebourne Exp $
|
||||
* ====================================================================
|
||||
*
|
||||
* The Apache Software License, Version 1.1
|
||||
@ -69,22 +69,22 @@ import org.apache.commons.collections.TestBag;
|
||||
* {@link ObservableBag} implementation.
|
||||
*
|
||||
* @since Commons Collections 3.0
|
||||
* @version $Revision: 1.2 $ $Date: 2003/09/21 16:00:55 $
|
||||
* @version $Revision: 1.1 $ $Date: 2003/09/21 20:01:53 $
|
||||
*
|
||||
* @author Stephen Colebourne
|
||||
*/
|
||||
public class TestObservedBag extends TestBag implements ObservedTestHelper.ObservedFactory {
|
||||
public class TestObservableBag extends TestBag implements ObservedTestHelper.ObservedFactory {
|
||||
|
||||
public TestObservedBag(String testName) {
|
||||
public TestObservableBag(String testName) {
|
||||
super(testName);
|
||||
}
|
||||
|
||||
public static Test suite() {
|
||||
return new TestSuite(TestObservedBag.class);
|
||||
return new TestSuite(TestObservableBag.class);
|
||||
}
|
||||
|
||||
public static void main(String args[]) {
|
||||
String[] testCaseName = { TestObservedBag.class.getName()};
|
||||
String[] testCaseName = { TestObservableBag.class.getName()};
|
||||
junit.textui.TestRunner.main(testCaseName);
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/test/org/apache/commons/collections/observed/Attic/TestObservedBuffer.java,v 1.2 2003/09/21 16:00:55 scolebourne Exp $
|
||||
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/test/org/apache/commons/collections/observed/Attic/TestObservableBuffer.java,v 1.1 2003/09/21 20:01:53 scolebourne Exp $
|
||||
* ====================================================================
|
||||
*
|
||||
* The Apache Software License, Version 1.1
|
||||
@ -72,22 +72,22 @@ import org.apache.commons.collections.TestCollection;
|
||||
* {@link ObservableBuffer} implementation.
|
||||
*
|
||||
* @since Commons Collections 3.0
|
||||
* @version $Revision: 1.2 $ $Date: 2003/09/21 16:00:55 $
|
||||
* @version $Revision: 1.1 $ $Date: 2003/09/21 20:01:53 $
|
||||
*
|
||||
* @author Stephen Colebourne
|
||||
*/
|
||||
public class TestObservedBuffer extends TestCollection implements ObservedTestHelper.ObservedFactory {
|
||||
public class TestObservableBuffer extends TestCollection implements ObservedTestHelper.ObservedFactory {
|
||||
|
||||
public TestObservedBuffer(String testName) {
|
||||
public TestObservableBuffer(String testName) {
|
||||
super(testName);
|
||||
}
|
||||
|
||||
public static Test suite() {
|
||||
return new TestSuite(TestObservedBuffer.class);
|
||||
return new TestSuite(TestObservableBuffer.class);
|
||||
}
|
||||
|
||||
public static void main(String args[]) {
|
||||
String[] testCaseName = { TestObservedBuffer.class.getName()};
|
||||
String[] testCaseName = { TestObservableBuffer.class.getName()};
|
||||
junit.textui.TestRunner.main(testCaseName);
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/test/org/apache/commons/collections/observed/Attic/TestObservedCollection.java,v 1.2 2003/09/21 16:00:56 scolebourne Exp $
|
||||
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/test/org/apache/commons/collections/observed/Attic/TestObservableCollection.java,v 1.1 2003/09/21 20:01:53 scolebourne Exp $
|
||||
* ====================================================================
|
||||
*
|
||||
* The Apache Software License, Version 1.1
|
||||
@ -72,22 +72,22 @@ import org.apache.commons.collections.TestCollection;
|
||||
* {@link ObservedCollection} implementation.
|
||||
*
|
||||
* @since Commons Collections 3.0
|
||||
* @version $Revision: 1.2 $ $Date: 2003/09/21 16:00:56 $
|
||||
* @version $Revision: 1.1 $ $Date: 2003/09/21 20:01:53 $
|
||||
*
|
||||
* @author Stephen Colebourne
|
||||
*/
|
||||
public class TestObservedCollection extends TestCollection implements ObservedTestHelper.ObservedFactory {
|
||||
public class TestObservableCollection extends TestCollection implements ObservedTestHelper.ObservedFactory {
|
||||
|
||||
public TestObservedCollection(String testName) {
|
||||
public TestObservableCollection(String testName) {
|
||||
super(testName);
|
||||
}
|
||||
|
||||
public static Test suite() {
|
||||
return new TestSuite(TestObservedCollection.class);
|
||||
return new TestSuite(TestObservableCollection.class);
|
||||
}
|
||||
|
||||
public static void main(String args[]) {
|
||||
String[] testCaseName = { TestObservedCollection.class.getName()};
|
||||
String[] testCaseName = { TestObservableCollection.class.getName()};
|
||||
junit.textui.TestRunner.main(testCaseName);
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/test/org/apache/commons/collections/observed/Attic/TestObservedList.java,v 1.2 2003/09/21 16:00:56 scolebourne Exp $
|
||||
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/test/org/apache/commons/collections/observed/Attic/TestObservableList.java,v 1.1 2003/09/21 20:01:53 scolebourne Exp $
|
||||
* ====================================================================
|
||||
*
|
||||
* The Apache Software License, Version 1.1
|
||||
@ -71,22 +71,22 @@ import org.apache.commons.collections.TestList;
|
||||
* {@link ObservedList} implementation.
|
||||
*
|
||||
* @since Commons Collections 3.0
|
||||
* @version $Revision: 1.2 $ $Date: 2003/09/21 16:00:56 $
|
||||
* @version $Revision: 1.1 $ $Date: 2003/09/21 20:01:53 $
|
||||
*
|
||||
* @author Stephen Colebourne
|
||||
*/
|
||||
public class TestObservedList extends TestList implements ObservedTestHelper.ObservedFactory {
|
||||
public class TestObservableList extends TestList implements ObservedTestHelper.ObservedFactory {
|
||||
|
||||
public TestObservedList(String testName) {
|
||||
public TestObservableList(String testName) {
|
||||
super(testName);
|
||||
}
|
||||
|
||||
public static Test suite() {
|
||||
return new TestSuite(TestObservedList.class);
|
||||
return new TestSuite(TestObservableList.class);
|
||||
}
|
||||
|
||||
public static void main(String args[]) {
|
||||
String[] testCaseName = { TestObservedList.class.getName()};
|
||||
String[] testCaseName = { TestObservableList.class.getName()};
|
||||
junit.textui.TestRunner.main(testCaseName);
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/test/org/apache/commons/collections/observed/Attic/TestObservedSet.java,v 1.2 2003/09/21 16:00:56 scolebourne Exp $
|
||||
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/test/org/apache/commons/collections/observed/Attic/TestObservableSet.java,v 1.1 2003/09/21 20:01:53 scolebourne Exp $
|
||||
* ====================================================================
|
||||
*
|
||||
* The Apache Software License, Version 1.1
|
||||
@ -71,22 +71,22 @@ import org.apache.commons.collections.TestSet;
|
||||
* {@link ObservedSet} implementation.
|
||||
*
|
||||
* @since Commons Collections 3.0
|
||||
* @version $Revision: 1.2 $ $Date: 2003/09/21 16:00:56 $
|
||||
* @version $Revision: 1.1 $ $Date: 2003/09/21 20:01:53 $
|
||||
*
|
||||
* @author Stephen Colebourne
|
||||
*/
|
||||
public class TestObservedSet extends TestSet implements ObservedTestHelper.ObservedFactory {
|
||||
public class TestObservableSet extends TestSet implements ObservedTestHelper.ObservedFactory {
|
||||
|
||||
public TestObservedSet(String testName) {
|
||||
public TestObservableSet(String testName) {
|
||||
super(testName);
|
||||
}
|
||||
|
||||
public static Test suite() {
|
||||
return new TestSuite(TestObservedSet.class);
|
||||
return new TestSuite(TestObservableSet.class);
|
||||
}
|
||||
|
||||
public static void main(String args[]) {
|
||||
String[] testCaseName = { TestObservedSet.class.getName()};
|
||||
String[] testCaseName = { TestObservableSet.class.getName()};
|
||||
junit.textui.TestRunner.main(testCaseName);
|
||||
}
|
||||
|
@ -0,0 +1,118 @@
|
||||
/*
|
||||
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/test/org/apache/commons/collections/observed/Attic/TestObservableSortedSet.java,v 1.1 2003/09/21 20:01:53 scolebourne Exp $
|
||||
* ====================================================================
|
||||
*
|
||||
* The Apache Software License, Version 1.1
|
||||
*
|
||||
* Copyright (c) 2003 The Apache Software Foundation. All rights
|
||||
* reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* 3. The end-user documentation included with the redistribution, if
|
||||
* any, must include the following acknowledgement:
|
||||
* "This product includes software developed by the
|
||||
* Apache Software Foundation (http://www.apache.org/)."
|
||||
* Alternately, this acknowledgement may appear in the software itself,
|
||||
* if and wherever such third-party acknowledgements normally appear.
|
||||
*
|
||||
* 4. The names "The Jakarta Project", "Commons", and "Apache Software
|
||||
* Foundation" must not be used to endorse or promote products derived
|
||||
* from this software without prior written permission. For written
|
||||
* permission, please contact apache@apache.org.
|
||||
*
|
||||
* 5. Products derived from this software may not be called "Apache"
|
||||
* nor may "Apache" appear in their names without prior written
|
||||
* permission of the Apache Software Foundation.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
|
||||
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
||||
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
||||
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
* ====================================================================
|
||||
*
|
||||
* This software consists of voluntary contributions made by many
|
||||
* individuals on behalf of the Apache Software Foundation. For more
|
||||
* information on the Apache Software Foundation, please see
|
||||
* <http://www.apache.org/>.
|
||||
*
|
||||
*/
|
||||
package org.apache.commons.collections.observed;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
|
||||
import junit.framework.Test;
|
||||
import junit.framework.TestSuite;
|
||||
|
||||
import org.apache.commons.collections.TestSortedSet;
|
||||
|
||||
/**
|
||||
* Extension of {@link TestSet} for exercising the
|
||||
* {@link ObservedSet} implementation.
|
||||
*
|
||||
* @since Commons Collections 3.0
|
||||
* @version $Revision: 1.1 $ $Date: 2003/09/21 20:01:53 $
|
||||
*
|
||||
* @author Stephen Colebourne
|
||||
*/
|
||||
public class TestObservableSortedSet extends TestSortedSet implements ObservedTestHelper.ObservedFactory {
|
||||
|
||||
public TestObservableSortedSet(String testName) {
|
||||
super(testName);
|
||||
}
|
||||
|
||||
public static Test suite() {
|
||||
return new TestSuite(TestObservableSortedSet.class);
|
||||
}
|
||||
|
||||
public static void main(String args[]) {
|
||||
String[] testCaseName = { TestObservableSortedSet.class.getName()};
|
||||
junit.textui.TestRunner.main(testCaseName);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
public Set makeEmptySet() {
|
||||
return ObservableSortedSet.decorate(new TreeSet(), ObservedTestHelper.LISTENER);
|
||||
}
|
||||
|
||||
protected Set makeFullSet() {
|
||||
Set set = new TreeSet();
|
||||
set.addAll(Arrays.asList(getFullElements()));
|
||||
return ObservableSortedSet.decorate(set, ObservedTestHelper.LISTENER);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
public void testObservedSortedSet() {
|
||||
ObservedTestHelper.bulkTestObservedSortedSet(this);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
public ObservableCollection createObservedCollection() {
|
||||
return ObservableSortedSet.decorate(new TreeSet());
|
||||
}
|
||||
|
||||
public ObservableCollection createObservedCollection(Object listener) {
|
||||
return ObservableSortedSet.decorate(new TreeSet(), listener);
|
||||
}
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user