This project has retired. For details please refer to its Attic page.
OptionBean xref
View Javadoc

1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   *     http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing, software
13   * 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 and
16   * limitations under the License.
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  }