2 * collectd/java - org/collectd/api/OConfigItem.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 import java.util.List;
25 import java.util.ArrayList;
28 * Java representation of collectd/src/plugin.h:data_set_t structure.
30 * @author Florian Forster <octo at verplant.org>
35 private List<DataSource> _ds;
40 this._ds = new ArrayList<DataSource> ();
43 public DataSet (String type)
46 this._ds = new ArrayList<DataSource> ();
49 public DataSet (String type, DataSource dsrc)
52 this._ds = new ArrayList<DataSource> ();
56 public DataSet (String type, List<DataSource> ds)
62 public void setType (String type)
67 public String getType ()
72 public void addDataSource (DataSource dsrc)
77 public List<DataSource> getDataSources ()
82 public String toString ()
84 StringBuffer sb = new StringBuffer ();
87 sb.append (this._type);
88 for (i = 0; i < this._ds.size (); i++)
94 sb.append (this._ds.get (i).toString ());
97 return (sb.toString ());
100 static public DataSet parseDataSet (String str)
102 DataSet ds = new DataSet ();
107 if (str.length() == 0) {
110 if (str.charAt(0) == '#') {
114 fields = str.split ("\\s+");
115 if (fields.length < 2)
118 ds._type = fields[0];
120 for (i = 1; i < fields.length; i++) {
123 dsrc = DataSource.parseDataSource (fields[i]);
130 if (i < fields.length)
134 } /* DataSet parseDataSet */
135 } /* class DataSet */
137 /* vim: set sw=4 sts=4 et : */