1/*2 * Licensed to the Apache Software Foundation (ASF) under one3 * or more contributor license agreements. See the NOTICE file4 * distributed with this work for additional information5 * regarding copyright ownership. The ASF licenses this file6 * to you under the Apache License, Version 2.0 (the7 * "License"); you may not use this file except in compliance8 * with the License. You may obtain a copy of the License at9 *10 * http://www.apache.org/licenses/LICENSE-2.011 *12 * Unless required by applicable law or agreed to in writing, software13 * distributed under the License is distributed on an "AS IS" BASIS,14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.15 * See the License for the specific language governing permissions and16 * limitations under the License.17 */1819package org.apache.hadoop.chukwa.rest.bean;
2021import java.text.ParseException;
2223import javax.xml.bind.annotation.XmlElement;
2425import org.apache.commons.logging.Log;
26import org.apache.commons.logging.LogFactory;
27import org.json.simple.JSONArray;
28import org.json.simple.JSONObject;
2930import org.apache.hadoop.chukwa.util.ExceptionUtil;
3132publicclassColumnBean {
33privateWidgetBean[] widgets;
3435privatestatic Log log = LogFactory.getLog(ColumnBean.class);
3637publicColumnBean() {
38 }
3940publicColumnBean(JSONArray json) throws ParseException {
41try {
42 widgets = newWidgetBean[json.size()];
43for(int i=0;i<json.size();i++) {
44 widgets[i]=newWidgetBean((JSONObject) json.get(i));
45 }
46 } catch (Exception e) {
47 log.error(ExceptionUtil.getStackTrace(e));
48thrownew ParseException(ExceptionUtil.getStackTrace(e), 0);
49 }
50 }
5152 @XmlElement
53publicWidgetBean[] getWidgets() {
54return widgets.clone();
55 }
5657publicvoid setWidgets(WidgetBean[] ws) {
58 widgets=(WidgetBean[]) ws.clone();
59 }
6061publicvoid update() {
62for(int i=0;i<widgets.length;i++) {
63 widgets[i].update();
64 }
65 }
6667public JSONArray deserialize() {
68 JSONArray ja = new JSONArray();
69for(int i=0;i<widgets.length;i++) {
70 ja.add(widgets[i].deserialize());
71 }
72return ja;
73 }
74 }