Package oshi.software.common
Class AbstractOperatingSystem
- java.lang.Object
-
- oshi.software.common.AbstractOperatingSystem
-
- All Implemented Interfaces:
java.io.Serializable
,OperatingSystem
- Direct Known Subclasses:
FreeBsdOperatingSystem
,LinuxOperatingSystem
,MacOperatingSystem
,SolarisOperatingSystem
,WindowsOperatingSystem
public abstract class AbstractOperatingSystem extends java.lang.Object implements OperatingSystem
- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface oshi.software.os.OperatingSystem
OperatingSystem.ProcessSort
-
-
Field Summary
Fields Modifier and Type Field Description protected int
bitness
protected java.lang.String
family
protected java.lang.String
manufacturer
protected OperatingSystemVersion
version
-
Constructor Summary
Constructors Constructor Description AbstractOperatingSystem()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
getBitness()
Gets the bitness (32 or 64) of the operating system.java.lang.String
getFamily()
Operating system family.java.lang.String
getManufacturer()
Manufacturer.OSProcess[]
getProcesses(int limit, OperatingSystem.ProcessSort sort)
Gets currently running processes.java.util.List<OSProcess>
getProcesses(java.util.Collection<java.lang.Integer> pids)
Gets information on a currently running processes.OperatingSystemVersion
getVersion()
Operating system version.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.java.lang.String
toString()
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface oshi.software.os.OperatingSystem
getChildProcesses, getFileSystem, getNetworkParams, getProcess, getProcessCount, getProcesses, getProcessId, getThreadCount
-
-
-
-
Field Detail
-
manufacturer
protected java.lang.String manufacturer
-
family
protected java.lang.String family
-
version
protected OperatingSystemVersion version
-
bitness
protected int bitness
-
-
Method Detail
-
getVersion
public OperatingSystemVersion getVersion()
Operating system version.- Specified by:
getVersion
in interfaceOperatingSystem
- Returns:
- Version.
-
getFamily
public java.lang.String getFamily()
Operating system family.- Specified by:
getFamily
in interfaceOperatingSystem
- Returns:
- String.
-
getManufacturer
public java.lang.String getManufacturer()
Manufacturer.- Specified by:
getManufacturer
in interfaceOperatingSystem
- Returns:
- String.
-
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 sortlimit
- The number of results to return if positive; if zero returns all resultssort
- The sorting to use, or null- Returns:
- An array of size limit (if positive) or of all processes, sorted as specified
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
getProcesses
public OSProcess[] getProcesses(int limit, OperatingSystem.ProcessSort sort)
Gets currently running processes. If a positive limit is specified, returns only that number of processes; zero will return all processes. The order may be specified by the sort parameter, for example, to return the top cpu or memory consuming processes; if null, no order is guaranteed.- Specified by:
getProcesses
in interfaceOperatingSystem
- Parameters:
limit
- Max number of results to return, or 0 to return all resultssort
- If not null, determines sorting of results- Returns:
- An array of
OSProcess
objects for the specified number (or all) of currently running processes, sorted as specified. The array may contain null elements if a process terminates during iteration. Some fields that are slow to retrieve (e.g., group information on Windows, open files on Unix and Linux) will be skipped.
-
getProcesses
public java.util.List<OSProcess> getProcesses(java.util.Collection<java.lang.Integer> pids)
Gets information on a currently running processes. This has improved performance on Windows based operating systems vs. iterating individual processes.- Specified by:
getProcesses
in interfaceOperatingSystem
- Parameters:
pids
- A collection of process IDs- Returns:
- An
OSProcess
object for the specified process ids if it is running
-
getBitness
public int getBitness()
Gets the bitness (32 or 64) of the operating system.- Specified by:
getBitness
in interfaceOperatingSystem
- Returns:
- The number of bits supported by the operating system.
-
-