Index: lutinutil/src/java/org/codelutin/util/MultiOptionAction.java diff -u /dev/null lutinutil/src/java/org/codelutin/util/MultiOptionAction.java:1.1 --- /dev/null Thu Dec 13 01:24:39 2007 +++ lutinutil/src/java/org/codelutin/util/MultiOptionAction.java Thu Dec 13 01:24:34 2007 @@ -0,0 +1,51 @@ +/* +* ##% Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007 Code Lutin, +* Benjamin Poussin, Tony Chemit +* +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License +* as published by the Free Software Foundation; either version 2 +* of the License, or (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +* ##% */ +package org.codelutin.util; + +/** + * A simple multi-action for an option with four hooks : one before all ,one after all. + * on before each action, one after each action. + * + * @author tony + */ +public abstract class MultiOptionAction implements OptionAction { + + protected void runBeforeAllAction(OptionParser parser) throws Exception { + } + + protected void runAfterAllAction(OptionParser parser) throws Exception { + } + + protected void runAfterAction(OptionParser parser, Option t) throws Exception { + } + + protected void runBeforeAction(OptionParser parser, Option t) throws Exception { + } + + public void run(OptionParser parser, T... option) throws Exception { + runBeforeAllAction(parser); + for (T t : option) { + runBeforeAction(parser, t); + run(parser, t); + runAfterAction(parser, t); + } + runAfterAllAction(parser); + } +}