diff options
| author | bculkin2442 <bjculkin@mix.wvu.edu> | 2017-02-26 09:38:26 -0500 |
|---|---|---|
| committer | bculkin2442 <bjculkin@mix.wvu.edu> | 2017-02-26 09:40:25 -0500 |
| commit | 0b4fd83d36eb82c92a39af8b8e1c521d822bd4c3 (patch) | |
| tree | 79bdddd59f526451411362559b213bdb8485406a /BJC-Utils2/src/main/java/bjc/utils/cli/CLICommander.java | |
| parent | e8567df90f38e5f2e15fbb245aa4ac45d37a3003 (diff) | |
Formatting
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 | 31 |
1 files changed, 11 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 179eec0..bc3e56e 100644 --- a/BJC-Utils2/src/main/java/bjc/utils/cli/CLICommander.java +++ b/BJC-Utils2/src/main/java/bjc/utils/cli/CLICommander.java @@ -16,14 +16,14 @@ public class CLICommander { /* * The streams used for input and normal/error output */ - private InputStream input; + private InputStream input; private OutputStream output; private OutputStream error; /* * The command mode to start execution in */ - private ICommandMode initialMode; + private ICommandMode initialMode; /** * Create a new CLI interface powered by streams. @@ -35,17 +35,13 @@ public class CLICommander { * @param error * The stream to send error output to. */ - public CLICommander(InputStream input, OutputStream output, - OutputStream error) { + public CLICommander(InputStream input, OutputStream output, OutputStream error) { if (input == null) { - throw new NullPointerException( - "Input stream must not be null"); + throw new NullPointerException("Input stream must not be null"); } else if (output == null) { - throw new NullPointerException( - "Output stream must not be null"); + throw new NullPointerException("Output stream must not be null"); } else if (error == null) { - throw new NullPointerException( - "Error stream must not be null"); + throw new NullPointerException("Error stream must not be null"); } this.input = input; @@ -95,21 +91,17 @@ public class CLICommander { // Handle commands we can handle if (currentMode.canHandle(currentLine)) { String[] commandTokens = currentLine.split(" "); - String[] commandArgs = null; // Parse args if they are present if (commandTokens.length > 1) { - commandArgs = Arrays.copyOfRange(commandTokens, 1, - commandTokens.length); + commandArgs = Arrays.copyOfRange(commandTokens, 1, commandTokens.length); } // Process command - currentMode = currentMode.process(commandTokens[0], - commandArgs); + currentMode = currentMode. process(commandTokens[0], commandArgs); } else { - errorOutput.print( - "Error: Unrecognized command " + currentLine); + errorOutput.print("Error: Unrecognized command " + currentLine); } } @@ -124,10 +116,9 @@ public class CLICommander { */ public void setInitialCommandMode(ICommandMode initialMode) { if (initialMode == null) { - throw new NullPointerException( - "Initial mode must be non-zero"); + throw new NullPointerException("Initial mode must be non-zero"); } this.initialMode = initialMode; } -}
\ No newline at end of file +} |
