aboutsummaryrefslogtreecommitdiff
path: root/src/esieequest/controller/Input.java
diff options
context:
space:
mode:
authorPacien TRAN-GIRARD2014-04-19 14:41:30 +0200
committerPacien TRAN-GIRARD2014-04-19 14:42:52 +0200
commit86d6f56dd14fdb94411a02679b9ad4bd556d8a32 (patch)
tree7f3f287b861f54d523d4643b3a349752c01bec32 /src/esieequest/controller/Input.java
parent006daa5c112fd9a5e3bdc38d760ba22b2558651c (diff)
downloadesieequest-86d6f56dd14fdb94411a02679b9ad4bd556d8a32.tar.gz
Refactoring + implement Sides
Diffstat (limited to 'src/esieequest/controller/Input.java')
-rw-r--r--src/esieequest/controller/Input.java59
1 files changed, 59 insertions, 0 deletions
diff --git a/src/esieequest/controller/Input.java b/src/esieequest/controller/Input.java
new file mode 100644
index 0000000..4b4ada5
--- /dev/null
+++ b/src/esieequest/controller/Input.java
@@ -0,0 +1,59 @@
1package esieequest.controller;
2
3import esieequest.controller.commands.Command;
4
5/**
6 * An user textual input.
7 *
8 * @author Pacien TRAN-GIRARD
9 */
10public class Input {
11
12 private Command command;
13 private final String argument;
14
15 /**
16 *
17 * @param command
18 * @param argument
19 */
20 public Input(final Command command, final String argument) {
21 this.command = command;
22 this.argument = argument;
23 }
24
25 /**
26 * Builds an Input from a textual input String.
27 *
28 * @param inputString
29 * the textual input String
30 */
31 public Input(final String inputString) {
32 final String[] elements = inputString.split(" ", 2);
33 try {
34 this.command = Command.valueOf(elements[0].toUpperCase());
35 } catch (final Exception exception) {
36 this.command = null;
37 }
38 if (elements.length >= 2) {
39 this.argument = elements[1];
40 } else {
41 this.argument = null;
42 }
43 }
44
45 /**
46 * @return the command
47 */
48 public Command getCommand() {
49 return this.command;
50 }
51
52 /**
53 * @return the argument
54 */
55 public String getArgument() {
56 return this.argument;
57 }
58
59}