igpp.util
Class Process

java.lang.Object
  extended by igpp.util.Process

public class Process
extends Object

Run a command line and collect the output in String buffers. Class is threaded so that multiple instances can be executed.

Since:
1.0
Author:
Todd King

Constructor Summary
Process()
           
 
Method Summary
static ArrayList<String> argSplit(String buffer, boolean onlyWhitespace)
          Split a string into one or more substrings by parsing on whitespace and treating "!" and "=" as individual arguments.
 ArrayList<String> getOutput()
          Retrieve the output from the last run.
 String getOutputHTML()
          Retrieve the output from the last run formatted for HTML.
 int run(String command)
          Run a command line.
 int run(String command, String home)
          Run a command line with a specified path as the home directory.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Process

public Process()
Method Detail

run

public int run(String command)
Run a command line. Output from the command (or error messages) are available with the method getOutput().

Parameters:
command - the command line to run.
Returns:
the exit status of the command.
Since:
1.0

run

public int run(String command,
               String home)
Run a command line with a specified path as the home directory. Output from the command (or error messages) are available with the method getOutput().

Parameters:
command - the command line to run.
home - the path to the home directory in which to run the command.
Returns:
the exit status of the command.
Since:
1.0

getOutput

public ArrayList<String> getOutput()
Retrieve the output from the last run.

Returns:
an ArrayList of Strings with each line of the output.

getOutputHTML

public String getOutputHTML()
Retrieve the output from the last run formatted for HTML. Each line of output has a "
" tag appended.

Returns:
a String containing the output formatted as HTML.

argSplit

public static ArrayList<String> argSplit(String buffer,
                                         boolean onlyWhitespace)
Split a string into one or more substrings by parsing on whitespace and treating "!" and "=" as individual arguments. Arguments in quotes are kept intack. Escaped characters are converted preserved with the escape removed.

Parameters:
buffer - the string to parse.
onlyWhitespace - if true split the string using only whitespace as a delimiter. If false the string is parsed on whitespace and "!" and "=" are considered as individual arguments.
Returns:
ArrayList an array of arguments.
Since:
1.0


Copyright © 2008-2009 Regents University of California. All Rights Reserved.