Class HkeyPerformanceDataUtil
java.lang.Object
oshi.driver.common.windows.registry.HkeyPerformanceDataUtil
Base class for HKEY_PERFORMANCE_DATA utilities. Contains the common logic for building the counter name/index map and
resolving counter indices from enum definitions. Subclasses provide the platform-specific native call to read the
registry string array.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbuildCounterIndexMap(String[] counterText) Builds the counter index map from a string array of alternating index/name pairs.Looks up the counter index values for the given counter object and the enum of counter names.
-
Field Details
-
HKEY_PERFORMANCE_TEXT
Registry key containing English counter name/index pairs.- See Also:
-
COUNTER
-
-
Constructor Details
-
HkeyPerformanceDataUtil
protected HkeyPerformanceDataUtil()Subclass-only constructor.
-
-
Method Details
-
buildCounterIndexMap
Builds the counter index map from a string array of alternating index/name pairs.The array format is pairs of
"<index>", "<name>". The first pair is a length/count entry (e.g.,"1", "1847") followed by actual counter definitions such as"2", "System", "4", "Memory", "6", "% Processor Time", .... Even positions (0, 2, 4, ...) hold numeric index strings and odd positions (1, 3, 5, ...) hold the corresponding counter names.- Parameters:
counterText- The string array from the registry, or null if the read failed- Returns:
- An unmodifiable map of counter name to index
-
getCounterIndices
protected static <T extends Enum<T> & PdhCounterWildcardProperty> Pair<Integer, EnumMap<T,Integer>> getCounterIndices(String objectName, Class<T> counterEnum, Map<String, Integer> counterIndexMap) Looks up the counter index values for the given counter object and the enum of counter names.- Type Parameters:
T- An enum containing the counters, whose class is passed ascounterEnum- Parameters:
objectName- The counter object to look up the index forcounterEnum- TheEnumcontaining counters to look up the indices for. The first Enum value will be ignored.counterIndexMap- The map of counter names to their indices- Returns:
- A
Paircontaining the index of the counter object as the first element, and anEnumMapmapping counter enum values to their index as the second element, if the lookup is successful; null otherwise.
-