commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Stephen Colebourne" <scolebou...@btopenworld.com>
Subject Re: [collections] Observable next steps
Date Wed, 28 May 2003 21:12:38 GMT
From: "Michael Heuer" <heuermh@acm.org>
> On Sat, 24 May 2003, Stephen Colebourne wrote:
>
> > CollectionChangeEvent:
> >  Collection collection - the collection (current reference, ie. after
> > change)
> >  int numberChanged - the number of elements changing
> >  int changeIndex - for Lists, the index where the change starts
> >  Object changed - the value/collection being added/removed/changed
> >  boolean bulkOperation - true if addAll() etc. or clear()
> >  int oldSize - size before change
> >  int newSize - size after change
> >  boolean sizeChanged - (derived from previous two)
>
> It looks to me that collecting this information may require
> synchronization in the decorator -- is that acceptable?
>
> ObservableCollection
>   extends AbstractCollectionDecorator
>
> public boolean add(Object object)
> {
>   // synchronized {
>
>   int oldSize = size();
>   boolean returnVal = super.add(object);
>   int newSize = size();
>
>   // }
>
>   if (returnVal)
>     support.fireElementAdded(oldSize, newSize, object);
>
>   return returnVal;
> }
>

Synchronization is not the concern of the Observable classes. The user must
synchronize themselves if it is important.

Stephen




---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message