diff options
| author | EVE <EVE@EVE-PC> | 2017-03-14 12:07:14 -0400 |
|---|---|---|
| committer | EVE <EVE@EVE-PC> | 2017-03-14 12:07:14 -0400 |
| commit | 504ca816530efdff06bc202e0432ebd354aec304 (patch) | |
| tree | 4836932fb81d1d625470502c78c94d202c9a7420 /BJC-Utils2/src/main/java/bjc/utils/cli/CLICommander.java | |
| parent | 5c1163df17c46f7d3e15b6c7949c38843ec56146 (diff) | |
Cleanup
Diffstat (limited to 'BJC-Utils2/src/main/java/bjc/utils/cli/CLICommander.java')
| -rw-r--r-- | BJC-Utils2/src/main/java/bjc/utils/cli/CLICommander.java | 36 |
1 files changed, 16 insertions, 20 deletions
diff --git a/BJC-Utils2/src/main/java/bjc/utils/cli/CLICommander.java b/BJC-Utils2/src/main/java/bjc/utils/cli/CLICommander.java index 22fb276..b732f01 100644 --- a/BJC-Utils2/src/main/java/bjc/utils/cli/CLICommander.java +++ b/BJC-Utils2/src/main/java/bjc/utils/cli/CLICommander.java @@ -8,7 +8,7 @@ import java.util.Scanner; /** * Runs a CLI interface from the provided set of streams. - * + * * @author ben * */ @@ -16,9 +16,9 @@ public class CLICommander { /* * The streams used for input and normal/error output */ - private InputStream input; - private OutputStream output; - private OutputStream error; + private InputStream input; + private OutputStream output; + private OutputStream error; /* * The command mode to start execution in @@ -27,7 +27,7 @@ public class CLICommander { /** * Create a new CLI interface powered by streams. - * + * * @param input * The stream to get user input from. * @param output @@ -36,13 +36,11 @@ public class CLICommander { * The stream to send error output to. */ public CLICommander(InputStream input, OutputStream output, OutputStream error) { - if (input == null) { + if(input == null) throw new NullPointerException("Input stream must not be null"); - } else if (output == null) { + else if(output == null) throw new NullPointerException("Output stream must not be null"); - } else if (error == null) { - throw new NullPointerException("Error stream must not be null"); - } + else if(error == null) throw new NullPointerException("Error stream must not be null"); this.input = input; this.output = output; @@ -59,7 +57,7 @@ public class CLICommander { /* * Set up input streams. - * + * * We're suppressing the warning because we might use the input * stream multiple times */ @@ -68,18 +66,18 @@ public class CLICommander { /* * The mode currently being used to handle commands. - * + * * Used to preserve the initial mode */ ICommandMode currentMode = initialMode; // Process commands until we're told to stop - while (currentMode != null) { + while(currentMode != null) { /* * Print out the command prompt, using a custom prompt * if one is specified */ - if (currentMode.isCustomPromptEnabled()) { + if(currentMode.isCustomPromptEnabled()) { normalOutput.print(currentMode.getCustomPrompt()); } else { normalOutput.print(currentMode.getName() + ">> "); @@ -89,12 +87,12 @@ public class CLICommander { String currentLine = inputSource.nextLine(); // Handle commands we can handle - if (currentMode.canHandle(currentLine)) { + if(currentMode.canHandle(currentLine)) { String[] commandTokens = currentLine.split(" "); String[] commandArgs = null; // Parse args if they are present - if (commandTokens.length > 1) { + if(commandTokens.length > 1) { commandArgs = Arrays.copyOfRange(commandTokens, 1, commandTokens.length); } @@ -110,14 +108,12 @@ public class CLICommander { /** * Set the initial command mode to use - * + * * @param initialMode * The initial command mode to use */ public void setInitialCommandMode(ICommandMode initialMode) { - if (initialMode == null) { - throw new NullPointerException("Initial mode must be non-zero"); - } + if(initialMode == null) throw new NullPointerException("Initial mode must be non-zero"); this.initialMode = initialMode; } |
