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.JSONArray;
28 import org.json.simple.JSONObject;
29
30 import org.apache.hadoop.chukwa.util.ExceptionUtil;
31
32 public class ColumnBean {
33 private WidgetBean[] widgets;
34
35 private static Log log = LogFactory.getLog(ColumnBean.class);
36
37 public ColumnBean() {
38 }
39
40 public ColumnBean(JSONArray json) throws ParseException {
41 try {
42 widgets = new WidgetBean[json.size()];
43 for(int i=0;i<json.size();i++) {
44 widgets[i]=new WidgetBean((JSONObject) json.get(i));
45 }
46 } catch (Exception e) {
47 log.error(ExceptionUtil.getStackTrace(e));
48 throw new ParseException(ExceptionUtil.getStackTrace(e), 0);
49 }
50 }
51
52 @XmlElement
53 public WidgetBean[] getWidgets() {
54 return widgets.clone();
55 }
56
57 public void setWidgets(WidgetBean[] ws) {
58 widgets=(WidgetBean[]) ws.clone();
59 }
60
61 public void update() {
62 for(int i=0;i<widgets.length;i++) {
63 widgets[i].update();
64 }
65 }
66
67 public JSONArray deserialize() {
68 JSONArray ja = new JSONArray();
69 for(int i=0;i<widgets.length;i++) {
70 ja.add(widgets[i].deserialize());
71 }
72 return ja;
73 }
74 }