aboutsummaryrefslogtreecommitdiff
path: root/src/esieequest/controller/Parser.java
blob: 452c27c391f8ded74c55b050fbf5227cf0bf0d35 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package esieequest.controller;

import esieequest.model.commands.Command;

/**
 * The command parser.
 * 
 * @author Pacien TRAN-GIRARD
 */
class Parser {

	/**
	 * The default constructor.
	 */
	public Parser() {
	}

	/**
	 * Creates a command from a String.
	 * 
	 * @param commandString
	 *            the command as a String
	 * 
	 * @return the command
	 */
	public Command getCommand(final String commandString) {
		final String[] elements = commandString.split(" ");

		String action = null;
		String option = null;

		if (elements.length > 0) {
			action = elements[0];
		}
		if (elements.length > 1) {
			option = elements[1];
		}

		return new Command(action, option);
	}

	/**
	 * Checks whether the command contains a valid action with a valid option.
	 */
	private boolean validateCommand() {
		// TODO
		return true;
	}

}