|
static void | main (String[] args) throws Exception |
|
static String [] | translateCommandline (String toProcess) |
|
|
static final CliEntry< String > | PROGRAM |
|
|
static final CliEntry [] | PROG_CLI_ENTRIES |
|
Definition at line 25 of file UartbusAttachProcess.java.
◆ translateCommandline()
static String [] eu.javaexperience.electronic.uartbus.cli.apps.UartbusAttachProcess.translateCommandline |
( |
String |
toProcess | ) |
|
|
inlinestatic |
https://stackoverflow.com/questions/3259143/split-a-string-containing-command-line-parameters-into-a-string-in-java [code borrowed from ant.jar] Crack a command line.
- Parameters
-
toProcess | the command line to process. |
- Returns
- the command line broken into strings. An empty or null toProcess parameter results in a zero sized array.
Definition at line 138 of file UartbusAttachProcess.java.
139 if (toProcess == null || toProcess.length() == 0) {
141 return new String[0];
145 final int normal = 0;
146 final int inQuote = 1;
147 final int inDoubleQuote = 2;
149 final StringTokenizer tok =
new StringTokenizer(toProcess,
"\"\' ",
true);
150 final ArrayList<String> result =
new ArrayList<String>();
151 final StringBuilder current =
new StringBuilder();
152 boolean lastTokenHasBeenQuoted =
false;
154 while (tok.hasMoreTokens()) {
155 String nextTok = tok.nextToken();
158 if (
"\'".equals(nextTok)) {
159 lastTokenHasBeenQuoted =
true;
162 current.append(nextTok);
166 if (
"\"".equals(nextTok)) {
167 lastTokenHasBeenQuoted =
true;
170 current.append(nextTok);
174 if (
"\'".equals(nextTok)) {
176 }
else if (
"\"".equals(nextTok)) {
177 state = inDoubleQuote;
178 }
else if (
" ".equals(nextTok)) {
179 if (lastTokenHasBeenQuoted || current.length() != 0) {
180 result.add(current.toString());
181 current.setLength(0);
184 current.append(nextTok);
186 lastTokenHasBeenQuoted =
false;
190 if (lastTokenHasBeenQuoted || current.length() != 0) {
191 result.add(current.toString());
193 if (state == inQuote || state == inDoubleQuote) {
194 throw new RuntimeException(
"unbalanced quotes in " + toProcess);
196 return result.toArray(
new String[result.size()]);
◆ PROG_CLI_ENTRIES
final CliEntry [] eu.javaexperience.electronic.uartbus.cli.apps.UartbusAttachProcess.PROG_CLI_ENTRIES |
|
staticprotected |
◆ PROGRAM
final CliEntry<String> eu.javaexperience.electronic.uartbus.cli.apps.UartbusAttachProcess.PROGRAM |
|
static |
Initial value:= CliEntry.createFirstArgParserEntry
(
(e)->e,
"Application with arguments",
"a", "-program"
)
Definition at line 27 of file UartbusAttachProcess.java.
The documentation for this class was generated from the following file:
- /home/javaexperience/git-repositories/javaexperience/uartbus/source/java/uartbus/src/main/java/eu/javaexperience/electronic/uartbus/cli/apps/UartbusAttachProcess.java