{GPL, other}: Relicense to MIT license.
[collectd.git] / bindings / java / org / collectd / api / OConfigItem.java
1 /**
2  * collectd - bindings/java/org/collectd/api/OConfigItem.java
3  * Copyright (C) 2009       Florian octo Forster
4  *
5  * Permission is hereby granted, free of charge, to any person obtaining a
6  * copy of this software and associated documentation files (the "Software"),
7  * to deal in the Software without restriction, including without limitation
8  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9  * and/or sell copies of the Software, and to permit persons to whom the
10  * Software is furnished to do so, subject to the following conditions:
11  *
12  * The above copyright notice and this permission notice shall be included in
13  * all copies or substantial portions of the Software.
14  *
15  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21  * DEALINGS IN THE SOFTWARE.
22  *
23  * Authors:
24  *   Florian octo Forster <octo at collectd.org>
25  */
26
27 package org.collectd.api;
28
29 import java.util.List;
30 import java.util.ArrayList;
31
32 /**
33  * Java representation of collectd/src/liboconfig/oconfig.h:oconfig_item_t structure.
34  *
35  * @author Florian Forster &lt;octo at collectd.org&gt;
36  */
37 public class OConfigItem
38 {
39   private String _key = null;
40   private List<OConfigValue> _values   = new ArrayList<OConfigValue> ();
41   private List<OConfigItem>  _children = new ArrayList<OConfigItem> ();
42
43   public OConfigItem (String key)
44   {
45     _key = key;
46   } /* OConfigItem (String key) */
47
48   public String getKey ()
49   {
50     return (_key);
51   } /* String getKey () */
52
53   public void addValue (OConfigValue cv)
54   {
55     _values.add (cv);
56   } /* void addValue (OConfigValue cv) */
57
58   public void addValue (String s)
59   {
60     _values.add (new OConfigValue (s));
61   } /* void addValue (String s) */
62
63   public void addValue (Number n)
64   {
65     _values.add (new OConfigValue (n));
66   } /* void addValue (String s) */
67
68   public void addValue (boolean b)
69   {
70     _values.add (new OConfigValue (b));
71   } /* void addValue (String s) */
72
73   public List<OConfigValue> getValues ()
74   {
75     return (_values);
76   } /* List<OConfigValue> getValues () */
77
78   public void addChild (OConfigItem ci)
79   {
80     _children.add (ci);
81   } /* void addChild (OConfigItem ci) */
82
83   public List<OConfigItem> getChildren ()
84   {
85     return (_children);
86   } /* List<OConfigItem> getChildren () */
87
88   public String toString ()
89   {
90     return (new String ("{ key: " + _key + "; "
91           + "values: " + _values.toString () + "; "
92           + "children: " + _children.toString () + "; }"));
93   } /* String toString () */
94 } /* class OConfigItem */
95
96 /* vim: set sw=2 sts=2 et fdm=marker : */