Logo Search packages:      
Sourcecode: jmk version File versions  Download package

void edu::neu::ccs::jmk::ClassOperator::exec ( String[]  args,
PrintWriter  out 
) throws CommandFailedException [inline]

Applies the operation specified by the first argument to the remaining arguments.

Parameters:
args operands from the command
out place to write messages
Exceptions:
CommandFailedException if operation failed

Definition at line 57 of file ClassOperator.java.

  {
    String msg = null;        // For error messages
    try {
      if (args.length > 0) {
      Class cls = Class.forName(args[0]);
      Operator operator = (Operator)cls.newInstance();
      String[] params = new String[args.length - 1];
      for (int i = 0; i < params.length; i++)
        params[i] = args[i + 1];
      operator.exec(params, out);
      }
      else
      msg = "Missing class name";
    }
    catch (CommandFailedException ex) {   // From exec
      throw ex;
    }
    catch (ClassNotFoundException ex) {   // From forName
      msg = args[0] + " class not found";
    }
    catch (ClassCastException ex) { // From (Operator)newInstance()
      msg = args[0] + " does not implement Operator";
    }
    catch (IllegalAccessException ex) {
      msg = "Cannot create an instance of " + args[0] +
      " due to access restrictions";
    }
    catch (InstantiationException ex) {
      msg = "Cannot create an instance of " + args[0];
    }
    if (msg != null)
      throw new CommandFailedException(msg);
  }


Generated by  Doxygen 1.6.0   Back to index