javax.management.openmbean.CompositeData#getCompositeType ( )源码实例Demo

下面列出了javax.management.openmbean.CompositeData#getCompositeType ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

/** Validate if the input CompositeData has the expected
 * CompositeType (i.e. contain all attributes with expected
 * names and types).
 */
public static void validateCompositeData(CompositeData cd) {
    if (cd == null) {
        throw new NullPointerException("Null CompositeData");
    }

    CompositeType ct = cd.getCompositeType();
    if (!isTypeMatched(stackTraceElementCompositeType, ct)) {
        if (!isTypeMatched(stackTraceElementV6CompositeType, ct)) {
            throw new IllegalArgumentException(
                "Unexpected composite type for StackTraceElement");
        }
    }
}
 
源代码2 项目: openjdk-jdk9   文件: VMOptionOpenDataTest.java
private static void validateType(CompositeData data) {
    CompositeType type = data.getCompositeType();
    Set<String> keys = Arrays.stream(names).collect(Collectors.toSet());
    if (!type.keySet().equals(keys)) {
        throw new RuntimeException("key not matched: " + type.keySet().toString());
    }
    for (int i=0; i < names.length; i++) {
        OpenType t = type.getType(names[i]);
        if (t != types[i]) {
            throw new AssertionError(names[i] + ": type not matched: " +
                t + " expected: " + types[i]);
        }
    }
}
 
源代码3 项目: hadoop   文件: JMXJsonServlet.java
private void writeObject(JsonGenerator jg, Object value) throws IOException {
  if(value == null) {
    jg.writeNull();
  } else {
    Class<?> c = value.getClass();
    if (c.isArray()) {
      jg.writeStartArray();
      int len = Array.getLength(value);
      for (int j = 0; j < len; j++) {
        Object item = Array.get(value, j);
        writeObject(jg, item);
      }
      jg.writeEndArray();
    } else if(value instanceof Number) {
      Number n = (Number)value;
      jg.writeNumber(n.toString());
    } else if(value instanceof Boolean) {
      Boolean b = (Boolean)value;
      jg.writeBoolean(b);
    } else if(value instanceof CompositeData) {
      CompositeData cds = (CompositeData)value;
      CompositeType comp = cds.getCompositeType();
      Set<String> keys = comp.keySet();
      jg.writeStartObject();
      for(String key: keys) {
        writeAttribute(jg, key, cds.get(key));
      }
      jg.writeEndObject();
    } else if(value instanceof TabularData) {
      TabularData tds = (TabularData)value;
      jg.writeStartArray();
      for(Object entry : tds.values()) {
        writeObject(jg, entry);
      }
      jg.writeEndArray();
    } else {
      jg.writeString(value.toString());
    }
  }
}
 
源代码4 项目: big-c   文件: JMXJsonServlet.java
private void writeObject(JsonGenerator jg, Object value) throws IOException {
  if(value == null) {
    jg.writeNull();
  } else {
    Class<?> c = value.getClass();
    if (c.isArray()) {
      jg.writeStartArray();
      int len = Array.getLength(value);
      for (int j = 0; j < len; j++) {
        Object item = Array.get(value, j);
        writeObject(jg, item);
      }
      jg.writeEndArray();
    } else if(value instanceof Number) {
      Number n = (Number)value;
      jg.writeNumber(n.toString());
    } else if(value instanceof Boolean) {
      Boolean b = (Boolean)value;
      jg.writeBoolean(b);
    } else if(value instanceof CompositeData) {
      CompositeData cds = (CompositeData)value;
      CompositeType comp = cds.getCompositeType();
      Set<String> keys = comp.keySet();
      jg.writeStartObject();
      for(String key: keys) {
        writeAttribute(jg, key, cds.get(key));
      }
      jg.writeEndObject();
    } else if(value instanceof TabularData) {
      TabularData tds = (TabularData)value;
      jg.writeStartArray();
      for(Object entry : tds.values()) {
        writeObject(jg, entry);
      }
      jg.writeEndArray();
    } else {
      jg.writeString(value.toString());
    }
  }
}
 
源代码5 项目: cuba   文件: AttributeHelper.java
private static String compositeToString(CompositeData compositeData) {
    if (canConvertToTrueObject(compositeData)) {
        try {
            Object trueObject = convertToTrueObject(compositeData);
            return String.valueOf(trueObject);
        }
        catch (Exception e) {
            return e.getClass().getName() + " " + e.getMessage();
        }
    }

    CompositeType type = compositeData.getCompositeType();

    StringBuilder b = new StringBuilder();
    b.append("[");
    List<String> keys = new ArrayList<>(type.keySet());
    Collections.sort(keys); // alphabetically
    for (String key: keys) {
        b.append(key).append(": ");
        Object value = compositeData.get(key);
        b.append(convertToString(value));
        if (keys.indexOf(key) != keys.size() - 1) {
            b.append(", ");
        }
    }
    b.append("]\n");
    return b.toString();
}
 
