Package com.openhtmltopdf.context
Class StylesheetFactoryImpl
- java.lang.Object
-
- com.openhtmltopdf.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.
-
-
Field Summary
Fields Modifier and Type Field Description private CSSParser
_cssParser
private java.util.Map<java.lang.String,java.lang.Integer>
_seenStylesheetUris
This may avoid @import loops, ie.private UserAgentCallback
_userAgentCallback
the UserAgentCallback to resolve urisprivate static int
MAX_STYLESHEET_INCLUDES
The maximum number of times a stylesheet uri can be link or imported before we give up and conclude there is a loop.
-
Constructor Summary
Constructors Constructor Description StylesheetFactoryImpl(UserAgentCallback userAgentCallback)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Stylesheet
getStylesheet(StylesheetInfo info)
Returns a sheet by its key null if not able to loadprivate Stylesheet
parse(StylesheetInfo info)
Stylesheet
parse(java.io.Reader reader, StylesheetInfo info)
Ruleset
parseStyleDeclaration(int origin, java.lang.String styleDeclaration)
void
setSupportCMYKColors(boolean b)
void
setUserAgentCallback(UserAgentCallback userAgent)
-
-
-
Field Detail
-
_userAgentCallback
private UserAgentCallback _userAgentCallback
the UserAgentCallback to resolve uris
-
_seenStylesheetUris
private final java.util.Map<java.lang.String,java.lang.Integer> _seenStylesheetUris
This may avoid @import loops, ie. one.css includes two.css which then includes one.css.
-
MAX_STYLESHEET_INCLUDES
private static final int MAX_STYLESHEET_INCLUDES
The maximum number of times a stylesheet uri can be link or imported before we give up and conclude there is a loop.- See Also:
- Constant Field Values
-
_cssParser
private final CSSParser _cssParser
-
-
Constructor Detail
-
StylesheetFactoryImpl
public StylesheetFactoryImpl(UserAgentCallback userAgentCallback)
-
-
Method Detail
-
parse
public Stylesheet parse(java.io.Reader reader, StylesheetInfo info)
- Specified by:
parse
in interfaceStylesheetFactory
-
parse
private Stylesheet parse(StylesheetInfo info)
- Returns:
- Returns null if uri could not be loaded
-
parseStyleDeclaration
public Ruleset parseStyleDeclaration(int origin, java.lang.String styleDeclaration)
- Specified by:
parseStyleDeclaration
in interfaceStylesheetFactory
-
getStylesheet
public Stylesheet getStylesheet(StylesheetInfo info)
Returns a sheet by its key 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)
-
-