📄 testdatatype.java
字号:
e.printStackTrace (); return false; } } private boolean runTestBOOLEAN (CIMClient cimClient, CIMInstance cimInstance, CIMObjectPath cop) { try { // set BOOLEAN CIMValue cv = null; cv = new CIMValue (new Boolean (false), new CIMDataType (CIMDataType.BOOLEAN)); if (DEBUG) { System.err.println ("cv = " + cv); System.err.println ("Setting a Boolean"); } cimInstance.setProperty ("PropertyBoolean", cv); if (DEBUG) System.err.println ("cimInstance = " + cimInstance); // get BOOLEAN CIMProperty cp = null; cp = cimInstance.getProperty ("PropertyBoolean"); 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.println ("b = " + b); return true; } catch (Exception e) { System.out.println ("Caught " + e); e.printStackTrace (); return false; } } private boolean runTestREAL32 (CIMClient cimClient, CIMInstance cimInstance, CIMObjectPath cop) { try { // set REAL32 CIMValue cv = null; cv = new CIMValue (new Float (3.14159), new CIMDataType (CIMDataType.REAL32)); if (DEBUG) { System.err.println ("cv = " + cv); System.err.println ("Setting a Real32"); } cimInstance.setProperty ("PropertyReal32", cv); if (DEBUG) System.err.println ("cimInstance = " + cimInstance); // get REAL32 CIMProperty cp = null; cp = cimInstance.getProperty ("PropertyReal32"); 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.println ("f = " + f); return true; } catch (Exception e) { System.out.println ("Caught " + e); e.printStackTrace (); return false; } } private boolean runTestREAL64 (CIMClient cimClient, CIMInstance cimInstance, CIMObjectPath cop) { try { // set REAL64 CIMValue cv = null; cv = new CIMValue (new Double (2.718281828), new CIMDataType (CIMDataType.REAL64)); if (DEBUG) { System.err.println ("cv = " + cv); System.err.println ("Setting a Real64"); } cimInstance.setProperty ("PropertyReal64", cv); if (DEBUG) System.err.println ("cimInstance = " + cimInstance); // get REAL64 CIMProperty cp = null; cp = cimInstance.getProperty ("PropertyReal64"); 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.println ("d = " + d); return true; } catch (Exception e) { System.out.println ("Caught " + e); e.printStackTrace (); return false; } } private boolean runTestDATETIME (CIMClient cimClient, CIMInstance cimInstance, CIMObjectPath cop) { try { // set DATETIME CIMValue cv = null; cv = new CIMValue (new CIMDateTime ("20051216161710.000000:000"), new CIMDataType (CIMDataType.DATETIME)); if (DEBUG) { System.err.println ("cv = " + cv); System.err.println ("Setting a DateTime"); } cimInstance.setProperty ("PropertyDateTime", cv); if (DEBUG) System.err.println ("cimInstance = " + cimInstance); // get DATETIME CIMProperty cp = null; cp = cimInstance.getProperty ("PropertyDateTime"); 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.println ("char = " + cdt); return true; } catch (Exception e) { System.out.println ("Caught " + e); e.printStackTrace (); return false; } } private boolean runTestCHAR16 (CIMClient cimClient, CIMInstance cimInstance, CIMObjectPath cop) { try { // set CHAR16 CIMValue cv = null; cv = new CIMValue (new Character ('!'), new CIMDataType (CIMDataType.CHAR16)); if (DEBUG) { System.err.println ("cv = " + cv); System.err.println ("Setting a Char16"); } cimInstance.setProperty ("PropertyChar16", cv); if (DEBUG) System.err.println ("cimInstance = " + cimInstance); // get CHAR16 CIMProperty cp = null; cp = cimInstance.getProperty ("PropertyChar16"); 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 ch = (Character)o; if (DEBUG) System.err.println ("char = " + ch); return true; } catch (Exception e) { System.out.println ("Caught " + e); e.printStackTrace (); return false; } } private boolean runTestINSTANCE (CIMClient cimClient, CIMInstance cimInstance, CIMObjectPath cop) { try { // set INSTANCE CIMValue cv = null; cv = new CIMValue (new CIMObject (cimInstance), new CIMDataType (CIMDataType.OBJECT)); if (DEBUG) { System.err.println ("cv = " + cv); System.err.println ("Setting an object"); } cimInstance.setProperty ("PropertyObject", cv); if (DEBUG) System.err.println ("cimInstance = " + cimInstance); // get INSTANCE CIMProperty cp = null; cp = cimInstance.getProperty ("PropertyObject"); 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 cimObject = (CIMObject)o; CIMInstance cimInstance2 = cimObject.getCIMInstance (); if (DEBUG) System.err.println ("cimInstance2 = " + cimInstance2); return true; } catch (Exception e) { System.out.println ("Caught " + e); e.printStackTrace (); return false; } } private boolean runTestCLASS (CIMClient cimClient, CIMInstance cimInstance, CIMObjectPath cop) { try { // set CLASS CIMValue cv = null; CIMClass cimClass = null; cimClass = cimClient.getClass (cop, false); if (DEBUG) System.err.println ("cimClass = " + cimClass); cv = new CIMValue (new CIMObject (cimClass), new CIMDataType (CIMDataType.OBJECT)); if (DEBUG) { System.err.println ("cv = " + cv); System.err.println ("Setting a class"); } cimInstance.setProperty ("PropertyObject", cv); if (DEBUG) System.err.println ("cimInstance = " + cimInstance); // get CLASS CIMProperty cp = null; cp = cimInstance.getProperty ("PropertyObject"); 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 cimObject = (CIMObject)o; CIMClass cimClass2 = cimObject.getCIMClass (); if (DEBUG) System.err.println ("cimClass2 = " + cimClass2); return true; } catch (Exception e) { System.out.println ("Caught " + e); e.printStackTrace (); return false; } } private boolean runTestUINT8_ARRAY (CIMClient cimClient, CIMInstance cimInstance, CIMObjectPath cop) { try { // set UINT8_ARRAY CIMValue cv = null; Vector vectorUINT8 = new Vector (); vectorUINT8.addElement (new UnsignedInt8 ((byte)64)); vectorUINT8.addElement (new UnsignedInt8 ((byte)127)); vectorUINT8.addElement (new UnsignedInt8 ((byte)10)); cv = new CIMValue (vectorUINT8, new CIMDataType (CIMDataType.UINT8_ARRAY)); if (DEBUG) { System.err.println ("cv = " + cv); System.err.println ("Setting an array of uint8s"); } cimInstance.setProperty ("PropertyArrayUint8", cv); // get UINT8_ARRAY CIMProperty cp = null; cp = cimInstance.getProperty ("PropertyArrayUint8"); 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); UnsignedInt8 ui8[] = (UnsignedInt8[])o; if (DEBUG) { System.err.print ("ui8 = ["); for (int i = 0; i < ui8.length; i++) { System.err.print (ui8[i]); if (i < ui8.length - 1) System.err.print (","); } System.err.println ("]"); } return true; } catch (Exception e) { System.out.println ("Caught " + e); e.printStackTrace (); return false; } } private boolean runTestSINT8_ARRAY (CIMClient cimClient, CIMInstance cimInstance, CIMObjectPath cop) { try { // set SINT8_ARRAY CIMValue cv = null; Vector vectorSINT8 = new Vector (); vectorSINT8.addElement (new Byte ((byte)0)); vectorSINT8.addElement (new Byte ((byte)-128)); vectorSINT8.addElement (new Byte ((byte)-77)); cv = new CIMValue (vectorSINT8, new CIMDataType (CIMDataType.SINT8_ARRAY)); if (DEBUG) { System.err.println ("cv = " + cv);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -