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.JSONObject;
2829import org.apache.hadoop.chukwa.util.ExceptionUtil;
3031publicclassOptionBean {
32private String label;
33private String value;
34privatestatic Log log = LogFactory.getLog(OptionBean.class);
3536publicOptionBean() {
37 }
3839publicOptionBean(JSONObject json) throws ParseException {
40try {
41 label = (String) json.get("label");
42 value = (String) json.get("value");
43 } catch (Exception e) {
44thrownew ParseException(ExceptionUtil.getStackTrace(e), 0);
45 }
46 }
4748 @XmlElement
49public String getLabel() {
50return label;
51 }
5253 @XmlElement
54public String getValue() {
55return value;
56 }
5758publicvoid setLabel(String label) {
59this.label=label;
60 }
6162publicvoid setValue(String value) {
63this.value=value;
64 }
6566publicvoid update() {
6768 }
6970public JSONObject deserialize() {
71 JSONObject json = new JSONObject();
72try {
73 json.put("label", label);
74 json.put("value", value);
75 } catch (Exception e) {
76 log.error(ExceptionUtil.getStackTrace(e));
77 }
78return json;
79 }
80 }