Changeset 72 for trunk/src/org/expeditee/actions/Actions.java
- Timestamp:
- 05/23/08 09:02:59 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/expeditee/actions/Actions.java
r41 r72 45 45 46 46 public static final String ROOT_PACKAGE = "org.expeditee."; 47 47 48 48 // Package and class file locations 49 49 private static final String ACTIONS_PACKAGE = ROOT_PACKAGE + "actions."; 50 50 51 51 private static final String AGENTS_PACKAGE = ROOT_PACKAGE + "agents."; 52 53 private static final String NAVIGATIONS_CLASS = ROOT_PACKAGE + "actions.NavigationActions"; 54 52 53 private static final String NAVIGATIONS_CLASS = ROOT_PACKAGE 54 + "actions.NavigationActions"; 55 55 56 public static Class[] getClasses(String pckgname) 56 57 throws ClassNotFoundException { … … 232 233 233 234 /** 234 * Performs the given KMS action command. The source Frame and Item are235 * given because they are required by some actions. Note that the source236 * framedoes not have to be the Item's parent Frame.235 * Performs the given action command. The source Frame and Item are given 236 * because they are required by some actions. Note that the source frame 237 * does not have to be the Item's parent Frame. 237 238 * 238 239 * @param source … … 246 247 if (!command.equalsIgnoreCase("Restore")) 247 248 FrameIO.SaveFrame(source, false); 248 249 249 250 // separate method name and parameter names 250 251 String mname = getName(command); … … 278 279 // Need to save the frame if we are navigating away from it so we dont 279 280 // loose changes 280 if (toRun.getDeclaringClass().getName().equals( 281 NAVIGATIONS_CLASS)) { 281 if (toRun.getDeclaringClass().getName().equals(NAVIGATIONS_CLASS)) { 282 282 FrameIO.SaveFrame(DisplayIO.getCurrentFrame()); 283 283 } … … 363 363 if (con == null) { 364 364 FrameGraphics.DisplayMessage("Invalid parametres for agent."); 365 // System.out.println("Constructor not found...");365 // System.out.println("Constructor not found..."); 366 366 return; 367 367 } … … 482 482 } 483 483 484 String param ;484 String param = values; 485 485 // convert the rest of the objects 486 486 for (; ind < objects.length; ind++) { 487 // strip off the next value488 param = ParseValue(values);489 values = RemainingParams(values);490 491 487 // check if its the last param and combine 492 if (values.length() > 0 && ind == objects.length - 1) 493 param = param.trim() + ' ' + values.trim(); 494 488 if (values.length() > 0 && ind == objects.length - 1) { 489 param = values.trim(); 490 // check if its a string 491 if (param.length() > 0 && param.charAt(0) == '"'){ 492 int endOfString = param.indexOf('"', 1); 493 if (endOfString > 0){ 494 param = param.substring(0,endOfString); 495 } 496 } 497 } else {// strip off the next value 498 param = ParseValue(values); 499 values = RemainingParams(values); 500 } 495 501 // convert the value to an object 496 502 Object o = Conversion.Convert(paramTypes[ind], param); … … 509 515 * @return the remaining N - 1 parameters 510 516 */ 511 p rivatestatic String RemainingParams(String params) {517 public static String RemainingParams(String params) { 512 518 if (params.length() == 0) 513 519 return null; … … 523 529 // Check if we have a string parameter 524 530 if (params.charAt(0) == '"') { 525 return params.substring(params.indexOf('"', 1) + 1); 526 } 527 528 return params.substring(params.indexOf(" ")); 531 int endOfString = params.indexOf('"', 1); 532 if (endOfString > 0){ 533 if (endOfString > params.length()) 534 return ""; 535 return params.substring(endOfString + 1).trim(); 536 } 537 } 538 539 return params.substring(params.indexOf(" ")).trim(); 529 540 } 530 541 … … 537 548 * @return The first value in the String 538 549 */ 539 p rivatestatic String ParseValue(String params) {550 public static String ParseValue(String params) { 540 551 if (params.length() == 0) 541 552 return null; … … 543 554 // remove leading and trailing spaces 544 555 String param = params.trim(); 556 557 // Check if we have a string parameter 558 if (param.charAt(0) == '"') { 559 int endOfString = param.indexOf('"', 1); 560 if (endOfString > 0) 561 return param.substring(1, endOfString); 562 } 545 563 546 564 // if there are no more parameters, we are done … … 549 567 } 550 568 551 // Check if we have a string parameter552 if (param.charAt(0) == '"') {553 return param.substring(1, param.indexOf('"', 1));554 }555 556 569 return param.substring(0, param.indexOf(" ")); 557 570 }
Note:
See TracChangeset
for help on using the changeset viewer.