📄 testdatatype.java
字号:
System.err.println ("cv = " + cv); System.err.println ("Setting an array of strings"); } cimInstance.setProperty ("PropertyArrayString", cv); // get STRING_ARRAY CIMProperty cp = null; cp = cimInstance.getProperty ("PropertyArrayString"); if (DEBUG) System.err.println ("cp = " + cp); cv = cp.getValue (); if (DEBUG) System.err.println ("cv = " + cv); Object o = cv.getValue (false); if (DEBUG) System.err.println ("o = " + o); String string[] = (String[])o; if (DEBUG) { System.err.print ("string = ["); for (int i = 0; i < string.length; i++) { System.err.print (string[i]); if (i < string.length - 1) System.err.print (","); } System.err.println ("]"); } return true; } catch (Exception e) { System.out.println ("Caught " + e); e.printStackTrace (); return false; } } private boolean runTestBOOLEAN_ARRAY (CIMClient cimClient, CIMInstance cimInstance, CIMObjectPath cop) { try { // set BOOLEAN_ARRAY CIMValue cv = null; Vector vectorBOOLEAN = new Vector (); vectorBOOLEAN.addElement (new Boolean (true)); vectorBOOLEAN.addElement (new Boolean (false)); vectorBOOLEAN.addElement (new Boolean (true)); cv = new CIMValue (vectorBOOLEAN, new CIMDataType (CIMDataType.BOOLEAN_ARRAY)); if (DEBUG) { System.err.println ("cv = " + cv); System.err.println ("Setting an array of booleans"); } cimInstance.setProperty ("PropertyArrayBoolean", cv); // get BOOLEAN_ARRAY CIMProperty cp = null; cp = cimInstance.getProperty ("PropertyArrayBoolean"); if (DEBUG) System.err.println ("cp = " + cp); cv = cp.getValue (); if (DEBUG) System.err.println ("cv = " + cv); Object o = cv.getValue (false); if (DEBUG) System.err.println ("o = " + o); Boolean b[] = (Boolean[])o; if (DEBUG) { System.err.print ("b = ["); for (int i = 0; i < b.length; i++) { System.err.print (b[i]); if (i < b.length - 1) System.err.print (","); } System.err.println ("]"); } return true; } catch (Exception e) { System.out.println ("Caught " + e); e.printStackTrace (); return false; } } private boolean runTestREAL32_ARRAY (CIMClient cimClient, CIMInstance cimInstance, CIMObjectPath cop) { try { // set REAL32_ARRAY CIMValue cv = null; Vector vectorREAL32 = new Vector (); vectorREAL32.addElement (new Float (1.23456789012345678e-01)); vectorREAL32.addElement (new Float (1.40129846432481707e-45)); vectorREAL32.addElement (new Float (3.40282346638528860e+38)); cv = new CIMValue (vectorREAL32, new CIMDataType (CIMDataType.REAL32_ARRAY)); if (DEBUG) { System.err.println ("cv = " + cv); System.err.println ("Setting an array of REAL32s"); } cimInstance.setProperty ("PropertyArrayREAL32", cv); // get REAL32_ARRAY CIMProperty cp = null; cp = cimInstance.getProperty ("PropertyArrayREAL32"); if (DEBUG) System.err.println ("cp = " + cp); cv = cp.getValue (); if (DEBUG) System.err.println ("cv = " + cv); Object o = cv.getValue (false); if (DEBUG) System.err.println ("o = " + o); Float f[] = (Float[])o; if (DEBUG) { System.err.print ("f = ["); for (int i = 0; i < f.length; i++) { System.err.print (f[i]); if (i < f.length - 1) System.err.print (","); } System.err.println ("]"); } return true; } catch (Exception e) { System.out.println ("Caught " + e); e.printStackTrace (); return false; } } private boolean runTestREAL64_ARRAY (CIMClient cimClient, CIMInstance cimInstance, CIMObjectPath cop) { try { // set REAL64_ARRAY CIMValue cv = null; Vector vectorREAL64 = new Vector (); vectorREAL64.addElement (new Double (9.876)); vectorREAL64.addElement (new Double (4.94065645841246544e-324d)); vectorREAL64.addElement (new Double (1.79769313486231570e+308d)); cv = new CIMValue (vectorREAL64, new CIMDataType (CIMDataType.REAL64_ARRAY)); if (DEBUG) { System.err.println ("cv = " + cv); System.err.println ("Setting an array of REAL64s"); } cimInstance.setProperty ("PropertyArrayREAL64", cv); // get REAL64_ARRAY CIMProperty cp = null; cp = cimInstance.getProperty ("PropertyArrayREAL64"); if (DEBUG) System.err.println ("cp = " + cp); cv = cp.getValue (); if (DEBUG) System.err.println ("cv = " + cv); Object o = cv.getValue (false); if (DEBUG) System.err.println ("o = " + o); Double d[] = (Double[])o; if (DEBUG) { System.err.print ("d = ["); for (int i = 0; i < d.length; i++) { System.err.print (d[i]); if (i < d.length - 1) System.err.print (","); } System.err.println ("]"); } return true; } catch (Exception e) { System.out.println ("Caught " + e); e.printStackTrace (); return false; } } private boolean runTestDATETIME_ARRAY (CIMClient cimClient, CIMInstance cimInstance, CIMObjectPath cop) { try { // set DATETIME_ARRAY CIMValue cv = null; Vector vectorDATETIME = new Vector (); vectorDATETIME.addElement (new CIMDateTime ("20051216161710.000000:000")); vectorDATETIME.addElement (new CIMDateTime ("20041115151609.100000:000")); vectorDATETIME.addElement (new CIMDateTime ("20031014141508.200000:000")); cv = new CIMValue (vectorDATETIME, new CIMDataType (CIMDataType.DATETIME_ARRAY)); if (DEBUG) { System.err.println ("cv = " + cv); System.err.println ("Setting an array of datetime"); } cimInstance.setProperty ("PropertyArrayDatetime", cv); // get DATETIME_ARRAY CIMProperty cp = null; cp = cimInstance.getProperty ("PropertyArrayDatetime"); if (DEBUG) System.err.println ("cp = " + cp); cv = cp.getValue (); if (DEBUG) System.err.println ("cv = " + cv); Object o = cv.getValue (false); if (DEBUG) System.err.println ("o = " + o); CIMDateTime cdt[] = (CIMDateTime[])o; if (DEBUG) { System.err.print ("cdt = ["); for (int i = 0; i < cdt.length; i++) { System.err.print (cdt[i]); if (i < cdt.length - 1) System.err.print (","); } System.err.println ("]"); } return true; } catch (Exception e) { System.out.println ("Caught " + e); e.printStackTrace (); return false; } } private boolean runTestCHAR16_ARRAY (CIMClient cimClient, CIMInstance cimInstance, CIMObjectPath cop) { try { // set CHAR16_ARRAY CIMValue cv = null; Vector vectorCHAR16 = new Vector (); vectorCHAR16.addElement (new Character ('B')); vectorCHAR16.addElement (new Character ('o')); vectorCHAR16.addElement (new Character ('b')); cv = new CIMValue (vectorCHAR16, new CIMDataType (CIMDataType.CHAR16_ARRAY)); if (DEBUG) { System.err.println ("cv = " + cv); System.err.println ("Setting an array of char16"); } cimInstance.setProperty ("PropertyArrayChar16", cv); // get CHAR16_ARRAY CIMProperty cp = null; cp = cimInstance.getProperty ("PropertyArrayChar16"); if (DEBUG) System.err.println ("cp = " + cp); cv = cp.getValue (); if (DEBUG) System.err.println ("cv = " + cv); Object o = cv.getValue (false); if (DEBUG) System.err.println ("o = " + o); Character c[] = (Character[])o; if (DEBUG) { System.err.print ("c = ["); for (int i = 0; i < c.length; i++) { System.err.print (c[i]); if (i < c.length - 1) System.err.print (","); } System.err.println ("]"); } return true; } catch (Exception e) { System.out.println ("Caught " + e); e.printStackTrace (); return false; } } private boolean runTestINSTANCE_ARRAY (CIMClient cimClient, CIMInstance cimInstance, CIMObjectPath cop) { try { // set INSTANCE_ARRAY CIMValue cv = null; Vector vectorINSTANCE = new Vector (); vectorINSTANCE.addElement (new CIMObject (cimInstance)); vectorINSTANCE.addElement (new CIMObject (cimInstance)); vectorINSTANCE.addElement (new CIMObject (cimInstance)); cv = new CIMValue (vectorINSTANCE, new CIMDataType (CIMDataType.OBJECT_ARRAY)); if (DEBUG) { System.err.println ("cv = " + cv); System.err.println ("Setting an array of objects"); } cimInstance.setProperty ("PropertyArrayObject", cv); // get INSTANCE_ARRAY CIMProperty cp = null; cp = cimInstance.getProperty ("PropertyArrayObject"); if (DEBUG) System.err.println ("cp = " + cp); cv = cp.getValue (); if (DEBUG) System.err.println ("cv = " + cv); Object o = cv.getValue (false); if (DEBUG) System.err.println ("o = " + o); CIMObject co[] = (CIMObject[])o; for (int i = 0; i < co.length; i++) { CIMInstance cimInstance2 = co[i].getCIMInstance (); if (cimInstance2 == null) return false; } if (DEBUG) { System.err.print ("co = ["); for (int i = 0; i < co.length; i++) { System.err.print (co[i]); if (i < co.length - 1) System.err.print (","); } System.err.println ("]"); } return true; } catch (Exception e) { System.out.println ("Caught " + e); e.printStackTrace (); return false; } } private boolean runTestCLASS_ARRAY (CIMClient cimClient, CIMInstance cimInstance, CIMObjectPath cop) { try { // set CLASS_ARRAY CIMValue cv = null; CIMClass cimClass = null; Vector vectorCLASS = new Vector (); cimClass = cimClient.getClass (cop, false); if (DEBUG) System.err.println ("cimClass = " + cimClass); vectorCLASS.addElement (new CIMObject (cimClass)); vectorCLASS.addElement (new CIMObject (cimClass)); vectorCLASS.addElement (new CIMObject (cimClass)); cv = new CIMValue (vectorCLASS, new CIMDataType (CIMDataType.OBJECT_ARRAY)); if (DEBUG)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -