2 * collectd/java - org/collectd/api/OConfigValue.java
3 * Copyright (C) 2009 Florian octo Forster
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.
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.
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
19 * Florian octo Forster <octo at verplant.org>
22 package org.collectd.api;
24 public class OConfigValue
26 public static final int OCONFIG_TYPE_STRING = 0;
27 public static final int OCONFIG_TYPE_NUMBER = 1;
28 public static final int OCONFIG_TYPE_BOOLEAN = 2;
31 private String _value_string;
32 private Number _value_number;
33 private boolean _value_boolean;
35 public OConfigValue (String s)
37 _type = OCONFIG_TYPE_STRING;
40 _value_boolean = false;
41 } /* OConfigValue (String s) */
43 public OConfigValue (Number n)
45 _type = OCONFIG_TYPE_NUMBER;
48 _value_boolean = false;
49 } /* OConfigValue (String s) */
51 public OConfigValue (boolean b)
53 _type = OCONFIG_TYPE_BOOLEAN;
57 } /* OConfigValue (String s) */
64 public String getString ()
66 return (_value_string);
67 } /* String getString */
69 public Number getNumber ()
71 return (_value_number);
72 } /* String getString */
74 public boolean getBoolean ()
76 return (_value_boolean);
77 } /* String getString */
79 public String toString ()
81 if (_type == OCONFIG_TYPE_STRING)
82 return (_value_string);
83 else if (_type == OCONFIG_TYPE_NUMBER)
84 return (_value_number.toString ());
85 else if (_type == OCONFIG_TYPE_BOOLEAN)
86 return (Boolean.toString (_value_boolean));
88 } /* String toString () */
89 } /* class OConfigValue */
91 /* vim: set sw=2 sts=2 et fdm=marker : */