源代码6 项目: cuba   文件: AttributeHelper.java
private static Object convertToTrueObject(CompositeData compositeData) {
    CompositeType type = compositeData.getCompositeType();
    try {
        Class<?> _class = Class.forName(type.getTypeName());
        Method method = _class.getMethod("from", CompositeData.class);
        if (Modifier.isStatic(method.getModifiers()) && method.getReturnType() == _class) {
            return method.invoke(null, compositeData);
        }
        return null;
    } catch (ClassNotFoundException | NoSuchMethodException | InvocationTargetException | IllegalAccessException e) {
        throw new RuntimeException(e);
    }
}
 
源代码7 项目: dragonwell8_jdk   文件: ThreadInfoCompositeData.java
/** Validate if the input CompositeData has the expected
 * CompositeType (i.e. contain all attributes with expected
 * names and types).
 */
public static void validateCompositeData(CompositeData cd) {
    if (cd == null) {
        throw new NullPointerException("Null CompositeData");
    }

    CompositeType type = cd.getCompositeType();
    boolean currentVersion = true;
    if (!isTypeMatched(threadInfoCompositeType, type)) {
        currentVersion = false;
        // check if cd is an older version
        if (!isTypeMatched(threadInfoV5CompositeType, type)) {
            throw new IllegalArgumentException(
                "Unexpected composite type for ThreadInfo");
        }
    }

    CompositeData[] stackTraceData =
        (CompositeData[]) cd.get(STACK_TRACE);
    if (stackTraceData == null) {
        throw new IllegalArgumentException(
            "StackTraceElement[] is missing");
    }
    if (stackTraceData.length > 0) {
        StackTraceElementCompositeData.validateCompositeData(stackTraceData[0]);
    }

    // validate v6 attributes
    if (currentVersion) {
        CompositeData li = (CompositeData) cd.get(LOCK_INFO);
        if (li != null) {
            if (!isTypeMatched(lockInfoCompositeType,
                               li.getCompositeType())) {
                throw new IllegalArgumentException(
                    "Unexpected composite type for \"" +
                    LOCK_INFO + "\" attribute.");
            }
        }

        CompositeData[] lms = (CompositeData[]) cd.get(LOCKED_MONITORS);
        if (lms == null) {
            throw new IllegalArgumentException("MonitorInfo[] is null");
        }
        if (lms.length > 0) {
            MonitorInfoCompositeData.validateCompositeData(lms[0]);
        }

        CompositeData[] lsyncs = (CompositeData[]) cd.get(LOCKED_SYNCS);
        if (lsyncs == null) {
            throw new IllegalArgumentException("LockInfo[] is null");
        }
        if (lsyncs.length > 0) {
            if (!isTypeMatched(lockInfoCompositeType,
                               lsyncs[0].getCompositeType())) {
                throw new IllegalArgumentException(
                    "Unexpected composite type for \"" +
                    LOCKED_SYNCS + "\" attribute.");
            }
        }

    }
}
 
源代码8 项目: TencentKona-8   文件: ThreadInfoCompositeData.java
/** Validate if the input CompositeData has the expected
 * CompositeType (i.e. contain all attributes with expected
 * names and types).
 */
