Class WmiUtil

java.lang.Object
oshi.util.platform.windows.WmiUtil

@ThreadSafe public final class WmiUtil extends Object
Helper class for WMI
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
    The namespace where Open Hardware Monitor publishes to WMI, OHM_NAMESPACE="ROOT\\OpenHardwareMonitor".
  • Method Summary

    Modifier and Type
    Method
    Description
    static <T extends Enum<T>>
    String
    getDateString(com.sun.jna.platform.win32.COM.WbemcliUtil.WmiResult<T> result, T property, int index)
    Gets a Date value from a WmiResult as a String in ISO 8601 format
    static <T extends Enum<T>>
    OffsetDateTime
    getDateTime(com.sun.jna.platform.win32.COM.WbemcliUtil.WmiResult<T> result, T property, int index)
    Gets a DateTime value from a WmiResult as an OffsetDateTime
    static <T extends Enum<T>>
    float
    getFloat(com.sun.jna.platform.win32.COM.WbemcliUtil.WmiResult<T> result, T property, int index)
    Gets a Float value from a WmiResult
    static <T extends Enum<T>>
    String
    getRefString(com.sun.jna.platform.win32.COM.WbemcliUtil.WmiResult<T> result, T property, int index)
    Gets a Reference value from a WmiResult as a String
    static <T extends Enum<T>>
    int
    getSint32(com.sun.jna.platform.win32.COM.WbemcliUtil.WmiResult<T> result, T property, int index)
    Gets a Sint32 value from a WmiResult.
    static <T extends Enum<T>>
    String
    getString(com.sun.jna.platform.win32.COM.WbemcliUtil.WmiResult<T> result, T property, int index)
    Gets a String value from a WmiResult
    static <T extends Enum<T>>
    int
    getUint16(com.sun.jna.platform.win32.COM.WbemcliUtil.WmiResult<T> result, T property, int index)
    Gets a Uint16 value from a WmiResult.
    static <T extends Enum<T>>
    int
    getUint32(com.sun.jna.platform.win32.COM.WbemcliUtil.WmiResult<T> result, T property, int index)
    Gets an UINT32 value from a WmiResult.
    static <T extends Enum<T>>
    long
    getUint32asLong(com.sun.jna.platform.win32.COM.WbemcliUtil.WmiResult<T> result, T property, int index)
    Gets an UINT32 value from a WmiResult as a long, preserving the unsignedness.
    static <T extends Enum<T>>
    long
    getUint64(com.sun.jna.platform.win32.COM.WbemcliUtil.WmiResult<T> result, T property, int index)
    Gets a Uint64 value from a WmiResult (parsing the String).
    static <T extends Enum<T>>
    String
    queryToString(com.sun.jna.platform.win32.COM.WbemcliUtil.WmiQuery<T> query)
    Translate a WmiQuery to the actual query string

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • OHM_NAMESPACE

      public static final String OHM_NAMESPACE
      The namespace where Open Hardware Monitor publishes to WMI, OHM_NAMESPACE="ROOT\\OpenHardwareMonitor". This namespace is not built-in to WMI, so if OHM is not running would result in unnecessary log messages.
      See Also:
  • Method Details

    • queryToString

      public static <T extends Enum<T>> String queryToString(com.sun.jna.platform.win32.COM.WbemcliUtil.WmiQuery<T> query)
      Translate a WmiQuery to the actual query string
      Type Parameters:
      T - WMI queries use an Enum to identify the fields to query, and use the enum values as keys to retrieve the results.
      Parameters:
      query - The WmiQuery object
      Returns:
      The string that is queried in WMI
    • getString

      public static <T extends Enum<T>> String getString(com.sun.jna.platform.win32.COM.WbemcliUtil.WmiResult<T> result, T property, int index)
      Gets a String value from a WmiResult
      Type Parameters:
      T - WMI queries use an Enum to identify the fields to query, and use the enum values as keys to retrieve the results.
      Parameters:
      result - The WmiResult from which to fetch the value
      property - The property (column) to fetch
      index - The index (row) to fetch
      Returns:
      The stored value if non-null, an empty-string otherwise
    • getDateString

      public static <T extends Enum<T>> String getDateString(com.sun.jna.platform.win32.COM.WbemcliUtil.WmiResult<T> result, T property, int index)
      Gets a Date value from a WmiResult as a String in ISO 8601 format
      Type Parameters:
      T - WMI queries use an Enum to identify the fields to query, and use the enum values as keys to retrieve the results.
      Parameters:
      result - The WmiResult from which to fetch the value
      property - The property (column) to fetch
      index - The index (row) to fetch
      Returns:
      The stored value if non-null, an empty-string otherwise
    • getDateTime

      public static <T extends Enum<T>> OffsetDateTime getDateTime(com.sun.jna.platform.win32.COM.WbemcliUtil.WmiResult<T> result, T property, int index)
      Gets a DateTime value from a WmiResult as an OffsetDateTime
      Type Parameters:
      T - WMI queries use an Enum to identify the fields to query, and use the enum values as keys to retrieve the results.
      Parameters:
      result - The WmiResult from which to fetch the value
      property - The property (column) to fetch
      index - The index (row) to fetch
      Returns:
      The stored value if non-null, otherwise the constant Constants.UNIX_EPOCH
    • getRefString

      public static <T extends Enum<T>> String getRefString(com.sun.jna.platform.win32.COM.WbemcliUtil.WmiResult<T> result, T property, int index)
      Gets a Reference value from a WmiResult as a String
      Type Parameters:
      T - WMI queries use an Enum to identify the fields to query, and use the enum values as keys to retrieve the results.
      Parameters:
      result - The WmiResult from which to fetch the value
      property - The property (column) to fetch
      index - The index (row) to fetch
      Returns:
      The stored value if non-null, an empty-string otherwise
    • getUint64

      public static <T extends Enum<T>> long getUint64(com.sun.jna.platform.win32.COM.WbemcliUtil.WmiResult<T> result, T property, int index)
      Gets a Uint64 value from a WmiResult (parsing the String). Note that while the CIM type is unsigned, the return type is signed and the parsing will exclude any return values above Long.MAX_VALUE.
      Type Parameters:
      T - WMI queries use an Enum to identify the fields to query, and use the enum values as keys to retrieve the results.
      Parameters:
      result - The WmiResult from which to fetch the value
      property - The property (column) to fetch
      index - The index (row) to fetch
      Returns:
      The stored value if non-null and parseable as a long, 0 otherwise
    • getUint32

      public static <T extends Enum<T>> int getUint32(com.sun.jna.platform.win32.COM.WbemcliUtil.WmiResult<T> result, T property, int index)
      Gets an UINT32 value from a WmiResult. Note that while a UINT32 CIM type is unsigned, the return type is signed and requires further processing by the user if unsigned values are desired.
      Type Parameters:
      T - WMI queries use an Enum to identify the fields to query, and use the enum values as keys to retrieve the results.
      Parameters:
      result - The WmiResult from which to fetch the value
      property - The property (column) to fetch
      index - The index (row) to fetch
      Returns:
      The stored value if non-null, 0 otherwise
    • getUint32asLong

      public static <T extends Enum<T>> long getUint32asLong(com.sun.jna.platform.win32.COM.WbemcliUtil.WmiResult<T> result, T property, int index)
      Gets an UINT32 value from a WmiResult as a long, preserving the unsignedness.
      Type Parameters:
      T - WMI queries use an Enum to identify the fields to query, and use the enum values as keys to retrieve the results.
      Parameters:
      result - The WmiResult from which to fetch the value
      property - The property (column) to fetch
      index - The index (row) to fetch
      Returns:
      The stored value if non-null, 0 otherwise
    • getSint32

      public static <T extends Enum<T>> int getSint32(com.sun.jna.platform.win32.COM.WbemcliUtil.WmiResult<T> result, T property, int index)
      Gets a Sint32 value from a WmiResult. Note that while the CIM type is unsigned, the return type is signed and requires further processing by the user if unsigned values are desired.
      Type Parameters:
      T - WMI queries use an Enum to identify the fields to query, and use the enum values as keys to retrieve the results.
      Parameters:
      result - The WmiResult from which to fetch the value
      property - The property (column) to fetch
      index - The index (row) to fetch
      Returns:
      The stored value if non-null, 0 otherwise
    • getUint16

      public static <T extends Enum<T>> int getUint16(com.sun.jna.platform.win32.COM.WbemcliUtil.WmiResult<T> result, T property, int index)
      Gets a Uint16 value from a WmiResult. Note that while the CIM type is unsigned, the return type is signed and requires further processing by the user if unsigned values are desired.
      Type Parameters:
      T - WMI queries use an Enum to identify the fields to query, and use the enum values as keys to retrieve the results.
      Parameters:
      result - The WmiResult from which to fetch the value
      property - The property (column) to fetch
      index - The index (row) to fetch
      Returns:
      The stored value if non-null, 0 otherwise
    • getFloat

      public static <T extends Enum<T>> float getFloat(com.sun.jna.platform.win32.COM.WbemcliUtil.WmiResult<T> result, T property, int index)
      Gets a Float value from a WmiResult
      Type Parameters:
      T - WMI queries use an Enum to identify the fields to query, and use the enum values as keys to retrieve the results.
      Parameters:
      result - The WmiResult from which to fetch the value
      property - The property (column) to fetch
      index - The index (row) to fetch
      Returns:
      The stored value if non-null, 0 otherwise