本文整理匯總了Java中javax.management.openmbean.CompositeData.toString方法的典型用法代碼示例。如果您正苦於以下問題:Java CompositeData.toString方法的具體用法?Java CompositeData.toString怎麽用?Java CompositeData.toString使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.management.openmbean.CompositeData
的用法示例。
在下文中一共展示了CompositeData.toString方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: main
import javax.management.openmbean.CompositeData; //導入方法依賴的package包/類
public static void main(String[] args) throws Exception {
CompositeType basicCT = new CompositeType(
"basicCT", "basic CompositeType",
new String[] {"name", "value"},
new String[] {"name", "value"},
new OpenType<?>[] {SimpleType.STRING, SimpleType.INTEGER});
CompositeType ct = new CompositeType(
"noddy", "descr",
new String[] {"strings", "ints", "cds"},
new String[] {"string array", "int array", "composite data array"},
new OpenType<?>[] {
ArrayType.getArrayType(SimpleType.STRING),
ArrayType.getPrimitiveArrayType(int[].class),
ArrayType.getArrayType(basicCT)
});
CompositeData basicCD1 = new CompositeDataSupport(
basicCT, new String[] {"name", "value"}, new Object[] {"ceathar", 4});
CompositeData basicCD2 = new CompositeDataSupport(
basicCT, new String[] {"name", "value"}, new Object[] {"naoi", 9});
CompositeData cd = new CompositeDataSupport(
ct,
new String[] {"strings", "ints", "cds"},
new Object[] {
new String[] {"fred", "jim", "sheila"},
new int[] {2, 3, 5, 7},
new CompositeData[] {basicCD1, basicCD2}
});
String s = cd.toString();
System.out.println("CompositeDataSupport.toString(): " + s);
String[] expected = {
"fred, jim, sheila",
"2, 3, 5, 7",
"ceathar",
"naoi",
};
boolean ok = true;
for (String expect : expected) {
if (s.contains(expect))
System.out.println("OK: string contains <" + expect + ">");
else {
ok = false;
System.out.println("NOT OK: string does not contain <" +
expect + ">");
}
}
if (ok)
System.out.println("TEST PASSED");
else
throw new Exception("TEST FAILED: string did not contain expected substrings");
}