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

Added more features to the Greenstone Search

File:
1 edited

Legend:

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

    r311 r313  
    77import java.lang.reflect.Modifier;
    88import java.net.URL;
     9import java.rmi.UnexpectedException;
    910import java.util.ArrayList;
    1011import java.util.Collection;
     
    506507                                        params = new Object[paramCount];
    507508                                        String[] paramStrings = parameters.split("\\s+");
    508                                         if (paramCount != paramStrings.length)
     509                                        /**
     510                                         * Any extra parametres will be treated as the rest of the
     511                                         * string if the last param is a string
     512                                         */
     513                                        if (paramCount > paramStrings.length)
    509514                                                continue;
    510                                         for (int i = 0; i < paramCount; i++) {
    511                                                 SString nextParam = new SString(paramStrings[i]);
    512                                                 try {
     515                                        /**
     516                                         * If there are extra parametres the last param must be a
     517                                         * String
     518                                         */
     519                                        int lastParam = paramTypes.length - 1;
     520
     521                                        if (paramCount < paramStrings.length
     522                                                        && !paramTypes[lastParam].equals(String.class))
     523                                                continue;
     524                                        try {
     525                                                for (int i = 0; i < paramCount; i++) {
     526                                                        SString nextParam = new SString(paramStrings[i]);
    513527                                                        params[i] = null;
    514528                                                        if (paramTypes[i].equals(int.class)
     
    531545                                                                params[i] = nextParam.stringValue();
    532546                                                        } else {
    533                                                                 continue;
     547                                                                throw new UnexpectedException(
     548                                                                                "Unexpected type "
     549                                                                                                + paramTypes[i].getClass()
     550                                                                                                                .toString());
    534551                                                        }
    535                                                 } catch (Exception e) {
    536                                                         continue;
    537552                                                }
     553                                        } catch (Exception e) {
     554                                                continue;
    538555                                        }
     556                                        /** Append extra params on the end of the last string param */
     557                                        String s = params[lastParam].toString();
     558                                        for (int i = paramCount; i < paramStrings.length; i++) {
     559                                                s += ' ' + paramStrings[i];
     560                                        }
     561                                        params[lastParam] = s;
     562
    539563                                        con = c;
    540564                                        break;
     
    861885                try {
    862886                        return PerformAction(current, launcher, command);
    863                 }catch (RuntimeException e) {
     887                } catch (RuntimeException e) {
    864888                        MessageBay.errorMessage("Action failed: " + e.getMessage());
    865889                } catch (Exception e) {
    866                         MessageBay.errorMessage("Action failed: " + e.getClass().getSimpleName());
     890                        MessageBay.errorMessage("Action failed: "
     891                                        + e.getClass().getSimpleName());
    867892                }
    868893                return null;
Note: See TracChangeset for help on using the changeset viewer.