package Sequenic.T2; import Sequenic.T2.Engines.* ; import Sequenic.T2.Msg.*; import java.util.*; import jargs.gnu.*; import Sequenic.P2.* ; /** * The T2 main tool. This is a console application. It is actually a mini * framework where one or more main functionalities can be plugged in. * Two standard functionalities are included, namely (automated) testing and * replaying saved tests (regression). */ public class Main extends ToolPlug { static public class ToolDescriptor { public String selector; public String name; public ToolPlug tool; public ToolDescriptor(String s, String n, ToolPlug plug) { selector = s; name = n; tool = plug; } } public List tools = new LinkedList () ; public ToolDescriptor maintool = null ; // Derived variables: private String[] options = null ; // Options without the first element: private String[] options1 = null; public Main() { ToolDescriptor BaseEngine = new ToolDescriptor("E","Base-engine", new BaseEngineToolPlug()) ; tools.add(BaseEngine); ToolDescriptor ReplayEngine = new ToolDescriptor("R","Replay-tool", new ReplayToolPlug()) ; tools.add(ReplayEngine) ; ToolDescriptor CombinatoricEngine = new ToolDescriptor("C","Combinatoric-engine", new CombinatoricEngineToolPlug()) ; tools.add(CombinatoricEngine) ; ToolDescriptor primePathEngine = new ToolDescriptor("P","PrimePath-engine", new PrimePathEngineToolPlug()) ; tools.add(primePathEngine) ; maintool = BaseEngine ; } private boolean isValidSelector(String sel) { boolean found = false; for (ToolDescriptor td : tools) { found = sel.equals("-" + td.selector); if (found) { break; } } return found; } private boolean isHelpRequest(String opt) { return opt.equals("--help"); } public void configure(String[] args) { options = args; if (options.length > 1) { options1 = new String[options.length - 1]; for (int i = 1; i < options.length; i++) { options1[i - 1] = options[i]; } } else { options1 = new String[0]; } } public void run() { if (options.length <= 0 || isHelpRequest(options[0])) { consoleHelp(); return; } // Now #options > 0 // This the the case of --selector or --selector --help if (isValidSelector(options[0]) && (options.length == 1 || (options.length == 2 && isHelpRequest(options[1])))) { for (ToolDescriptor td : tools) { if (options[0].equals("-" + td.selector)) { td.tool.consoleHelp(); break; } } return; } // The case of either (1)