[collectd] [PATCH] Move some classes to the org.collectd.api namespace.

Florian Forster octo at verplant.org
Sat Feb 21 12:09:34 CET 2009


From: Florian Forster <octo at leeloo.lan.home.verplant.org>

This is done separately from the following commit to preserve change
history. (Otherwise Git doesn't recognize all moved and changed files..)

Signed-off-by: Florian Forster <octo at leeloo.lan.home.verplant.org>
---
 src/main/java/org/collectd/api/DataSource.java     |   98 +++++++++++++++
 src/main/java/org/collectd/api/Notification.java   |   70 +++++++++++
 src/main/java/org/collectd/api/PluginData.java     |  127 ++++++++++++++++++++
 src/main/java/org/collectd/api/ValueList.java      |  105 ++++++++++++++++
 .../java/org/collectd/protocol/DataSource.java     |   98 ---------------
 .../java/org/collectd/protocol/Notification.java   |   70 -----------
 .../java/org/collectd/protocol/PluginData.java     |  127 --------------------
 src/main/java/org/collectd/protocol/ValueList.java |  105 ----------------
 8 files changed, 400 insertions(+), 400 deletions(-)
 create mode 100644 src/main/java/org/collectd/api/DataSource.java
 create mode 100644 src/main/java/org/collectd/api/Notification.java
 create mode 100644 src/main/java/org/collectd/api/PluginData.java
 create mode 100644 src/main/java/org/collectd/api/ValueList.java
 delete mode 100644 src/main/java/org/collectd/protocol/DataSource.java
 delete mode 100644 src/main/java/org/collectd/protocol/Notification.java
 delete mode 100644 src/main/java/org/collectd/protocol/PluginData.java
 delete mode 100644 src/main/java/org/collectd/protocol/ValueList.java

diff --git a/src/main/java/org/collectd/api/DataSource.java b/src/main/java/org/collectd/api/DataSource.java
new file mode 100644
index 0000000..c090cde
--- /dev/null
+++ b/src/main/java/org/collectd/api/DataSource.java
@@ -0,0 +1,98 @@
+/*
+ * jcollectd
+ * Copyright (C) 2009 Hyperic, Inc.
+ * 
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; only version 2 of the License is applicable.
+ * 
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
+ */
+
+package org.collectd.protocol;
+
+/**
+ * Java representation of collectd/src/plugin.h:data_source_t structure. 
+ */
+public class DataSource {
+    public static final int TYPE_COUNTER = 0;
+    public static final int TYPE_GAUGE   = 1;
+
+    static final String COUNTER = "COUNTER";
+    static final String GAUGE = "GAUGE";
+
+    static final String NAN = "U";
+    private static final String[] TYPES = { COUNTER, GAUGE };
+
+    String _name;
+    int _type;
+    double _min;
+    double _max;
+
+    public String getName() {
+        return _name;
+    }
+
+    public void setName(String name) {
+        _name = name;
+    }
+
+    public int getType() {
+        return _type;
+    }
+
+    public void setType(int type) {
+        _type = type;
+    }
+
+    public double getMin() {
+        return _min;
+    }
+
+    public void setMin(double min) {
+        _min = min;
+    }
+
+    public double getMax() {
+        return _max;
+    }
+
+    public void setMax(double max) {
+        _max = max;
+    }
+
+    static double toDouble(String val) {
+        if (val.equals(NAN)) {
+            return Double.NaN;
+        }
+        else {
+            return Double.parseDouble(val);
+        }
+    }
+
+    private String asString(double val) {
+        if (Double.isNaN(val)) {
+            return NAN;
+        }
+        else {
+            return String.valueOf(val);
+        }
+    }
+
+    public String toString() {
+        StringBuffer sb = new StringBuffer();
+        final char DLM = ':';
+        sb.append(_name).append(DLM);
+        sb.append(TYPES[_type]).append(DLM);
+        sb.append(asString(_min)).append(DLM);
+        sb.append(asString(_max));
+        return sb.toString();
+    }
+}
diff --git a/src/main/java/org/collectd/api/Notification.java b/src/main/java/org/collectd/api/Notification.java
new file mode 100644
index 0000000..6029aef
--- /dev/null
+++ b/src/main/java/org/collectd/api/Notification.java
@@ -0,0 +1,70 @@
+/*
+ * jcollectd
+ * Copyright (C) 2009 Hyperic, Inc.
+ * 
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; only version 2 of the License is applicable.
+ * 
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
+ */
+
+package org.collectd.protocol;
+
+/**
+ * Java representation of collectd/src/plugin.h:notfication_t structure.
+ */
+public class Notification extends PluginData {
+    public static final int FAILURE = 1;
+    public static final int WARNING = 2;
+    public static final int OKAY    = 4;
+
+    public static String[] SEVERITY = {
+        "FAILURE",
+        "WARNING",
+        "OKAY",
+        "UNKNOWN"
+    };
+
+    int _severity;
+    String _message;
+
+    Notification(PluginData pd) {
+        super(pd);
+    }
+
+    public int getSeverity() {
+        return _severity;
+    }
+
+    public String getSeverityString() {
+        switch (_severity) {
+            case FAILURE:
+                return SEVERITY[0];
+            case WARNING:
+                return SEVERITY[1];
+            case OKAY:
+                return SEVERITY[2];
+            default:
+                return SEVERITY[3];
+        }
+    }
+
+    public String getMessage() {
+        return _message;
+    }
+
+    public String toString() {
+        StringBuffer sb = new StringBuffer(super.toString());
+        sb.append(" [").append(getSeverityString()).append("] ");
+        sb.append(_message);
+        return sb.toString();
+    }
+}
diff --git a/src/main/java/org/collectd/api/PluginData.java b/src/main/java/org/collectd/api/PluginData.java
new file mode 100644
index 0000000..734a999
--- /dev/null
+++ b/src/main/java/org/collectd/api/PluginData.java
@@ -0,0 +1,127 @@
+/*
+ * jcollectd
+ * Copyright (C) 2009 Hyperic, Inc.
+ * 
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; only version 2 of the License is applicable.
+ * 
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
+ */
+
+package org.collectd.protocol;
+
+import java.util.Date;
+
+/**
+ * Shared members of value_list_t and notification_t structures.
+ */
+public class PluginData {
+
+    protected long _time;
+    protected String _host;
+    protected String _plugin;
+    protected String _pluginInstance = "";
+    protected String _type = "";
+    protected String _typeInstance = "";
+
+    public PluginData() {
+        
+    }
+
+    public PluginData(PluginData pd) {
+        _time = pd._time;
+        _host = pd._host;
+        _plugin = pd._plugin;
+        _pluginInstance = pd._pluginInstance;
+        _type = pd._type;
+        _typeInstance = pd._typeInstance;
+    }
+
+    public long getTime() {
+        return _time;
+    }
+
+    public void setTime(long time) {
+        _time = time;
+    }
+
+    public String getHost() {
+        return _host;
+    }
+
+    public void setHost(String host) {
+        _host = host;
+    }
+
+    public String getPlugin() {
+        return _plugin;
+    }
+
+    public void setPlugin(String plugin) {
+        _plugin = plugin;
+    }
+
+    public String getPluginInstance() {
+        return _pluginInstance;
+    }
+
+    public void setPluginInstance(String pluginInstance) {
+        _pluginInstance = pluginInstance;
+    }
+
+    public String getType() {
+        return _type;
+    }
+
+    public void setType(String type) {
+        _type = type;
+    }
+
+    public String getTypeInstance() {
+        return _typeInstance;
+    }
+
+    public void setTypeInstance(String typeInstance) {
+        _typeInstance = typeInstance;
+    }
+
+    public boolean defined(String val) {
+        return (val != null) && (val.length() > 0);
+    }
+
+    public String getSource() {
+        final char DLM = '/';
+        StringBuffer sb = new StringBuffer();
+        if (defined(_host)) {
+            sb.append(_host);
+        }
+        if (defined(_plugin)) {
+            sb.append(DLM).append(_plugin);
+        }
+        if (defined(_pluginInstance)) {
+            sb.append(DLM).append(_pluginInstance);
+        }
+        if (defined(_type)) {
+            sb.append(DLM).append(_type);
+        }
+        if (defined(_typeInstance)) {
+            sb.append(DLM).append(_typeInstance);
+        }
+        return sb.toString();        
+    }
+
+    public String toString() {
+        StringBuffer sb = new StringBuffer();
+        sb.append('[').append(new Date(_time)).append("] ");
+        sb.append(getSource());
+        return sb.toString();
+    }
+}
diff --git a/src/main/java/org/collectd/api/ValueList.java b/src/main/java/org/collectd/api/ValueList.java
new file mode 100644
index 0000000..7ae2d3d
--- /dev/null
+++ b/src/main/java/org/collectd/api/ValueList.java
@@ -0,0 +1,105 @@
+/*
+ * jcollectd
+ * Copyright (C) 2009 Hyperic, Inc.
+ * 
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; only version 2 of the License is applicable.
+ * 
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
+ */
+
+package org.collectd.protocol;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Java representation of collectd/src/plugin.h:value_list_t structure.
+ */
+public class ValueList extends PluginData {
+
+    List<Number> _values = new ArrayList<Number>();
+    List<DataSource> _ds = new ArrayList<DataSource>();
+
+    long _interval;
+
+    public ValueList() {
+        
+    }
+
+    public ValueList(PluginData pd) {
+        super(pd);
+    }
+
+    public ValueList(ValueList vl) {
+        this((PluginData)vl);
+        _interval = vl._interval;
+        _values.addAll(vl.getValues());
+        _ds.addAll(vl._ds);
+    }
+
+    public List<Number> getValues() {
+        return _values;
+    }
+
+    public void setValues(List<Number> values) {
+        _values = values;
+    }
+
+    public void addValue(Number value) {
+        _values.add(value);
+    }
+
+    public List<DataSource> getDataSource() {
+        if (_ds.size() > 0) {
+            return _ds;
+        }
+        else {
+            TypesDB db = TypesDB.getInstance();
+            return db.getType(_type);
+        }
+    }
+
+    public void setDataSource(List<DataSource> ds) {
+        _ds = ds;
+    }
+
+    public long getInterval() {
+        return _interval;
+    }
+
+    public void setInterval(long interval) {
+        _interval = interval;
+    }
+
+    public String toString() {
+        StringBuffer sb = new StringBuffer(super.toString());
+        sb.append("=[");
+        List<DataSource> ds = getDataSource();
+        int size = _values.size();
+        for (int i=0; i<size; i++) {
+            Number val = _values.get(i);
+            String name;
+            if (ds == null) {
+                name = "unknown" + i;
+            }
+            else {
+                name = ds.get(i).getName();
+            }
+            sb.append(name).append('=').append(val);
+            if (i < size-1) {
+                sb.append(',');
+            }
+        }
+        sb.append("]");
+        return sb.toString();
+    }
+}
diff --git a/src/main/java/org/collectd/protocol/DataSource.java b/src/main/java/org/collectd/protocol/DataSource.java
deleted file mode 100644
index c090cde..0000000
--- a/src/main/java/org/collectd/protocol/DataSource.java
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- * jcollectd
- * Copyright (C) 2009 Hyperic, Inc.
- * 
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; only version 2 of the License is applicable.
- * 
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * General Public License for more details.
- * 
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
- */
-
-package org.collectd.protocol;
-
-/**
- * Java representation of collectd/src/plugin.h:data_source_t structure. 
- */
-public class DataSource {
-    public static final int TYPE_COUNTER = 0;
-    public static final int TYPE_GAUGE   = 1;
-
-    static final String COUNTER = "COUNTER";
-    static final String GAUGE = "GAUGE";
-
-    static final String NAN = "U";
-    private static final String[] TYPES = { COUNTER, GAUGE };
-
-    String _name;
-    int _type;
-    double _min;
-    double _max;
-
-    public String getName() {
-        return _name;
-    }
-
-    public void setName(String name) {
-        _name = name;
-    }
-
-    public int getType() {
-        return _type;
-    }
-
-    public void setType(int type) {
-        _type = type;
-    }
-
-    public double getMin() {
-        return _min;
-    }
-
-    public void setMin(double min) {
-        _min = min;
-    }
-
-    public double getMax() {
-        return _max;
-    }
-
-    public void setMax(double max) {
-        _max = max;
-    }
-
-    static double toDouble(String val) {
-        if (val.equals(NAN)) {
-            return Double.NaN;
-        }
-        else {
-            return Double.parseDouble(val);
-        }
-    }
-
-    private String asString(double val) {
-        if (Double.isNaN(val)) {
-            return NAN;
-        }
-        else {
-            return String.valueOf(val);
-        }
-    }
-
-    public String toString() {
-        StringBuffer sb = new StringBuffer();
-        final char DLM = ':';
-        sb.append(_name).append(DLM);
-        sb.append(TYPES[_type]).append(DLM);
-        sb.append(asString(_min)).append(DLM);
-        sb.append(asString(_max));
-        return sb.toString();
-    }
-}
diff --git a/src/main/java/org/collectd/protocol/Notification.java b/src/main/java/org/collectd/protocol/Notification.java
deleted file mode 100644
index 6029aef..0000000
--- a/src/main/java/org/collectd/protocol/Notification.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * jcollectd
- * Copyright (C) 2009 Hyperic, Inc.
- * 
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; only version 2 of the License is applicable.
- * 
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * General Public License for more details.
- * 
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
- */
-
-package org.collectd.protocol;
-
-/**
- * Java representation of collectd/src/plugin.h:notfication_t structure.
- */
-public class Notification extends PluginData {
-    public static final int FAILURE = 1;
-    public static final int WARNING = 2;
-    public static final int OKAY    = 4;
-
-    public static String[] SEVERITY = {
-        "FAILURE",
-        "WARNING",
-        "OKAY",
-        "UNKNOWN"
-    };
-
-    int _severity;
-    String _message;
-
-    Notification(PluginData pd) {
-        super(pd);
-    }
-
-    public int getSeverity() {
-        return _severity;
-    }
-
-    public String getSeverityString() {
-        switch (_severity) {
-            case FAILURE:
-                return SEVERITY[0];
-            case WARNING:
-                return SEVERITY[1];
-            case OKAY:
-                return SEVERITY[2];
-            default:
-                return SEVERITY[3];
-        }
-    }
-
-    public String getMessage() {
-        return _message;
-    }
-
-    public String toString() {
-        StringBuffer sb = new StringBuffer(super.toString());
-        sb.append(" [").append(getSeverityString()).append("] ");
-        sb.append(_message);
-        return sb.toString();
-    }
-}
diff --git a/src/main/java/org/collectd/protocol/PluginData.java b/src/main/java/org/collectd/protocol/PluginData.java
deleted file mode 100644
index 734a999..0000000
--- a/src/main/java/org/collectd/protocol/PluginData.java
+++ /dev/null
@@ -1,127 +0,0 @@
-/*
- * jcollectd
- * Copyright (C) 2009 Hyperic, Inc.
- * 
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; only version 2 of the License is applicable.
- * 
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * General Public License for more details.
- * 
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
- */
-
-package org.collectd.protocol;
-
-import java.util.Date;
-
-/**
- * Shared members of value_list_t and notification_t structures.
- */
-public class PluginData {
-
-    protected long _time;
-    protected String _host;
-    protected String _plugin;
-    protected String _pluginInstance = "";
-    protected String _type = "";
-    protected String _typeInstance = "";
-
-    public PluginData() {
-        
-    }
-
-    public PluginData(PluginData pd) {
-        _time = pd._time;
-        _host = pd._host;
-        _plugin = pd._plugin;
-        _pluginInstance = pd._pluginInstance;
-        _type = pd._type;
-        _typeInstance = pd._typeInstance;
-    }
-
-    public long getTime() {
-        return _time;
-    }
-
-    public void setTime(long time) {
-        _time = time;
-    }
-
-    public String getHost() {
-        return _host;
-    }
-
-    public void setHost(String host) {
-        _host = host;
-    }
-
-    public String getPlugin() {
-        return _plugin;
-    }
-
-    public void setPlugin(String plugin) {
-        _plugin = plugin;
-    }
-
-    public String getPluginInstance() {
-        return _pluginInstance;
-    }
-
-    public void setPluginInstance(String pluginInstance) {
-        _pluginInstance = pluginInstance;
-    }
-
-    public String getType() {
-        return _type;
-    }
-
-    public void setType(String type) {
-        _type = type;
-    }
-
-    public String getTypeInstance() {
-        return _typeInstance;
-    }
-
-    public void setTypeInstance(String typeInstance) {
-        _typeInstance = typeInstance;
-    }
-
-    public boolean defined(String val) {
-        return (val != null) && (val.length() > 0);
-    }
-
-    public String getSource() {
-        final char DLM = '/';
-        StringBuffer sb = new StringBuffer();
-        if (defined(_host)) {
-            sb.append(_host);
-        }
-        if (defined(_plugin)) {
-            sb.append(DLM).append(_plugin);
-        }
-        if (defined(_pluginInstance)) {
-            sb.append(DLM).append(_pluginInstance);
-        }
-        if (defined(_type)) {
-            sb.append(DLM).append(_type);
-        }
-        if (defined(_typeInstance)) {
-            sb.append(DLM).append(_typeInstance);
-        }
-        return sb.toString();        
-    }
-
-    public String toString() {
-        StringBuffer sb = new StringBuffer();
-        sb.append('[').append(new Date(_time)).append("] ");
-        sb.append(getSource());
-        return sb.toString();
-    }
-}
diff --git a/src/main/java/org/collectd/protocol/ValueList.java b/src/main/java/org/collectd/protocol/ValueList.java
deleted file mode 100644
index 7ae2d3d..0000000
--- a/src/main/java/org/collectd/protocol/ValueList.java
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- * jcollectd
- * Copyright (C) 2009 Hyperic, Inc.
- * 
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; only version 2 of the License is applicable.
- * 
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * General Public License for more details.
- * 
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
- */
-
-package org.collectd.protocol;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * Java representation of collectd/src/plugin.h:value_list_t structure.
- */
-public class ValueList extends PluginData {
-
-    List<Number> _values = new ArrayList<Number>();
-    List<DataSource> _ds = new ArrayList<DataSource>();
-
-    long _interval;
-
-    public ValueList() {
-        
-    }
-
-    public ValueList(PluginData pd) {
-        super(pd);
-    }
-
-    public ValueList(ValueList vl) {
-        this((PluginData)vl);
-        _interval = vl._interval;
-        _values.addAll(vl.getValues());
-        _ds.addAll(vl._ds);
-    }
-
-    public List<Number> getValues() {
-        return _values;
-    }
-
-    public void setValues(List<Number> values) {
-        _values = values;
-    }
-
-    public void addValue(Number value) {
-        _values.add(value);
-    }
-
-    public List<DataSource> getDataSource() {
-        if (_ds.size() > 0) {
-            return _ds;
-        }
-        else {
-            TypesDB db = TypesDB.getInstance();
-            return db.getType(_type);
-        }
-    }
-
-    public void setDataSource(List<DataSource> ds) {
-        _ds = ds;
-    }
-
-    public long getInterval() {
-        return _interval;
-    }
-
-    public void setInterval(long interval) {
-        _interval = interval;
-    }
-
-    public String toString() {
-        StringBuffer sb = new StringBuffer(super.toString());
-        sb.append("=[");
-        List<DataSource> ds = getDataSource();
-        int size = _values.size();
-        for (int i=0; i<size; i++) {
-            Number val = _values.get(i);
-            String name;
-            if (ds == null) {
-                name = "unknown" + i;
-            }
-            else {
-                name = ds.get(i).getName();
-            }
-            sb.append(name).append('=').append(val);
-            if (i < size-1) {
-                sb.append(',');
-            }
-        }
-        sb.append("]");
-        return sb.toString();
-    }
-}
-- 
1.5.6.5




More information about the collectd mailing list