Class StylesheetFactoryImpl

java.lang.Object
org.xhtmlrenderer.context.StylesheetFactoryImpl
All Implemented Interfaces:
StylesheetFactory

public class StylesheetFactoryImpl extends Object implements StylesheetFactory
A Factory class for Cascading Style Sheets. Sheets are parsed using a single parser instance for all sheets. Sheets are cached by URI using LRU test, but timestamp of file is not checked.
  • Field Details

  • Constructor Details

    • StylesheetFactoryImpl

      public StylesheetFactoryImpl(UserAgentCallback userAgentCallback)
  • Method Details

    • parse

      public Stylesheet parse(Reader reader, StylesheetInfo info)
      Specified by:
      parse in interface StylesheetFactory
    • parse

      @Nullable private Stylesheet parse(StylesheetInfo info)
      Returns:
      Returns null if uri could not be loaded
    • parseStyleDeclaration

      public Ruleset parseStyleDeclaration(int origin, String styleDeclaration)
      Specified by:
      parseStyleDeclaration in interface StylesheetFactory
    • putStylesheet

      public void putStylesheet(String key, Stylesheet sheet)
      Adds a stylesheet to the factory cache. Will overwrite older entry for same key.
      Parameters:
      key - Key to use to reference sheet later; must be unique in factory.
      sheet - The sheet to cache.
    • containsStylesheet

      public boolean containsStylesheet(String key)
      Returns:
      true if a Stylesheet with this key has been put in the cache. Note that the Stylesheet may be null.
    • removeCachedStylesheet

      public void removeCachedStylesheet(String key)
      Removes a cached sheet by its key.
      Parameters:
      key - The key for this sheet; same as key passed to putStylesheet();
    • flushCachedStylesheets

      void flushCachedStylesheets()
    • getStylesheet

      public Stylesheet getStylesheet(StylesheetInfo info)
      Returns a cached sheet by its key; loads and caches it if not in cache; null if not able to load
      Specified by:
      getStylesheet in interface StylesheetFactory
      Parameters:
      info - The StylesheetInfo for this sheet
      Returns:
      The stylesheet
    • setUserAgentCallback

      void setUserAgentCallback(UserAgentCallback userAgent)
    • setSupportCMYKColors

      void setSupportCMYKColors(boolean b)