本文整理匯總了Java中javax.management.openmbean.CompositeData.getCompositeType方法的典型用法代碼示例。如果您正苦於以下問題:Java CompositeData.getCompositeType方法的具體用法?Java CompositeData.getCompositeType怎麽用?Java CompositeData.getCompositeType使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.management.openmbean.CompositeData
的用法示例。
在下文中一共展示了CompositeData.getCompositeType方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: writeObject
import javax.management.openmbean.CompositeData; //導入方法依賴的package包/類
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());
}
}
}
示例2: validateCompositeData
import javax.management.openmbean.CompositeData; //導入方法依賴的package包/類
/** 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");
}
}
}
示例3: validateType
import javax.management.openmbean.CompositeData; //導入方法依賴的package包/類
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]);
}
}
}
示例4: validateCompositeData
import javax.management.openmbean.CompositeData; //導入方法依賴的package包/類
/** 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.");
}
}
}
}
示例5: validateCompositeData
import javax.management.openmbean.CompositeData; //導入方法依賴的package包/類
/** 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.");
}
}
}
}
示例6: writeObject
import javax.management.openmbean.CompositeData; //導入方法依賴的package包/類
private static void writeObject(final JsonGenerator jg, final boolean description, 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, description, 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, null, cds.get(key));
}
jg.writeEndObject();
} else if(value instanceof TabularData) {
TabularData tds = (TabularData)value;
jg.writeStartArray();
for(Object entry : tds.values()) {
writeObject(jg, description, entry);
}
jg.writeEndArray();
} else {
jg.writeString(value.toString());
}
}
}