+ /** Can be overridden by specific command wrapper*/
+ protected CommandLine createCommandLine() {
+ // Check if an OS specific command overrides
+ String osName = System.getProperty("os.name");
+ List<Object> commandToUse = null;
+ if (osCommands.containsKey(osName))
+ commandToUse = osCommands.get(osName);
+ else
+ commandToUse = command;
+ String cmdToUse = null;
+ if (osCmds.containsKey(osName))
+ cmdToUse = osCmds.get(osName);
+ else
+ cmdToUse = cmd;
+
+ final CommandLine commandLine;
+
+ // Which command definition to use
+ if (commandToUse == null && cmdToUse == null)
+ throw new SlcException("Please specify a command.");
+ else if (commandToUse != null && cmdToUse != null)
+ throw new SlcException(
+ "Specify the command either as a line or as a list.");
+ else if (cmdToUse != null) {
+ commandLine = CommandLine.parse(cmdToUse);
+ } else if (commandToUse != null) {
+ if (commandToUse.size() == 0)
+ throw new SlcException("Command line is empty.");
+
+ commandLine = new CommandLine(commandToUse.get(0).toString());
+ for (int i = 1; i < commandToUse.size(); i++)
+ commandLine.addArgument(commandToUse.get(i).toString());
+ } else {
+ // all cases covered previously
+ throw new UnsupportedOperationException();
+ }
+ return commandLine;
+ }
+