Coverage Report - net.sf.jmatchparser.template.engine.template.command.plain.Command
 
Classes in this File Line Coverage Branch Coverage Complexity
Command
100%
43/43
N/A
1
 
 1  
 /*
 2  
  * Copyright (c) 2006 - 2011 Michael Schierl
 3  
  * All rights reserved.
 4  
  * 
 5  
  * This program is free software: you can redistribute it and/or modify
 6  
  * it under the terms of the GNU General Public License as published by
 7  
  * the Free Software Foundation, either version 2 of the License, or
 8  
  * (at your option) any later version.
 9  
  * 
 10  
  * This program is distributed in the hope that it will be useful,
 11  
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
 12  
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 13  
  * GNU General Public License for more details.
 14  
  * 
 15  
  * You should have received a copy of the GNU General Public License
 16  
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 17  
  */
 18  
 package net.sf.jmatchparser.template.engine.template.command.plain;
 19  
 
 20  
 import java.util.HashMap;
 21  
 import java.util.Map;
 22  
 
 23  
 import net.sf.jmatchparser.template.engine.template.PlainBlockCommandState;
 24  
 import net.sf.jmatchparser.template.engine.template.MatchTemplateImpl;
 25  
 
 26  39
 public abstract class Command {
 27  
 
 28  1
         private static final Map<String, Command> commands = new HashMap<String, Command>();
 29  
 
 30  
         static {
 31  
                 // assignment commands
 32  1
                 commands.put("block", new XMLBlockCommand());
 33  1
                 commands.put("set", new SetCommand(false));
 34  1
                 commands.put("setexpression", new SetCommand(true));
 35  
 
 36  
                 // control flow commands
 37  1
                 commands.put("loop", new LoopCommand());
 38  1
                 commands.put("alternative", new AlternativeCommand(false));
 39  1
                 commands.put("alt", new AlternativeCommand(false));
 40  1
                 commands.put("optionalalternative", new AlternativeCommand(true));
 41  1
                 commands.put("optalt", new AlternativeCommand(true));
 42  1
                 commands.put("optional", new OptionalCommand(false));
 43  1
                 commands.put("opt", new OptionalCommand(false));
 44  1
                 commands.put("repeated", new OptionalCommand(true));
 45  1
                 commands.put("checkothers", new CheckOthersCommand());
 46  1
                 commands.put("finishothers", new FinishOthersCommand());
 47  1
                 commands.put("deftemplate", new DefTemplateCommand());
 48  1
                 commands.put("calltemplate", new CallTemplateCommand());
 49  1
                 commands.put("setlocal", new SetLocalCommand());
 50  
 
 51  
                 // CHECK commands
 52  1
                 commands.put("check", new MatchCommand(true, false, false));
 53  1
                 commands.put("checknot", new MatchCommand(true, true, false));
 54  1
                 commands.put("checkline", new MatchCommand(true, false, true));
 55  1
                 commands.put("checklinenot", new MatchCommand(true, true, true));
 56  1
                 commands.put("checktext", new MatchTextCommand(true, false));
 57  1
                 commands.put("checktextnot", new MatchTextCommand(true, true));
 58  1
                 commands.put("cl", new MatchCommand(true, false, true));
 59  1
                 commands.put("checkxml", new MatchXMLCommand(false));
 60  
 
 61  
                 // MATCH commands
 62  1
                 commands.put("match", new MatchCommand(false, false, false));
 63  1
                 commands.put("matchline", new MatchCommand(false, false, true));
 64  1
                 commands.put("matchtext", new MatchTextCommand(false, false));
 65  1
                 commands.put("ml", new MatchCommand(false, false, true));
 66  1
                 commands.put("matchxml", new MatchXMLCommand(true));
 67  1
                 commands.put("matchany", new MatchAnyCommand());
 68  
 
 69  
                 // WRITE comands
 70  1
                 commands.put("write", new WriteCommand(false));
 71  1
                 commands.put("writeline", new WriteCommand(true));
 72  1
                 commands.put("wl", new WriteCommand(true));
 73  1
                 commands.put("format", new FormatCommand());
 74  1
                 commands.put("nextpass", new NextPassCommand());
 75  
 
 76  
                 // other commands
 77  1
                 commands.put("debugwrite", new DebugWriteCommand());
 78  1
                 commands.put("dw", new DebugWriteCommand());
 79  1
                 commands.put("dumpline", new DumpLineCommand());
 80  1
                 commands.put("dl", new DumpLineCommand());
 81  1
         }
 82  
 
 83  
         public static Command getCommand(String commandName) {
 84  983
                 return commands.get(commandName);
 85  
         }
 86  
 
 87  
         public abstract PlainBlockCommandState parse(MatchTemplateImpl template, String parameters);
 88  
 }