Example #1
0
	public void processLine(String line) throws Exception {
		line = line.trim();
		if (line.length() > 0 && line.substring(0, 1).equals("#")) {
			return;
		}
		String[] chunks = line.split(" ");
		String command = chunks[0];
		
		String[] params = new String[chunks.length -1];
		for (int i = 1; i< chunks.length; i++) {
			params[i - 1] = chunks[i];
		}
		
		switch (Keyword.toKeyword(command)) {
			case q:
			case quit:
				throw new RuntimeException("quit!");
			case trans:
			case t:
				translateSpelling(params[0]);
				break;
			case h:
			case help:
				InputStream stream = Console.class.getResourceAsStream("ConsoleHelp.txt");
				BufferedReader in = new BufferedReader(new InputStreamReader(stream));
				String tmpLine = null;
				while((tmpLine = in.readLine()) != null) out(tmpLine);
				stream.close();
				break;
			default:
				throw new RuntimeException("unknown command " + command);
		}
	}