public static void validateCompositeData(CompositeData cd) {
    if (cd == null) {
        throw new NullPointerException("Null CompositeData");
    }

    CompositeType type = cd.getCompositeType();
    boolean currentVersion = true;
    if (!isTypeMatched(threadInfoCompositeType, type)) {
        currentVersion = false;
        // check if cd is an older version
        if (!isTypeMatched(threadInfoV5CompositeType, type)) {
            throw new IllegalArgumentException(
                "Unexpected composite type for ThreadInfo");
        }
    }

    CompositeData[] stackTraceData =
        (CompositeData[]) cd.get(STACK_TRACE);
    if (stackTraceData == null) {
        throw new IllegalArgumentException(
            "StackTraceElement[] is missing");
    }
    if (stackTraceData.length > 0) {
        StackTraceElementCompositeData.validateCompositeData(stackTraceData[0]);
    }

    // validate v6 attributes
    if (currentVersion) {
        CompositeData li = (CompositeData) cd.get(LOCK_INFO);
        if (li != null) {
            if (!isTypeMatched(lockInfoCompositeType,
                               li.getCompositeType())) {
                throw new IllegalArgumentException(
                    "Unexpected composite type for \"" +
                    LOCK_INFO + "\" attribute.");
            }
        }

        CompositeData[] lms = (CompositeData[]) cd.get(LOCKED_MONITORS);
        if (lms == null) {
            throw new IllegalArgumentException("MonitorInfo[] is null");
        }
        if (lms.length > 0) {
            MonitorInfoCompositeData.validateCompositeData(lms[0]);
        }

        CompositeData[] lsyncs = (CompositeData[]) cd.get(LOCKED_SYNCS);
        if (lsyncs == null) {
            throw new IllegalArgumentException("LockInfo[] is null");
        }
        if (lsyncs.length > 0) {
            if (!isTypeMatched(lockInfoCompositeType,
                               lsyncs[0].getCompositeType())) {
                throw new IllegalArgumentException(
                    "Unexpected composite type for \"" +
                    LOCKED_SYNCS + "\" attribute.");
            }
        }

    }
}
 
源代码9 项目: jdk8u60   文件: ThreadInfoCompositeData.java
/** Validate if the input CompositeData has the expected
 * CompositeType (i.e. contain all attributes with expected
 * names and types).
 */
public static void validateCompositeData(CompositeData cd) {
    if (cd == null) {
        throw new NullPointerException("Null CompositeData");
    }

    CompositeType type = cd.getCompositeType();
    boolean currentVersion = true;
    if (!isTypeMatched(threadInfoCompositeType, type)) {
        currentVersion = false;
        // check if cd is an older version
        if (!isTypeMatched(threadInfoV5CompositeType, type)) {
            throw new IllegalArgumentException(
                "Unexpected composite type for ThreadInfo");
        }
    }

    CompositeData[] stackTraceData =
        (CompositeData[]) cd.get(STACK_TRACE);
    if (stackTraceData == null) {
        throw new IllegalArgumentException(
            "StackTraceElement[] is missing");
    }
    if (stackTraceData.length > 0) {
        StackTraceElementCompositeData.validateCompositeData(stackTraceData[0]);
    }

    // validate v6 attributes
    if (currentVersion) {
        CompositeData li = (CompositeData) cd.get(LOCK_INFO);
        if (li != null) {
            if (!isTypeMatched(lockInfoCompositeType,
                               li.getCompositeType())) {
                throw new IllegalArgumentException(
                    "Unexpected composite type for \"" +
                    LOCK_INFO + "\" attribute.");
            }
        }

        CompositeData[] lms = (CompositeData[]) cd.get(LOCKED_MONITORS);
        if (lms == null) {
            throw new IllegalArgumentException("MonitorInfo[] is null");
        }
        if (lms.length > 0) {
            MonitorInfoCompositeData.validateCompositeData(lms[0]);
        }

        CompositeData[] lsyncs = (CompositeData[]) cd.get(LOCKED_SYNCS);
        if (lsyncs == null) {
            throw new IllegalArgumentException("LockInfo[] is null");
        }
        if (lsyncs.length > 0) {
            if (!isTypeMatched(lockInfoCompositeType,
                               lsyncs[0].getCompositeType())) {
                throw new IllegalArgumentException(
                    "Unexpected composite type for \"" +
                    LOCKED_SYNCS + "\" attribute.");
            }
        }

    }
}
 
源代码10 项目: openjdk-jdk8u   文件: ThreadInfoCompositeData.java
/** Validate if the input CompositeData has the expected
 * CompositeType (i.e. contain all attributes with expected
 * names and types).
 */
