Class DemoUserAgent

java.lang.Object
org.xhtmlrenderer.demo.aboutbox.DemoUserAgent
All Implemented Interfaces:
UserAgentCallback

@ParametersAreNonnullByDefault public class DemoUserAgent extends Object implements UserAgentCallback
  • Field Details

    • log

      private static final org.slf4j.Logger log
    • baseUrl

      private String baseUrl
    • index

      private int index
    • history

      private final List<String> history
    • imageCacheCapacity

      private final int imageCacheCapacity
      an LRU cache
      See Also:
    • imageCache

      private final Map<String,ImageResource> imageCache
  • Constructor Details

    • DemoUserAgent

      public DemoUserAgent()
  • Method Details

    • getCSSResource

      public CSSResource getCSSResource(String resourceUri)
      Description copied from interface: UserAgentCallback
      Retrieves the CSS at the given URI. This is a synchronous call.
      Specified by:
      getCSSResource in interface UserAgentCallback
      Parameters:
      resourceUri - 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.
    • getBinaryResource

      @Nullable @CheckReturnValue public byte[] 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
    • 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

      @CheckReturnValue public boolean isVisited(@Nullable String uri)
      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 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

      @Nullable @CheckReturnValue public 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

      public String getBaseURL()
      Specified by:
      getBaseURL in interface UserAgentCallback
      Returns:
      the base uri, possibly in the implementations private uri-space
    • getForward

      public String getForward()
    • getBack

      public String getBack()
    • hasForward

      public boolean hasForward()
    • hasBack

      public boolean hasBack()