2 * collectd - bindings/java/org/collectd/api/DataSet.java
3 * Copyright (C) 2009 Florian octo Forster
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:
12 * The above copyright notice and this permission notice shall be included in
13 * all copies or substantial portions of the Software.
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.
24 * Florian octo Forster <octo at collectd.org>
27 package org.collectd.api;
29 import java.util.List;
30 import java.util.ArrayList;
33 * Java representation of collectd/src/plugin.h:data_set_t structure.
35 * @author Florian Forster <octo at collectd.org>
40 private List<DataSource> _ds;
45 this._ds = new ArrayList<DataSource> ();
48 public DataSet (String type)
51 this._ds = new ArrayList<DataSource> ();
54 public DataSet (String type, DataSource dsrc)
57 this._ds = new ArrayList<DataSource> ();
61 public DataSet (String type, List<DataSource> ds)
67 public void setType (String type)
72 public String getType ()
77 public void addDataSource (DataSource dsrc)
82 public List<DataSource> getDataSources ()
87 public String toString ()
89 StringBuffer sb = new StringBuffer ();
92 sb.append (this._type);
93 for (i = 0; i < this._ds.size (); i++)
99 sb.append (this._ds.get (i).toString ());
102 return (sb.toString ());
105 static public DataSet parseDataSet (String str)
107 DataSet ds = new DataSet ();
112 if (str.length() == 0) {
115 if (str.charAt(0) == '#') {
119 fields = str.split ("\\s+");
120 if (fields.length < 2)
123 ds._type = fields[0];
125 for (i = 1; i < fields.length; i++) {
128 dsrc = DataSource.parseDataSource (fields[i]);
135 if (i < fields.length)
139 } /* DataSet parseDataSet */
140 } /* class DataSet */
142 /* vim: set sw=4 sts=4 et : */