Package org.xhtmlrenderer.context
Class StylesheetFactoryImpl
- java.lang.Object
-
- org.xhtmlrenderer.context.StylesheetFactoryImpl
-
- All Implemented Interfaces:
StylesheetFactory
public class StylesheetFactoryImpl extends java.lang.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 a LRU test, but timestamp of file is not checked.- Author:
- Torbj�rn Gannholm
-
-
Constructor Summary
Constructors Constructor Description StylesheetFactoryImpl(UserAgentCallback userAgentCallback)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
containsStylesheet(java.lang.Object key)
void
flushCachedStylesheets()
Stylesheet
getCachedStylesheet(java.lang.Object key)
Returns a cached sheet by its key; null if no entry for that key.Stylesheet
getStylesheet(StylesheetInfo info)
Returns a cached sheet by its key; loads and caches it if not in cache; null if not able to loadStylesheet
parse(java.io.Reader reader, StylesheetInfo info)
Ruleset
parseStyleDeclaration(int origin, java.lang.String styleDeclaration)
void
putStylesheet(java.lang.Object key, Stylesheet sheet)
Adds a stylesheet to the factory cache.java.lang.Object
removeCachedStylesheet(java.lang.Object key)
Removes a cached sheet by its key.void
setSupportCMYKColors(boolean b)
void
setUserAgentCallback(UserAgentCallback userAgent)
-
-
-
Constructor Detail
-
StylesheetFactoryImpl
public StylesheetFactoryImpl(UserAgentCallback userAgentCallback)
-
-
Method Detail
-
parse
public Stylesheet parse(java.io.Reader reader, StylesheetInfo info)
- Specified by:
parse
in interfaceStylesheetFactory
-
parseStyleDeclaration
public Ruleset parseStyleDeclaration(int origin, java.lang.String styleDeclaration)
- Specified by:
parseStyleDeclaration
in interfaceStylesheetFactory
-
putStylesheet
public void putStylesheet(java.lang.Object 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(java.lang.Object key)
- Parameters:
key
-- Returns:
- true if a Stylesheet with this key has been put in the cache. Note that the Stylesheet may be null.
-
getCachedStylesheet
public Stylesheet getCachedStylesheet(java.lang.Object key)
Returns a cached sheet by its key; null if no entry for that key.- Parameters:
key
- The key for this sheet; same as key passed to putStylesheet();- Returns:
- The stylesheet
-
removeCachedStylesheet
public java.lang.Object removeCachedStylesheet(java.lang.Object key)
Removes a cached sheet by its key.- Parameters:
key
- The key for this sheet; same as key passed to putStylesheet();
-
flushCachedStylesheets
public 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 interfaceStylesheetFactory
- Parameters:
info
- The StylesheetInfo for this sheet- Returns:
- The stylesheet
-
setUserAgentCallback
public void setUserAgentCallback(UserAgentCallback userAgent)
-
setSupportCMYKColors
public void setSupportCMYKColors(boolean b)
-
-