com.jkristian.cli
Class CommandLine

java.lang.Object
  extended by com.jkristian.cli.CommandLine
Direct Known Subclasses:
JavaCommandLine

public class CommandLine
extends java.lang.Object

A named program and its parameters.

Author:
John Kristian

Field Summary
protected  java.util.List list
           
 
Constructor Summary
CommandLine(java.lang.String line)
           
 
Method Summary
 CommandLine append(java.lang.String parameter)
          Add a parameter to the list.
static java.lang.String enquote(java.lang.String s)
          Enquote a String if necessary to make it interpreted as a single string by the command line interpreter.
 java.lang.Process exec()
          Start a process executing this command line.
 java.lang.String[] toArray()
          Convert the command line to an array.
 java.lang.String toString()
          Convert the command line to a String suitable for input to the command line interpreter.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

list

protected java.util.List list
Constructor Detail

CommandLine

public CommandLine(java.lang.String line)
Parameters:
line - a space-separated list, containing the program name and its parameters. This is parsed by StringTokenizer(line), so parameters cannot be enquoted or contain whitespace.
Method Detail

append

public CommandLine append(java.lang.String parameter)
Add a parameter to the list.


exec

public java.lang.Process exec()
                       throws java.io.IOException
Start a process executing this command line.

Throws:
java.io.IOException

toArray

public java.lang.String[] toArray()
Convert the command line to an array. The first element is the program name; subsequent elements are parameters.


toString

public java.lang.String toString()
Convert the command line to a String suitable for input to the command line interpreter. The program name and/or parameters are enquoted if necessary.

Overrides:
toString in class java.lang.Object

enquote

public static java.lang.String enquote(java.lang.String s)
Enquote a String if necessary to make it interpreted as a single string by the command line interpreter.