org.fhcrc.cpl.viewer
Class CommandFileRunner

java.lang.Object
  extended by org.fhcrc.cpl.viewer.CommandFileRunner

public class CommandFileRunner
extends java.lang.Object

Provides macro-running functionality in MSInspect. Knows how to read commands and arguments form a macro file in the following format: -Comment lines begin with # and are ignored -Commands begin immediately on a given line. Anything other than a comment that begins immediately at the start of a line is considered a command -Arguments start with a tab character. Anything other than a comment that begins with a tab is considered an argument. Arguments are of the format NAME=VALUE. For this reason, '=' is not currently allowed in arguments. For unnamed arguments, simply us a tab followed by the argument value -Arguments for a given command should follow directly after that command All handling of individual macro commands is spelled out here. In general it's desirable to have these macros follow the same code path as the UI, to the greatest extent possible


Nested Class Summary
static class CommandFileRunner.CommandFileRunnerAction
          action for the menu item that kicks macro-running off
 
Constructor Summary
CommandFileRunner()
           
 
Method Summary
static java.lang.String createCommandFileEntry(java.lang.String commandName, java.util.Map<java.lang.String,java.lang.String> argumentMap)
          Utility method to create a command, for use in a command file, based on a command name and argument map
static java.util.Map<java.lang.String,java.lang.String> getArguments(java.io.BufferedReader reader, CommandLineModule module)
          Gobbles a list of arguments, stopping when it hits eof or a protein definition.
static java.lang.String getNextCommand(java.io.BufferedReader reader)
          skips past any argument lines to the next command, in my funky file format TODO: this should probably be reimplemented as an Iterator
protected static void macroError()
          print out a generic error message
protected static void macroMissingArguments()
          print out a missing-arguments error message
protected static Pair<java.lang.String,java.lang.String> processArgument(java.lang.String argument, CommandLineModule module)
          split an argument around an = sign TODO: add error handling
static void runMacroFile(java.io.File macroFile)
          Parse a macro file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CommandFileRunner

public CommandFileRunner()
Method Detail

runMacroFile

public static void runMacroFile(java.io.File macroFile)
Parse a macro file. For each command, with arguments, invoke one of the known command handlers if there is one for this command

Parameters:
macroFile -

getNextCommand

public static java.lang.String getNextCommand(java.io.BufferedReader reader)
skips past any argument lines to the next command, in my funky file format TODO: this should probably be reimplemented as an Iterator

Parameters:
reader -
Returns:

getArguments

public static java.util.Map<java.lang.String,java.lang.String> getArguments(java.io.BufferedReader reader,
                                                                            CommandLineModule module)
Gobbles a list of arguments, stopping when it hits eof or a protein definition. If it hits a protein definition, it backs up

Parameters:
reader -
Returns:

processArgument

protected static Pair<java.lang.String,java.lang.String> processArgument(java.lang.String argument,
                                                                         CommandLineModule module)
split an argument around an = sign TODO: add error handling

Parameters:
argument -
Returns:
the argument name and value, or null if splitting around = gives something other than two strings

macroError

protected static void macroError()
print out a generic error message


macroMissingArguments

protected static void macroMissingArguments()
print out a missing-arguments error message


createCommandFileEntry

public static java.lang.String createCommandFileEntry(java.lang.String commandName,
                                                      java.util.Map<java.lang.String,java.lang.String> argumentMap)
Utility method to create a command, for use in a command file, based on a command name and argument map

Parameters:
commandName -
argumentMap -


Fred Hutchinson Cancer Research Center