edu.stanford.ejalbert.launching.windows
Class WindowsBrowserLaunching

java.lang.Object
  extended by edu.stanford.ejalbert.launching.windows.WindowsBrowserLaunching
All Implemented Interfaces:
IBrowserLaunching

public class WindowsBrowserLaunching
extends java.lang.Object
implements IBrowserLaunching

Handles initialization, configuration, and calls to open a url.


Field Summary
protected  net.sf.wraplog.AbstractLogger logger
           
static java.lang.String WINKEY_WIN2000
          config file key for Windows 2000
static java.lang.String WINKEY_WIN9X
          config file key for Windows 9x
static java.lang.String WINKEY_WINNT
          config file key for Windows NT
static java.lang.String WINKEY_WINVISTA
          config file key for Windows Vista
 
Fields inherited from interface edu.stanford.ejalbert.launching.IBrowserLaunching
BROWSER_DEFAULT, BROWSER_SYSTEM_PROPERTY, PROP_KEY_BROWSER_PREFIX, PROP_KEY_DELIMITER, PROTOCOL_FILE, PROTOCOL_HTTP, PROTOCOL_MAILTO, WINDOWS_BROWSER_DISC_POLICY_DISK, WINDOWS_BROWSER_DISC_POLICY_PROPERTY, WINDOWS_BROWSER_DISC_POLICY_REGISTRY
 
Constructor Summary
WindowsBrowserLaunching(net.sf.wraplog.AbstractLogger logger, java.lang.String windowsKey)
          Checks that the windows key is valid.
 
Method Summary
 java.util.List getBrowserList()
          Returns a list of browsers to be used for browser targetting.
 boolean getNewWindowPolicy()
          Returns the policy used for opening a url in a browser.
 void initialize()
          Initializes the browser launcher from the windows config file.
 void openUrl(java.util.List browsers, java.lang.String urlString)
          Allows user to target several browsers.
 void openUrl(java.lang.String urlString)
          Opens a url using the default browser.
 void openUrl(java.lang.String browser, java.lang.String urlString)
          Opens a url using a specific browser.
 void setNewWindowPolicy(boolean forceNewWindow)
          Sets the policy used for opening a url in a browser.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

WINKEY_WINVISTA

public static final java.lang.String WINKEY_WINVISTA
config file key for Windows Vista

See Also:
Constant Field Values

WINKEY_WIN2000

public static final java.lang.String WINKEY_WIN2000
config file key for Windows 2000

See Also:
Constant Field Values

WINKEY_WIN9X

public static final java.lang.String WINKEY_WIN9X
config file key for Windows 9x

See Also:
Constant Field Values

WINKEY_WINNT

public static final java.lang.String WINKEY_WINNT
config file key for Windows NT

See Also:
Constant Field Values

logger

protected final net.sf.wraplog.AbstractLogger logger
Constructor Detail

WindowsBrowserLaunching

public WindowsBrowserLaunching(net.sf.wraplog.AbstractLogger logger,
                               java.lang.String windowsKey)
Checks that the windows key is valid.

Parameters:
logger - AbstractLogger
windowsKey - String
Method Detail

initialize

public void initialize()
                throws BrowserLaunchingInitializingException
Initializes the browser launcher from the windows config file. It initializes the browsers to check list and the command line args to use for version of windows referenced by the windowsKey.

Specified by:
initialize in interface IBrowserLaunching
Throws:
BrowserLaunchingInitializingException
See Also:
windowsKey

openUrl

public void openUrl(java.lang.String urlString)
             throws UnsupportedOperatingSystemException,
                    BrowserLaunchingExecutionException,
                    BrowserLaunchingInitializingException
Opens a url using the default browser.

Specified by:
openUrl in interface IBrowserLaunching
Parameters:
urlString - String
Throws:
UnsupportedOperatingSystemException
BrowserLaunchingExecutionException
BrowserLaunchingInitializingException

openUrl

public void openUrl(java.lang.String browser,
                    java.lang.String urlString)
             throws UnsupportedOperatingSystemException,
                    BrowserLaunchingExecutionException,
                    BrowserLaunchingInitializingException
Opens a url using a specific browser.

If the specified browser is not available, the method will fall through to calling the default openUrl method.

Specified by:
openUrl in interface IBrowserLaunching
Parameters:
browser - String
urlString - String
Throws:
UnsupportedOperatingSystemException
BrowserLaunchingExecutionException
BrowserLaunchingInitializingException

openUrl

public void openUrl(java.util.List browsers,
                    java.lang.String urlString)
             throws UnsupportedOperatingSystemException,
                    BrowserLaunchingExecutionException,
                    BrowserLaunchingInitializingException
Allows user to target several browsers. The names of potential browsers can be accessed via the getBrowserList method.

The browsers from the list will be tried in order (first to last) until one of the calls succeeds. If all the calls to the requested browsers fail, the code will fail over to the default browser.

Specified by:
openUrl in interface IBrowserLaunching
Parameters:
browsers - List
urlString - String
Throws:
UnsupportedOperatingSystemException
BrowserLaunchingExecutionException
BrowserLaunchingInitializingException

getBrowserList

public java.util.List getBrowserList()
Returns a list of browsers to be used for browser targetting. This list will always contain at least one item--the BROWSER_DEFAULT.

Specified by:
getBrowserList in interface IBrowserLaunching
Returns:
List

getNewWindowPolicy

public boolean getNewWindowPolicy()
Returns the policy used for opening a url in a browser.

If the policy is true, an attempt will be made to force the url to be opened in a new instance (window) of the browser.

If the policy is false, the url may open in a new window or a new tab.

Some browsers on Windows systems have command line options to support this feature.

Specified by:
getNewWindowPolicy in interface IBrowserLaunching
Returns:
boolean

setNewWindowPolicy

public void setNewWindowPolicy(boolean forceNewWindow)
Sets the policy used for opening a url in a browser.

Specified by:
setNewWindowPolicy in interface IBrowserLaunching
Parameters:
forceNewWindow - boolean