public class LaunchBrowser extends java.lang.Object implements ILaunchBrowser
If the desktop supports the "browse" action then the desktop browse support is used.
Otherwise the following default launch command is used:
Windows: cmd /C "start URL" (for non-file URLs) Windows: cmd /C "URL" (for file URLs) Macintosh: /usr/bin/open URL Other: xdg-open URL
NO_ERROR, NON_WINDOWS
ALPHA_CAP_CHARS, ALPHA_CHARS, ALPHA_LOW_CHARS, ALPHANUM_CHARS_STRING, ALPHANUMERIC_CHARS, BOOLEAN_FALSE_TEXT, BOOLEAN_TRUE_TEXT, DATE_FORMAT_AMPM_STR, DATE_FORMAT_RFC_822_STR, DATE_FORMAT24_STR, DEFAULT_JAVA_VERSION_STRING, DEFAULT_NULL_STR, DEFAULT_SEP_STR, EFLOAT_CHARS, EMPTY_CHARS, EMPTY_STRING, EMPTY_STRINGS, FLOAT_CHARS, HEX_ALPHA_CAP_CHARS, HEX_ALPHA_LOW_CHARS, HEX_CHARS, HEX_PREFIX, INTEGER_CHARS, INVALID_FILENAME_CHARS, MODIFIER_TEXT_ALT, MODIFIER_TEXT_CTRL, MODIFIER_TEXT_META, MODIFIER_TEXT_META_ALT, MODIFIER_TEXT_META_CTRL, NONE, QUOTE_STRING, SIGNED_EFLOAT_CHARS, SIGNED_FLOAT_CHARS, SIGNED_INT_CHARS, SMTP_ENCRYPTION_OPTIONS, SMTP_SERVER_AUTHENTICATION_NAME, SMTP_SERVER_AUTHENTICATION_TEXT, SPACE_STRING, SSL, SSL_KEY_STORE_PROP_KEY, SSL_KEY_STORE_TYPE_PROP_KEY, SSL_TRUST_STORE_PROP_KEY, SSL_TRUST_STORE_TYPE_PROP_KEY, STARTTLS, TLS, TOD_CHARS, UNKNOWN_STRING, US_ASCII, WHITE_SPACE_CHARS, WILDCARD_ALL_CHAR, WILDCARD_CHARS, WILDCARD_SINGLE_CHAR
Modifier and Type | Method and Description |
---|---|
static boolean |
checkResponseCodeOK(int codeVal)
Determines if the given response code corresponds to the HTTP_OK code.
|
static boolean |
checkResponseCodeOK(java.net.URL urlObj)
Determines if the response code fetched for the given URL corresponds to
the HTTP_OK code.
|
static boolean |
checkResponseCodeOK(java.net.URLConnection urlConnObj)
Determines if the response code fetched for the given URLConnection
corresponds to the HTTP_OK code.
|
void |
clearErrorMessage()
Clears the error message string.
|
boolean |
getErrorFlag()
Returns true if an error was detected.
|
java.lang.String |
getErrorMessage()
Returns message string for last error (or 'No error' if none).
|
static ILaunchBrowser |
getInstance()
Get the launch browser.
|
java.lang.String |
getLaunchBrowserCommand()
Get the launch browser command.
|
static int |
getResponseCode(java.net.URL urlObj)
Returns the status code from an HTTP response message.
|
static int |
getResponseCode(java.net.URLConnection urlConnObj)
Returns the status code from an HTTP response message.
|
boolean |
isEnabled()
Returns an indicator of whether or not the launching of browsers is
enabled.
|
static boolean |
isURLAddress(java.lang.String str)
Returns true if the contents of the given string qualify as a valid URL
address; otherwise returns false.
|
boolean |
launchBrowser(java.lang.String uri)
Displays the given URI in a browser.
|
static java.net.URLConnection |
openConnection(java.net.URL urlObj)
Opens a connection to the given URL.
|
void |
setEnabled(boolean flgVal)
Enables or disables the launching of a browser.
|
void |
setLaunchBrowserCommand(java.lang.String s)
Set the launch browser command.
|
boolean |
showURI(java.net.URI uri)
Displays the given URI in a browser.
|
boolean |
showURL(java.lang.String uri)
Displays the given URI in a browser.
|
static boolean |
waitForURLAvailable(java.net.URL urlObj,
int timeOutMs,
int checkIntvlMs)
Waits for the specified URL to become available.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getDesktop
public static boolean checkResponseCodeOK(int codeVal)
codeVal
- response code to check.public static boolean checkResponseCodeOK(java.net.URL urlObj)
urlObj
- URL object to use.public static boolean checkResponseCodeOK(java.net.URLConnection urlConnObj)
urlConnObj
- URL-connection object to use.public static ILaunchBrowser getInstance()
public static int getResponseCode(java.net.URL urlObj)
urlObj
- URL object to use.public static int getResponseCode(java.net.URLConnection urlConnObj)
urlConnObj
- URL-connection object to use.public static boolean isURLAddress(java.lang.String str)
str
- the string to check.public static java.net.URLConnection openConnection(java.net.URL urlObj)
urlObj
- URL object for the given URL.public static boolean waitForURLAvailable(java.net.URL urlObj, int timeOutMs, int checkIntvlMs)
urlObj
- URL object for URL.timeOutMs
- maximum time to wait (in ms), or 0 for indefinite.checkIntvlMs
- delay time between checks (in ms).public void clearErrorMessage()
public boolean getErrorFlag()
public java.lang.String getErrorMessage()
ILaunchBrowser
getErrorMessage
in interface ILaunchBrowser
public java.lang.String getLaunchBrowserCommand()
ILaunchBrowser
getLaunchBrowserCommand
in interface ILaunchBrowser
public boolean isEnabled()
ILaunchBrowser
isEnabled
in interface ILaunchBrowser
public boolean launchBrowser(java.lang.String uri)
ILaunchBrowser
launchBrowser
in interface ILaunchBrowser
uri
- the URI.public void setEnabled(boolean flgVal)
ILaunchBrowser
setEnabled
in interface ILaunchBrowser
flgVal
- true to enable, false to disable.public void setLaunchBrowserCommand(java.lang.String s)
ILaunchBrowser
setLaunchBrowserCommand
in interface ILaunchBrowser
s
- the launch browser command or null or empty string if none.public boolean showURI(java.net.URI uri)
ILaunchBrowser
showURI
in interface ILaunchBrowser
uri
- the URI.public boolean showURL(java.lang.String uri)
ILaunchBrowser
showURL
in interface ILaunchBrowser
uri
- the URI.