Show InputProcessor.java syntax highlighted
/*
* Copyright (C) 2001-2005 Pleasant nightmare studio
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
* See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
package org.pleasantnightmare.riotinecity.console;
import com.jme.scene.Node;
/**
* @author: deus
* @since: Mar 26, 2007 2:30:08 PM
* @version: 1.0
*/
public abstract class InputProcessor {
protected ConsoleModel model;
protected Node rootNode;
protected ConsoleEngine engine;
public void setModel(ConsoleModel model) {
this.model = model;
}
public void setEngine(ConsoleEngine engine) {
this.engine = engine;
}
public void setRootNode(Node rootNode) {
this.rootNode = rootNode;
}
/**
* Tries to process given input. Allowed to write onto
* the given writer and can also ask given buffered
* reader to wait for input.
*
* @param input command to process
* @throws ProcessingError in case processor failed somehow.
* Error message holds message to write out
*/
public abstract void process(String input) throws ProcessingError;
/**
* Quick test to check if this <code>InputProcessor</code>
* can process given input.
* <p/>
* Its preferable for this test to be quick, possibly matching
* only the command name. This command must guarantee only that this
* <code>InputProcessor</code> can possibly process given input.
* Command execution failures due to wrong input or states are to
* be signalled by throwing ProcessingError when process(String)
* is called.
*
* @param input typed command, with parameters
* @return true if command is processable, false if it isn't.
* Does <strong>not</strong> guarantee that the input *will* be
* processed succesfully when calling process.
*/
public abstract boolean isProcessable(String input);
/**
* Gets name by which this processor is called.
* @return processor name
*/
public abstract String getCommand();
}
See more files for this project here