platform
Class AbstractOS

java.lang.Object
  extended by platform.AbstractOS
All Implemented Interfaces:
JAPHelp.IExternalEMailCaller, JAPHelp.IExternalURLCaller
Direct Known Subclasses:
LinuxOS, MacOS, UnknownOS, WindowsOS

public abstract class AbstractOS
extends java.lang.Object
implements JAPHelp.IExternalURLCaller, JAPHelp.IExternalEMailCaller

This abstract class provides access to OS-specific implementations of certain functions. It tries to instantiate an OS-specific class by determining on which operating system JAP is currently running.


Nested Class Summary
static class AbstractOS.AbstractRetryCopyProcess
           
static class AbstractOS.AbstractURLOpener
           
private  class AbstractOS.InitEnvRunner
           
static interface AbstractOS.IURLErrorNotifier
           
 
Field Summary
private static java.lang.String[] BROWSERLIST
           
private  java.util.Properties m_envVars
           
private  AbstractOS.IURLErrorNotifier m_notifier
           
private  AbstractOS.AbstractURLOpener m_URLOpener
           
private static AbstractOS ms_operatingSystem
          The instanciated operation system class.
private static java.io.File ms_tmpDir
           
private static java.lang.Class[] REGISTERED_PLATFORM_CLASSES
          Make sure that the default OS is the last OS in the array.
static java.lang.String URL_MAIL_TO
           
private static java.lang.String WHITESPACE_ENCODED
           
 
Constructor Summary
AbstractOS()
           
 
Method Summary
 boolean copyAsRoot(java.io.File a_sourceFile, java.io.File a_targetDirectory, AbstractOS.AbstractRetryCopyProcess a_checkRetry)
          Copies a file with root/administrator rights to the specified directory.
static java.lang.String createBrowserCommand(java.lang.String pFFExecutable)
           
 JAPDialog.ILinkedInformation createURLLink(java.net.URL a_url, java.lang.String a_optionalText)
           
 JAPDialog.ILinkedInformation createURLLink(java.net.URL a_url, java.lang.String a_optionalText, java.lang.String a_helpContext)
           
 java.util.Vector getActiveVMs()
          Returns a vector of all running VMs.
 java.lang.String getAppdataDefaultDirectory(java.lang.String a_applicationName)
          If available, returns the specific directory path where the application data (config files etc.) is stored by default.
protected  java.lang.String getAsString(java.net.URL a_url)
           
abstract  java.lang.String getConfigPath(java.lang.String a_applicationName)
          Implementations must return a valid path to the config file.
 java.lang.String getDefaultBrowserPath()
           
 java.lang.String getDefaultHelpPath(java.lang.String a_applicationName)
          returns the default destination path for an external installtion of the help files.
static java.lang.String getDefaultTempPath()
           
 java.lang.String getenv(java.lang.String a_environmentVariable)
           
static AbstractOS getInstance()
          Instantiates an OS-specific class.
 java.lang.String getProperty(java.lang.String a_systemProperty)
           
 java.lang.String getTempPath()
           
 void init(AbstractOS.IURLErrorNotifier a_notifier, AbstractOS.AbstractURLOpener a_URLOpener)
           
protected  void initEnv(java.lang.String a_envCommand)
           
 boolean isDefaultURLAvailable()
           
 boolean isHelpAutoInstalled()
           
 boolean openBrowser()
          Just opens the browser with the default URL.
 boolean openBrowser(java.lang.String a_browserCommand)
           
 boolean openEMail(java.lang.String a_mailto)
          Returns if the caller was able to open the URL in the browser
protected abstract  boolean openLink(java.lang.String a_link)
           
 boolean openURL(java.net.URL a_url)
          Returns if the caller was able to open the URL in the browser
static java.lang.String toAbsolutePath(java.lang.String path)
           
static java.lang.String toRelativePath(java.lang.String a_path)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

URL_MAIL_TO

public static final java.lang.String URL_MAIL_TO
See Also:
Constant Field Values

REGISTERED_PLATFORM_CLASSES

private static java.lang.Class[] REGISTERED_PLATFORM_CLASSES
Make sure that the default OS is the last OS in the array.


BROWSERLIST

private static final java.lang.String[] BROWSERLIST

WHITESPACE_ENCODED

private static final java.lang.String WHITESPACE_ENCODED
See Also:
Constant Field Values

ms_operatingSystem

private static AbstractOS ms_operatingSystem
The instanciated operation system class. (no, ms_operating system does not mean only Microsoft OS are supported... ;-))


