Class AbstractOperatingSystem

java.lang.Object
oshi.software.common.AbstractOperatingSystem
All Implemented Interfaces:
OperatingSystem
Direct Known Subclasses:
FreeBsdOperatingSystem, LinuxOperatingSystem, MacOperatingSystem, SolarisOperatingSystem, WindowsOperatingSystem

public abstract class AbstractOperatingSystem
extends java.lang.Object
implements OperatingSystem
  • Constructor Details

  • Method Details

    • getManufacturer

      public java.lang.String getManufacturer()
      Description copied from interface: OperatingSystem
      Manufacturer.
      Specified by:
      getManufacturer in interface OperatingSystem
      Returns:
      String.
    • queryManufacturer

      protected abstract java.lang.String queryManufacturer()
    • getFamily

      public java.lang.String getFamily()
      Description copied from interface: OperatingSystem
      Operating system family.
      Specified by:
      getFamily in interface OperatingSystem
      Returns:
      String.
    • getVersionInfo

      public OperatingSystem.OSVersionInfo getVersionInfo()
      Description copied from interface: OperatingSystem
      Operating system version information.
      Specified by:
      getVersionInfo in interface OperatingSystem
      Returns:
      Version information.
    • queryFamilyVersionInfo

      protected abstract AbstractOperatingSystem.FamilyVersionInfo queryFamilyVersionInfo()
    • getBitness

      public int getBitness()
      Description copied from interface: OperatingSystem
      Gets the bitness (32 or 64) of the operating system.
      Specified by:
      getBitness in interface OperatingSystem
      Returns:
      The number of bits supported by the operating system.
    • queryBitness

      protected abstract int queryBitness​(int jvmBitness)
      Backup OS-specific query to determine bitness if previous checks fail
      Parameters:
      jvmBitness - The bitness of the JVM
      Returns:
      The operating system bitness
    • isElevated

      public boolean isElevated()
      Description copied from interface: OperatingSystem
      Determine whether the current process has elevated permissions such as sudo / Administrator
      Specified by:
      isElevated in interface OperatingSystem
      Returns:
      True if this process has elevated permissions
    • getServices

      public OSService[] getServices()
      Description copied from interface: OperatingSystem
      Gets the all services on the system. The definition of what is a service is platform-dependent.
      Specified by:
      getServices in interface OperatingSystem
      Returns:
      An array of OSService objects
    • queryElevated

      protected abstract boolean queryElevated()
    • processSort

      protected java.util.List<OSProcess> processSort​(java.util.List<OSProcess> processes, int limit, OperatingSystem.ProcessSort sort)
      Sorts an array of processes using the specified sorting, returning an array with the top limit results if positive.
      Parameters:
      processes - The array to sort
      limit - The number of results to return if positive; if zero returns all results
      sort - The sorting to use, or null
      Returns:
      An array of size limit (if positive) or of all processes, sorted as specified
    • getProcesses

      public java.util.List<OSProcess> getProcesses()
      Description copied from interface: OperatingSystem
      Gets currently running processes. No order is guaranteed.
      Specified by:
      getProcesses in interface OperatingSystem
      Returns:
      An UnmodifiableList of OSProcess objects for the specified number (or all) of currently running processes, sorted as specified. The list may contain null elements or processes with a state of OSProcess.State.INVALID if a process terminates during iteration.
    • getProcesses

      public java.util.List<OSProcess> getProcesses​(java.util.Collection<java.lang.Integer> pids)
      Description copied from interface: OperatingSystem
      Gets information on a Collection of currently running processes. This has potentially improved performance vs. iterating individual processes.
      Specified by:
      getProcesses in interface OperatingSystem
      Parameters:
      pids - A collection of process IDs
      Returns:
      An UnmodifiableList of OSProcess objects for the specified process ids if it is running
    • toString

      public java.lang.String toString()
      Overrides:
      toString in class java.lang.Object