Example usage for javax.management.openmbean SimpleType SHORT

List of usage examples for javax.management.openmbean SimpleType SHORT

Introduction

In this page you can find the example usage for javax.management.openmbean SimpleType SHORT.

Prototype

SimpleType SHORT

To view the source code for javax.management.openmbean SimpleType SHORT.

Click Source Link

Document

The SimpleType instance describing values whose Java class name is java.lang.Short.

Usage

From source file:org.eclipse.gyrex.monitoring.internal.mbeans.MetricSetMBean.java

private OpenType detectType(final Class type) {
    if ((Long.class == type) || (Long.TYPE == type)) {
        return SimpleType.LONG;
    } else if ((Integer.class == type) || (Integer.TYPE == type)) {
        return SimpleType.INTEGER;
    } else if ((Double.class == type) || (Double.TYPE == type)) {
        return SimpleType.DOUBLE;
    } else if ((Float.class == type) || (Float.TYPE == type)) {
        return SimpleType.FLOAT;
    } else if ((Byte.class == type) || (Byte.TYPE == type)) {
        return SimpleType.BYTE;
    } else if ((Short.class == type) || (Short.TYPE == type)) {
        return SimpleType.SHORT;
    } else if ((Boolean.class == type) || (Boolean.TYPE == type)) {
        return SimpleType.BOOLEAN;
    } else if (BigDecimal.class == type) {
        return SimpleType.BIGDECIMAL;
    } else if (BigInteger.class == type) {
        return SimpleType.BIGINTEGER;
    } else if ((Character.class == type) || (Character.TYPE == type)) {
        return SimpleType.CHARACTER;
    }//from   ww w.j  av a  2  s . c o m

    // last fallback to strings
    if (isConvertibleToString(type)) {
        return SimpleType.STRING;
    }

    // give up
    return null;
}

From source file:org.jolokia.converter.json.TabularDataExtractor.java

private Object getKey(CompositeType rowType, String key, String value) {
    OpenType keyType = rowType.getType(key);
    if (SimpleType.STRING == keyType) {
        return value;
    } else if (SimpleType.INTEGER == keyType) {
        return Integer.parseInt(value);
    } else if (SimpleType.LONG == keyType) {
        return Long.parseLong(value);
    } else if (SimpleType.SHORT == keyType) {
        return Short.parseShort(value);
    } else if (SimpleType.BYTE == keyType) {
        return Byte.parseByte(value);
    } else if (SimpleType.OBJECTNAME == keyType) {
        try {/* w w w  . ja  v  a  2  s  . c  o m*/
            return new ObjectName(value);
        } catch (MalformedObjectNameException e) {
            throw new IllegalArgumentException("Can not convert " + value + " to an ObjectName", e);
        }
    } else {
        throw new IllegalArgumentException(
                "All keys must be a string, integer, long, short, byte or ObjectName type for accessing TabularData via a path. "
                        + "This is not the case for '" + key + "' which is of type " + keyType);
    }
}