public static void validateCompositeData(CompositeData cd) {
    if (cd == null) {
        throw new NullPointerException("Null CompositeData");
    }

    CompositeType type = cd.getCompositeType();
    boolean currentVersion = true;
    if (!isTypeMatched(threadInfoCompositeType, type)) {
        currentVersion = false;
        // check if cd is an older version
        if (!isTypeMatched(threadInfoV5CompositeType, type)) {
            throw new IllegalArgumentException(
                "Unexpected composite type for ThreadInfo");
        }
    }

    CompositeData[] stackTraceData =
        (CompositeData[]) cd.get(STACK_TRACE);
    if (stackTraceData == null) {
        throw new IllegalArgumentException(
            "StackTraceElement[] is missing");
    }
    if (stackTraceData.length > 0) {
        StackTraceElementCompositeData.validateCompositeData(stackTraceData[0]);
    }

    // validate v6 attributes
    if (currentVersion) {
        CompositeData li = (CompositeData) cd.get(LOCK_INFO);
        if (li != null) {
            if (!isTypeMatched(lockInfoCompositeType,
                               li.getCompositeType())) {
                throw new IllegalArgumentException(
                    "Unexpected composite type for \"" +
                    LOCK_INFO + "\" attribute.");
            }
        }

        CompositeData[] lms = (CompositeData[]) cd.get(LOCKED_MONITORS);
        if (lms == null) {
            throw new IllegalArgumentException("MonitorInfo[] is null");
        }
        if (lms.length > 0) {
            MonitorInfoCompositeData.validateCompositeData(lms[0]);
        }

        CompositeData[] lsyncs = (CompositeData[]) cd.get(LOCKED_SYNCS);
        if (lsyncs == null) {
            throw new IllegalArgumentException("LockInfo[] is null");
        }
        if (lsyncs.length > 0) {
            if (!isTypeMatched(lockInfoCompositeType,
                               lsyncs[0].getCompositeType())) {
                throw new IllegalArgumentException(
                    "Unexpected composite type for \"" +
                    LOCKED_SYNCS + "\" attribute.");
            }
        }

    }
}
 
源代码11 项目: hbase   文件: JSONBean.java
private static void writeObject(JsonWriter writer, Object value) throws IOException {
  if (value == null) {
    writer.nullValue();
  } else {
    Class<?> c = value.getClass();
    if (c.isArray()) {
      writer.beginArray();
      int len = Array.getLength(value);
      for (int j = 0; j < len; j++) {
        Object item = Array.get(value, j);
        writeObject(writer, item);
      }
      writer.endArray();
    } else if (value instanceof Number) {
      Number n = (Number) value;
      if (Double.isFinite(n.doubleValue())) {
        writer.value(n);
      } else {
        writer.value(n.toString());
      }
    } else if (value instanceof Boolean) {
      Boolean b = (Boolean) value;
      writer.value(b);
    } else if (value instanceof CompositeData) {
      CompositeData cds = (CompositeData) value;
      CompositeType comp = cds.getCompositeType();
      Set<String> keys = comp.keySet();
      writer.beginObject();
      for (String key : keys) {
        writeAttribute(writer, key, null, cds.get(key));
      }
      writer.endObject();
    } else if (value instanceof TabularData) {
      TabularData tds = (TabularData) value;
      writer.beginArray();
      for (Object entry : tds.values()) {
        writeObject(writer, entry);
      }
      writer.endArray();
    } else {
      writer.value(value.toString());
    }
  }
}
 
源代码12 项目: openjdk-jdk9   文件: ThreadInfoCompositeData.java
/** Validate if the input CompositeData has the expected
 * CompositeType (i.e. contain all attributes with expected
 * names and types).
 */
public static void validateCompositeData(CompositeData cd) {
    if (cd == null) {
        throw new NullPointerException("Null CompositeData");
    }

    CompositeType type = cd.getCompositeType();
    boolean currentVersion = true;
    if (!isTypeMatched(threadInfoCompositeType, type)) {
        currentVersion = false;
        // check if cd is an older version
        if (!isTypeMatched(threadInfoV5CompositeType, type) &&
            !isTypeMatched(threadInfoV6CompositeType, type)) {
            throw new IllegalArgumentException(
                "Unexpected composite type for ThreadInfo");
        }
    }

    CompositeData[] stackTraceData =
        (CompositeData[]) cd.get(STACK_TRACE);
    if (stackTraceData == null) {
        throw new IllegalArgumentException(
            "StackTraceElement[] is missing");
    }
    if (stackTraceData.length > 0) {
        StackTraceElementCompositeData.validateCompositeData(stackTraceData[0]);
    }

    // validate v6 attributes
    if (currentVersion) {
        CompositeData li = (CompositeData) cd.get(LOCK_INFO);
        if (li != null) {
            if (!isTypeMatched(lockInfoCompositeType,
                               li.getCompositeType())) {
                throw new IllegalArgumentException(
                    "Unexpected composite type for \"" +
                    LOCK_INFO + "\" attribute.");
            }
        }

        CompositeData[] lms = (CompositeData[]) cd.get(LOCKED_MONITORS);
        if (lms == null) {
            throw new IllegalArgumentException("MonitorInfo[] is null");
        }
        if (lms.length > 0) {
            MonitorInfoCompositeData.validateCompositeData(lms[0]);
        }

        CompositeData[] lsyncs = (CompositeData[]) cd.get(LOCKED_SYNCS);
        if (lsyncs == null) {
            throw new IllegalArgumentException("LockInfo[] is null");
        }
        if (lsyncs.length > 0) {
            if (!isTypeMatched(lockInfoCompositeType,
                               lsyncs[0].getCompositeType())) {
                throw new IllegalArgumentException(
                    "Unexpected composite type for \"" +
                    LOCKED_SYNCS + "\" attribute.");
            }
        }

    }
}
 
