- All Implemented Interfaces:
CSSStyleSheetFactory,Serializable
- Direct Known Subclasses:
CSSDOMImplementation,DOMCSSStyleSheetFactory
- See Also:
-
Field Summary
Fields inherited from interface io.sf.carte.doc.style.css.CSSStyleSheetFactory
FLAG_STRING_DOUBLE_QUOTE, FLAG_STRING_SINGLE_QUOTE, ORIGIN_AUTHOR, ORIGIN_USER, ORIGIN_USER_AGENT, ORIGIN_USER_IMPORTANT -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedprotectedBaseCSSStyleSheetFactory(EnumSet<Parser.Flag> parserFlags) -
Method Summary
Modifier and TypeMethodDescriptionprotected StyleFormattingFactoryprotected abstract BaseDocumentCSSStyleSheetcreateDocumentStyleSheet(int origin) Creates a Document CSS style sheet for all media.createImmutableMediaQueryList(String media, Node owner) Parses and creates an unmodifiable media query list for the given media.Create a new StyleDeclarationErrorHandler for the given style rule.createMediaQueryList(String mediaQueryString, Node owner) ParsesmediaQueryStringand creates a new media query list.createPropertyDefinition(String name, CSSValueSyntax syntax, boolean inherited, LexicalUnit initialValue) Create a property definition.protected abstract AbstractCSSStyleSheetcreateRuleStyleSheet(AbstractCSSRule ownerRule, String title, MediaQueryList mediaList) Creates a CSS style sheet owned by a CSS rule.protected ParserCreate a NSAC Parser with the proper flags enabled.createSheetErrorHandler(CSSStyleSheet<? extends CSSRule> sheet) Creates a style sheet error handler.Create a new StyleDeclarationErrorHandler for the given style rule.createStyleSheet(String title, MediaQueryList media) Creates a stand-alone author style sheet.Gets the device factory.protected EnumSet<Parser.Flag> Get the parser flags that should be used by NSAC parsers.Get the style formatting factory to be used with this sheet factory.getSystemDefaultValue(String propertyName) Get a system default value for the given property.protected AbstractCSSStyleSheetGet the priority-important part of the user style sheet, i.e. the style sheet with the declarations ofimportantpriority.protected AbstractCSSStyleSheetGet the normal part of the user style sheet, i.e. the style sheet with the declarations of normal priority.protected ValueFactoryGet a value factory set to the appropriate flags.protected booleanCheck for Internet Explorer legacy compatibility value flags.protected booleanhasFactoryFlag(short flag) Check whether the given factory flag is set.protected BaseDocumentCSSStyleSheetReturns a default user agent style sheet for (X)HTML documents, strict mode.protected BaseDocumentCSSStyleSheetReturns a default user agent style sheet for (X)HTML documents, quirks mode.voidsetClassLoader(ClassLoader loader) Sets the class loader to be used when loading internal style sheets.voidsetDeviceFactory(DeviceFactory deviceFactory) Sets the device factory.voidsetFactoryFlag(short flag) Set a configuration flag.booleansetFlag(Parser.Flag flag) Set the given parser flag.voidsetLenientSystemValues(boolean lenient) The style sheet factories provide system default values, and its behaviour depends on alenientSystemValuesflag.voidSet a style formatting factory to format style serializations made with sheets created by this sheet factory.voidSets the CSS style sheet defined by the end user.voidsetUserStyleSheet(String url, Reader re) Sets the CSS style sheet defined by the end user.booleanunsetFlag(Parser.Flag flag) Unset the given parser flag.Methods inherited from class io.sf.carte.doc.style.css.om.AbstractCSSStyleSheetFactory
createAnonymousStyleDeclaration, createInlineStyle, createLinkedStyleSheet, getDefaultStyleSheet, setDefaultHTMLUserAgentSheetMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.sf.carte.doc.style.css.CSSStyleSheetFactory
getUserAgentStyleSheet
-
Constructor Details
-
BaseCSSStyleSheetFactory
protected BaseCSSStyleSheetFactory() -
BaseCSSStyleSheetFactory
-
-
Method Details
-
createDefaultStyleFormattingFactory
-
createDocumentStyleSheet
Creates a Document CSS style sheet for all media.- Parameters:
origin- the origin of the sheet (likeauthor,user agent, etc.)- Returns:
- the style sheet.
-
createStyleSheet
Creates a stand-alone author style sheet.- Specified by:
createStyleSheetin interfaceCSSStyleSheetFactory- Specified by:
createStyleSheetin classAbstractCSSStyleSheetFactory- Parameters:
title- the advisory title.media- the target media for the style sheet.- Returns:
- the style sheet.
-
createRuleStyleSheet
protected abstract AbstractCSSStyleSheet createRuleStyleSheet(AbstractCSSRule ownerRule, String title, MediaQueryList mediaList) Creates a CSS style sheet owned by a CSS rule.- Specified by:
createRuleStyleSheetin classAbstractCSSStyleSheetFactory- Parameters:
ownerRule- the owner rule.title- the advisory title.mediaList- the list of target media for style.- Returns:
- the style sheet.
-
setClassLoader
Sets the class loader to be used when loading internal style sheets.- Parameters:
loader- the class loader.
-
createPropertyDefinition
public CSSPropertyDefinition createPropertyDefinition(String name, CSSValueSyntax syntax, boolean inherited, LexicalUnit initialValue) throws DOMException Description copied from interface:CSSStyleSheetFactoryCreate a property definition.To parse the syntax, use a parser like
SyntaxParser.- Parameters:
name- the property name (unescaped).syntax- the syntax.inherited- whether the property is inherited or not.initialValue- the initial value.- Returns:
- the property definition.
- Throws:
DOMException- INVALID_ACCESS_ERR if the initial value does not match the syntax.
-
getStyleFormattingFactory
Description copied from interface:CSSStyleSheetFactoryGet the style formatting factory to be used with this sheet factory.- Returns:
- the style formatting factory.
-
setStyleFormattingFactory
Description copied from interface:CSSStyleSheetFactorySet a style formatting factory to format style serializations made with sheets created by this sheet factory.- Parameters:
factory- the style formatting factory.
-
setUserStyleSheet
Sets the CSS style sheet defined by the end user.The sheet in the supplied reader should contain user preferences, and will be appropriately merged with the other style sheets.
- Parameters:
url- the URL of the style sheet. Ifnull, the call is equivalent tosetUserStyleSheet(Reader).re- the reader with the user style sheet. Ifnull, a connection to the URL shall be opened. If both arguments arenull, the user style sheet shall be cleared.- Throws:
DOMException- if a problem is found parsing the sheet.IOException- if there is a problem opening the URL or reading the reader.
-
setUserStyleSheet
Sets the CSS style sheet defined by the end user.The sheet in the supplied reader should contain user preferences, and will be appropriately merged with the other style sheets.
- Parameters:
re- the reader with the user style sheet. Ifnull, the user style sheet shall be cleared.- Throws:
DOMException- if a problem is found parsing the sheet.IOException- if there is a problem retrieving the reader.
-
getUserImportantStyleSheet
Description copied from class:AbstractCSSStyleSheetFactoryGet the priority-important part of the user style sheet, i.e. the style sheet with the declarations ofimportantpriority.- Specified by:
getUserImportantStyleSheetin classAbstractCSSStyleSheetFactory- Returns:
- the important part of the user style sheet.
-
getUserNormalStyleSheet
Description copied from class:AbstractCSSStyleSheetFactoryGet the normal part of the user style sheet, i.e. the style sheet with the declarations of normal priority.- Specified by:
getUserNormalStyleSheetin classAbstractCSSStyleSheetFactory- Returns:
- the normal part of the user style sheet.
-
htmlDefaultSheet
Returns a default user agent style sheet for (X)HTML documents, strict mode.- Returns:
- the default style sheet for HTML.
- Throws:
IllegalStateException- if a problem arose when reading the default sheet.
-
htmlQuirksDefaultSheet
Returns a default user agent style sheet for (X)HTML documents, quirks mode.- Returns:
- the default style sheet for HTML.
- Throws:
IllegalStateException- if a problem arose when reading the default sheet.
-
getValueFactory
Description copied from class:AbstractCSSStyleSheetFactoryGet a value factory set to the appropriate flags.- Specified by:
getValueFactoryin classAbstractCSSStyleSheetFactory- Returns:
- the value factory.
-
setFactoryFlag
public void setFactoryFlag(short flag) Description copied from interface:CSSStyleSheetFactorySet a configuration flag. Do not confuse with NSAC flags, which must be set at this object's creation time (see the documentation for implementation's constructors).The flags are implementation-dependent.
- Parameters:
flag- the flag to set.
-
hasFactoryFlag
protected boolean hasFactoryFlag(short flag) Description copied from class:AbstractCSSStyleSheetFactoryCheck whether the given factory flag is set.- Specified by:
hasFactoryFlagin classAbstractCSSStyleSheetFactory- Parameters:
flag- the flag.- Returns:
trueif the flag is set.
-
setLenientSystemValues
public void setLenientSystemValues(boolean lenient) The style sheet factories provide system default values, and its behaviour depends on a
lenientSystemValuesflag. The lenient flag allows to compute values by giving reasonable defaults to properties with system-dependent initial values: '#000000' for color and 'serif' for font-family.If you work with style databases you do not need
lenientSystemValues.Default value is
true.- Parameters:
lenient-trueorfalseto enable/disable thelenientSystemValuesflag.
-
getSystemDefaultValue
Get a system default value for the given property.If the
lenientSystemValuesflag is set, returns a reasonable default for the property. Otherwise, it returns a system default meta-value.- Specified by:
getSystemDefaultValuein interfaceCSSStyleSheetFactory- Specified by:
getSystemDefaultValuein classAbstractCSSStyleSheetFactory- Parameters:
propertyName- the property name.- Returns:
- the system default css primitive value.
-
createSACParser
Description copied from class:AbstractCSSStyleSheetFactoryCreate a NSAC Parser with the proper flags enabled.- Specified by:
createSACParserin classAbstractCSSStyleSheetFactory- Returns:
- the NSAC parser.
-
getParserFlags
Get the parser flags that should be used by NSAC parsers.- Specified by:
getParserFlagsin classAbstractCSSStyleSheetFactory- Returns:
- the NSAC parser flags.
-
setFlag
Set the given parser flag.- Specified by:
setFlagin classAbstractCSSStyleSheetFactory- Parameters:
flag- the flag.- Returns:
trueif the flag was newly set,falseif the flag was already set.
-
unsetFlag
Unset the given parser flag.- Specified by:
unsetFlagin classAbstractCSSStyleSheetFactory- Parameters:
flag- the flag.- Returns:
trueif the flag was unset,falseif the flag was not set.
-
hasCompatValueFlags
protected boolean hasCompatValueFlags()Description copied from class:AbstractCSSStyleSheetFactoryCheck for Internet Explorer legacy compatibility value flags.- Specified by:
hasCompatValueFlagsin classAbstractCSSStyleSheetFactory- Returns:
trueif the factory has any compatibility value flags set (note:STARHACKis not considered a value flag).
-
createInlineStyleErrorHandler
Description copied from interface:CSSStyleSheetFactoryCreate a new StyleDeclarationErrorHandler for the given style rule.- Parameters:
owner- the element owner of the inline style.- Returns:
- the StyleDeclarationErrorHandler.
-
createStyleDeclarationErrorHandler
Create a new StyleDeclarationErrorHandler for the given style rule.- Parameters:
rule- the declaration rule the handler is for.- Returns:
- the StyleDeclarationErrorHandler.
-
createSheetErrorHandler
Creates a style sheet error handler.- Parameters:
sheet- the sheet that will be handled.- Returns:
- the error handler.
-
createMediaQueryList
public MediaQueryList createMediaQueryList(String mediaQueryString, Node owner) throws CSSBudgetException ParsesmediaQueryStringand creates a new media query list.- Parameters:
mediaQueryString- the media query string.owner- the node that would handle errors, if any.- Returns:
- a new media list for
mediaQueryString. - Throws:
CSSBudgetException- if a hard-coded limit in nested expressions was reached.
-
createImmutableMediaQueryList
public MediaQueryList createImmutableMediaQueryList(String media, Node owner) throws CSSBudgetException Parses and creates an unmodifiable media query list for the given media.- Parameters:
media- the comma-separated list of media. Ifnull, the media list will be for all media.owner- the node that would handle errors, if any.- Returns:
- the unmodifiable media list.
- Throws:
CSSBudgetException- if a hard-coded limit in nested expressions was reached.
-
getDeviceFactory
Gets the device factory.- Returns:
- the device factory.
-
setDeviceFactory
Sets the device factory.- Parameters:
deviceFactory- the device factory.
-