⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 commoninstanceprovider.java

📁 Pegasus is an open-source implementationof the DMTF CIM and WBEM standards. It is designed to be por
💻 JAVA
📖 第 1 页 / 共 4 页
字号:
       {           System.out.println (providerName + "::findCOPInPropertyTypesNew: comparing \"" + cop1 + "\"");       }       // Iterate through each ObjectPath in our ObjectPaths       for (int i = 0; i < pathsPropertyTypes.size (); i++)       {           CIMObjectPath cop2     = (CIMObjectPath)pathsPropertyTypes.elementAt (i);           Vector        keysCop1 = cop1.getKeys ();           HashMap       hashCop1 = new HashMap ();           if (DEBUG)           {               System.out.println (providerName + "::findCOPInPropertyTypesNew: to \"" + cop2 + "\"");           }           // Iterate though each property in the ObjectPath           for (int idxPath = 0; idxPath < keysCop1.size (); idxPath++)           {               CIMProperty cp          = (CIMProperty)keysCop1.elementAt (idxPath);               String      cpKeyValue  = cp.getValue ().toString ();               String      copKeyValue = cop2.getKeyValue (cp.getName ());               if (DEBUG)               {                   System.out.println (providerName + "::findCOPInPropertyTypesNew: cpKeyValue  \"" + cpKeyValue + "\"");                   System.out.println (providerName + "::findCOPInPropertyTypesNew: copKeyValue \"" + copKeyValue + "\"");               }               if (copKeyValue != null)               {                  // Compare the property values and save it for later                  hashCop1.put (cp.toString (), new Boolean (cpKeyValue.equals (copKeyValue)));               }           }           // Save the result of all of the property comparisons           hashPaths.put (cop2, hashCop1);       }       if (DEBUG)       {           System.out.println (providerName + "::findCOPInPropertyTypesNew: hashPaths = " + hashPaths);       }       Iterator itrHashPaths = hashPaths.keySet ().iterator ();       // Iterate through all of our results       while (itrHashPaths.hasNext ())       {           Object   key     = itrHashPaths.next ();           HashMap  hash    = (HashMap)hashPaths.get (key);           boolean  found   = true;           Iterator itrHash = hash.values ().iterator ();           while (itrHash.hasNext ())           {               if (!((Boolean)itrHash.next ()).booleanValue ())               {                   found = false;               }           }           if (DEBUG)           {               System.out.println (providerName + "::findCOPInPropertyTypesNew: found = " + found + ", key = " + key);           }           // Were they all equal?           if (found)           {               // Return the index of it               return pathsPropertyTypes.indexOf (key);           }       }       return -1;   }   private void testTestElementInstance (CIMInstance instanceObject)      throws CIMException   {   }   private void testPropertyTypeInstance (CIMInstance instanceObject)      throws CIMException   {      Vector properties     = instanceObject.getProperties ();      int    iPropertyCount = properties.size ();      for (int j = 0; j < iPropertyCount; j++)      {         CIMProperty property      = (CIMProperty)properties.elementAt (j);         String      propertyName  = property.getName ();         CIMValue    propertyValue = property.getValue ();         Object      value         = propertyValue.getValue ();         int         type          = property.getType ().getType ();         switch (type)         {         case CIMDataType.UINT8:         {            if (!(value instanceof UnsignedInt8))               throw new CIMException (CIMException.CIM_ERR_INVALID_PARAMETER);            if (((UnsignedInt8)value).intValue () >= 255)               throw new CIMException (CIMException.CIM_ERR_INVALID_PARAMETER);            break;         }         case CIMDataType.UINT16:         {            if (!(value instanceof UnsignedInt16))               throw new CIMException (CIMException.CIM_ERR_INVALID_PARAMETER);            if (((UnsignedInt16)value).intValue () >= 10000)               throw new CIMException (CIMException.CIM_ERR_INVALID_PARAMETER);            break;         }         case CIMDataType.UINT32:         {            if (!(value instanceof UnsignedInt32))               throw new CIMException (CIMException.CIM_ERR_INVALID_PARAMETER);            if (((UnsignedInt32)value).intValue () >= 10000000)               throw new CIMException (CIMException.CIM_ERR_INVALID_PARAMETER);            break;         }         case CIMDataType.UINT64:         {            if (!(value instanceof UnsignedInt64))               throw new CIMException (CIMException.CIM_ERR_INVALID_PARAMETER);            if (((UnsignedInt64)value).longValue () >= 1000000000)               throw new CIMException (CIMException.CIM_ERR_INVALID_PARAMETER);            break;         }         case CIMDataType.SINT8:         {            if (!(value instanceof Byte))               throw new CIMException (CIMException.CIM_ERR_INVALID_PARAMETER);            if (((Byte)value).intValue () <= -120)               throw new CIMException (CIMException.CIM_ERR_INVALID_PARAMETER);            break;         }         case CIMDataType.SINT16:         {            if (!(value instanceof Short))               throw new CIMException (CIMException.CIM_ERR_INVALID_PARAMETER);            if (((Short)value).intValue () < -10000)               throw new CIMException (CIMException.CIM_ERR_INVALID_PARAMETER);            break;         }         case CIMDataType.SINT32:         {            if (!(value instanceof Integer))               throw new CIMException (CIMException.CIM_ERR_INVALID_PARAMETER);            if (((Integer)value).intValue () <= -10000000)               throw new CIMException (CIMException.CIM_ERR_INVALID_PARAMETER);            break;         }         case CIMDataType.SINT64:         {            if (!(value instanceof Long))               throw new CIMException (CIMException.CIM_ERR_INVALID_PARAMETER);            if (((Long)value).intValue () <= -1000000000)               throw new CIMException (CIMException.CIM_ERR_INVALID_PARAMETER);            break;         }         case CIMDataType.REAL32:         {            if (!(value instanceof Float))               throw new CIMException (CIMException.CIM_ERR_INVALID_PARAMETER);            if (((Float)value).floatValue () >= 10000000.32)               throw new CIMException (CIMException.CIM_ERR_INVALID_PARAMETER);            break;         }         case CIMDataType.REAL64:         {            if (!(value instanceof Double))               throw new CIMException (CIMException.CIM_ERR_INVALID_PARAMETER);            if (((Double)value).doubleValue () >= 1000000000.64)               throw new CIMException (CIMException.CIM_ERR_INVALID_PARAMETER);            break;         }         default:         {            break;         }         }      }   }   private interface Compare   {      abstract boolean lessThan        (Object lhs, Object rhs);      abstract boolean lessThanOrEqual (Object lhs, Object rhs);   }   private class SortableVector                 extends Vector   {      private Compare compare;      public SortableVector (Compare compare)      {         this.compare = compare;      }      public void sort ()      {         quickSort (0, size() - 1);      }      private void quickSort (int left, int right)      {         if (right > left)         {            Object o1 = elementAt (right);            int    i  = left - 1;            int    j  = right;            while (true)            {               while (compare.lessThan (elementAt (++i), o1))                  ;               while (j > 0)                  if(compare.lessThanOrEqual (elementAt (--j), o1))                     break;               if (i >= j)                  break;               swap (i, j);            }            swap (i , right);            quickSort (left, i - 1);            quickSort (i + 1, right);         }      }      private void swap (int loc1, int loc2)      {         Object tmp = elementAt(loc1);         setElementAt (elementAt (loc2), loc1);         setElementAt (tmp, loc2);      }   }   private class CIMInstanceComparer                 implements Compare   {      private int getInstanceId (Object o)      {         try         {            CIMInstance       ci = (CIMInstance)o;            CIMProperty       cp = ci.getProperty ("InstanceId");            UnsignedInt64     id = (UnsignedInt64)cp.getValue ().getValue ();            return id.intValue ();         }         catch (Exception e)         {            return 0;         }      }      public boolean lessThan (Object lhs, Object rhs)      {         return getInstanceId (lhs) < getInstanceId (rhs);      }      public boolean lessThanOrEqual (Object lhs, Object rhs)      {         return getInstanceId (lhs) <= getInstanceId (rhs);      }   }   private class CIMObjectPathComparer                 implements Compare   {      private int getInstanceId (Object o)      {         try         {            CIMObjectPath     cop   = (CIMObjectPath)o;            String            value = cop.getKeyValue ("InstanceId");            UnsignedInt64     id    = new UnsignedInt64 (value);            return id.intValue ();         }         catch (Exception e)         {            return 0;         }      }      public boolean lessThan (Object lhs, Object rhs)      {         return getInstanceId (lhs) < getInstanceId (rhs);      }      public boolean lessThanOrEqual (Object lhs, Object rhs)      {         return getInstanceId (lhs) <= getInstanceId (rhs);      }   }   //   private String              providerName            = "";   private String              testElementClassname    = "";   private String              propertyTypesClassname  = "";   //   private String              namespace               = "";   private CIMOMHandle         handle                  = null;   private SortableVector      pathsTestElements       = new SortableVector (new CIMObjectPathComparer ());   private SortableVector      instancesTestElements   = new SortableVector (new CIMInstanceComparer ());   private SortableVector      pathsPropertyTypes      = new SortableVector (new CIMObjectPathComparer ());   private SortableVector      instancesPropertyTypes  = new SortableVector (new CIMInstanceComparer ());   private boolean             fEnableModifications    = true;   private final boolean       DEBUG                   = true;   private final String[] TESTELEMENT_KEYS = {      "CreationClassName",      "InstanceId"   };   private final String[] TESTELEMENT_PROPS = {      "CreationClassName",      "InstanceId"   };   private final String[] PROPERTYTYPES_KEYS = {      "CreationClassName",      "InstanceId"   };   private final String[] PROPERTYTYPES_PROPS = {      "CreationClassName",      "InstanceId",      "PropertyString",      "PropertyUint8",      "PropertyUint16",      "PropertyUint32",      "PropertyUint64",      "PropertySint8",      "PropertySint16",      "PropertySint32",      "PropertySint64",      "PropertyBoolean",      "PropertyReal32",      "PropertyReal64",      "PropertyDatetime",      "PropertyChar16",      "PropertyObject",      "PropertyReference",      "PropertyArrayUint8",      "PropertyArrayUint16",      "PropertyArrayUint32",      "PropertyArrayUint64",      "PropertyArraySint8",      "PropertyArraySint16",      "PropertyArraySint32",      "PropertyArraySint64",      "PropertyArrayBoolean",      "PropertyArrayReal32",      "PropertyArrayReal64",      "PropertyArrayDatetime",      "PropertyArrayChar16",      "PropertyArrayObject"   };}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -