Ignore:
Timestamp:
06/05/08 10:11:18 (16 years ago)
Author:
ra33
Message:

Added DebugFrame action
Added GetCometStats
Lots of bug fixes

File:
1 edited

Legend:

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

    r80 r86  
    4646public class Actions {
    4747
     48        private static final String INVALID_PARAMETERS_ERROR = "Invalid parameters for agent: "; //$NON-NLS-1$
     49
    4850        // the currently running agent (if there is one)
    4951        private static Agent _Agent = null;
     
    164166         * Clears out the Action and JAG Hashtables and refills them. Normally this
    165167         * is only called once when the system starts.
    166          * @return a warning message if there were any problems loading agents or actions.
     168         *
     169         * @return a warning message if there were any problems loading agents or
     170         *         actions.
    167171         */
    168172        public static Collection<String> Init() {
    169173                Collection<String> warnings = new LinkedList<String>();
    170174                Class[] classes;
    171                
     175
    172176                try {
    173177                        classes = getClasses(AGENTS_PACKAGE);
     
    327331
    328332                for (Method possible : possibles) {
    329 
    330333                        // try first with the launching item as a parameter
    331334
     
    346349                                e.printStackTrace();
    347350                        }
     351                }
     352                if (possibles.size() > 0) {
     353                        FrameGraphics.ErrorMessage("Incorrect parameters for " + mname);
     354                } else {
     355                        assert(false);
     356                        FrameGraphics.ErrorMessage(mname + " action not found");
    348357                }
    349358        }
     
    386395                        // get the constructor for the JAG class
    387396                        Constructor con = null;
    388                         Constructor constructors[] = agentClass.getConstructors();
     397                        Constructor[] constructors = agentClass.getConstructors();
    389398                        Object[] params = null;
    390399
     
    397406                                        params[0] = parameters;
    398407                                        break;
    399                                 } else if (c.getParameterTypes().length == 0 && con == null)
     408                                } else if (c.getParameterTypes().length == 0 && con == null) {
    400409                                        con = c;
     410                                }
    401411                        }
    402412
    403413                        // if there is no constructor, return
    404414                        if (con == null) {
    405                                 FrameGraphics.DisplayMessage("Invalid parametres for agent: "
     415                                FrameGraphics.DisplayMessage(INVALID_PARAMETERS_ERROR
    406416                                                + nameWithCorrectCase);
    407417                                // System.out.println("Constructor not found...");
     
    433443
    434444                } catch (ClassNotFoundException cnf) {
    435                         FrameGraphics.ErrorMessage("Error: '" + nameWithCorrectCase
     445                        FrameGraphics.ErrorMessage(nameWithCorrectCase
    436446                                        + "' is not an action or agent.");
    437447                } catch (Exception e) {
     
    540550                        }
    541551                        // convert the value to an object
    542                         Object o = Conversion.Convert(paramTypes[ind], param);
    543                         if (o == null)
     552                        try {
     553                                Object o = Conversion.Convert(paramTypes[ind], param);
     554                                if (o == null)
     555                                        return null;
     556                                objects[ind] = o;
     557                        } catch (Exception e) {
    544558                                return null;
    545                         objects[ind] = o;
     559                        }
    546560                }
    547561
Note: See TracChangeset for help on using the changeset viewer.