源代码13 项目: jdk8u-jdk   文件: ThreadInfoCompositeData.java
/** Validate if the input CompositeData has the expected
 * CompositeType (i.e. contain all attributes with expected
 * names and types).
 */
public static void validateCompositeData(CompositeData cd) {
    if (cd == null) {
        throw new NullPointerException("Null CompositeData");
    }

    CompositeType type = cd.getCompositeType();
    boolean currentVersion = true;
    if (!isTypeMatched(threadInfoCompositeType, type)) {
        currentVersion = false;
        // check if cd is an older version
        if (!isTypeMatched(threadInfoV5CompositeType, type)) {
            throw new IllegalArgumentException(
                "Unexpected composite type for ThreadInfo");
        }
    }

    CompositeData[] stackTraceData =
        (CompositeData[]) cd.get(STACK_TRACE);
    if (stackTraceData == null) {
        throw new IllegalArgumentException(
            "StackTraceElement[] is missing");
    }
    if (stackTraceData.length > 0) {
        StackTraceElementCompositeData.validateCompositeData(stackTraceData[0]);
    }

    // validate v6 attributes
    if (currentVersion) {
        CompositeData li = (CompositeData) cd.get(LOCK_INFO);
        if (li != null) {
            if (!isTypeMatched(lockInfoCompositeType,
                               li.getCompositeType())) {
                throw new IllegalArgumentException(
                    "Unexpected composite type for \"" +
                    LOCK_INFO + "\" attribute.");
            }
        }

        CompositeData[] lms = (CompositeData[]) cd.get(LOCKED_MONITORS);
        if (lms == null) {
            throw new IllegalArgumentException("MonitorInfo[] is null");
        }
        if (lms.length > 0) {
            MonitorInfoCompositeData.validateCompositeData(lms[0]);
        }

        CompositeData[] lsyncs = (CompositeData[]) cd.get(LOCKED_SYNCS);
        if (lsyncs == null) {
            throw new IllegalArgumentException("LockInfo[] is null");
        }
        if (lsyncs.length > 0) {
            if (!isTypeMatched(lockInfoCompositeType,
                               lsyncs[0].getCompositeType())) {
                throw new IllegalArgumentException(
                    "Unexpected composite type for \"" +
                    LOCKED_SYNCS + "\" attribute.");
            }
        }

    }
}
 
源代码14 项目: hottub   文件: ThreadInfoCompositeData.java
/** Validate if the input CompositeData has the expected
 * CompositeType (i.e. contain all attributes with expected
 * names and types).
 */
public static void validateCompositeData(CompositeData cd) {
    if (cd == null) {
        throw new NullPointerException("Null CompositeData");
    }

    CompositeType type = cd.getCompositeType();
    boolean currentVersion = true;
    if (!isTypeMatched(threadInfoCompositeType, type)) {
        currentVersion = false;
        // check if cd is an older version
        if (!isTypeMatched(threadInfoV5CompositeType, type)) {
            throw new IllegalArgumentException(
                "Unexpected composite type for ThreadInfo");
        }
    }

    CompositeData[] stackTraceData =
        (CompositeData[]) cd.get(STACK_TRACE);
    if (stackTraceData == null) {
        throw new IllegalArgumentException(
            "StackTraceElement[] is missing");
    }
    if (stackTraceData.length > 0) {
        StackTraceElementCompositeData.validateCompositeData(stackTraceData[0]);
    }

    // validate v6 attributes
    if (currentVersion) {
        CompositeData li = (CompositeData) cd.get(LOCK_INFO);
        if (li != null) {
            if (!isTypeMatched(lockInfoCompositeType,
                               li.getCompositeType())) {
                throw new IllegalArgumentException(
                    "Unexpected composite type for \"" +
                    LOCK_INFO + "\" attribute.");
            }
        }

        CompositeData[] lms = (CompositeData[]) cd.get(LOCKED_MONITORS);
        if (lms == null) {
            throw new IllegalArgumentException("MonitorInfo[] is null");
        }
        if (lms.length > 0) {
            MonitorInfoCompositeData.validateCompositeData(lms[0]);
        }

        CompositeData[] lsyncs = (CompositeData[]) cd.get(LOCKED_SYNCS);
        if (lsyncs == null) {
            throw new IllegalArgumentException("LockInfo[] is null");
        }
        if (lsyncs.length > 0) {
            if (!isTypeMatched(lockInfoCompositeType,
                               lsyncs[0].getCompositeType())) {
                throw new IllegalArgumentException(
                    "Unexpected composite type for \"" +
                    LOCKED_SYNCS + "\" attribute.");
            }
        }

    }
}
 
