Package com.lingocoder.io
Class CommandHelper
- java.lang.Object
-
- com.lingocoder.io.CommandHelper
-
public class CommandHelper extends java.lang.ObjectA 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)ProducesStringarray 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 aStringarray that contains commands that thejavatool could execute from the command line.java.lang.StringtoCommand(java.io.File aJar, java.util.List<java.lang.String> args)Produces aStringthat thejavatool could execute from the command line.java.lang.StringtoString(java.lang.String... args)Produces a flattened representation of the givenStringarray.
-
-
-
Method Detail
-
toString
public java.lang.String toString(java.lang.String... args)
Produces a flattened representation of the givenStringarray.- Parameters:
args- A sequence ofStrings that will be flattened into a singleString.- Returns:
- All of the elements of the given
argsparam, concatenated into a singleString.
-
toCmdArray
public java.lang.String[] toCmdArray(java.io.File aJar, java.util.List<java.lang.String> args)Produces aStringarray that contains commands that thejavatool could execute from the command line.- Parameters:
aJar- AFilerepresenting ajar.args- The sequence of commands or arguments that the main class within the givenaJarparam would process.- Returns:
- A
Stringarray 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 aStringthat thejavatool could execute from the command line.- Parameters:
aJar- AFilerepresenting ajar.args- The sequence of commands or arguments that the main class within the givenaJarparam would process.- Returns:
- A
Stringof the form: „java -jar ${aJar} ${args}...“
-
refreshCmds
public java.lang.String[] refreshCmds(java.util.Optional<java.lang.String> hyphen, java.lang.String... commands)ProducesStringarray containing one of two Java command line tools to execute, followed by the given commands/arguments.- Parameters:
hyphen- AnOptionalcontaining 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 thehypenparam is „Optional.of(‚-‘)“. Otherwise, returns „jar ${commands}“ if thehypenparam is „Optional.empty()“ (or anything other than „Optional.of(‚-‘)“).
-
-