summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 1a73830)
raw | patch | inline | side by side (parent: 1a73830)
author | Florian Forster <sifnfors@informatik.stud.uni-erlangen.de> | |
Mon, 3 Aug 2009 09:56:26 +0000 (11:56 +0200) | ||
committer | Florian Forster <sifnfors@informatik.stud.uni-erlangen.de> | |
Mon, 3 Aug 2009 09:56:26 +0000 (11:56 +0200) |
bindings/java/org/collectd/java/GenericJMXConfValue.java | patch | blob | history |
diff --git a/bindings/java/org/collectd/java/GenericJMXConfValue.java b/bindings/java/org/collectd/java/GenericJMXConfValue.java
index b81ceb7dfc554ab1ed2739245514cdee18ac11ff..cdca02f3a2dbce17b91f63ec33888ac940d37dd5 100644 (file)
import java.util.Iterator;
import java.util.ArrayList;
+import java.math.BigDecimal;
+import java.math.BigInteger;
+
import javax.management.MBeanServerConnection;
import javax.management.ObjectName;
import javax.management.openmbean.OpenType;
private String _instance_prefix;
private boolean _is_table;
+ /**
+ * Converts a generic (OpenType) object to a number.
+ *
+ * Returns null if a conversion is not possible or not implemented.
+ */
private Number genericObjectToNumber (Object obj, int ds_type) /* {{{ */
{
if (obj instanceof String)
return (null);
}
}
+ else if (obj instanceof Byte)
+ {
+ return (new Byte ((Byte) obj));
+ }
+ else if (obj instanceof Short)
+ {
+ return (new Short ((Short) obj));
+ }
else if (obj instanceof Integer)
{
return (new Integer ((Integer) obj));
{
return (new Long ((Long) obj));
}
+ else if (obj instanceof Float)
+ {
+ return (new Float ((Float) obj));
+ }
else if (obj instanceof Double)
{
return (new Double ((Double) obj));
}
+ else if (obj instanceof BigDecimal)
+ {
+ return (BigDecimal.ZERO.add ((BigDecimal) obj));
+ }
+ else if (obj instanceof BigInteger)
+ {
+ return (BigInteger.ZERO.add ((BigInteger) obj));
+ }
return (null);
} /* }}} Number genericObjectToNumber */