源代码15 项目: openjdk-8-source   文件: ThreadInfoCompositeData.java
/** Validate if the input CompositeData has the expected
 * CompositeType (i.e. contain all attributes with expected
 * names and types).
 */
public static void validateCompositeData(CompositeData cd) {
    if (cd == null) {
        throw new NullPointerException("Null CompositeData");
    }

    CompositeType type = cd.getCompositeType();
    boolean currentVersion = true;
    if (!isTypeMatched(threadInfoCompositeType, type)) {
        currentVersion = false;
        // check if cd is an older version
        if (!isTypeMatched(threadInfoV5CompositeType, type)) {
            throw new IllegalArgumentException(
                "Unexpected composite type for ThreadInfo");
        }
    }

    CompositeData[] stackTraceData =
        (CompositeData[]) cd.get(STACK_TRACE);
    if (stackTraceData == null) {
        throw new IllegalArgumentException(
            "StackTraceElement[] is missing");
    }
    if (stackTraceData.length > 0) {
        StackTraceElementCompositeData.validateCompositeData(stackTraceData[0]);
    }

    // validate v6 attributes
    if (currentVersion) {
        CompositeData li = (CompositeData) cd.get(LOCK_INFO);
        if (li != null) {
            if (!isTypeMatched(lockInfoCompositeType,
                               li.getCompositeType())) {
                throw new IllegalArgumentException(
                    "Unexpected composite type for \"" +
                    LOCK_INFO + "\" attribute.");
            }
        }

        CompositeData[] lms = (CompositeData[]) cd.get(LOCKED_MONITORS);
        if (lms == null) {
            throw new IllegalArgumentException("MonitorInfo[] is null");
        }
        if (lms.length > 0) {
            MonitorInfoCompositeData.validateCompositeData(lms[0]);
        }

        CompositeData[] lsyncs = (CompositeData[]) cd.get(LOCKED_SYNCS);
        if (lsyncs == null) {
            throw new IllegalArgumentException("LockInfo[] is null");
        }
        if (lsyncs.length > 0) {
            if (!isTypeMatched(lockInfoCompositeType,
                               lsyncs[0].getCompositeType())) {
                throw new IllegalArgumentException(
                    "Unexpected composite type for \"" +
                    LOCKED_SYNCS + "\" attribute.");
            }
        }

    }
}
 
源代码16 项目: openjdk-8   文件: ThreadInfoCompositeData.java
/** Validate if the input CompositeData has the expected
 * CompositeType (i.e. contain all attributes with expected
 * names and types).
 */
public static void validateCompositeData(CompositeData cd) {
    if (cd == null) {
        throw new NullPointerException("Null CompositeData");
    }

    CompositeType type = cd.getCompositeType();
    boolean currentVersion = true;
    if (!isTypeMatched(threadInfoCompositeType, type)) {
        currentVersion = false;
        // check if cd is an older version
        if (!isTypeMatched(threadInfoV5CompositeType, type)) {
            throw new IllegalArgumentException(
                "Unexpected composite type for ThreadInfo");
        }
    }

    CompositeData[] stackTraceData =
        (CompositeData[]) cd.get(STACK_TRACE);
    if (stackTraceData == null) {
        throw new IllegalArgumentException(
            "StackTraceElement[] is missing");
    }
    if (stackTraceData.length > 0) {
        StackTraceElementCompositeData.validateCompositeData(stackTraceData[0]);
    }

    // validate v6 attributes
    if (currentVersion) {
        CompositeData li = (CompositeData) cd.get(LOCK_INFO);
        if (li != null) {
            if (!isTypeMatched(lockInfoCompositeType,
                               li.getCompositeType())) {
                throw new IllegalArgumentException(
                    "Unexpected composite type for \"" +
                    LOCK_INFO + "\" attribute.");
            }
        }

        CompositeData[] lms = (CompositeData[]) cd.get(LOCKED_MONITORS);
        if (lms == null) {
            throw new IllegalArgumentException("MonitorInfo[] is null");
        }
        if (lms.length > 0) {
            MonitorInfoCompositeData.validateCompositeData(lms[0]);
        }

        CompositeData[] lsyncs = (CompositeData[]) cd.get(LOCKED_SYNCS);
        if (lsyncs == null) {
            throw new IllegalArgumentException("LockInfo[] is null");
        }
        if (lsyncs.length > 0) {
            if (!isTypeMatched(lockInfoCompositeType,
                               lsyncs[0].getCompositeType())) {
                throw new IllegalArgumentException(
                    "Unexpected composite type for \"" +
                    LOCKED_SYNCS + "\" attribute.");
            }
        }

    }
}
 
