Package com.lingocoder.io
Class CommandHelper
- java.lang.Object
-
- com.lingocoder.io.CommandHelper
-
public class CommandHelper extends java.lang.Object
A utility that provides convenience methods for working with command lines.
-
-
Constructor Summary
Constructors Constructor Description CommandHelper()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.String[]
refreshCmds(java.util.Optional<java.lang.String> hyphen, java.lang.String... commands)
ProducesString
array containing one of two Java command line tools to execute, followed by the given commands/arguments.java.lang.String[]
toCmdArray(java.io.File aJar, java.util.List<java.lang.String> args)
Produces aString
array that contains commands that thejava
tool could execute from the command line.java.lang.String
toCommand(java.io.File aJar, java.util.List<java.lang.String> args)
Produces aString
that thejava
tool could execute from the command line.java.lang.String
toString(java.lang.String... args)
Produces a flattened representation of the givenString
array.
-
-
-
Method Detail
-
toString
public java.lang.String toString(java.lang.String... args)
Produces a flattened representation of the givenString
array.- Parameters:
args
- A sequence ofString
s that will be flattened into a singleString
.- Returns:
- All of the elements of the given
args
param, concatenated into a singleString
.
-
toCmdArray
public java.lang.String[] toCmdArray(java.io.File aJar, java.util.List<java.lang.String> args)
Produces aString
array that contains commands that thejava
tool could execute from the command line.- Parameters:
aJar
- AFile
representing ajar
.args
- The sequence of commands or arguments that the main class within the givenaJar
param would process.- Returns:
- A
String
array that expands to: „java -jar ${aJar} ${args}...
“
-
toCommand
public java.lang.String toCommand(java.io.File aJar, java.util.List<java.lang.String> args)
Produces aString
that thejava
tool could execute from the command line.- Parameters:
aJar
- AFile
representing ajar
.args
- The sequence of commands or arguments that the main class within the givenaJar
param would process.- Returns:
- A
String
of the form: „java -jar ${aJar} ${args}...
“
-
refreshCmds
public java.lang.String[] refreshCmds(java.util.Optional<java.lang.String> hyphen, java.lang.String... commands)
ProducesString
array containing one of two Java command line tools to execute, followed by the given commands/arguments.- Parameters:
hyphen
- AnOptional
containing either an „Optional.of(‚-‘)
“ or „Optional.empty()
“.commands
- The sequence of commands or arguments that the particular selected program would process.- Returns:
- „
java -jar ${commands}...
“ if thehypen
param is „Optional.of(‚-‘)
“. Otherwise, returns „jar ${commands}
“ if thehypen
param is „Optional.empty()
“ (or anything other than „Optional.of(‚-‘)
“).
-
-