Class NaiveUserAgent
java.lang.Object
org.xhtmlrenderer.swt.NaiveUserAgent
- All Implemented Interfaces:
UserAgentCallback
Naive user agent, copy of org.xhtmlrenderer.swing.NaiveUserAgent (but
modified for SWT, of course).
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate @Nullable Stringprivate final org.eclipse.swt.graphics.Deviceprivate final Map<String, ImageResource> private final intan LRU cache -
Constructor Summary
ConstructorsConstructorDescriptionNaiveUserAgent(org.eclipse.swt.graphics.Device device) Creates a new instance of NaiveUserAgent -
Method Summary
Modifier and TypeMethodDescriptionprotected ImageResourcecreateImageResource(@Nullable String uri, InputStream is) Factory method to generate ImageResources from a given Image.voidDispose all images in cache and clean the cache.@Nullable Stringbyte @Nullable []getBinaryResource(String uri) Retrieves a binary resource located at a given URI and returns its contents as a byte array ornullif 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.booleanGets the visited attribute of the NaiveUserAgent objectprivate ImageResource@Nullable StringresolveURI(@Nullable String uri) Used to find an uri that may be relative to the BaseURL.voidsetBaseURL(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:UserAgentCallbackRetrieves the CSS at the given URI. This is a synchronous call.- Specified by:
getCSSResourcein interfaceUserAgentCallback- Parameters:
uri- Location of the CSS- Returns:
- A CSSResource for the content at the URI.
-
getImageResource
Description copied from interface:UserAgentCallbackRetrieves the Image at the given URI. This is a synchronous call.- Specified by:
getImageResourcein 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:UserAgentCallbackRetrieves the XML at the given URI. This is a synchronous call.- Specified by:
getXMLResourcein 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:
isVisitedin interfaceUserAgentCallback- Parameters:
uri- A URI which may have been visited by this user agent.- Returns:
- The visited value
-
setBaseURL
Description copied from interface:UserAgentCallbackDoes not need to be a correct URL, only an identifier that the implementation can resolve.- Specified by:
setBaseURLin interfaceUserAgentCallback- Parameters:
url- A URL against which relative references can be resolved.
-
resolveURI
Description copied from interface:UserAgentCallbackUsed 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:
resolveURIin 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:
getBaseURLin 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:UserAgentCallbackRetrieves a binary resource located at a given URI and returns its contents as a byte array ornullif the resource could not be loaded.- Specified by:
getBinaryResourcein interfaceUserAgentCallback
-