org.fhcrc.cpl.toolbox.commandline
Class CommandLineModuleUtilities

java.lang.Object
  extended by org.fhcrc.cpl.toolbox.commandline.CommandLineModuleUtilities

public class CommandLineModuleUtilities
extends java.lang.Object

Utility class for commandline modules


Field Summary
static org.apache.log4j.Logger _log
           
 
Constructor Summary
CommandLineModuleUtilities()
           
 
Method Summary
static java.io.File createFailureReport(CommandLineModule module, java.lang.Exception exception, boolean isLogEnabled, java.io.File logFile, java.lang.String headerText)
           
static java.lang.String createFailureReportAndPrompt(CommandLineModule module, java.lang.Exception exception, boolean logEnabled, java.io.File logFile, java.lang.String additionalErrorText, java.lang.String failureReportHeaderText)
           
static java.lang.String createFailureReportEntry(java.lang.String commandName, java.util.Map<java.lang.String,java.lang.String> argumentMap)
          Create an entry in the failure report for an invocation of a command
static java.io.File createOutputFile(java.io.File inputFile, java.lang.String newSuffix, java.io.File outputDir)
           
static java.lang.String createOutputFilename(java.lang.String inputFileName, java.lang.String newSuffix)
           
static java.io.File findFileLikeFile(java.io.File inputFile, java.io.File directory, java.lang.String suffix)
           
static java.io.File findFileWithPrefix(java.lang.String prefix, java.io.File directory, java.lang.String suffix)
           
static CommandLineArgumentDefinition getUnnamedArgumentDefinition(CommandLineModule module)
          Does this set of argument definitions allow the unnamed (single) argument?
static CommandLineArgumentDefinition getUnnamedArgumentSeriesDefinition(CommandLineModule module)
           
static boolean isUnnamedArgument(CommandLineArgumentDefinition argDef)
           
static boolean isUnnamedSeriesArgument(CommandLineArgumentDefinition argDef)
           
static java.util.Map<java.lang.String,java.lang.String> parseRawArguments(CommandLineModule module, java.lang.String[] args)
          Parse the raw arguments passed in by the user, in the context of the supplied module.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_log

public static org.apache.log4j.Logger _log
Constructor Detail

CommandLineModuleUtilities

public CommandLineModuleUtilities()
Method Detail

createOutputFilename

public static java.lang.String createOutputFilename(java.lang.String inputFileName,
                                                    java.lang.String newSuffix)

createOutputFile

public static java.io.File createOutputFile(java.io.File inputFile,
                                            java.lang.String newSuffix,
                                            java.io.File outputDir)

findFileLikeFile

public static java.io.File findFileLikeFile(java.io.File inputFile,
                                            java.io.File directory,
                                            java.lang.String suffix)
                                     throws java.io.FileNotFoundException
Throws:
java.io.FileNotFoundException

findFileWithPrefix

public static java.io.File findFileWithPrefix(java.lang.String prefix,
                                              java.io.File directory,
                                              java.lang.String suffix)
                                       throws java.io.FileNotFoundException
Throws:
java.io.FileNotFoundException

createFailureReport

public static java.io.File createFailureReport(CommandLineModule module,
                                               java.lang.Exception exception,
                                               boolean isLogEnabled,
                                               java.io.File logFile,
                                               java.lang.String headerText)
                                        throws java.io.IOException
Parameters:
module -
exception -
isLogEnabled -
logFile -
Returns:
Throws:
java.io.IOException

createFailureReportEntry

public static java.lang.String createFailureReportEntry(java.lang.String commandName,
                                                        java.util.Map<java.lang.String,java.lang.String> argumentMap)
Create an entry in the failure report for an invocation of a command

Parameters:
commandName -
argumentMap -
Returns:

createFailureReportAndPrompt

public static java.lang.String createFailureReportAndPrompt(CommandLineModule module,
                                                            java.lang.Exception exception,
                                                            boolean logEnabled,
                                                            java.io.File logFile,
                                                            java.lang.String additionalErrorText,
                                                            java.lang.String failureReportHeaderText)

isUnnamedSeriesArgument

public static boolean isUnnamedSeriesArgument(CommandLineArgumentDefinition argDef)

isUnnamedArgument

public static boolean isUnnamedArgument(CommandLineArgumentDefinition argDef)

getUnnamedArgumentDefinition

public static CommandLineArgumentDefinition getUnnamedArgumentDefinition(CommandLineModule module)
Does this set of argument definitions allow the unnamed (single) argument?

Returns:

getUnnamedArgumentSeriesDefinition

public static CommandLineArgumentDefinition getUnnamedArgumentSeriesDefinition(CommandLineModule module)

parseRawArguments

public static java.util.Map<java.lang.String,java.lang.String> parseRawArguments(CommandLineModule module,
                                                                                 java.lang.String[] args)
                                                                          throws java.lang.IllegalArgumentException
Parse the raw arguments passed in by the user, in the context of the supplied module. Return a map from argument name to argument value. If undefined arguments are supplied, throw an IllegalArgumentException

Parameters:
module -
args -
Returns:
Throws:
java.lang.IllegalArgumentException - if undefined arguments are supplied


Fred Hutchinson Cancer Research Center