Example usage for javax.management.openmbean ArrayType getElementOpenType

List of usage examples for javax.management.openmbean ArrayType getElementOpenType

Introduction

In this page you can find the example usage for javax.management.openmbean ArrayType getElementOpenType.

Prototype

public OpenType<?> getElementOpenType() 

Source Link

Document

Returns the open type of element values contained in the arrays described by this ArrayType instance.

Usage

From source file:org.jolokia.converter.object.ArrayTypeConverter.java

/** {@inheritDoc} */
@Override/* w w w.  j a va  2  s .  co m*/
public Object convertToObject(ArrayType type, Object pFrom) {
    JSONAware value = toJSON(pFrom);
    // prepare each value in the array and then process the array of values
    if (!(value instanceof JSONArray)) {
        throw new IllegalArgumentException("Can not convert " + value + " to type " + type
                + " because JSON object type " + value.getClass() + " is not a JSONArray");

    }

    JSONArray jsonArray = (JSONArray) value;
    OpenType elementOpenType = type.getElementOpenType();
    Object[] valueArray = createTargetArray(elementOpenType, jsonArray.size());

    int i = 0;
    for (Object element : jsonArray) {
        valueArray[i++] = getDispatcher().convertToObject(elementOpenType, element);
    }

    return valueArray;
}