Show ThinkcapAction.java syntax highlighted
package org.integratedmodelling.thinkcap;
import org.integratedmodelling.thinkcap.exceptions.ThinkcapException;
import org.integratedmodelling.thinklab.KnowledgeManager;
import org.integratedmodelling.thinklab.command.Command;
import org.integratedmodelling.thinklab.exception.ThinklabException;
import org.integratedmodelling.thinklab.interfaces.IAction;
import org.integratedmodelling.thinklab.value.Value;
public abstract class ThinkcapAction implements IAction {
public abstract void execute(ThinkcapCommand command, ThinkcapAnswer value) throws ThinklabException;
final public Value execute(Command cmd, KnowledgeManager km)
throws ThinklabException {
// shouldn't happen, unless user implements some strange command loop. Anyway...
if (cmd.getClass() != ThinkcapCommand.class)
throw new ThinkcapException("internal: Thinkcap cannot handle non-thinkcap command " + cmd);
ThinkcapCommand tc = (ThinkcapCommand)cmd;
// set everything needed into the answer value
ThinkcapAnswer ret = new ThinkcapAnswer(tc.context);
// call virtual; redirect exception to Thinkcap reporting
execute((ThinkcapCommand)tc, ret);
return ret;
}
}
See more files for this project here