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
RevLine 
[77]1package com.framsticks.communication.queries;
2
[96]3import com.framsticks.util.lang.Pair;
4
[77]5/**
6 * @author Piotr Sniegowski
7 */
8public class SetRequest extends ApplicationRequest {
[96]9
10        protected String field;
[77]11        protected String value;
12
13        public SetRequest() {
14        }
15
[96]16        public SetRequest field(String field) {
17                this.field = field;
18                return this;
19        }
20
[77]21        public SetRequest value(String value) {
22                this.value = value;
23                return this;
24        }
25
26        @Override
27        protected StringBuilder construct(StringBuilder buffer) {
[96]28                return quoteArgumentIfNeeded(super.construct(buffer).append(' ').append(field).append(' '), value);
[77]29        }
[96]30
[77]31        @Override
32        public String getCommand() {
33                return "set";
34        }
[96]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        }
[77]60}
Note: See TracBrowser for help on using the repository browser.