net.m2technologies.open_arm.utilities.collections
Class ExceptionalClosure

java.lang.Object
  extended bynet.m2technologies.open_arm.utilities.collections.ExceptionalClosure

public abstract class ExceptionalClosure
extends java.lang.Object

Copyright 2005 Mark Masterson

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Description: Abstract class to use the Closure interface to handle checked exceptions. Normally, an iteration shouldn't cause any checked exceptions. Every checked exception is wrapped into a RuntimeClosureException. The user of this class has to rewrite the #basicExecute method. The usage of this class may be combined with a special #forAllDo method to clear the checked exception or unwrap it to throw it again.

Version:
0.009
Author:
Peter Ko´┐Żek

Constructor Summary
ExceptionalClosure()
           
 
Method Summary
protected abstract  void basicExecute(java.lang.Object o)
          method to wrap any selecting code who can throw a checked exception.
 void execute(java.lang.Object o)
          redefine the #execute method to establish a mechanism to tunnel checked exceptions through the Commons-Collection API which doesn't know checked exceptions.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ExceptionalClosure

public ExceptionalClosure()
Method Detail

execute

public final void execute(java.lang.Object o)
                   throws RuntimeClosureException
redefine the #execute method to establish a mechanism to tunnel checked exceptions through the Commons-Collection API which doesn't know checked exceptions. The method is declared final because you should use #basicExecute now.

Throws:
RuntimeClosureException
See Also:
org.apache.commons.collections.Closure#execute

basicExecute

protected abstract void basicExecute(java.lang.Object o)
                              throws java.lang.Exception
method to wrap any selecting code who can throw a checked exception. This method is called by the #execute method of this class, which will wrap the exception into a RuntimeClosureException.

Throws:
java.lang.Exception