Class CIMDataType

java.lang.Object
org.sblim.wbem.cim.CIMDataType
All Implemented Interfaces:
Serializable, Cloneable

public class CIMDataType extends Object implements Serializable, Cloneable
Provides the basic interface to define CIM data type defined by the CIM specification.
See Also:
  • Field Details

  • Constructor Details

    • CIMDataType

      public CIMDataType(int pType)
      Constructs an object of cim data type using the specified data type value. If the specified data type is an array type, assigns the size field to SIZE_UNLIMITED, otherwise assign it to SIZE_SINGLE.
      Parameters:
      pType - One of the type constants in this class
      Throws:
      IllegalArgumentException - if the specified data type is invalid
    • CIMDataType

      public CIMDataType(int pType, int pSize)
      Constructs a cim data type with the specified type and size. A valid type value must be passed. This must be a value between MIN_SINGLE_TYPE and MAX_SINGLE_TYPE or between MIN_ARRAY_TYPE and MAX_ARRAY_TYPE. Additionally a valid size must be specified. A positive value or zero indicates that the array length is fixed. A value of SIZE_UNLIMITED means that the array is of variable size A value of SIZE_SINGLE is not meaningful.
      Parameters:
      pType - One of the type constants in this class
      pSize - The desirtd size SIZE_UNLIMITED, 0..MAX_INT_SIZE
      Throws:
      IllegalArgumentException - if the data type is invalid or if the size is invalid.
    • CIMDataType

      public CIMDataType(String pRefClassName)
      Construct a CIMDataType which is a references of the specified CIMClass.
      Parameters:
      pRefClassName - The referenced class' name
    • CIMDataType

      public CIMDataType(String pRefClassName, int pSize)
      Construct a CIMDataType which is an array of references of the specified CIMClass.
      Parameters:
      pRefClassName - The referenced class' name
      pSize - The size of the array
  • Method Details

    • getRefClassName

      public String getRefClassName()
      Returns the class name pointed by this data type.
      Returns:
      The referenced class' name
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • getType

      public int getType()
      Returns the type of this object.
      Returns:
      The type
    • setType

      public void setType(int pType)
      Sets the current type of the object. Additionally, modifies the size field to SIZE_UNLIMITED if specified data type is an array type, otherwise assigns it to SIZE_SINGLE
      Parameters:
      pType - The type
      Throws:
      IllegalArgumentException - if the assigned data type is invalid
    • getSize

      public int getSize()
      Returns the current size of the data type.
      Returns:
      an integer which represents the size of the data type. A value of zero or a positive value means that the data type is an array type, and the value represent the size of the array. If the returned value is SIZE_UNLIMITED, the data type represents an unlimited size array, which means that the size has not been specified. If the returned value is SIZE_SINGLE, the data type represents a single element entity.
    • findType

      public static int findType(Object pValue)
      Returns an integer value that represents the data type for the specified object. (i.e. NULL for null values, UINT8 for Unsigned8 values, and so on). If the value type is undetermined, return INVALID type.
      Parameters:
      pValue - The value
      Returns:
      The CIM data type fitting the value
    • getDataType

      public static CIMDataType getDataType(String typeStr, boolean isArray)
      Returns the corresponding CIMDataType object for the specified string type. Given a string representation of the data type (i.e. "uint16") returns the appropriate CIMDataType. The isArray argument determine if the resulting data type must be an array type or a single type element.
      Parameters:
      typeStr -
      isArray -
      Returns:
      CIMDataType
    • getPredefinedType

      public static CIMDataType getPredefinedType(int pType)
      Return a predefined value for the CIMDataType. Applications are encourage to use this method instead of creating new CIMDataType objects. An exception to use this is when an array data type, with an specific size other than unlimited size, needs to be used.
      Parameters:
      pType - One of the data type constants in this class
      Returns:
      The data type
    • isArrayType

      public boolean isArrayType()
      Defermines if the current data type is an array type.
      Returns:
      true if this type is an array type, false otherwise
    • isTypeCompatible

      public static boolean isTypeCompatible(Object pValue, CIMDataType pDataType)
      Defermines if the specified data type is is compatible with the data type of the specified value.
      Parameters:
      pValue - The value
      pDataType - The data type
      Returns:
      true, if compatible, falseotherwise
    • isReferenceType

      public boolean isReferenceType()
      Determines if the current data type is a reference type.
      Returns:
      true if this data type is a reference type, false otherwise
    • clone

      public Object clone()
      Overrides:
      clone in class Object
    • findArrayType

      public static int findArrayType(int pSimpleType)
      Returns a value which represents the array type representation of a single type passed as an argument.
      Parameters:
      pSimpleType - The simple type
      Returns:
      returns the corresponding array element type, or INVALID if the specified data type does not has a corresponding array type element.
    • findSimpleType

      public static int findSimpleType(int pArrayType)
      Returns a value which represents the single type representation of an array type passed as an argument.
      Parameters:
      pArrayType - The array type
      Returns:
      returns the corresponding single element type, or INVALID if the specified data type does not has a corresponding single type element.
    • getStringType

      public String getStringType()
      Returns the string representation of this type.
      Returns:
      The string representation
    • toMOF

      public String toMOF()
      Returns the MOF representation of this object.
      Returns:
      Teh MOF representation
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • main

      public static void main(String[] args)