Hello!Does anyone know of a collection package/API that extendsjava.util.Observable collection classes such as Set, List and Map?I also looked at Apache collections, but they don't seem to includethat.I'd also like to get some input on whether I/you/someone need/sObservable collections at all. For me its main use would be for GUIupdates (of course), for JList's, JTabbedPane's, that is higher levelmodels.I've also looked at JGoodies binding for that matter, however thatpackage doesn't use java.util.Observable and (which is worse) doesn'tseem to be compatible with JTabbedPane's. So I came to the pointwriting Observable collections.An idea would be to build a set of collection classes as a Decorator,adding allow/forbid null, allow/forbid duplicates, and Observablefunctionality as needed. Of course, this will decrease theperformance, but this is not much of a matter (at least right now).Since I couldn't find something like it, I suspect my approach mightnot be the best and/or that there are different approaches.Can you share your experience with me please? What do you think(comments and suggestions welcome)?Karsten
|
|
0
|
|
|
|
Reply
|
kwutzke (87)
|
8/9/2007 10:01:48 AM |
|
Hi KarstenI am not sure if i came accross any such collection.just a thought ..u can think of making a class thatextends java.util.Observable and has a pvtOn Aug 9, 3:01 pm, Karsten Wutzke <kwut...@web.de> wrote:> Hello!>> Does anyone know of a collection package/API that extends> java.util.Observable collection classes such as Set, List and Map?>> I also looked at Apache collections, but they don't seem to include> that.>> I'd also like to get some input on whether I/you/someone need/s> Observable collections at all. For me its main use would be for GUI> updates (of course), for JList's, JTabbedPane's, that is higher level> models.>> I've also looked at JGoodies binding for that matter, however that> package doesn't use java.util.Observable and (which is worse) doesn't> seem to be compatible with JTabbedPane's. So I came to the point> writing Observable collections.>> An idea would be to build a set of collection classes as a Decorator,> adding allow/forbid null, allow/forbid duplicates, and Observable> functionality as needed. Of course, this will decrease the> performance, but this is not much of a matter (at least right now).>> Since I couldn't find something like it, I suspect my approach might> not be the best and/or that there are different approaches.>> Can you share your experience with me please? What do you think> (comments and suggestions welcome)?>> Karsten
|
|
0
|
|
|
|
Reply
|
inquisitive
|
8/9/2007 10:23:26 AM
|
|
u can think of making a class that
- extends java.util.Observable
- has a pvt Collection member (set/list/map)
- public getter setter and other public methods that you need (to
add , modify collection )
regards
lavnish
On Aug 9, 3:23 pm, inquisitive <lavni...@gmail.com> wrote:
> Hi Karsten
> I am not sure if i came accross any such collection.
> just a thought ..
> u can think of making a class that
> extends java.util.Observable and has a pvt
>
> On Aug 9, 3:01 pm, Karsten Wutzke <kwut...@web.de> wrote:
>
>
>
> > Hello!
>
> > Does anyone know of a collection package/API that extends
> > java.util.Observable collection classes such as Set, List and Map?
>
> > I also looked at Apache collections, but they don't seem to include
> > that.
>
> > I'd also like to get some input on whether I/you/someone need/s
> > Observable collections at all. For me its main use would be for GUI
> > updates (of course), for JList's, JTabbedPane's, that is higher level
> > models.
>
> > I've also looked at JGoodies binding for that matter, however that
> > package doesn't use java.util.Observable and (which is worse) doesn't
> > seem to be compatible with JTabbedPane's. So I came to the point
> > writing Observable collections.
>
> > An idea would be to build a set of collection classes as a Decorator,
> > adding allow/forbid null, allow/forbid duplicates, and Observable
> > functionality as needed. Of course, this will decrease the
> > performance, but this is not much of a matter (at least right now).
>
> > Since I couldn't find something like it, I suspect my approach might
> > not be the best and/or that there are different approaches.
>
> > Can you share your experience with me please? What do you think
> > (comments and suggestions welcome)?
>
> > Karsten- Hide quoted text -
>
> - Show quoted text -
|
|
0
|
|
|
|
Reply
|
inquisitive
|
8/9/2007 10:26:55 AM
|
|
On 9 Aug., 12:26, inquisitive <lavni...@gmail.com> wrote:
> u can think of making a class that
>
> - extends java.util.Observable
> - has a pvt Collection member (set/list/map)
> - public getter setter and other public methods that you need (to
> add , modify collection )
>
> regards
> lavnish
>
> On Aug 9, 3:23 pm, inquisitive <lavni...@gmail.com> wrote:
>
> > Hi Karsten
> > I am not sure if i came accross any such collection.
> > just a thought ..
> > u can think of making a class that
> > extends java.util.Observable and has a pvt
>
> > On Aug 9, 3:01 pm, Karsten Wutzke <kwut...@web.de> wrote:
>
> > > Hello!
>
> > > Does anyone know of a collection package/API that extends
> > > java.util.Observable collection classes such as Set, List and Map?
>
> > > I also looked at Apache collections, but they don't seem to include
> > > that.
>
> > > I'd also like to get some input on whether I/you/someone need/s
> > > Observable collections at all. For me its main use would be for GUI
> > > updates (of course), for JList's, JTabbedPane's, that is higher level
> > > models.
>
> > > I've also looked at JGoodies binding for that matter, however that
> > > package doesn't use java.util.Observable and (which is worse) doesn't
> > > seem to be compatible with JTabbedPane's. So I came to the point
> > > writing Observable collections.
>
> > > An idea would be to build a set of collection classes as a Decorator,
> > > adding allow/forbid null, allow/forbid duplicates, and Observable
> > > functionality as needed. Of course, this will decrease the
> > > performance, but this is not much of a matter (at least right now).
>
> > > Since I couldn't find something like it, I suspect my approach might
> > > not be the best and/or that there are different approaches.
>
> > > Can you share your experience with me please? What do you think
> > > (comments and suggestions welcome)?
>
> > > Karsten- Hide quoted text -
>
> > - Show quoted text -
Sure something like:
public class ObservableList<E> extends Observable implements List<E>,
Queue<E>, Cloneable, Serializable
{
protected static final int UNRESTRICTED = -1;
//list instance delegate
private final List<E> list;
....
}
However, the thought was that something that trivial has already been
implemented and published by someone...
Karsten
|
|
0
|
|
|
|
Reply
|
Karsten
|
8/9/2007 10:34:18 AM
|
|
hmmmmm
try
http://commons.apache.org/sandbox/events/apidocs/org/apache/commons/events/observable/ObservableCollection.html
but it has only list
http://commons.apache.org/sandbox/events/apidocs/org/apache/commons/events/observable/ObservableList.html
and Set
http://commons.apache.org/sandbox/events/apidocs/org/apache/commons/events/observable/ObservableSet.html
cheerz !!
On Aug 9, 3:34 pm, Karsten Wutzke <kwut...@web.de> wrote:
> On 9 Aug., 12:26, inquisitive <lavni...@gmail.com> wrote:
>
>
>
>
>
> > u can think of making a class that
>
> > - extends java.util.Observable
> > - has a pvt Collection member (set/list/map)
> > - public getter setter and other public methods that you need (to
> > add , modify collection )
>
> > regards
> > lavnish
>
> > On Aug 9, 3:23 pm, inquisitive <lavni...@gmail.com> wrote:
>
> > > Hi Karsten
> > > I am not sure if i came accross any such collection.
> > > just a thought ..
> > > u can think of making a class that
> > > extends java.util.Observable and has a pvt
>
> > > On Aug 9, 3:01 pm, Karsten Wutzke <kwut...@web.de> wrote:
>
> > > > Hello!
>
> > > > Does anyone know of a collection package/API that extends
> > > > java.util.Observable collection classes such as Set, List and Map?
>
> > > > I also looked at Apache collections, but they don't seem to include
> > > > that.
>
> > > > I'd also like to get some input on whether I/you/someone need/s
> > > > Observable collections at all. For me its main use would be for GUI
> > > > updates (of course), for JList's, JTabbedPane's, that is higher level
> > > > models.
>
> > > > I've also looked at JGoodies binding for that matter, however that
> > > > package doesn't use java.util.Observable and (which is worse) doesn't
> > > > seem to be compatible with JTabbedPane's. So I came to the point
> > > > writing Observable collections.
>
> > > > An idea would be to build a set of collection classes as a Decorator,
> > > > adding allow/forbid null, allow/forbid duplicates, and Observable
> > > > functionality as needed. Of course, this will decrease the
> > > > performance, but this is not much of a matter (at least right now).
>
> > > > Since I couldn't find something like it, I suspect my approach might
> > > > not be the best and/or that there are different approaches.
>
> > > > Can you share your experience with me please? What do you think
> > > > (comments and suggestions welcome)?
>
> > > > Karsten- Hide quoted text -
>
> > > - Show quoted text -
>
> Sure something like:
>
> public class ObservableList<E> extends Observable implements List<E>,
> Queue<E>, Cloneable, Serializable
> {
> protected static final int UNRESTRICTED = -1;
>
> //list instance delegate
> private final List<E> list;
>
> ...
>
> }
>
> However, the thought was that something that trivial has already been
> implemented and published by someone...
>
> Karsten- Hide quoted text -
>
> - Show quoted text -
|
|
0
|
|
|
|
Reply
|
inquisitive
|
8/9/2007 10:51:03 AM
|
|
Karsten Wutzke wrote:> > Does anyone know of a collection package/API that extends> java.util.Observable collection classes such as Set, List and Map?I don't know why you would want to use Observable. The event/listener idiom is the standard way to go about these sorts of things.Although I haven't used it myself, Glazed Lists seems to have attracted positive comments.http://publicobject.com/glazedlists/Tom Hawtin
|
|
0
|
|
|
|
Reply
|
Thomas
|
8/9/2007 11:14:10 AM
|
|
On 9 Aug., 12:51, inquisitive <lavni...@gmail.com> wrote:
> hmmmmm
> tryhttp://commons.apache.org/sandbox/events/apidocs/org/apache/commons/e...
> but it has only listhttp://commons.apache.org/sandbox/events/apidocs/org/apache/commons/e...
> and Sethttp://commons.apache.org/sandbox/events/apidocs/org/apache/commons/e...
>
> cheerz !!
>
snip
> > - Show quoted text -
Well I've been that far myself (using google)... That package is out
of date with generics and its classes are not java.util.Observable
subclasses.
So no cheers yet...
Karsten
|
|
0
|
|
|
|
Reply
|
Karsten
|
8/9/2007 12:36:23 PM
|
|
On 9 Aug., 13:14, Thomas Hawtin <use...@tackline.plus.com> wrote:
> Karsten Wutzke wrote:
>
> > Does anyone know of a collection package/API that extends
> > java.util.Observable collection classes such as Set, List and Map?
>
> I don't know why you would want to use Observable. The event/listener
> idiom is the standard way to go about these sorts of things.
>
> Although I haven't used it myself, Glazed Lists seems to have attracted
> positive comments.
>
> http://publicobject.com/glazedlists/
>
> Tom Hawtin
Well I have written some code that attaches any custom Observer
interface to any java.util.Observable. The code will generate adapter
classes *on the fly* that will downcast from Observable to the custom
observer interface:
public class SelectionObserverAdapter implements java.util.Observer
{
private SelectionObserver so;
public SelectionObserverAdapter(SelectionObserver s)
{
if ( s==null )
{
throw new NullPointerException("Selection observer is null.");
}
so = s;
}
public void update(Observable obs, Object arg)
{
so.update((Selection)obs);
}
}
Any Observable will have some custom adapter attached to be notified
on update. I wanted to avoid the downcast for every Observer
implementation and use custom observers like
public interface SelectionObserver extends GenericObserver
{
public void update(Selection s);
}
public interface EmailConstraintsObserver extends GenericObserver
{
public void update(EmailConstraints ec);
}
....
The observing class then only has to implement the respective custom
interfaces. Note attaching the two is done via generating byte code,
if I would'nt do this, I'd not only have to create the concrete
Observer interface but also an adapter class, which is a maintenance
nightmare. Since it works so nicely without this listener stuff I was
looking for Observable compatible collections...
Side notes:
1. The adapter mainly acts as a "method multiplexer", it calls the
right method due to the downcast in the update method.
2. I know the object of interest in observer is Object arg, I wanted
to get around downcasting as much as possible.
3. The code will add n adapters for every n custom observers
implemented in the observing class, so Observable will do n updates.
As this is only intended for a few connections, the overhead of
calling notifyObserver n times is not (yet?) recognizable. This is
still much cleaner than using some if then else construct with
downcasts to determine the concrete object's class.
4. Of course, I used some naming conventions for the whole class
generation stuff...
Well..... this explanation has gotton much bigger than intended. I
hope that the basic idea has become clear. In any case this is getting
a little off-topic now - I just wanted to outline my motivation.
I'm not really a friend of Java's listener concept, can't explain why
really... ?-/
Karsten
|
|
0
|
|
|
|
Reply
|
Karsten
|
8/9/2007 1:12:47 PM
|
|
|
7 Replies
321 Views
(page loaded in 0.144 seconds)
Similiar Articles: Observable collections (set, list, map) - comp.lang.java ...Hello!Does anyone know of a collection package/API that extendsjava.util.Observable collection classes such as Set, List and Map?I also looked at Apac... associative ,set associative and direct mapping - comp.arch ...Observable collections (set, list, map) - comp.lang.java ... associative ,set associative and direct mapping - comp.arch ... Observable collections (set, list, map) - comp ... iterator invalidation guarantees in tr1::unordered_map - comp.lang ...Observable collections (set, list, map) - comp.lang.java ... iterator invalidation guarantees in tr1::unordered_map - comp.lang ... TR1 examples? - comp.lang.c++.moderated ... Java Collections List : Converting from List 'Observable collections (set, list, map) - comp.lang.java ... Java Collections List : Converting from List ' Java Collections List : Converting from List '<Column ... transparent JTabbedPane - comp.lang.java.guiObservable collections (set, list, map) - comp.lang.java ... For me its main use would be for GUIupdates (of course), for JList's, JTabbedPane's ... custom class in java.* package - is it possible? - comp.lang.java ...Observable collections (set, list, map) - comp.lang.java ..... possible. 3. The code will add n adapters for every n custom observers implemented in the observing class ... Making a depot compatible with Apache 2.0 and 2.2 - comp.sys.hp ...Observable collections (set, list, map) - comp.lang.java ..... classes such as Set, List and Map?I also looked at Apache ... and (which is worse) doesn't> seem to be ... naming convention for class attributes (member data)? - comp.lang ...Observable collections (set, list, map) - comp.lang.java ... Observable collections (set, list, map) - comp.lang.java ... naming convention for class attributes (member ... calling member functions from WNPROC callback functions - comp ...You can create a map<HWND, MyClass*> to assiciate a ... window at creation time in a CREATESTRUCT), and set ... the what() member function should not modify the observable ... Largest Collection Of Solutions Manuals & Test Banks Over The Net ...Largest Collection Of Solutions Manuals & Test Banks Over The ... Gateways to Mind and Behavior with Concept Maps and ... Jackson, Slocum, Test Bank Manual AIS Practice Set ... Observable collections (set, list, map) - comp.lang.java ...Hello!Does anyone know of a collection package/API that extendsjava.util.Observable collection classes such as Set, List and Map?I also looked at Apac... Observable collections (set, list, map) - Velocity Reviews ...Hello! Does anyone know of a collection package/API that extends java.util.Observable collection classes such as Set, List and Map? I also looked at Apache ... 7/26/2012 1:36:29 AM
|