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 /** SELECT a resource (a card) to work on */
20 /** GET a remote card */
23 * PUT mode activation toggle for a card on the remote server (you can
24 * issue *_CONTACT commands when in PUT mode)
27 /** POST a new card to the remote server */
29 /** DELETE an existing contact from the remote server */
31 /** GET a remote contact */
34 * PUT mode activation toggle for a contact on the remote server (you
35 * can issue *_DATA commands when in PUT mode)
38 /** POST a new contact to the remote server */
40 /** DELETE an existing contact from the remote server */
42 /** GET a remote data */
44 /** POST a new data to the remote server */
46 /** DELETE an existing data from the remote server */
55 * Create a new, empty {@link Command} with the given {@link Verb} and
63 public Command(Verb verb
, int version
) {
64 this(verb
, null, version
);
68 * Create a new, empty {@link Command} with the given {@link Verb} and
76 public Command(Verb verb
, String param
, int version
) {
78 this.version
= version
;
83 * Read a command line (starting with a {@link Verb}) and process its
84 * content here in a more readable format.
89 * the version (which can be overrided by a {@link Verb#VERSION}
92 public Command(String input
, int version
) {
93 this.version
= version
;
97 int indexSp
= input
.indexOf(" ");
99 v
= input
.substring(0, indexSp
);
102 for (Verb verb
: Verb
.values()) {
103 if (v
.equals(verb
.name())) {
111 param
= input
.substring(indexSp
+ 1);
115 if (verb
== Verb
.VERSION
) {
117 version
= Integer
.parseInt(param
);
118 } catch (NumberFormatException e
) {
129 * @return the version
131 public int getVersion() {
136 * Return the {@link Verb}
138 * @return the {@link Verb}
140 public Verb
getVerb() {
145 * Return the parameter of this {@link Command} if any.
147 * @return the parameter or NULL
149 public String
getParam() {
154 public String
toString() {
156 return "[null command]";
160 return verb
.name() + " " + version
;
162 return verb
.name() + (param
== null ?
"" : " " + param
);