edu.stanford.ejalbert.launching.windows
Class DefaultWindowsBrowserLaunching

    java.lang.Object
    extended byedu.stanford.ejalbert.launching.windows.WindowsBrowserLaunching
    extended byedu.stanford.ejalbert.launching.windows.DefaultWindowsBrowserLaunching
All Implemented Interfaces:
IBrowserLaunching
Direct Known Subclasses:
Windows2000BrowserLaunching, Windows9xBrowserLaunching, WindowsNtBrowserLaunching

abstract class DefaultWindowsBrowserLaunching
extends WindowsBrowserLaunching

Author:
Markus Gebhard, Jeff Chapman, Chris Dance

Field Summary
protected static String FIRST_WINDOWS_PARAMETER
          The first parameter that needs to be passed into Runtime.exec() to open the default web browser on Windows.
protected static String SECOND_WINDOWS_PARAMETER
          The second parameter for Runtime.exec() on Windows.
protected static String THIRD_WINDOWS_PARAMETER
          The third parameter for Runtime.exec() on Windows.
 
Fields inherited from class edu.stanford.ejalbert.launching.windows.WindowsBrowserLaunching
logger
 
Fields inherited from interface edu.stanford.ejalbert.launching.IBrowserLaunching
BROWSER_DEFAULT, PROTOCOL_FILE, PROTOCOL_HTTP, PROTOCOL_MAILTO
 
Constructor Summary
protected DefaultWindowsBrowserLaunching(AbstractLogger logger)
           
 
Method Summary
protected  Map getAvailableBrowsers(List browsersToCheck)
          Accesses the Windows registry to look for browser exes.
 List getBrowserList()
          Returns a list of browsers to be used for browser targetting.
protected  Map getBrowserMap()
          Returns map of browser names and exe names to WindowsBrowser objects.
protected abstract  String[] getCommandArgs(String protocol, String urlString)
          Returns the windows arguments for launching a default browser.
protected abstract  String[] getCommandArgs(String protocol, String browserName, String urlString)
          Returns the windows arguments for launching a specified browser.
 void openUrl(String urlString)
          Opens the passed url in the system's default browser.
 void openUrl(String browser, String urlString)
          Allows user to target a specific browser.
 
Methods inherited from class edu.stanford.ejalbert.launching.windows.WindowsBrowserLaunching
getArrayAsString, getProtocol, initialize
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

FIRST_WINDOWS_PARAMETER

    protected static final String FIRST_WINDOWS_PARAMETER
The first parameter that needs to be passed into Runtime.exec() to open the default web browser on Windows.

See Also:
Constant Field Values

SECOND_WINDOWS_PARAMETER

    protected static final String SECOND_WINDOWS_PARAMETER
The second parameter for Runtime.exec() on Windows.

See Also:
Constant Field Values

THIRD_WINDOWS_PARAMETER

    protected static final String THIRD_WINDOWS_PARAMETER
The third parameter for Runtime.exec() on Windows. This is a "title" parameter that the command line expects. Setting this parameter allows URLs containing spaces to work.

See Also:
Constant Field Values
Constructor Detail

DefaultWindowsBrowserLaunching

    protected DefaultWindowsBrowserLaunching(AbstractLogger logger)
Method Detail

getCommandArgs

    protected abstract String[] getCommandArgs(String protocol,
    String urlString)
Returns the windows arguments for launching a default browser.

Parameters:
protocol - String
urlString - String
Returns:
String[]

getCommandArgs

    protected abstract String[] getCommandArgs(String protocol,
    String browserName,
    String urlString)
Returns the windows arguments for launching a specified browser.

Parameters:
protocol - String
browserName - String
urlString - String
Returns:
String[]

getAvailableBrowsers

    protected Map getAvailableBrowsers(List browsersToCheck)
Accesses the Windows registry to look for browser exes. The browsers search for are in the browsersToCheck list. The returned map will use display names and exe names as keys to the WindowsBrowser objects.

Parameters:
browsersToCheck - List
Returns:
Map

getBrowserMap

    protected final Map getBrowserMap()
Returns map of browser names and exe names to WindowsBrowser objects.

This is the preferred method for accessing the browser name and exe map.

Returns:
Map

openUrl

    public void openUrl(String urlString)
    throws UnsupportedOperatingSystemException,
    BrowserLaunchingExecutionException,
    BrowserLaunchingInitializingException
Description copied from interface: IBrowserLaunching
Opens the passed url in the system's default browser.

Parameters:
urlString - String
Throws:
UnsupportedOperatingSystemException
BrowserLaunchingExecutionException
BrowserLaunchingInitializingException

openUrl

    public void openUrl(String browser,
    String urlString)
    throws UnsupportedOperatingSystemException,
    BrowserLaunchingExecutionException,
    BrowserLaunchingInitializingException
Description copied from interface: IBrowserLaunching
Allows user to target a specific browser. The names of potential browsers can be accessed via the getBrowserList method.

If the call to the requested browser fails, the code will fail over to the default browser.

Parameters:
browser - String
urlString - String
Throws:
BrowserLaunchingExecutionException
BrowserLaunchingInitializingException
UnsupportedOperatingSystemException

getBrowserList

    public 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.

Returns:
List