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.Date;
24 * Shared members of value_list_t and notification_t structures.
26 public class PluginData {
28 protected long _time = 0;
29 protected String _host;
30 protected String _plugin;
31 protected String _pluginInstance = "";
32 protected String _type = "";
33 protected String _typeInstance = "";
39 public PluginData(PluginData pd) {
43 _pluginInstance = pd._pluginInstance;
45 _typeInstance = pd._typeInstance;
48 public long getTime() {
52 public void setTime(long time) {
56 public String getHost() {
60 public void setHost(String host) {
64 public String getPlugin() {
68 public void setPlugin(String plugin) {
72 public String getPluginInstance() {
73 return _pluginInstance;
76 public void setPluginInstance(String pluginInstance) {
77 _pluginInstance = pluginInstance;
80 public String getType() {
84 public void setType(String type) {
88 public String getTypeInstance() {
92 public void setTypeInstance(String typeInstance) {
93 _typeInstance = typeInstance;
96 public boolean defined(String val) {
97 return (val != null) && (val.length() > 0);
100 public String getSource() {
101 final char DLM = '/';
102 StringBuffer sb = new StringBuffer();
103 if (defined(_host)) {
106 if (defined(_plugin)) {
107 sb.append(DLM).append(_plugin);
109 if (defined(_pluginInstance)) {
110 sb.append(DLM).append(_pluginInstance);
112 if (defined(_type)) {
113 sb.append(DLM).append(_type);
115 if (defined(_typeInstance)) {
116 sb.append(DLM).append(_typeInstance);
118 return sb.toString();
121 public String toString() {
122 StringBuffer sb = new StringBuffer();
123 sb.append('[').append(new Date(_time)).append("] ");
124 sb.append(getSource());
125 return sb.toString();