Niall Pemberton wrote on Friday, January 12, 2007 1:44 AM:
> On 1/12/07, James Carman <[EMAIL PROTECTED]> wrote:
>> "Sorry, but this doesn't seem like a very good argument to me - on
>> this basis you could argue against the whole existance of IO - since
>> it provides stuff thats not in the JDK"
>>
>> I don't know if I agree with this point, Niall. The "stuff" that's
>> in IO wasn't left out of the JDK because of coding style, which is
>> the reason Stephen (I believe that's who said it) is saying we
>> shouldn't use nested exception classes. I would agree that nested
>> exception classes should be avoided. I wouldn't want to have to
>> qualify my exceptions in my catch blocks:
>
> Sorry, the "existance of IO" comment was a bad attempt at "tongue in
> cheek humour" :-(
>
>> catch( DirectoryWalker.CancelException e )
>>
>> That just looks ugly/weird to me and people just usually don't do
>> that. I would agree, however, that it does group stuff logically.
>
> OK but CancelException is primarily there to control the processing
> flow internally within DirectoryWalker - its a class designed to be
> extended and implementations that do extend it don't have to qualify
> the exception. When thrown it unwinds from the recursive depths and
> causes the handleCancelled() lifecycle method to be called.
>
>
> So IMO your more likely to see an implementation that does
> something like
>
> public class MyWalker extends DirectoryWalker {
> protected void handleStart(....) throws IOException { if
> (...) { throw new CancelException(...);
> }
>
> }
> protected void handleCancelled(...) {
> // my cancel processing here
> }
> }
>
> The default implementation of that method does re-throw it and we have
> 2 scenrios for this class - cancelling internally by the process
> itself or cancelling by an external process. Where users handle
> cancellation outside of the implementation then yes they will have to
> use the DirectoryWalker.CancelException notation (I personally don't
> agree its ugly btw) - but if they don't like it they can easily
> re-throw their own.
>
> Niall
[snip]
Looks reasonable for me in this case.
- Jörg
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]