PTP
Release 7.0

org.eclipse.ptp.core.util
Class ArgumentParser

java.lang.Object
  extended by org.eclipse.ptp.core.util.ArgumentParser

public class ArgumentParser
extends Object

Utilitiy class for managing command line arguments.

Since:
7.0

Constructor Summary
ArgumentParser(List<String> tokenList)
          Create a command line representation from an array of strings.
ArgumentParser(String commandline)
          Create a command line representation from the string with a shell command line.
ArgumentParser(String[] tokenArray)
          Create a command line representation from an array of strings.
ArgumentParser(String command, List<String> parameterList)
          Create a command line representation from the command and an list of parameters.
ArgumentParser(String command, String[] parameterArray)
          Create a command line representation from the command and an array of parameters.
 
Method Summary
 String getCommand()
          Returns the command of the command line, assuming that the first entry is always the command.
 String getCommandLine(boolean fullEscape)
          Convert all tokens in a full command line that can be executed in a shell.
 String getEscapedCommand(boolean fullEscalpe)
          Returns the command of the command line, assuming that the first entry is always the command.
 String[] getParameterArray()
          Returns a list of all arguments, assuming that the first entry is the command name.
 List<String> getParameterList()
          Returns a list of all arguments, assuming that the first entry is the command name.
 int getSize()
          Returns the total number of entries.
 String[] getTokenArray()
          Returns a List of all entries of the command line.
 List<String> getTokenList()
          Returns a List of all entries of the command line.
 String toString()
          Returns a representation of the command line for debug purposes.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ArgumentParser

public ArgumentParser(String commandline)
Create a command line representation from the string with a shell command line. The command line is parsed and split on spaces. Quoted or escaped spaces are preserved..

Since:
2.0

ArgumentParser

public ArgumentParser(String[] tokenArray)
Create a command line representation from an array of strings. The first element of the array is assumed to be the command, the remaining, the arguments. The elements are not parsed not (un)escaped., but taked as the are.

Since:
2.0

ArgumentParser

public ArgumentParser(List<String> tokenList)
Create a command line representation from an array of strings. The first element of the list is assumed to be the command, the remaining, the arguments. The elements are not parsed not (un)escaped., but taked as the are.

Since:
2.0

ArgumentParser

public ArgumentParser(String command,
                      String[] parameterArray)
Create a command line representation from the command and an array of parameters. The elements are not parsed not (un)escaped., but taked as the are.

Since:
2.0

ArgumentParser

public ArgumentParser(String command,
                      List<String> parameterList)
Create a command line representation from the command and an list of parameters. The elements are not parsed not (un)escaped., but taked as the are.

Since:
2.0
Method Detail

getCommandLine

public String getCommandLine(boolean fullEscape)
Convert all tokens in a full command line that can be executed in a shell.

Parameters:
fullEscape - If every special character shall be escaped. If false, only white spaces are escaped and the shell will interpret the special chars. If true, then all special chars are quoted.
Since:
2.0

getTokenArray

public String[] getTokenArray()
Returns a List of all entries of the command line.

Returns:
The Array
Since:
2.0

getTokenList

public List<String> getTokenList()
Returns a List of all entries of the command line.

Returns:
The List
Since:
2.0

getCommand

public String getCommand()
Returns the command of the command line, assuming that the first entry is always the command.

Returns:
The command or null if the command lines has no command nor arguments.
Since:
2.0

getEscapedCommand

public String getEscapedCommand(boolean fullEscalpe)
Returns the command of the command line, assuming that the first entry is always the command.

Parameters:
fullEscape - If every special character shall be escaped. If false, only white spaces are escaped and the shell will interpret the special chars. If true, then all special chars are quoted.
Returns:
The command or null if the command lines has no command nor arguments.
Since:
2.0

getParameterArray

public String[] getParameterArray()
Returns a list of all arguments, assuming that the first entry is the command name.

Returns:
The Array or null if the command lines has no command nor arguments.
Since:
2.0

getParameterList

public List<String> getParameterList()
Returns a list of all arguments, assuming that the first entry is the command name.

Returns:
The List or null if the command lines has no command nor arguments.
Since:
2.0

getSize

public int getSize()
Returns the total number of entries.

Returns:
Since:
2.0

toString

public String toString()
Returns a representation of the command line for debug purposes.

Overrides:
toString in class Object

PTP
Release 7.0

Copyright (c) 2011 IBM Corporation and others. All Rights Reserved.