Package oshi.util

Class Util


  • @ThreadSafe
    public final class Util
    extends java.lang.Object
    General utility methods
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private static org.slf4j.Logger LOG  
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private Util()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static void freeMemory​(com.sun.jna.Pointer p)
      If the given Pointer is of class Memory, executes the close method on it to free its native allocation
      static boolean isBlank​(java.lang.String s)
      Tests if a String is either null or empty.
      static boolean isBlankOrUnknown​(java.lang.String s)
      Tests if a String is either null or empty or the unknown constant.
      static boolean isSessionValid​(java.lang.String user, java.lang.String device, java.lang.Long loginTime)
      Tests if session of a user logged in a device is valid or not.
      static void sleep​(long ms)
      Sleeps for the specified number of milliseconds.
      static boolean wildcardMatch​(java.lang.String text, java.lang.String pattern)
      Tests if a String matches another String with a wildcard pattern.
      • Methods inherited from class java.lang.Object

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

      • LOG

        private static final org.slf4j.Logger LOG
    • Constructor Detail

      • Util

        private Util()
    • Method Detail

      • sleep

        public static void sleep​(long ms)
        Sleeps for the specified number of milliseconds.
        Parameters:
        ms - How long to sleep
      • wildcardMatch

        public static boolean wildcardMatch​(java.lang.String text,
                                            java.lang.String pattern)
        Tests if a String matches another String with a wildcard pattern.
        Parameters:
        text - The String to test
        pattern - The String containing a wildcard pattern where ? represents a single character and * represents any number of characters. If the first character of the pattern is a carat (^) the test is performed against the remaining characters and the result of the test is the opposite.
        Returns:
        True if the String matches or if the first character is ^ and the remainder of the String does not match.
      • isBlank

        public static boolean isBlank​(java.lang.String s)
        Tests if a String is either null or empty.
        Parameters:
        s - The string to test
        Returns:
        True if the String is either null or empty.
      • isBlankOrUnknown

        public static boolean isBlankOrUnknown​(java.lang.String s)
        Tests if a String is either null or empty or the unknown constant.
        Parameters:
        s - The string to test
        Returns:
        True if the String is either null or empty or the unknown constant.
      • freeMemory

        public static void freeMemory​(com.sun.jna.Pointer p)
        If the given Pointer is of class Memory, executes the close method on it to free its native allocation
        Parameters:
        p - A pointer
      • isSessionValid

        public static boolean isSessionValid​(java.lang.String user,
                                             java.lang.String device,
                                             java.lang.Long loginTime)
        Tests if session of a user logged in a device is valid or not.
        Parameters:
        user - The user logged in
        device - The device used by user
        loginTime - The login time of the user
        Returns:
        True if Session is valid or False if the user of device is empty or the login time is lesser than zero or greater than current time.