org.lobobrowser.html.test

Class SimpleUserAgentContext

Implemented Interfaces:
UserAgentContext

public class SimpleUserAgentContext
extends java.lang.Object
implements UserAgentContext

Simple implementation of UserAgentContext.

Method Summary

HttpRequest
createHttpRequest()
Creates a SimpleHttpRequest instance.
void
error(String message)
void
error(String message, Throwable throwable)
String
getAppCodeName()
String
getAppMinorVersion()
String
getAppName()
String
getAppVersion()
String
getBrowserLanguage()
String
getCookie(java.net.URL url)
String
getPlatform()
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()
boolean
isCookieEnabled()
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)
void
warn(String message)
void
warn(String message, Throwable throwable)

Method Details

createHttpRequest

public HttpRequest createHttpRequest()
Creates a SimpleHttpRequest instance. 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()
Specified by:
getAppCodeName in interface UserAgentContext

getAppMinorVersion

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

getAppName

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

getAppVersion

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

getBrowserLanguage

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

getCookie

public String getCookie(java.net.URL url)
Specified by:
getCookie in interface UserAgentContext

getPlatform

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

getProxy

protected java.net.Proxy getProxy()
Gets the connection proxy used in requests created by createHttpRequest() by default. It 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()
Specified by:
getUserAgent in interface UserAgentContext

isCookieEnabled

public boolean isCookieEnabled()
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)
Specified by:
setCookie in interface UserAgentContext

warn

public void warn(String message)

warn

public void warn(String message,
                 Throwable throwable)