Hi Dave

This all looks awesome! (Still got problems posting to the list?)

We should do some JUnit test cases or sample programs to demonstrate this
stuff too... :-)

From: "David White" <[EMAIL PROTECTED]>
> How about this:
>
>     private void initDispatchMode() {
>         if (dispatchHandler == null) {
>             setDispatchHandler(new DispatchHandler());
>         }
>     }
>
>     private DispatchHandler getDispatchHandler() {
>         return dispatchHandler;
>     }
>
>     private void setDispatchHandler(DispatchHandler dispatchHandler) {
>         this.dispatchHandler = dispatchHandler;
>     }
>
>     public void addHandler(String path, ElementHandler handler) {
>         initDispatchMode();
>         getDispatchHandler().addHandler(path, handler);
>     }
>
>     public void removeHandler(String path) {
>         initDispatchMode();
>         getDispatchHandler().removeHandler(path, handler);
>     }
>
>     public void setDefaultHandler(String path, ElementHandler handler) {
>         initDispatchMode();
>         getDispatchHandler().setDefaultHandler(path, handler);
>     }
>
> This way, the DispatchHandler is hidden from the user.  If all they
> want to do is have one ElementHandler for a particular path, then
> they would just do:
>
>     SAXReader reader = new SAXReader();
>     reader.addHandler("/some/path", new mySomePathHandler());
>
> If they want to have handler for multiple paths, then the just need
> to add more handlers:
>
>     reader.addHandler("/my/other/path", new myOtherPathHandler());
>
> I've also added the methods:
>
>     public void addHandler(String path, ElementHandler handler);
>     public void removeHandler(String path);
>
> to the ElementPath interface, which allows ElementHandlers to
> register/unregister sub-handlers in their onStart/onEnd methods
> respectively.  This is a necessity in order to handle recursively
> nested elements.


James



_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com


_______________________________________________
dom4j-dev mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/dom4j-dev

Reply via email to