Class HTMLDocumentFactory

java.lang.Object
nl.siegmann.epublib.viewer.HTMLDocumentFactory
All Implemented Interfaces:
NavigationEventListener

public class HTMLDocumentFactory extends Object implements NavigationEventListener
Creates swing HTML documents from resources. Between books the init(Book) function needs to be called in order for images to appear correctly.
  • Field Details

  • Constructor Details

    • HTMLDocumentFactory

      public HTMLDocumentFactory(Navigator navigator, EditorKit editorKit)
  • Method Details

    • init

      public void init(Book book)
    • putDocument

      private void putDocument(Resource resource, HTMLDocument document)
    • getDocument

      public HTMLDocument getDocument(Resource resource)
      Get the HTMLDocument representation of the resource. If the resource is not an XHTML resource then it returns null. It first tries to get the document from the cache. If the document is not in the cache it creates a document from the resource and adds it to the cache.
      Parameters:
      resource -
      Returns:
      the HTMLDocument representation of the resource.
    • stripHtml

      private String stripHtml(String input)
    • removeControlTags

      private static String removeControlTags(String input)
      Quick and dirty stripper of all <?...> and <!...> tags as these confuse the html viewer.
      Parameters:
      input -
      Returns:
      the input stripped of control characters
    • createDocument

      private HTMLDocument createDocument(Resource resource)
      Creates a swing HTMLDocument from the given resource. If the resources is not of type XHTML then null is returned.
      Parameters:
      resource -
      Returns:
      a swing HTMLDocument created from the given resource.
    • initDocumentCache

      private void initDocumentCache(Book book)