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 import javax.xml.bind.annotation.XmlRootElement;
25 import javax.xml.bind.annotation.XmlType;
26
27 import org.apache.commons.logging.Log;
28 import org.apache.commons.logging.LogFactory;
29 import org.json.simple.JSONObject;
30
31 import org.apache.hadoop.chukwa.util.ExceptionUtil;
32
33 @XmlRootElement
34 @XmlType(propOrder={"key", "value"})
35 public class ConfigBean {
36 private String key = null;
37 private String value = null;
38 private static Log log = LogFactory.getLog(ViewBean.class);
39
40 public ConfigBean() {
41 }
42
43 public ConfigBean(JSONObject json) throws ParseException {
44 try {
45 key = (String) json.get("key");
46 value = (String) json.get("value");
47 } catch (Exception e) {
48 log.error(ExceptionUtil.getStackTrace(e));
49 throw new ParseException("Error parsing user object.",0);
50 }
51 }
52
53 @XmlElement
54 public String getKey() {
55 return key;
56 }
57
58 @XmlElement
59 public String getValue() {
60 return value;
61 }
62
63 public void setKey(String key) {
64 this.key = key;
65 }
66
67 public void setValue(String value) {
68 this.value = value;
69 }
70 }