public abstract class Boss
extends java.lang.Object
Boss consists of the abstract "doRunParmCommand" and some common parameter validation functions used in sub-classes of Boss.
Modifier and Type | Field and Description |
---|---|
protected BatchFramework |
batchFramework |
protected RunParmArrayEntry |
runParm |
Constructor and Description |
---|
Boss(BatchFramework batchFramework)
Constructor with BatchFramework for access to environment.
|
Modifier and Type | Method and Description |
---|---|
protected void |
accumException(MMJException e) |
protected MMJException |
addContext(MMJException e) |
protected java.io.Reader |
buildBufferedFileReader(java.lang.String fileNameParm,
java.io.File parentDirectory)
Construct a Buffered File Reader using RunParm options plus an optional
parent directory File object.
|
protected java.io.BufferedWriter |
buildBufferedFileWriter(java.lang.String fileNameParm,
java.lang.String fileUsageParm,
java.io.File parentDirectory)
Construct a Buffered File Writer using RunParm options plus an optional
parent directory File object.
|
protected java.io.PrintWriter |
buildPrintWriter(java.io.File filePath,
java.lang.String fileNameParm,
java.lang.String fileUsageParm,
java.lang.String fileCharsetParm)
Construct a PrintWriter using RunParm options.
|
boolean |
doRunParmCommand(RunParmArrayEntry curRunParm)
Executes a single command from the RunParmFile.
|
protected java.lang.IllegalArgumentException |
error(ErrorCode code,
java.lang.Object... args) |
protected java.lang.IllegalArgumentException |
error(java.lang.Exception e,
ErrorCode code,
java.lang.Object... args) |
protected java.lang.IllegalArgumentException |
error(MMJException e) |
java.lang.String |
get(int valueFieldNbr)
Get a RunParm field.
|
protected boolean |
getBoolean(int valueFieldNbr,
boolean blank,
java.lang.String yes)
Validate a boolean value named by the
yes string, with the
no string being No prepended to the yes string. |
protected boolean |
getBoolean(int valueFieldNbr,
boolean blank,
java.lang.String yes,
java.lang.String no)
Validate a boolean value named by the
yes and no strings. |
protected java.awt.Color |
getColor()
Validate Required, RGB Color Parms
|
protected <E extends java.lang.Enum<E>> |
getEnum(int valueFieldNbr,
E blank,
MMJException e)
Validate Enum Parm.
|
protected java.io.File |
getExistingFile(java.io.File filePath,
int valueFieldNbr)
Validate existing folder RunParm (must exist!)
|
protected java.io.File |
getExistingFile(java.io.File filePath,
java.lang.String fileNameParm)
Build a File object for an existing File Name
|
protected java.io.File |
getExistingFolder(java.io.File filePath,
int valueFieldNbr)
Validate existing folder RunParm (must exist!)
|
protected java.io.File |
getExistingFolder(java.io.File filePath,
java.lang.String folderNameParm)
Validate existing folder RunParm (must exist!)
|
protected java.lang.String |
getFileCharset(int valueFieldNbr)
Validate File Charset Parm ("" or "UTF-8", etc).
|
protected java.lang.String |
getFileName(int valueFieldNbr)
Validate File Name.
|
protected java.lang.String |
getFileNameSuffix(int valueFieldNbr)
Validate Proof Worksheet File Name Suffix
|
protected java.lang.String |
getFileUsage(int valueFieldNbr)
Validate File Usage Parm ("new" or "update").
|
protected int |
getInt(int valueFieldNbr)
Validate Required Integer Parm.
|
java.lang.String |
getNonBlank(int valueFieldNbr,
ErrorCode code)
Get a non-blank RunParm field.
|
protected int |
getNonnegInt(int valueFieldNbr)
Validate Non-Negative Integer Parm.
|
protected boolean |
getOnOff(int valueFieldNbr)
Validate Required On/Off Parm.
|
protected int |
getPosInt(int valueFieldNbr)
Validate Positive Integer Parm.
|
protected java.lang.String |
getPrintableNoBlanksString(int valueFieldNbr)
Validate RunParm String with length greater than zero and no embedded
blanks or unprintable characters.
|
protected java.io.PrintWriter |
getPrintWriter(java.io.File filePath)
Validate PrintWriter RunParm and its options.
|
protected int |
getSelectorCount(int valueFieldNbr)
Get SelectorCount RunParm Option.
|
protected Theorem |
getSelectorTheorem(int valueFieldNbr,
java.util.Map<java.lang.String,Stmt> stmtTbl)
Get SelectorTheorem RunParm Option if present or null.
|
protected Stmt |
getStmt(int valueFieldNbr,
LogicalSystem logicalSystem)
Validate RunParm Statement Label String.
|
protected Theorem |
getTheorem(int valueFieldNbr,
LogicalSystem logicalSystem)
Validate RunParm Theorem Label String.
|
protected boolean |
getYesNo(int valueFieldNbr)
Validate Required Yes/No Parm.
|
java.lang.String |
opt(int valueFieldNbr)
Get a RunParm field.
|
protected int |
parseInt(java.lang.String value)
Validate Integer Parm.
|
protected void |
putCommand(BatchCommand cmd,
java.util.function.BooleanSupplier op) |
protected void |
putCommand(BatchCommand cmd,
java.lang.Runnable op) |
protected void |
require(int n)
Validate Required Number of RunParm fields.
|
protected BatchFramework batchFramework
protected RunParmArrayEntry runParm
public Boss(BatchFramework batchFramework)
batchFramework
- for access to environment.protected void putCommand(BatchCommand cmd, java.util.function.BooleanSupplier op)
protected void putCommand(BatchCommand cmd, java.lang.Runnable op)
public boolean doRunParmCommand(RunParmArrayEntry curRunParm)
curRunParm
- the RunParmFile line to execute.true
if the RunParm was "consumed"protected void require(int n)
n
- required number of fields in the RunParm line.java.lang.IllegalArgumentException
- if an error occurredpublic java.lang.String get(int valueFieldNbr)
valueFieldNbr
- the index of the value field, starting at 1public java.lang.String getNonBlank(int valueFieldNbr, ErrorCode code)
valueFieldNbr
- the index of the value field, starting at 1code
- The error message to give if the value is blankpublic java.lang.String opt(int valueFieldNbr)
valueFieldNbr
- the index of the value field, starting at 1protected java.io.File getExistingFolder(java.io.File filePath, int valueFieldNbr)
filePath
- path used to resolve file name. May be null or absolute
or relative path.valueFieldNbr
- number of field in RunParm line.protected java.io.File getExistingFolder(java.io.File filePath, java.lang.String folderNameParm)
filePath
- path used to resolve file name. May be null or absolute
or relative path.folderNameParm
- The folder nameprotected java.io.File getExistingFile(java.io.File filePath, int valueFieldNbr)
filePath
- path name for building files. May be null, relative or
absolute.valueFieldNbr
- number of field in RunParm line.protected java.lang.String getFileNameSuffix(int valueFieldNbr)
valueFieldNbr
- number of field in RunParm line.protected java.io.File getExistingFile(java.io.File filePath, java.lang.String fileNameParm)
filePath
- path name for building files. May be null, relative or
absolute.fileNameParm
- name of filejava.lang.IllegalArgumentException
- if an error occurredprotected java.io.PrintWriter getPrintWriter(java.io.File filePath)
filePath
- path for building files. May be null, absolute, or
relative.java.lang.IllegalArgumentException
- if an error occurredprotected java.io.PrintWriter buildPrintWriter(java.io.File filePath, java.lang.String fileNameParm, java.lang.String fileUsageParm, java.lang.String fileCharsetParm)
filePath
- path for building files. May be null, absolute or
relative.fileNameParm
- RunParmFile line parsed into RunParmArrayEntry.fileUsageParm
- "new" or "update"fileCharsetParm
- optional, "UTF-8", etc.java.lang.IllegalArgumentException
- if an error occurredprotected java.io.Reader buildBufferedFileReader(java.lang.String fileNameParm, java.io.File parentDirectory)
fileNameParm
- RunParmFile line parsed into RunParmArrayEntry.parentDirectory
- the root directoryjava.lang.IllegalArgumentException
- if an error occurredprotected java.io.BufferedWriter buildBufferedFileWriter(java.lang.String fileNameParm, java.lang.String fileUsageParm, java.io.File parentDirectory)
fileNameParm
- RunParmFile line parsed into RunParmArrayEntry.fileUsageParm
- "new" or "update"parentDirectory
- the root directoryjava.lang.IllegalArgumentException
- if an error occurredprotected java.lang.String getFileName(int valueFieldNbr)
valueFieldNbr
- number of field in RunParm line.java.lang.IllegalArgumentException
- if an error occurredprotected java.lang.String getFileUsage(int valueFieldNbr)
valueFieldNbr
- number of field in RunParm line.java.lang.IllegalArgumentException
- if an error occurredprotected java.lang.String getFileCharset(int valueFieldNbr)
valueFieldNbr
- number of field in RunParm line.java.lang.IllegalArgumentException
- if an error occurredprotected int getSelectorCount(int valueFieldNbr)
If "*" input returns Integer.MAX_VALUE
, if positive integer input
returns integer value, otherwise, if negative or zero integer, throws an
exception. If none of the above returns 0.
valueFieldNbr
- number of field in RunParm line.protected Theorem getSelectorTheorem(int valueFieldNbr, java.util.Map<java.lang.String,Stmt> stmtTbl)
If present, and not a valid Theorem label, an IllegalArgumentException is thrown.
valueFieldNbr
- number of field in RunParm line.stmtTbl
- stmtTbl map from LogicalSystem.java.lang.IllegalArgumentException
- if an error occurredprotected boolean getYesNo(int valueFieldNbr)
valueFieldNbr
- number of field in RunParm line.java.lang.IllegalArgumentException
- if an error occurredprotected boolean getOnOff(int valueFieldNbr)
valueFieldNbr
- number of field in RunParm line.java.lang.IllegalArgumentException
- if an error occurredprotected boolean getBoolean(int valueFieldNbr, boolean blank, java.lang.String yes)
yes
string, with the
no
string being No
prepended to the yes
string.valueFieldNbr
- number of field in RunParm line.blank
- Value to return if the field is blankyes
- Value to return trueprotected boolean getBoolean(int valueFieldNbr, boolean blank, java.lang.String yes, java.lang.String no)
yes
and no
strings.valueFieldNbr
- number of field in RunParm line.blank
- Value to return if the field is blankyes
- Value to return trueno
- Value to return falseprotected <E extends java.lang.Enum<E>> E getEnum(int valueFieldNbr, E blank, MMJException e)
E
- The enum typevalueFieldNbr
- number of field in RunParm line.blank
- Value to return if blanke
- String to return if the input did not match any valuesprotected java.awt.Color getColor()
java.lang.IllegalArgumentException
- if an error occurredprotected int getInt(int valueFieldNbr)
valueFieldNbr
- number of field in RunParm line.java.lang.IllegalArgumentException
- if an error occurredprotected int parseInt(java.lang.String value)
value
- a string to convertjava.lang.IllegalArgumentException
- if an error occurredprotected int getPosInt(int valueFieldNbr)
valueFieldNbr
- number of field in RunParm line.java.lang.IllegalArgumentException
- if an error occurredprotected int getNonnegInt(int valueFieldNbr)
valueFieldNbr
- number of field in RunParm line.java.lang.IllegalArgumentException
- if an error occurredprotected Theorem getTheorem(int valueFieldNbr, LogicalSystem logicalSystem)
valueFieldNbr
- number of field in RunParm line.logicalSystem
- Uh-oh, Mr. Big. Heavy validation using
LogicalSystem.stmtTbl.java.lang.IllegalArgumentException
- if an error occurredprotected Stmt getStmt(int valueFieldNbr, LogicalSystem logicalSystem)
valueFieldNbr
- number of field in RunParm line.logicalSystem
- Uh-oh, Mr. Big. Heavy validation using
LogicalSystem.stmtTbl.java.lang.IllegalArgumentException
- if an error occurredprotected java.lang.IllegalArgumentException error(ErrorCode code, java.lang.Object... args)
protected java.lang.IllegalArgumentException error(java.lang.Exception e, ErrorCode code, java.lang.Object... args)
protected MMJException addContext(MMJException e)
protected java.lang.IllegalArgumentException error(MMJException e)
protected void accumException(MMJException e)
protected java.lang.String getPrintableNoBlanksString(int valueFieldNbr)
valueFieldNbr
- required number of fields in the RunParm line.java.lang.IllegalArgumentException
- if an error occurred