Ignore:
Timestamp:
05/23/08 09:02:59 (16 years ago)
Author:
ra33
Message:

Added lots of stuff

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/expeditee/actions/Actions.java

    r41 r72  
    4545
    4646        public static final String ROOT_PACKAGE = "org.expeditee.";
    47        
     47
    4848        // Package and class file locations
    4949        private static final String ACTIONS_PACKAGE = ROOT_PACKAGE + "actions.";
    5050
    5151        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
    5556        public static Class[] getClasses(String pckgname)
    5657                        throws ClassNotFoundException {
     
    232233
    233234        /**
    234          * Performs the given KMS action command. The source Frame and Item are
    235          * given because they are required by some actions. Note that the source
    236          * frame does 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.
    237238         *
    238239         * @param source
     
    246247                if (!command.equalsIgnoreCase("Restore"))
    247248                        FrameIO.SaveFrame(source, false);
    248                
     249
    249250                // separate method name and parameter names
    250251                String mname = getName(command);
     
    278279                // Need to save the frame if we are navigating away from it so we dont
    279280                // loose changes
    280                 if (toRun.getDeclaringClass().getName().equals(
    281                                  NAVIGATIONS_CLASS)) {
     281                if (toRun.getDeclaringClass().getName().equals(NAVIGATIONS_CLASS)) {
    282282                        FrameIO.SaveFrame(DisplayIO.getCurrentFrame());
    283283                }
     
    363363                        if (con == null) {
    364364                                FrameGraphics.DisplayMessage("Invalid parametres for agent.");
    365                                 //System.out.println("Constructor not found...");
     365                                // System.out.println("Constructor not found...");
    366366                                return;
    367367                        }
     
    482482                }
    483483
    484                 String param;
     484                String param = values;
    485485                // convert the rest of the objects
    486486                for (; ind < objects.length; ind++) {
    487                         // strip off the next value
    488                         param = ParseValue(values);
    489                         values = RemainingParams(values);
    490 
    491487                        // 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                        }
    495501                        // convert the value to an object
    496502                        Object o = Conversion.Convert(paramTypes[ind], param);
     
    509515         * @return the remaining N - 1 parameters
    510516         */
    511         private static String RemainingParams(String params) {
     517        public static String RemainingParams(String params) {
    512518                if (params.length() == 0)
    513519                        return null;
     
    523529                // Check if we have a string parameter
    524530                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();
    529540        }
    530541
     
    537548         * @return The first value in the String
    538549         */
    539         private static String ParseValue(String params) {
     550        public static String ParseValue(String params) {
    540551                if (params.length() == 0)
    541552                        return null;
     
    543554                // remove leading and trailing spaces
    544555                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                }
    545563
    546564                // if there are no more parameters, we are done
     
    549567                }
    550568
    551                 // Check if we have a string parameter
    552                 if (param.charAt(0) == '"') {
    553                         return param.substring(1, param.indexOf('"', 1));
    554                 }
    555 
    556569                return param.substring(0, param.indexOf(" "));
    557570        }
Note: See TracChangeset for help on using the changeset viewer.