Top Description Fields Constructors Methods
com.openhtmltopdf.context

public Class StylesheetFactoryImpl

extends Object
implements StylesheetFactory
Class Inheritance
All Implemented Interfaces
com.openhtmltopdf.css.extend.StylesheetFactory
Imports
java.io.IOException, .Reader, java.util.HashMap, .Map, java.util.logging.Level, com.openhtmltopdf.css.extend.StylesheetFactory, com.openhtmltopdf.css.parser.CSSParser, com.openhtmltopdf.css.sheet.Ruleset, .Stylesheet, .StylesheetInfo, com.openhtmltopdf.extend.UserAgentCallback, com.openhtmltopdf.resource.CSSResource, com.openhtmltopdf.util.LogMessageId, .XRLog

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
Torbjoern Gannholm

Field Summary

Modifier and TypeField and Description
private final CSSParser
private final Map<String, Integer>
_seenStylesheetUris

This may avoid @import loops, ie.

private UserAgentCallback
_userAgentCallback

the UserAgentCallback to resolve uris

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.

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public Stylesheet

Returns:

The stylesheet
getStylesheet
(StylesheetInfo
The StylesheetInfo for this sheet
info
)

Implements com.openhtmltopdf.css.extend.StylesheetFactory.getStylesheet.

Returns a sheet by its key null if not able to load

public Stylesheet
private Stylesheet

Returns:

Returns null if uri could not be loaded
parse
(StylesheetInfo info)

public Ruleset
public void
public void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

_cssParserback to summary
private final CSSParser _cssParser
_seenStylesheetUrisback to summary
private final Map<String, Integer> _seenStylesheetUris

This may avoid @import loops, ie. one.css includes two.css which then includes one.css.

_userAgentCallbackback to summary
private UserAgentCallback _userAgentCallback

the UserAgentCallback to resolve uris

MAX_STYLESHEET_INCLUDESback to summary
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.

Constructor Detail

StylesheetFactoryImplback to summary
public StylesheetFactoryImpl(UserAgentCallback userAgentCallback)

Method Detail

getStylesheetback to summary
public Stylesheet getStylesheet(StylesheetInfo info)

Implements com.openhtmltopdf.css.extend.StylesheetFactory.getStylesheet.

Returns a sheet by its key null if not able to load

Parameters
info:StylesheetInfo

The StylesheetInfo for this sheet

Returns:Stylesheet

The stylesheet

parseback to summary
public Stylesheet parse(Reader reader, StylesheetInfo info)

Implements com.openhtmltopdf.css.extend.StylesheetFactory.parse.

parseback to summary
private Stylesheet parse(StylesheetInfo info)
Returns:Stylesheet

Returns null if uri could not be loaded

parseStyleDeclarationback to summary
public Ruleset parseStyleDeclaration(int origin, String styleDeclaration)

Implements com.openhtmltopdf.css.extend.StylesheetFactory.parseStyleDeclaration.

setSupportCMYKColorsback to summary
public void setSupportCMYKColors(boolean b)
setUserAgentCallbackback to summary
public void setUserAgentCallback(UserAgentCallback userAgent)