1 /*
2 * collectd/java - org/collectd/api/OConfigItem.java
3 * Copyright (C) 2009 Florian octo Forster
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published by the
7 * Free Software Foundation; only version 2 of the License is applicable.
8 *
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17 *
18 * Authors:
19 * Florian octo Forster <octo at verplant.org>
20 */
22 package org.collectd.api;
24 import java.util.List;
25 import java.util.ArrayList;
27 /**
28 * Java representation of collectd/src/liboconfig/oconfig.h:oconfig_item_t structure.
29 *
30 * @author Florian Forster <octo at verplant.org>
31 */
32 public class OConfigItem
33 {
34 private String _key = null;
35 private List<OConfigValue> _values = new ArrayList<OConfigValue> ();
36 private List<OConfigItem> _children = new ArrayList<OConfigItem> ();
38 public OConfigItem (String key)
39 {
40 _key = key;
41 } /* OConfigItem (String key) */
43 public String getKey ()
44 {
45 return (_key);
46 } /* String getKey () */
48 public void addValue (OConfigValue cv)
49 {
50 _values.add (cv);
51 } /* void addValue (OConfigValue cv) */
53 public void addValue (String s)
54 {
55 _values.add (new OConfigValue (s));
56 } /* void addValue (String s) */
58 public void addValue (Number n)
59 {
60 _values.add (new OConfigValue (n));
61 } /* void addValue (String s) */
63 public void addValue (boolean b)
64 {
65 _values.add (new OConfigValue (b));
66 } /* void addValue (String s) */
68 public List<OConfigValue> getValues ()
69 {
70 return (_values);
71 } /* List<OConfigValue> getValues () */
73 public void addChild (OConfigItem ci)
74 {
75 _children.add (ci);
76 } /* void addChild (OConfigItem ci) */
78 public List<OConfigItem> getChildren ()
79 {
80 return (_children);
81 } /* List<OConfigItem> getChildren () */
83 public String toString ()
84 {
85 return (new String ("{ key: " + _key + "; "
86 + "values: " + _values.toString () + "; "
87 + "children: " + _children.toString () + "; }"));
88 } /* String toString () */
89 } /* class OConfigItem */
91 /* vim: set sw=2 sts=2 et fdm=marker : */