org.lobobrowser.html.test

Class SimpleUserAgentContext

Implemented Interfaces:
UserAgentContext

public class SimpleUserAgentContext
extends java.lang.Object
implements UserAgentContext

Simple implementation of UserAgentContext. This class is provided for user convenience. Normally this class should be extended in order to provide appropriate user agent information and more robust content loading routines.

Method Summary

HttpRequest
createHttpRequest()
Creates a SimpleHttpRequest instance.
void
error(String message)
void
error(String message, Throwable throwable)
String
getAppCodeName()
Override to provide the application "code name."
String
getAppMinorVersion()
Override to provide the application's minor version.
String
getAppName()
Override to provide the application name.
String
getAppVersion()
Override to provide the application version.
String
getBrowserLanguage()
Override to provide the browser language.
String
getCookie(java.net.URL url)
This implementation returns blank.
String
getPlatform()
Returns the value of Java property os.name.
String
getProduct()
protected java.net.Proxy
getProxy()
Gets the connection proxy used in requests created by createHttpRequest() by default.
int
getScriptingOptimizationLevel()
Returns -1.
Policy
getSecurityPolicy()
Returns null.
String
getUserAgent()
Returns a simple user-agent string.
String
getVendor()
boolean
isCookieEnabled()
This implementation returns false.
boolean
isMedia(String mediaName)
This implementation returns true for certain media names, such as screen.
boolean
isScriptingEnabled()
Returns true.
void
setCookie(java.net.URL url, String cookieSpec)
This implementation does nothing.
void
warn(String message)
void
warn(String message, Throwable throwable)

Method Details

createHttpRequest

public HttpRequest createHttpRequest()
Creates a SimpleHttpRequest instance. The HttpRequest object returned by this method is used to load images, scripts, style sheets, and to implement the Javascript XMLHttpRequest class. Override if a custom mechanism to make requests is needed.
Specified by:
createHttpRequest in interface UserAgentContext

error

public void error(String message)

error

public void error(String message,
                  Throwable throwable)

getAppCodeName

public String getAppCodeName()
Override to provide the application "code name."
Specified by:
getAppCodeName in interface UserAgentContext

getAppMinorVersion

public String getAppMinorVersion()
Override to provide the application's minor version.
Specified by:
getAppMinorVersion in interface UserAgentContext

getAppName

public String getAppName()
Override to provide the application name.
Specified by:
getAppName in interface UserAgentContext

getAppVersion

public String getAppVersion()
Override to provide the application version.
Specified by:
getAppVersion in interface UserAgentContext

getBrowserLanguage

public String getBrowserLanguage()
Override to provide the browser language. This implementation returns EN.
Specified by:
getBrowserLanguage in interface UserAgentContext

getCookie

public String getCookie(java.net.URL url)
This implementation returns blank. Override if a cookie store is implemented.
Specified by:
getCookie in interface UserAgentContext

getPlatform

public String getPlatform()
Returns the value of Java property os.name.
Specified by:
getPlatform in interface UserAgentContext

getProduct

public String getProduct()
Specified by:
getProduct in interface UserAgentContext

getProxy

protected java.net.Proxy getProxy()
Gets the connection proxy used in requests created by createHttpRequest() by default. This implementation returns Proxy.NO_PROXY, but it may be overridden.

getScriptingOptimizationLevel

public int getScriptingOptimizationLevel()
Returns -1. Override to provide a different Rhino optimization level.
Specified by:
getScriptingOptimizationLevel in interface UserAgentContext

getSecurityPolicy

public Policy getSecurityPolicy()
Returns null. This method must be overridden if JavaScript code is untrusted.
Specified by:
getSecurityPolicy in interface UserAgentContext

getUserAgent

public String getUserAgent()
Returns a simple user-agent string.
Specified by:
getUserAgent in interface UserAgentContext

getVendor

public String getVendor()
Specified by:
getVendor in interface UserAgentContext

isCookieEnabled

public boolean isCookieEnabled()
This implementation returns false. Override to give a different value.
Specified by:
isCookieEnabled in interface UserAgentContext

isMedia

public boolean isMedia(String mediaName)
This implementation returns true for certain media names, such as screen.
Specified by:
isMedia in interface UserAgentContext

isScriptingEnabled

public boolean isScriptingEnabled()
Returns true. Implementations wishing to disable JavaScript may override this method.
Specified by:
isScriptingEnabled in interface UserAgentContext

setCookie

public void setCookie(java.net.URL url,
                      String cookieSpec)
This implementation does nothing. Override if a cookie store is implemented.
Specified by:
setCookie in interface UserAgentContext

warn

public void warn(String message)

warn

public void warn(String message,
                 Throwable throwable)