edu.stanford.ejalbert.launching.windows
Class DefaultWindowsBrowserLaunching

java.lang.Object
  extended by edu.stanford.ejalbert.launching.windows.WindowsBrowserLaunching
      extended by edu.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
private  java.util.Map browserNameAndExeMap
          Maps display name and exe name to WindowsBrowser objects.
protected static java.lang.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 java.lang.String SECOND_WINDOWS_PARAMETER
          The second parameter for Runtime.exec() on Windows.
protected static java.lang.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  java.util.Map getAvailableBrowsers(java.util.List browsersToCheck)
          Accesses the Windows registry to look for browser exes.
 java.util.List getBrowserList()
          Returns a list of browsers to be used for browser targetting.
protected  java.util.Map getBrowserMap()
          Returns map of browser names and exe names to WindowsBrowser objects.
protected abstract  java.lang.String[] getCommandArgs(java.lang.String protocol, java.lang.String urlString)
          Returns the windows arguments for launching a default browser.
protected abstract  java.lang.String[] getCommandArgs(java.lang.String protocol, java.lang.String browserName, java.lang.String urlString)
          Returns the windows arguments for launching a specified browser.
private  void initBrowserMap()
          Handles lazy instantiation of available browser map.
 void openUrl(java.lang.String urlString)
          Opens the passed url in the system's default browser.
 void openUrl(java.lang.String browser, java.lang.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

browserNameAndExeMap

private java.util.Map browserNameAndExeMap
Maps display name and exe name to WindowsBrowser objects. Using name and exe as keys for backward compatiblity.


FIRST_WINDOWS_PARAMETER

protected static final java.lang.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 java.lang.String SECOND_WINDOWS_PARAMETER
The second parameter for Runtime.exec() on Windows.

See Also:
Constant Field Values

THIRD_WINDOWS_PARAMETER

protected static final java.lang.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 java.lang.String[] getCommandArgs(java.lang.String protocol,
                                                     java.lang.String urlString)
Returns the windows arguments for launching a default browser.

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

getCommandArgs

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

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

getAvailableBrowsers

protected java.util.Map getAvailableBrowsers(java.util.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

initBrowserMap

private void initBrowserMap()
Handles lazy instantiation of available browser map.


getBrowserMap

protected final java.util.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(java.lang.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(java.lang.String browser,
                    java.lang.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:
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.

Returns:
List