Package org.xhtmlrenderer.demo.aboutbox
Class DemoUserAgent
java.lang.Object
org.xhtmlrenderer.demo.aboutbox.DemoUserAgent
- All Implemented Interfaces:
UserAgentCallback
@ParametersAreNonnullByDefault
public class DemoUserAgent
extends Object
implements UserAgentCallback
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate String
private final Map
<String, ImageResource> private final int
an LRU cacheprivate int
private static final org.slf4j.Logger
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetBack()
byte[]
getBinaryResource
(String uri) Retrieves a binary resource located at a given URI and returns its contents as a byte array ornull
if the resource could not be loaded.getCSSResource
(String resourceUri) Retrieves the CSS at the given URI.getImageResource
(String uri) Retrieves the Image at the given URI.getXMLResource
(String uri) Retrieves the XML at the given URI.boolean
hasBack()
boolean
boolean
Normally, returns true if the user agent has visited this URI.resolveURI
(String uri) Used to find an uri that may be relative to the BaseURL.void
setBaseURL
(String url) Does not need to be a correct URL, only an identifier that the implementation can resolve.
-
Field Details
-
log
private static final org.slf4j.Logger log -
baseUrl
-
index
private int index -
history
-
imageCacheCapacity
private final int imageCacheCapacityan LRU cache- See Also:
-
imageCache
-
-
Constructor Details
-
DemoUserAgent
public DemoUserAgent()
-
-
Method Details
-
getCSSResource
Description copied from interface:UserAgentCallback
Retrieves the CSS at the given URI. This is a synchronous call.- Specified by:
getCSSResource
in interfaceUserAgentCallback
- Parameters:
resourceUri
- Location of the CSS- Returns:
- A CSSResource for the content at the URI.
-
getImageResource
Description copied from interface:UserAgentCallback
Retrieves the Image at the given URI. This is a synchronous call.- Specified by:
getImageResource
in interfaceUserAgentCallback
- Parameters:
uri
- Location of the image- Returns:
- An ImageResource for the content at the URI.
-
getBinaryResource
Description copied from interface:UserAgentCallback
Retrieves a binary resource located at a given URI and returns its contents as a byte array ornull
if the resource could not be loaded.- Specified by:
getBinaryResource
in interfaceUserAgentCallback
-
getXMLResource
Description copied from interface:UserAgentCallback
Retrieves the XML at the given URI. This is a synchronous call.- Specified by:
getXMLResource
in interfaceUserAgentCallback
- Parameters:
uri
- Location of the XML- Returns:
- A XMLResource for the content at the URI.
-
isVisited
Description copied from interface:UserAgentCallback
Normally, returns true if the user agent has visited this URI. UserAgent should consider if it should answer truthfully or not for privacy reasons.- Specified by:
isVisited
in interfaceUserAgentCallback
- Parameters:
uri
- A URI which may have been visited by this user agent.- Returns:
- The visited value
-
setBaseURL
Description copied from interface:UserAgentCallback
Does not need to be a correct URL, only an identifier that the implementation can resolve.- Specified by:
setBaseURL
in interfaceUserAgentCallback
- Parameters:
url
- A URL against which relative references can be resolved.
-
resolveURI
Description copied from interface:UserAgentCallback
Used to find an uri that may be relative to the BaseURL. The returned value will always only be used via methods in the same implementation of this interface, therefore may be a private uri-space.- Specified by:
resolveURI
in interfaceUserAgentCallback
- Parameters:
uri
- an absolute or relative (to baseURL) uri to be resolved.- Returns:
- the full uri in uri-spaces known to the current implementation.
-
getBaseURL
- Specified by:
getBaseURL
in interfaceUserAgentCallback
- Returns:
- the base uri, possibly in the implementations private uri-space
-
getForward
-
getBack
-
hasForward
public boolean hasForward() -
hasBack
public boolean hasBack()
-