source: java/main/src/main/java/com/framsticks/communication/queries/SetRequest.java @ 193

Last change on this file since 193 was 193, checked in by Maciej Komosinski, 10 years ago

Set svn:eol-style native for all textual files

  • Property svn:eol-style set to native
File size: 1.1 KB
Line 
1package com.framsticks.communication.queries;
2
3import com.framsticks.util.lang.Pair;
4
5/**
6 * @author Piotr Sniegowski
7 */
8public class SetRequest extends ApplicationRequest {
9
10        protected String field;
11        protected String value;
12
13        public SetRequest() {
14        }
15
16        public SetRequest field(String field) {
17                this.field = field;
18                return this;
19        }
20
21        public SetRequest value(String value) {
22                this.value = value;
23                return this;
24        }
25
26        @Override
27        protected StringBuilder construct(StringBuilder buffer) {
28                return quoteArgumentIfNeeded(super.construct(buffer).append(' ').append(field).append(' '), value);
29        }
30
31        @Override
32        public String getCommand() {
33                return "set";
34        }
35
36
37        @Override
38        public CharSequence parseRest(CharSequence rest) {
39                final Pair<CharSequence, CharSequence> fp = takeString(super.parseRest(rest));
40                field = fp.first.toString();
41                final Pair<CharSequence, CharSequence> vp = takeString(fp.second);
42                value = vp.first.toString();
43
44                return vp.second;
45        }
46
47        /**
48         * @return the field
49         */
50        public String getField() {
51                return field;
52        }
53
54        /**
55         * @return the value
56         */
57        public String getValue() {
58                return value;
59        }
60}
Note: See TracBrowser for help on using the repository browser.