Class StylesheetFactoryImpl
java.lang.Object
org.openpdf.context.StylesheetFactoryImpl
- All Implemented Interfaces:
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 Summary
FieldsModifier and TypeFieldDescriptionprivate final Map<String, Stylesheet> an LRU cacheprivate final CSSParserprivate UserAgentCallbackthe UserAgentCallback to resolve uris -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleancontainsStylesheet(String key) (package private) void@Nullable StylesheetgetStylesheet(StylesheetInfo info) Returns a cached sheet by its key; loads and caches it if not in cache; null if not able to loadparse(Reader reader, String uri, StylesheetInfo.Origin origin) parse(Reader reader, StylesheetInfo info) private @Nullable Stylesheetparse(StylesheetInfo info) parseStyleDeclaration(StylesheetInfo.Origin origin, String styleDeclaration) voidputStylesheet(String key, Stylesheet sheet) Adds a stylesheet to the factory cache.voidRemoves a cached sheet by its key.(package private) voidsetSupportCMYKColors(boolean b) (package private) voidsetUserAgentCallback(UserAgentCallback userAgent)
-
Field Details
-
_userAgentCallback
the UserAgentCallback to resolve uris -
_cache
an LRU cache -
_cssParser
-
-
Constructor Details
-
StylesheetFactoryImpl
-
-
Method Details
-
parse
- Specified by:
parsein interfaceStylesheetFactory
-
parse
- Specified by:
parsein interfaceStylesheetFactory
-
parse
- Returns:
- Returns null if uri could not be loaded
-
parseStyleDeclaration
- Specified by:
parseStyleDeclarationin interfaceStylesheetFactory
-
putStylesheet
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
- Returns:
- true if a Stylesheet with this key has been put in the cache. Note that the Stylesheet may be null.
-
removeCachedStylesheet
Removes a cached sheet by its key.- Parameters:
key- The key for this sheet; same as key passed to putStylesheet();
-
flushCachedStylesheets
void flushCachedStylesheets() -
getStylesheet
Returns a cached sheet by its key; loads and caches it if not in cache; null if not able to load- Specified by:
getStylesheetin interfaceStylesheetFactory- Parameters:
info- The StylesheetInfo for this sheet- Returns:
- The stylesheet
-
setUserAgentCallback
-
setSupportCMYKColors
void setSupportCMYKColors(boolean b)
-