|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcakoose.util.exec.WindowsArgProtector
public class WindowsArgProtector
Windows' command-line argument processing is stupid. This class contains functions to encode arguments so that they come out right after being parsed by Windows.
| Method Summary | |
|---|---|
static int |
calcEscapes(String arg)
Determines whether the argument needs quotes and, if so, how many characters need to be escaped. |
static void |
main(String[] args)
|
static String |
quote(String arg)
Given a string X, this function returns a string that, when passed through the Windows implementation of Java's Runtime.exec(String[]) or
ProcessBuilder, will appear to the spawned process as X. |
static void |
quote(StringBuffer buf,
String arg)
A version of 'quote' that appends to a buffer instead of returning a string. |
static String |
quoteMaybe(String arg)
Given a string X, this function returns a string that, when passed through the Windows implementation of Java's Runtime.exec(String[]) or
ProcessBuilder, will appear to the spawned process as X. |
static void |
quoteMaybe(StringBuffer buf,
String arg)
A version of 'quoteMaybe' that appends to a buffer instead of returning a string. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
|---|
public static String quote(String arg)
Runtime.exec(String[]) or
ProcessBuilder, will appear to the spawned process as X.
This function will always quote and escape the argument, even if it isn't
necessary. Use quoteMaybe(String) if you only want to quote when
necessary.
arg - The argument to quote.
public static void quote(StringBuffer buf,
String arg)
public static int calcEscapes(String arg)
public static String quoteMaybe(String arg)
Runtime.exec(String[]) or
ProcessBuilder, will appear to the spawned process as X.
This function differs from quote(String) in that this function
doesn't always add quotes around the argument. If the argument is fine
as-is, it will be returned unmodified.
arg - The argument to check and protect.
public static void quoteMaybe(StringBuffer buf,
String arg)
public static void main(String[] args)
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||