Class NaiveUserAgent

java.lang.Object
org.xhtmlrenderer.swt.NaiveUserAgent
All Implemented Interfaces:
UserAgentCallback

public class NaiveUserAgent extends Object implements UserAgentCallback
Naive user agent, copy of org.xhtmlrenderer.swing.NaiveUserAgent (but modified for SWT, of course).
  • Field Details

    • _imageCacheCapacity

      private final int _imageCacheCapacity
      an LRU cache
      See Also:
    • _imageCache

      private final Map<String,ImageResource> _imageCache
    • _baseURL

      private @Nullable String _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

      public CSSResource getCSSResource(String uri)
      Description copied from interface: UserAgentCallback
      Retrieves the CSS at the given URI. This is a synchronous call.
      Specified by:
      getCSSResource in interface UserAgentCallback
      Parameters:
      uri - Location of the CSS
      Returns:
      A CSSResource for the content at the URI.
    • getImageResource

      public ImageResource getImageResource(String uri)
      Description copied from interface: UserAgentCallback
      Retrieves the Image at the given URI. This is a synchronous call.
      Specified by:
      getImageResource in interface UserAgentCallback
      Parameters:
      uri - Location of the image
      Returns:
      An ImageResource for the content at the URI.
    • createImageResource

      protected ImageResource createImageResource(@Nullable String uri, InputStream is)
      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

      private ImageResource loadEmbeddedBase64ImageResource(String uri)
    • getXMLResource

      public XMLResource getXMLResource(String uri)
      Description copied from interface: UserAgentCallback
      Retrieves the XML at the given URI. This is a synchronous call.
      Specified by:
      getXMLResource in interface UserAgentCallback
      Parameters:
      uri - Location of the XML
      Returns:
      A XMLResource for the content at the URI.
    • isVisited

      public boolean isVisited(String uri)
      Gets the visited attribute of the NaiveUserAgent object
      Specified by:
      isVisited in interface UserAgentCallback
      Parameters:
      uri - A URI which may have been visited by this user agent.
      Returns:
      The visited value
    • setBaseURL

      public void setBaseURL(String url)
      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 interface UserAgentCallback
      Parameters:
      url - A URL against which relative references can be resolved.
    • resolveURI

      @CheckReturnValue public @Nullable String resolveURI(@Nullable String uri)
      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 interface UserAgentCallback
      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

      @CheckReturnValue public @Nullable String getBaseURL()
      Specified by:
      getBaseURL in interface UserAgentCallback
      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

      @CheckReturnValue public byte @Nullable [] getBinaryResource(String uri)
      Description copied from interface: UserAgentCallback
      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.
      Specified by:
      getBinaryResource in interface UserAgentCallback