Package org.ka2ddo.yaac.os
Class OSAdapter
java.lang.Object
org.ka2ddo.yaac.os.OSAdapter
This abstract class provides service methods for accessing operating-system-specific
information. No instances of this class should ever be instantiated, as all methods
are static.
- Author:
- Andrew Pavlin, KA2DDO
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic interface
Interface to a class that can provide a list of available serial ports on the host computer. -
Method Summary
Modifier and TypeMethodDescriptionstatic String[]
getCachedSerialPortNames
(String deviceName) Get the list of serial port device names, including the specified name.static File
getDirectoryFromCache
(String cacheId) Get a File representing a remembered directory for a particular type of file operation.Get the existing SerialPortListGetter.static String[]
getSerialPortNames
(String currentDevName) Obtain the list of unused serial ports on this system.static boolean
Test if the host operating system is Microsoft Windows.static void
If O/S and available libraries allow it, mark open file as only randomly accessed.static void
If O/S and available libraries allow it, mark open file as only sequentially accessed.static void
If O/S and available libraries allow it, mark open file as only sequentially accessed.static void
Launch O/S-specific browser to view a particular URL.static void
Purge the cached list of serial port device names, so the next query will have to build the list from scratch.static void
putDirectoryToCache
(String cacheId, File dir) remember the last directory used for a type of file operation.static long
releaseOldPages
(FileInputStream is, long startForFlush) If O/S and available libraries allow it, mark every page prior to the current seek position as no longer needed.static long
releaseOldPages
(FileOutputStream os, long startForFlush) If O/S and available libraries allow it, mark every page prior to the current seek position as no longer needed.static void
If O/S and available libraries allow it, mark every page in the RandomAccessFile as no longer needed.static void
releaseOldPages
(RandomAccessFile raf, long startPos, long endPos) If O/S and available libraries allow it, mark every page in the RandomAccessFile as no longer needed.static void
Launch O/S-specific email client to compose an outgoing email.static void
setSerialPortListGetter
(OSAdapter.SerialPortListGetter serialPortListGetter) Replace the SerialPortListGetter with a different one if the serial port library is changed by a plugin.
-
Method Details
-
getSerialPortListGetter
Get the existing SerialPortListGetter.- Returns:
- SerialPortListGetter currently in use
-
setSerialPortListGetter
Replace the SerialPortListGetter with a different one if the serial port library is changed by a plugin. Should only be called by plugins.- Parameters:
serialPortListGetter
- SerialPortListGetter instance
-
getSerialPortNames
Obtain the list of unused serial ports on this system.- Parameters:
currentDevName
- String of an already-busy device name to add to list, or null for no additional name- Returns:
- array String device names, or null if the system does not have access to serial ports
-
getCachedSerialPortNames
Get the list of serial port device names, including the specified name.- Parameters:
deviceName
- device name to include (in case the device is already open)- Returns:
- array of device name Strings
-
purgeSerialPortCache
public static void purgeSerialPortCache()Purge the cached list of serial port device names, so the next query will have to build the list from scratch. -
isWindows
public static boolean isWindows()Test if the host operating system is Microsoft Windows.- Returns:
- boolean true if running on Microsoft Windows (any release), false for any other operating system
-
openURL
Launch O/S-specific browser to view a particular URL. Must be called from AWT dispatch thread.- Parameters:
url
- String representation of URL to view
-
sendEmail
Launch O/S-specific email client to compose an outgoing email. Must be called from AWT dispatch thread.- Parameters:
emailAddr
- String representation of recipient email address- Throws:
Throwable
- if email client could not be launched for any reason
-
getDirectoryFromCache
Get a File representing a remembered directory for a particular type of file operation.- Parameters:
cacheId
- String name of file operation (such as log files, or tile files)- Returns:
- File pointing at the last directory for such operations, or null if never yet cached
-
putDirectoryToCache
remember the last directory used for a type of file operation.- Parameters:
cacheId
- String name of file typedir
- File pointing to the last directory used for those files
-
markStreamAsSequential
If O/S and available libraries allow it, mark open file as only sequentially accessed.- Parameters:
is
- FileInputStream whose file descriptor will be accessed
-
releaseOldPages
If O/S and available libraries allow it, mark every page prior to the current seek position as no longer needed.- Parameters:
is
- FileInputStream whose file descriptor will be accessedstartForFlush
- file position where no-longer-needed file system cache pages should start being released- Returns:
- file position where pages stopped being released
-
releaseOldPages
If O/S and available libraries allow it, mark every page prior to the current seek position as no longer needed.- Parameters:
os
- FileOutputStream whose file descriptor will be accessedstartForFlush
- file position where no-longer-needed file system cache pages should start being released- Returns:
- file position where pages stopped being released
-
releaseOldPages
If O/S and available libraries allow it, mark every page in the RandomAccessFile as no longer needed. Note that any user-mode cached data should be flushed to the operating system kernel prior to calling this method.- Parameters:
raf
- RandomAccessFile whose file descriptor will be accessed- See Also:
-
releaseOldPages
If O/S and available libraries allow it, mark every page in the RandomAccessFile as no longer needed. Note that any user-mode cached data should be flushed to the operating system kernel prior to calling this method.- Parameters:
raf
- RandomAccessFile whose file descriptor will be accessedstartPos
- starting offset in file to releaseendPos
- ending offset in file to release- See Also:
-
markStreamAsSequential
If O/S and available libraries allow it, mark open file as only sequentially accessed.- Parameters:
os
- FileOutputStream whose file descriptor will be accessed
-
markFileAsRandom
If O/S and available libraries allow it, mark open file as only randomly accessed.- Parameters:
raf
- RandomAccessFile whose file descriptor will be accessed
-