源代码17 项目: jdk8u_jdk   文件: ThreadInfoCompositeData.java
/** Validate if the input CompositeData has the expected
 * CompositeType (i.e. contain all attributes with expected
 * names and types).
 */
public static void validateCompositeData(CompositeData cd) {
    if (cd == null) {
        throw new NullPointerException("Null CompositeData");
    }

    CompositeType type = cd.getCompositeType();
    boolean currentVersion = true;
    if (!isTypeMatched(threadInfoCompositeType, type)) {
        currentVersion = false;
        // check if cd is an older version
        if (!isTypeMatched(threadInfoV5CompositeType, type)) {
            throw new IllegalArgumentException(
                "Unexpected composite type for ThreadInfo");
        }
    }

    CompositeData[] stackTraceData =
        (CompositeData[]) cd.get(STACK_TRACE);
    if (stackTraceData == null) {
        throw new IllegalArgumentException(
            "StackTraceElement[] is missing");
    }
    if (stackTraceData.length > 0) {
        StackTraceElementCompositeData.validateCompositeData(stackTraceData[0]);
    }

    // validate v6 attributes
    if (currentVersion) {
        CompositeData li = (CompositeData) cd.get(LOCK_INFO);
        if (li != null) {
            if (!isTypeMatched(lockInfoCompositeType,
                               li.getCompositeType())) {
                throw new IllegalArgumentException(
                    "Unexpected composite type for \"" +
                    LOCK_INFO + "\" attribute.");
            }
        }

        CompositeData[] lms = (CompositeData[]) cd.get(LOCKED_MONITORS);
        if (lms == null) {
            throw new IllegalArgumentException("MonitorInfo[] is null");
        }
        if (lms.length > 0) {
            MonitorInfoCompositeData.validateCompositeData(lms[0]);
        }

        CompositeData[] lsyncs = (CompositeData[]) cd.get(LOCKED_SYNCS);
        if (lsyncs == null) {
            throw new IllegalArgumentException("LockInfo[] is null");
        }
        if (lsyncs.length > 0) {
            if (!isTypeMatched(lockInfoCompositeType,
                               lsyncs[0].getCompositeType())) {
                throw new IllegalArgumentException(
                    "Unexpected composite type for \"" +
                    LOCKED_SYNCS + "\" attribute.");
            }
        }

    }
}
 
源代码18 项目: datacollector   文件: SdcInfoContentGenerator.java
private void writeObject(JsonGenerator jg, Object value) throws IOException {
  if(value == null) {
    jg.writeNull();
  } else {
    Class<?> c = value.getClass();
    if (c.isArray()) {
      jg.writeStartArray();
      int len = Array.getLength(value);
      for (int j = 0; j < len; j++) {
        Object item = Array.get(value, j);
        writeObject(jg, item);
      }
      jg.writeEndArray();
    } else if(value instanceof Number) {
      Number n = (Number)value;
      if (value instanceof Double && (((Double) value).isInfinite() || ((Double) value).isNaN())) {
        jg.writeString(n.toString());
      } else {
        jg.writeNumber(n.toString());
      }
    } else if(value instanceof Boolean) {
      Boolean b = (Boolean)value;
      jg.writeBoolean(b);
    } else if(value instanceof CompositeData) {
      CompositeData cds = (CompositeData)value;
      CompositeType comp = cds.getCompositeType();
      Set<String> keys = comp.keySet();
      jg.writeStartObject();
      for(String key: keys) {
        writeAttribute(jg, key, cds.get(key));
      }
      jg.writeEndObject();
    } else if(value instanceof TabularData) {
      TabularData tds = (TabularData)value;
      jg.writeStartArray();
      for(Object entry : tds.values()) {
        writeObject(jg, entry);
      }
      jg.writeEndArray();
    } else if (value instanceof GaugeValue) {
      ((GaugeValue)value).serialize(jg);
    } else {
      jg.writeString(value.toString());
    }
  }
}
 
