Class DefaultDocumentRequestHandler

java.lang.Object
com.codename1.ui.html.DefaultDocumentRequestHandler
All Implemented Interfaces:
AsyncDocumentRequestHandler, DocumentRequestHandler
Direct Known Subclasses:
AsyncDocumentRequestHandlerImpl

public class DefaultDocumentRequestHandler extends Object implements AsyncDocumentRequestHandler
Default implementation of the HTML components document request handler to allow simple HTML support in Codename One. This version includes only the basics supported by MIDP e.g. resources and jar file URL's such as jar:// and res://
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static Resources
    Allows URL's referring to a res:// local resource to default to this file
    boolean
    Allows tracking whether a URL was visited or not
    Implementations should return the document in the requested url as an InputStream This is triggered only for the main document requested and not for its resources.
    void
    This method is called by HTMLComponent when a resource is requested asynchronously.
    static void
    Allows URL's referring to a local:// local resource to default to this file
    void
    setTrackVisitedURLs(boolean trackVisitedURLs)
    Allows tracking whether a URL was visited or not
    protected void
    This method can be invoked to indicate a URL was visited fro tracking
    boolean
    Returns true if the URL was visited, requires trackVisitedURLs to be true

    Methods inherited from class Object

    clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    Modifier and Type
    Method
    Description
    protected Object
     
    boolean
    Indicates whether some other object is "equal to" this one.
    final Class
    Returns the runtime class of an object.
    int
    Returns a hash code value for the object.
    final void
    Wakes up a single thread that is waiting on this object's monitor.
    final void
    Wakes up all threads that are waiting on this object's monitor.
    Returns a string representation of the object.
    final void
    Causes current thread to wait until another thread invokes the method or the method for this object.
    final void
    wait(long timeout)
    Causes current thread to wait until either another thread invokes the method or the method for this object, or a specified amount of time has elapsed.
    final void
    wait(long timeout, int nanos)
    Causes current thread to wait until another thread invokes the method or the method for this object, or some other thread interrupts the current thread, or a certain amount of real time has elapsed.
  • Constructor Details

    • DefaultDocumentRequestHandler

      public DefaultDocumentRequestHandler()
  • Method Details

    • getResFile

      public static Resources getResFile()

      Allows URL's referring to a res:// local resource to default to this file

      Returns

      the resFile

    • setResFile

      public static void setResFile(Resources res)

      Allows URL's referring to a local:// local resource to default to this file

      Parameters
      • res: the resource
    • resourceRequestedAsync

      public void resourceRequestedAsync(DocumentInfo docInfo, IOCallback callback)

      This method is called by HTMLComponent when a resource is requested asynchronously. This method should return immediately and start a process of fetching the requested resource on another thread. When the resource was fetched, the HTMLComponent.streamReady should be called.

      Parameters
      • docInfo: A DocumentInfo object representing the requested URL and its attributes

      • callback: The HTMLComponent that should be called back when the stream was fetched.

      Specified by:
      resourceRequestedAsync in interface AsyncDocumentRequestHandler
    • resourceRequested

      public InputStream resourceRequested(DocumentInfo docInfo)

      Implementations should return the document in the requested url as an InputStream This is triggered only for the main document requested and not for its resources.

      Parameters
      • docInfo: A DocumentInfo object representing the requested URL and its attributes
      Returns

      the document at the URL as an InputStream

      Specified by:
      resourceRequested in interface DocumentRequestHandler
    • visitingURL

      protected void visitingURL(String url)

      This method can be invoked to indicate a URL was visited fro tracking

      Parameters
      • url: the url
    • wasURLVisited

      public boolean wasURLVisited(String url)

      Returns true if the URL was visited, requires trackVisitedURLs to be true

      Parameters
      • url: the url
      Returns

      true if it was visited

    • isTrackVisitedURLs

      public boolean isTrackVisitedURLs()

      Allows tracking whether a URL was visited or not

      Returns

      the trackVisitedURLs

    • setTrackVisitedURLs

      public void setTrackVisitedURLs(boolean trackVisitedURLs)

      Allows tracking whether a URL was visited or not

      Parameters
      • trackVisitedURLs: the trackVisitedURLs to set