Package org.xhtmlrenderer.swt
Class NaiveUserAgent
java.lang.Object
org.xhtmlrenderer.swt.NaiveUserAgent
- All Implemented Interfaces:
UserAgentCallback
- Direct Known Subclasses:
BrowserUserAgent
@ParametersAreNonnullByDefault
public class NaiveUserAgent
extends Object
implements UserAgentCallback
Naive user agent, copy of org.xhtmlrenderer.swing.NaiveUserAgent (but
modified for SWT, of course).
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate String
private final org.eclipse.swt.graphics.Device
private final Map<String,
ImageResource> private final int
an LRU cache -
Constructor Summary
ConstructorsConstructorDescriptionNaiveUserAgent
(org.eclipse.swt.graphics.Device device) Creates a new instance of NaiveUserAgent -
Method Summary
Modifier and TypeMethodDescriptionprotected ImageResource
createImageResource
(String uri, InputStream is) Factory method to generate ImageResources from a given Image.void
Dispose all images in cache and clean the cache.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 uri) 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
Gets the visited attribute of the NaiveUserAgent objectprivate ImageResource
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
-
_imageCacheCapacity
private final int _imageCacheCapacityan LRU cache- See Also:
-
_imageCache
-
_baseURL
-
_device
private final org.eclipse.swt.graphics.Device _device
-
-
Constructor Details
-
NaiveUserAgent
public NaiveUserAgent(org.eclipse.swt.graphics.Device device) Creates a new instance of NaiveUserAgent
-
-
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:
uri
- 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.
-
createImageResource
Factory method to generate ImageResources from a given Image. May be overridden in subclass.- Parameters:
uri
- The URI for the image, resolved to an absolute URI.is
- Stream of the image; may be null (for example, if image could not be loaded).- Returns:
- An ImageResource containing the image.
-
loadEmbeddedBase64ImageResource
-
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
Gets the visited attribute of the NaiveUserAgent object- 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
-
disposeCache
public void disposeCache()Dispose all images in cache and clean the cache. -
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
-