Justin Deoliveira ha scritto:
> Hi all,
>
> I have found in a couple of places when writing listeners for the
> catalog doing stuff like this:
>
> public void handleModifyEvent(CatalogModifyEvent event) {
> if ( event.getSource() instanceof DataStoreInfo ) {
>
> }
> else if ( event.getSource() instanceof FeatureTypeInfo ) {
>
> }
> else if ( ... )
>
> }
>
> And the list goes on. What would be nice is a visitor for catalog
> objects. So I could do somethign like this:
>
> public void handleModifyEvent(CatalogModifyEvent event) {
> CatalogVisitor visitor = new CatlaogVisitgor() {
> void visitDataStoreInfo( DataStoreInfo ) {
> }
>
> void visitDataStoreInfo( FeatureTypeInfo ) {
> }
>
> ...
> }
>
> event.getSource().accept( visitor );
> }
>
> And ideally a CatalogVisitorAdapter which stubs all the visitor methods
> so that a listener can implement only the methods of relevance.
Works for me, but how do we deal with code that wants to throw a
safeguard exception in the last else? The usual "there is a programing
error, I don't know what this thing is" kind of exception.
Cheers
Andrea
--
Andrea Aime
OpenGeo - http://opengeo.org
Expert service straight from the developers.
------------------------------------------------------------------------------
_______________________________________________
Geoserver-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geoserver-devel