源代码19 项目: jdk8u-jdk   文件: ThreadInfoCompositeData.java
/** Validate if the input CompositeData has the expected
 * CompositeType (i.e. contain all attributes with expected
 * names and types).
 */
public static void validateCompositeData(CompositeData cd) {
    if (cd == null) {
        throw new NullPointerException("Null CompositeData");
    }

    CompositeType type = cd.getCompositeType();
    boolean currentVersion = true;
    if (!isTypeMatched(threadInfoCompositeType, type)) {
        currentVersion = false;
        // check if cd is an older version
        if (!isTypeMatched(threadInfoV5CompositeType, type)) {
            throw new IllegalArgumentException(
                "Unexpected composite type for ThreadInfo");
        }
    }

    CompositeData[] stackTraceData =
        (CompositeData[]) cd.get(STACK_TRACE);
    if (stackTraceData == null) {
        throw new IllegalArgumentException(
            "StackTraceElement[] is missing");
    }
    if (stackTraceData.length > 0) {
        StackTraceElementCompositeData.validateCompositeData(stackTraceData[0]);
    }

    // validate v6 attributes
    if (currentVersion) {
        CompositeData li = (CompositeData) cd.get(LOCK_INFO);
        if (li != null) {
            if (!isTypeMatched(lockInfoCompositeType,
                               li.getCompositeType())) {
                throw new IllegalArgumentException(
                    "Unexpected composite type for \"" +
                    LOCK_INFO + "\" attribute.");
            }
        }

        CompositeData[] lms = (CompositeData[]) cd.get(LOCKED_MONITORS);
        if (lms == null) {
            throw new IllegalArgumentException("MonitorInfo[] is null");
        }
        if (lms.length > 0) {
            MonitorInfoCompositeData.validateCompositeData(lms[0]);
        }

        CompositeData[] lsyncs = (CompositeData[]) cd.get(LOCKED_SYNCS);
        if (lsyncs == null) {
            throw new IllegalArgumentException("LockInfo[] is null");
        }
        if (lsyncs.length > 0) {
            if (!isTypeMatched(lockInfoCompositeType,
                               lsyncs[0].getCompositeType())) {
                throw new IllegalArgumentException(
                    "Unexpected composite type for \"" +
                    LOCKED_SYNCS + "\" attribute.");
            }
        }

    }
}
 
源代码20 项目: jdk8u-dev-jdk   文件: ThreadInfoCompositeData.java
/** Validate if the input CompositeData has the expected
 * CompositeType (i.e. contain all attributes with expected
 * names and types).
 */
public static void validateCompositeData(CompositeData cd) {
    if (cd == null) {
        throw new NullPointerException("Null CompositeData");
    }

    CompositeType type = cd.getCompositeType();
    boolean currentVersion = true;
    if (!isTypeMatched(threadInfoCompositeType, type)) {
        currentVersion = false;
        // check if cd is an older version
        if (!isTypeMatched(threadInfoV5CompositeType, type)) {
            throw new IllegalArgumentException(
                "Unexpected composite type for ThreadInfo");
        }
    }

    CompositeData[] stackTraceData =
        (CompositeData[]) cd.get(STACK_TRACE);
    if (stackTraceData == null) {
        throw new IllegalArgumentException(
            "StackTraceElement[] is missing");
    }
    if (stackTraceData.length > 0) {
        StackTraceElementCompositeData.validateCompositeData(stackTraceData[0]);
    }

    // validate v6 attributes
    if (currentVersion) {
        CompositeData li = (CompositeData) cd.get(LOCK_INFO);
        if (li != null) {
            if (!isTypeMatched(lockInfoCompositeType,
                               li.getCompositeType())) {
                throw new IllegalArgumentException(
                    "Unexpected composite type for \"" +
                    LOCK_INFO + "\" attribute.");
            }
        }

        CompositeData[] lms = (CompositeData[]) cd.get(LOCKED_MONITORS);
        if (lms == null) {
            throw new IllegalArgumentException("MonitorInfo[] is null");
        }
        if (lms.length > 0) {
            MonitorInfoCompositeData.validateCompositeData(lms[0]);
        }

        CompositeData[] lsyncs = (CompositeData[]) cd.get(LOCKED_SYNCS);
        if (lsyncs == null) {
            throw new IllegalArgumentException("LockInfo[] is null");
        }
        if (lsyncs.length > 0) {
            if (!isTypeMatched(lockInfoCompositeType,
                               lsyncs[0].getCompositeType())) {
                throw new IllegalArgumentException(
                    "Unexpected composite type for \"" +
                    LOCKED_SYNCS + "\" attribute.");
            }
        }

    }
}