3 * Copyright (C) 2009 Hyperic, Inc.
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 package org.collectd.api;
21 import java.util.ArrayList;
22 import java.util.List;
25 * Java representation of collectd/src/plugin.h:value_list_t structure.
27 public class ValueList extends PluginData {
29 private List<Number> _values = new ArrayList<Number>();
32 private long _interval = 0;
38 public ValueList(PluginData pd) {
42 public ValueList(ValueList vl) {
44 _interval = vl._interval;
45 _values.addAll(vl.getValues());
49 public List<Number> getValues() {
53 public void setValues(List<Number> values) {
57 public void addValue(Number value) {
61 /* Used by the network parsing code */
62 public void clearValues () {
67 * @deprecated Use {@link #getDataSet()} instead.
69 public List<DataSource> getDataSource() {
72 return _ds.getDataSources ();
75 public DataSet getDataSet () {
79 public void setDataSet (DataSet ds) {
84 * @deprecated Use {@link #setDataSet(DataSet)} instead.
86 public void setDataSource(List<DataSource> dsrc) {
87 _ds = new DataSet (_type, dsrc);
91 * Returns the interval (in milliseconds) of the value list.
93 public long getInterval() {
98 * Sets the interval (in milliseconds) of the value list.
100 public void setInterval(long interval) {
101 _interval = interval;
104 public String toString() {
105 StringBuffer sb = new StringBuffer(super.toString());
107 List<DataSource> ds = getDataSource();
108 int size = _values.size();
109 for (int i=0; i<size; i++) {
110 Number val = _values.get(i);
113 name = "unknown" + i;
116 name = ds.get(i).getName();
118 sb.append(name).append('=').append(val);
124 return sb.toString();
128 /* vim: set sw=4 sts=4 et : */