1 package be
.nikiroo
.jvcard
.remote
;
5 /** VERSION of the protocol */
7 /** TIME of the remote server in milliseconds since the Unix epoch */
9 /** STOP the communication (client stops) */
12 * LIST all the contacts on the remote server that contain the search
13 * term, or all contacts if no search term given
16 /** HELP about the protocol for interactive access */
18 /** GET a remote contact */
20 /** PUT a new contact to the remote server or update an existing one */
22 /** POST a new contact to the remote server */
24 /** DELETE an existing contact from the remote server */
33 * Create a new, empty {@link Command} with the given {@link Verb} and
41 public Command(Verb verb
, int version
) {
42 this(verb
, null, version
);
46 * Create a new, empty {@link Command} with the given {@link Verb} and
54 public Command(Verb verb
, String param
, int version
) {
56 this.version
= version
;
61 * Read a command line (starting with a {@link Verb}) and process its
62 * content here in a more readable format.
67 * the version (which can be overrided by a {@link Verb#VERSION}
70 public Command(String input
, int version
) {
71 this.version
= version
;
75 int indexSp
= input
.indexOf(" ");
77 v
= input
.substring(0, indexSp
);
80 for (Verb verb
: Verb
.values()) {
81 if (v
.equals(verb
.name())) {
89 param
= input
.substring(indexSp
+ 1);
93 if (verb
== Verb
.VERSION
) {
95 version
= Integer
.parseInt(param
);
96 } catch (NumberFormatException e
) {
107 * @return the version
109 public int getVersion() {
114 * Return the {@link Verb}
116 * @return the {@link Verb}
118 public Verb
getVerb() {
123 * Return the parameter of this {@link Command} if any.
125 * @return the parameter or NULL
127 public String
getParam() {
132 public String
toString() {
134 return "[null command]";
138 return verb
.name() + " " + version
;
140 return verb
.name() + (param
== null ?
"" : " " + param
);