- java.lang.Object
-
- com.ibm.java.diagnostics.utils.commands.CommandParser
-
public class CommandParser extends Object
Handles command line entries and does extra interpretation, such as handling quoted strings (whilst discarding quotes themselves and handling escaped characters), recognising redirection to file etc. NOTE: As of Nov 2011, another copy of this class lives in com.ibm.j9ddr.command. Any changes to this file must be copied across.
-
-
Constructor Summary
Constructors Constructor Description CommandParser(String commandLine)
CommandParser(String command, String[] arguments)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description String[]
getArguments()
Just the command arguments, strips the ">" or ">>" and all strings that follow (i.e. file redirection).String
getCommand()
String
getOriginalLine()
PrintStream
getOutputFile()
Returns a PrintStream, which either writes to a new file or overwrites or appends to an existing one, depending on the command.boolean
isRedirectedToFile()
-
-
-
Constructor Detail
-
CommandParser
public CommandParser(String commandLine) throws ParseException
- Throws:
ParseException
-
CommandParser
public CommandParser(String command, String[] arguments) throws ParseException
- Throws:
ParseException
-
-
Method Detail
-
getOriginalLine
public String getOriginalLine()
-
getCommand
public String getCommand()
-
isRedirectedToFile
public boolean isRedirectedToFile()
-
getArguments
public String[] getArguments()
Just the command arguments, strips the ">" or ">>" and all strings that follow (i.e. file redirection).- Returns:
-
getOutputFile
public PrintStream getOutputFile() throws IOException
Returns a PrintStream, which either writes to a new file or overwrites or appends to an existing one, depending on the command.- Returns:
- Throws:
IOException
IllegalStateException
- - thrown if the command is not redirected to file. Use isRedirectedToFile() to check.
-
-