RunningStrategy.java |
1 /* 2 * Copyright (c) 1998-2005, The University of Sheffield. 3 * 4 * This file is part of GATE (see http://gate.ac.uk/), and is free 5 * software, licenced under the GNU Library General Public License, 6 * Version 2, June 1991 (in the distribution as file licence.html, 7 * and also available at http://gate.ac.uk/gate/licence.html). 8 * 9 * Valentin Tablan 11 Apr 2002 10 * 11 * $Id: RunningStrategy.java,v 1.5 2005/01/11 13:51:31 ian Exp $ 12 */ 13 package gate.creole; 14 15 16 import gate.ProcessingResource; 17 18 /** 19 * Base interface for objects that are used to decide whether a PR member of a 20 * {@link ConditionalController} needs to be run. 21 */ 22 23 public interface RunningStrategy{ 24 /** 25 * Returns true if the associated PR should be run. 26 * @return a boolean value. 27 */ 28 public boolean shouldRun(); 29 30 /** 31 * Returns the run mode (see {@link #RUN_ALWAYS}, {@link #RUN_NEVER}, 32 * {@link #RUN_CONDITIONAL}). 33 * @return and int value. 34 */ 35 public int getRunMode(); 36 37 /** 38 * Gets the associated ProcessingResource. 39 * @return a {@link ProcessingResource} value. 40 */ 41 public ProcessingResource getPR(); 42 43 44 /** 45 * Run mode constant meaning the associated PR should be run regardless of 46 * what the {@link #shouldRun()} method returns. 47 */ 48 public static final int RUN_ALWAYS = 1; 49 50 /** 51 * Run mode constant meaning the associated PR should NOT be run regardless of 52 * what the {@link #shouldRun()} method returns. 53 */ 54 public static final int RUN_NEVER = 2; 55 56 /** 57 * Run mode constant meaning the associated PR should be run only if the 58 * {@link #shouldRun()} method returns true. 59 */ 60 public static final int RUN_CONDITIONAL = 4; 61 62 public static class RunAlwaysStrategy implements RunningStrategy{ 63 public RunAlwaysStrategy(ProcessingResource pr){ 64 this.pr = pr; 65 } 66 public boolean shouldRun(){return true;} 67 68 public int getRunMode(){return RUN_ALWAYS;} 69 70 public ProcessingResource getPR(){return pr;} 71 72 ProcessingResource pr; 73 } 74 }