[Home] [By Thread] [By Date] [Recent Entries]
Uche Ogbuji wrote: > On Mon, 2005-01-03 at 09:11 -0500, Karl Waclawek wrote: > >>A SAX event handler can handle exceptions thrown by the calls it makes. >>Or it can let them escape. Depends on whether it wants to "notify" >>the event generator or not. How is that not possible in Java? > > > It sounds to me that the problem is that he does not want to have to > rewrite the ContentHandler to configure this behavior for each different > parse. I don't think this is possible in Java, because exceptions are > based on compile-time declarations. > > Perhaps you could look at my sample Python code for an example of what I > think he wants (which I think is only possible in such a straightforward > manner with a dynamic language). In my example, changing the exception > handling behavior is a matter of different handler instantiation > parameters, rather than different handler code. OK, I see what you mean. One thing that can be done easily in Java is to change the handler instance dynamically. > Then again, thinking about it, maybe this could be done in Java by > registering flags on the handler that are checked within the catch code > block in order to change behavior. Not as straightforward, but it may > work. Yes, but instead of flags one can use reflection. Karl
|

Cart



