1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.hadoop.chukwa.rest.bean;
20
21 import java.text.ParseException;
22
23 import javax.xml.bind.annotation.XmlElement;
24
25 import org.apache.commons.logging.Log;
26 import org.apache.commons.logging.LogFactory;
27 import org.json.simple.JSONObject;
28
29 import org.apache.hadoop.chukwa.util.ExceptionUtil;
30
31 public class OptionBean {
32 private String label;
33 private String value;
34 private static Log log = LogFactory.getLog(OptionBean.class);
35
36 public OptionBean() {
37 }
38
39 public OptionBean(JSONObject json) throws ParseException {
40 try {
41 label = (String) json.get("label");
42 value = (String) json.get("value");
43 } catch (Exception e) {
44 throw new ParseException(ExceptionUtil.getStackTrace(e), 0);
45 }
46 }
47
48 @XmlElement
49 public String getLabel() {
50 return label;
51 }
52
53 @XmlElement
54 public String getValue() {
55 return value;
56 }
57
58 public void setLabel(String label) {
59 this.label=label;
60 }
61
62 public void setValue(String value) {
63 this.value=value;
64 }
65
66 public void update() {
67
68 }
69
70 public JSONObject deserialize() {
71 JSONObject json = new JSONObject();
72 try {
73 json.put("label", label);
74 json.put("value", value);
75 } catch (Exception e) {
76 log.error(ExceptionUtil.getStackTrace(e));
77 }
78 return json;
79 }
80 }