m_notifier

private AbstractOS.IURLErrorNotifier m_notifier

m_URLOpener

private AbstractOS.AbstractURLOpener m_URLOpener

m_envVars

private java.util.Properties m_envVars

ms_tmpDir

private static java.io.File ms_tmpDir
Constructor Detail

AbstractOS

public AbstractOS()
Method Detail

getInstance

public static final AbstractOS getInstance()
Instantiates an OS-specific class. If no specific class is found, the default OS (which is a dummy implementation) is instanciated.

Returns:
the instanciated operating system class

createBrowserCommand

public static java.lang.String createBrowserCommand(java.lang.String pFFExecutable)

toRelativePath

public static java.lang.String toRelativePath(java.lang.String a_path)

toAbsolutePath

public static java.lang.String toAbsolutePath(java.lang.String path)

init

public void init(AbstractOS.IURLErrorNotifier a_notifier,
                 AbstractOS.AbstractURLOpener a_URLOpener)

createURLLink

public JAPDialog.ILinkedInformation createURLLink(java.net.URL a_url,
                                                  java.lang.String a_optionalText)

createURLLink

public JAPDialog.ILinkedInformation createURLLink(java.net.URL a_url,
                                                  java.lang.String a_optionalText,
                                                  java.lang.String a_helpContext)

openEMail

public final boolean openEMail(java.lang.String a_mailto)
Description copied from interface: JAPHelp.IExternalEMailCaller
Returns if the caller was able to open the URL in the browser

Specified by:
openEMail in interface JAPHelp.IExternalEMailCaller
Parameters:
a_mailto - an E-Mail address
Returns:
if the caller was able to open the E-Mail address in the browser

getDefaultBrowserPath

public final java.lang.String getDefaultBrowserPath()

isDefaultURLAvailable

public final boolean isDefaultURLAvailable()

openBrowser

public final boolean openBrowser()
Just opens the browser with the default URL. Does not work if no default URL is available.

Returns:
if the browser could be opened with the default URL

openBrowser

public final boolean openBrowser(java.lang.String a_browserCommand)

openURL

public final boolean openURL(java.net.URL a_url)
Description copied from interface: JAPHelp.IExternalURLCaller
Returns if the caller was able to open the URL in the browser

Specified by:
openURL in interface JAPHelp.IExternalURLCaller
Parameters:
a_url - a URL
Returns:
if the caller was able to open the URL in the browser

getConfigPath

public abstract java.lang.String getConfigPath(java.lang.String a_applicationName)
Implementations must return a valid path to the config file.


openLink

protected abstract boolean openLink(java.lang.String a_link)

getAsString

protected java.lang.String getAsString(java.net.URL a_url)

isHelpAutoInstalled

public boolean isHelpAutoInstalled()

getDefaultHelpPath

public java.lang.String getDefaultHelpPath(java.lang.String a_applicationName)
returns the default destination path for an external installtion of the help files. May be os specific. This method returns the path to the folder which contains the Jarfile or users working directory if JonDo is not executed. from a Jar file. A specific OS class may override this method if the help path should be another one.

Returns:
the path to the folder which contains the Jarfile or the users working directory if JonDo is not executed from a Jar file

getAppdataDefaultDirectory

public java.lang.String getAppdataDefaultDirectory(java.lang.String a_applicationName)
If available, returns the specific directory path where the application data (config files etc.) is stored by default.

Returns:

getActiveVMs

public java.util.Vector getActiveVMs()
Returns a vector of all running VMs. This only works on the Sun VM

Returns:
a vector of all running Virtual Machines

copyAsRoot

public boolean copyAsRoot(java.io.File a_sourceFile,
                          java.io.File a_targetDirectory,
                          AbstractOS.AbstractRetryCopyProcess a_checkRetry)
Copies a file with root/administrator rights to the specified directory.

Parameters:
a_sourceFile -
a_targetDirectory -
a_passwordReader - a password reader for getting the root/user password if needed
Returns:
true if copying the file was successful; false is an error occurred or if this operation is not supported on this platform

getTempPath

public java.lang.String getTempPath()

getDefaultTempPath

public static java.lang.String getDefaultTempPath()

getProperty

public java.lang.String getProperty(java.lang.String a_systemProperty)

getenv

public java.lang.String getenv(java.lang.String a_environmentVariable)

initEnv

protected void initEnv(java.lang.String a_envCommand)