@@ -294,18 +294,9 @@ private static String[] parseArgs(String argsString) {
294
294
return retList .toArray (StringUtils .EMPTY_STRING_ARRAY );
295
295
}
296
296
297
- /**
298
- * Given a string entry, converts it into a SsurgeonEdit object.
299
- */
300
- public static SsurgeonEdit parseEditLine (String editLine ) {
301
- // Extract the operation name first
302
- final String [] tuples1 = editLine .split ("\\ s+" , 2 );
303
- if (tuples1 .length < 1 ) {
304
- throw new SsurgeonParseException ("Error in SsurgeonEdit.parseEditLine: invalid number of arguments" );
305
- }
306
- final String command = tuples1 [0 ];
307
- final String [] argsArray = tuples1 .length == 1 ? new String [0 ] : parseArgs (tuples1 [1 ]);
297
+ private static SsurgeonArgs parseArgsBox (String args ) {
308
298
SsurgeonArgs argsBox = new SsurgeonArgs ();
299
+ final String [] argsArray = parseArgs (args );
309
300
310
301
for (int argIndex = 0 ; argIndex < argsArray .length ; ++argIndex ) {
311
302
switch (argsArray [argIndex ]) {
@@ -345,7 +336,29 @@ public static SsurgeonEdit parseEditLine(String editLine) {
345
336
throw new SsurgeonParseException ("Parsing Ssurgeon args: unknown flag " + argsArray [argIndex ]);
346
337
}
347
338
}
339
+ return argsBox ;
340
+ }
341
+
342
+ /**
343
+ * Given a string entry, converts it into a SsurgeonEdit object.
344
+ */
345
+ public static SsurgeonEdit parseEditLine (String editLine ) {
346
+ // Extract the operation name first
347
+ final String [] tuples1 = editLine .split ("\\ s+" , 2 );
348
+ if (tuples1 .length < 1 ) {
349
+ throw new SsurgeonParseException ("Error in SsurgeonEdit.parseEditLine: invalid number of arguments" );
350
+ }
351
+ final String command = tuples1 [0 ];
348
352
353
+ if (command .equalsIgnoreCase (SetRoots .LABEL )) {
354
+ String [] names = tuples1 [1 ].split ("\\ s+" );
355
+ List <String > newRoots = Arrays .asList (names );
356
+ return new SetRoots (newRoots );
357
+ } else if (command .equalsIgnoreCase (KillNonRootedNodes .LABEL )) {
358
+ return new KillNonRootedNodes ();
359
+ }
360
+
361
+ final SsurgeonArgs argsBox = parseArgsBox (tuples1 .length == 1 ? "" : tuples1 [1 ]);
349
362
350
363
// Parse the arguments based upon the type of command to execute.
351
364
// TODO: this logic really should be moved into the individual classes. The string-->class
@@ -367,12 +380,6 @@ public static SsurgeonEdit parseEditLine(String editLine) {
367
380
retEdit = new RemoveEdge (reln , argsBox .govNodeName , argsBox .dep );
368
381
} else if (command .equalsIgnoreCase (RemoveNamedEdge .LABEL )) {
369
382
retEdit = new RemoveNamedEdge (argsBox .edge );
370
- } else if (command .equalsIgnoreCase (SetRoots .LABEL )) {
371
- String [] names = tuples1 [1 ].split ("\\ s+" );
372
- List <String > newRoots = Arrays .asList (names );
373
- retEdit = new SetRoots (newRoots );
374
- } else if (command .equalsIgnoreCase (KillNonRootedNodes .LABEL )) {
375
- retEdit = new KillNonRootedNodes ();
376
383
} else if (command .equalsIgnoreCase (KillAllIncomingEdges .LABEL )) {
377
384
retEdit = new KillAllIncomingEdges (argsBox .node );
378
385
} else {
0 commit comments