3a32f0c49c965388204441704665965dc68251b9
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 card */
21 * PUT mode activation toggle for a card on the remote server (you can
22 * issue *_CONTACT commands when in PUT mode)
25 /** POST a new card to the remote server */
27 /** DELETE an existing contact from the remote server */
29 /** GET a remote contact */
32 * PUT mode activation toggle for a contact on the remote server (you
33 * can issue *_DATA commands when in PUT mode)
36 /** POST a new contact to the remote server */
38 /** DELETE an existing contact from the remote server */
40 /** GET a remote data */
42 /** POST a new data to the remote server */
44 /** DELETE an existing data from the remote server */
53 * Create a new, empty {@link Command} with the given {@link Verb} and
61 public Command(Verb verb
, int version
) {
62 this(verb
, null, version
);
66 * Create a new, empty {@link Command} with the given {@link Verb} and
74 public Command(Verb verb
, String param
, int version
) {
76 this.version
= version
;
81 * Read a command line (starting with a {@link Verb}) and process its
82 * content here in a more readable format.
87 * the version (which can be overrided by a {@link Verb#VERSION}
90 public Command(String input
, int version
) {
91 this.version
= version
;
95 int indexSp
= input
.indexOf(" ");
97 v
= input
.substring(0, indexSp
);
100 for (Verb verb
: Verb
.values()) {
101 if (v
.equals(verb
.name())) {
109 param
= input
.substring(indexSp
+ 1);
113 if (verb
== Verb
.VERSION
) {
115 version
= Integer
.parseInt(param
);
116 } catch (NumberFormatException e
) {
127 * @return the version
129 public int getVersion() {
134 * Return the {@link Verb}
136 * @return the {@link Verb}
138 public Verb
getVerb() {
143 * Return the parameter of this {@link Command} if any.
145 * @return the parameter or NULL
147 public String
getParam() {
152 public String
toString() {
154 return "[null command]";
158 return verb
.name() + " " + version
;
160 return verb
.name() + (param
== null ?
"" : " " + param
);