public interface UserAgentCallback
To be implemented by any user agent using the panel. "User agent" is a term defined by the W3C in the documentation for XHTML and CSS; in most cases, you can think of this as the rendering component for a browser.
This interface defines a simple callback mechanism for Flying Saucer to interact with a user agent. The FS toolkit provides a default implementation for this interface which in most cases you can leave as is.
The user agent in this case is responsible for retrieving external resources. For privacy reasons, if using the library in an application that can access URIs in an unrestricted fashion, you may decide to restrict access to XML, CSS or images retrieved from external sources; that's one of the purposes of the UAC.
To understand how to create your own UAC, it's best to look at some of the
implemetations shipped with the library, like the NaiveUserAgent.
| Modifier and Type | Method and Description |
|---|---|
String |
getBaseURL() |
default byte[] |
getBinaryResource(String uri)
Deprecated.
Use
getBinaryResource(String, ExternalResourceType) instead. |
byte[] |
getBinaryResource(String uri,
ExternalResourceType type)
Retrieves a binary resource located at a given URI and returns its contents
as a byte array or
null if the resource could not be loaded. |
default CSSResource |
getCSSResource(String uri)
Retrieves the CSS at the given URI.
|
CSSResource |
getCSSResource(String uri,
ExternalResourceType type) |
default ImageResource |
getImageResource(String uri)
Retrieves the Image at the given URI.
|
ImageResource |
getImageResource(String uri,
ExternalResourceType type) |
default XMLResource |
getXMLResource(String uri)
Deprecated.
Use
getXMLResource(String, ExternalResourceType) instead. |
XMLResource |
getXMLResource(String uri,
ExternalResourceType type)
Retrieves the XML at the given URI.
|
boolean |
isVisited(String uri)
Normally, returns true if the user agent has visited this URI.
|
String |
resolveURI(String uri)
Used to find a uri that may be relative to the BaseURL.
|
String |
resolveUri(String baseUri,
String uri) |
void |
setBaseURL(String url)
Does not need to be a correct URL, only an identifier that the
implementation can resolve.
|
default CSSResource getCSSResource(String uri)
uri - Location of the CSSCSSResource getCSSResource(String uri, ExternalResourceType type)
default ImageResource getImageResource(String uri)
uri - Location of the imageImageResource getImageResource(String uri, ExternalResourceType type)
@Deprecated default XMLResource getXMLResource(String uri)
getXMLResource(String, ExternalResourceType) instead.XMLResource getXMLResource(String uri, ExternalResourceType type)
uri - Location of the XMLtype - Either xhtml or svg.@Deprecated default byte[] getBinaryResource(String uri)
getBinaryResource(String, ExternalResourceType) instead.byte[] getBinaryResource(String uri, ExternalResourceType type)
null if the resource could not be loaded.boolean isVisited(String uri)
uri - A URI which may have been visited by this user agent.void setBaseURL(String url)
url - A URL against which relative references can be resolved.String getBaseURL()
String resolveURI(String uri)
uri - an absolute or relative (to baseURL) uri to be resolved.Copyright © 2004–2025. All rights reserved.