Class AbstractCSSStyleSheet
- All Implemented Interfaces:
CSSStyleSheet<AbstractCSSRule>,Serializable,Cloneable,org.w3c.dom.css.CSSStyleSheet,org.w3c.dom.stylesheets.StyleSheet
- Direct Known Subclasses:
BaseCSSStyleSheet
- See Also:
-
Field Summary
Fields inherited from interface io.sf.carte.doc.style.css.CSSStyleSheet
COMMENTS_AUTO, COMMENTS_IGNORE, COMMENTS_PRECEDING -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract voidacceptDeclarationRuleVisitor(io.sf.carte.util.Visitor<CSSDeclarationRule> visitor) Accept a declaration rule visitor.abstract voidacceptDescriptorRuleVisitor(io.sf.carte.util.Visitor<CSSDeclarationRule> visitor) Accept a descriptor rule visitor.abstract voidacceptStyleRuleVisitor(io.sf.carte.util.Visitor<CSSStyleRule> visitor) Accept a style rule visitor.abstract voidAdds the rules contained by the supplied style sheet, if that sheet is not disabled.abstract AbstractCSSStyleSheetclone()Clone this style sheet.abstract FontFaceRuleCreate a CSS Font Face rule compatible with this implementation.abstract ImportRulecreateImportRule(MediaQueryList mediaList, String href) Create a CSS import rule compatible with this implementation.abstract MediaRulecreateMediaRule(MediaQueryList mediaList) Create a CSS media rule.abstract PageRuleCreate a CSS page rule compatible with this implementation.abstract AbstractCSSStyleDeclarationCreate a CSS style declaration compatible with this implementation.protected abstract AbstractCSSStyleDeclarationCreate a style declaration from the given declaration rule.abstract StyleRuleCreate a CSS style rule.abstract SupportsRuleCreate a CSSSupportsRule compatible with this implementation.abstract UnknownRuleCreate a CSS unknown rule.abstract ViewportRuleCreate a CSSViewportRule compatible with this implementation.abstract CSSRuleArrayListGets the collection of all CSS rules contained within the style sheet.abstract StyleRulegetFirstStyleRule(SelectorList selectorList) Get the first style rule that exactly matches the given selector list, if any.protected abstract StringgetNamespacePrefix(String uri) Gets the namespace prefix associated to the given URI.abstract byteGet the origin of this sheet.abstract AbstractCSSRuleabstract AbstractCSSStyleSheetabstract CSSRuleArrayListgetStyleRules(Selector selector) Get the list of style rules that match the given selector.abstract AbstractCSSStyleSheetFactoryGet the style sheet factory used to produce this sheet.protected abstract booleanHas this style sheet defined a default namespace ?abstract booleanloadStyleSheet(URL url, String referrerPolicy) Load the styles fromurlinto this style sheet.openConnection(URL url, String referrerPolicy) Open a non-interactive connection to the given URL.static byteparseRelAttribute(String relText) Parses therelattribute.abstract booleanparseStyleSheet(Reader reader) Parses a style sheet.abstract booleanparseStyleSheet(Reader reader, short commentMode) Parses a style sheet.protected abstract voidregisterNamespace(CSSNamespaceRule nsrule) Register the namespace from the given namespace rule.abstract voidprotected abstract voidSets the parent style sheet.protected abstract voidunregisterNamespace(String namespaceURI) Unregister the namespace corresponding to the given namespace URI.Methods inherited from class io.sf.carte.doc.style.css.om.AbstractStyleSheet
getDocumentErrorHandler, getTitle, setMedia, setTitle, toMinifiedString, toStyleStringMethods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.sf.carte.doc.style.css.CSSStyleSheet
addRule, createCounterStyleRule, createFontFeatureValuesRule, createKeyframesRule, createMarginRule, createNamespaceRule, createPropertyRule, getErrorHandler, getMedia, getRulesForProperty, getSelectorsForProperty, hasRuleErrorsOrWarningsMethods inherited from interface org.w3c.dom.css.CSSStyleSheet
deleteRule, insertRuleMethods inherited from interface org.w3c.dom.stylesheets.StyleSheet
getDisabled, getHref, getOwnerNode, getTitle, getType, setDisabled
-
Constructor Details
-
AbstractCSSStyleSheet
-
-
Method Details
-
getCssRules
Description copied from interface:CSSStyleSheetGets the collection of all CSS rules contained within the style sheet.- Specified by:
getCssRulesin interfaceCSSStyleSheet<AbstractCSSRule>- Specified by:
getCssRulesin interfaceorg.w3c.dom.css.CSSStyleSheet- Returns:
- the list of all CSS rules contained within the style sheet.
-
getParentStyleSheet
- Specified by:
getParentStyleSheetin interfaceorg.w3c.dom.stylesheets.StyleSheet
-
getOwnerRule
- Specified by:
getOwnerRulein interfaceorg.w3c.dom.css.CSSStyleSheet
-
getStyleSheetFactory
Description copied from interface:CSSStyleSheetGet the style sheet factory used to produce this sheet.- Specified by:
getStyleSheetFactoryin interfaceCSSStyleSheet<AbstractCSSRule>- Returns:
- the style sheet factory.
-
parseStyleSheet
Parses a style sheet.If the style sheet is not empty, the rules from the parsed source will be added at the end of the rule list, with the same origin as the rule with a highest precedence origin.
Even if a specific media is set at the
InputSource, this method does not alter the sheet's current media attribute.The comments shall be processed according to
CSSStyleSheet.COMMENTS_AUTO.To create a sheet, see
CSSStyleSheetFactory.createStyleSheet(String,MediaQueryList)- Specified by:
parseStyleSheetin interfaceCSSStyleSheet<AbstractCSSRule>- Parameters:
reader- the character stream containing the CSS sheet.- Returns:
trueif the NSAC parser reported no errors or fatal errors, false otherwise.- Throws:
DOMException- if a problem is found parsing the sheet.IOException- if a problem is found reading the sheet.
-
parseStyleSheet
public abstract boolean parseStyleSheet(Reader reader, short commentMode) throws DOMException, IOException Parses a style sheet.If the style sheet is not empty, the rules from the parsed source will be added at the end of the rule list, with the same origin as the rule with a highest precedence origin.
Even if a specific media is set at the
InputSource, this method does not alter the sheet's current media attribute.If
commentModeis notCOMMENTS_IGNORE, the comments preceding a rule shall be available throughCSSRule.getPrecedingComments(), and ifCOMMENTS_AUTOwas set also the trailing ones, through the methodCSSRule.getTrailingComments().This method resets the state of this sheet's error handler.
To create a sheet, see
CSSStyleSheetFactory.createStyleSheet(String,MediaQueryList)- Specified by:
parseStyleSheetin interfaceCSSStyleSheet<AbstractCSSRule>- Parameters:
reader- the character stream containing the CSS sheet.commentMode-0if comments have to be ignored,1if all comments are considered as preceding a rule,2if the parser should try to figure out which comments are preceding and trailing a rule (auto mode).- Returns:
trueif the NSAC parser reported no errors or fatal errors, false otherwise.- Throws:
DOMException- if a problem is found parsing the sheet.IOException- if a problem is found reading the sheet.
-
addStyleSheet
Adds the rules contained by the supplied style sheet, if that sheet is not disabled.If the provided sheet does not target all media, a media rule is created.
- Specified by:
addStyleSheetin interfaceCSSStyleSheet<AbstractCSSRule>- Parameters:
sheet- the sheet whose rules are to be added.
-
loadStyleSheet
public abstract boolean loadStyleSheet(URL url, String referrerPolicy) throws DOMException, IOException Load the styles fromurlinto this style sheet.- Parameters:
url- the url to load the style sheet from.referrerPolicy- the content of thereferrerpolicycontent attribute, if any, or the empty string.- Returns:
trueif the NSAC parser reported no errors or fatal errors,falseotherwise.- Throws:
DOMPolicyException- if the style sheet was served with an invalid content type.DOMException- if there is a serious problem parsing the style sheet.IOException- if a problem appears fetching the url contents.
-
createFontFaceRule
Description copied from interface:CSSStyleSheetCreate a CSS Font Face rule compatible with this implementation.- Specified by:
createFontFaceRulein interfaceCSSStyleSheet<AbstractCSSRule>- Returns:
- a CSS Font Face rule object.
-
createImportRule
Description copied from interface:CSSStyleSheetCreate a CSS import rule compatible with this implementation.- Specified by:
createImportRulein interfaceCSSStyleSheet<AbstractCSSRule>- Parameters:
mediaList- a list of media types for which the new import rule may be used.href- the URI from which to import the sheet.- Returns:
- a CSS import rule.
-
createMediaRule
Description copied from interface:CSSStyleSheetCreate a CSS media rule.- Specified by:
createMediaRulein interfaceCSSStyleSheet<AbstractCSSRule>- Parameters:
mediaList- a list of media types for the new rule.- Returns:
- a CSS media rule.
-
createPageRule
Description copied from interface:CSSStyleSheetCreate a CSS page rule compatible with this implementation.- Specified by:
createPageRulein interfaceCSSStyleSheet<AbstractCSSRule>- Returns:
- a CSS page rule.
-
createStyleRule
Description copied from interface:CSSStyleSheetCreate a CSS style rule.- Specified by:
createStyleRulein interfaceCSSStyleSheet<AbstractCSSRule>- Returns:
- a CSS style rule.
-
createSupportsRule
Description copied from interface:CSSStyleSheetCreate a CSSSupportsRule compatible with this implementation.- Specified by:
createSupportsRulein interfaceCSSStyleSheet<AbstractCSSRule>- Returns:
- a CSSSupportsRule object.
-
createUnknownRule
Description copied from interface:CSSStyleSheetCreate a CSS unknown rule.Its contents can be set with
CSSRule.setCssText(String). Be careful to set a text that is compatible with a CSS rule, with an ending semicolon or balanced curly brackets, otherwise its serialization may break the style sheet serialization.- Specified by:
createUnknownRulein interfaceCSSStyleSheet<AbstractCSSRule>- Returns:
- a CSS unknown rule.
-
createViewportRule
Description copied from interface:CSSStyleSheetCreate a CSSViewportRule compatible with this implementation.- Specified by:
createViewportRulein interfaceCSSStyleSheet<AbstractCSSRule>- Returns:
- a CSSViewportRule object.
-
createStyleDeclaration
Description copied from interface:CSSStyleSheetCreate a CSS style declaration compatible with this implementation.- Specified by:
createStyleDeclarationin interfaceCSSStyleSheet<AbstractCSSRule>- Returns:
- a CSS style declaration.
-
createStyleDeclaration
Create a style declaration from the given declaration rule.- Parameters:
rule- the declaration rule.- Returns:
- the style declaration.
-
registerNamespace
Register the namespace from the given namespace rule.- Parameters:
nsrule- the namespace rule.
-
unregisterNamespace
Unregister the namespace corresponding to the given namespace URI.- Parameters:
namespaceURI- the namespace URI.
-
getNamespacePrefix
Gets the namespace prefix associated to the given URI.- Parameters:
uri- the namespace URI string.- Returns:
- the namespace prefix.
-
hasDefaultNamespace
protected abstract boolean hasDefaultNamespace()Has this style sheet defined a default namespace ?- Returns:
trueif a default namespace was defined,falseotherwise.
-
setHref
-
getOrigin
public abstract byte getOrigin()Get the origin of this sheet.- Returns:
- the origin of this sheet.
-
clone
Clone this style sheet.- Specified by:
clonein interfaceCSSStyleSheet<AbstractCSSRule>- Specified by:
clonein classAbstractStyleSheet- Returns:
- the cloned style sheet.
-
openConnection
Description copied from class:AbstractStyleSheetOpen a non-interactive connection to the given URL.If this sheet was obtained through a network connection, the returned connection should be opened by the same user agent (and appropriate credentials) that retrieved this sheet.
- Specified by:
openConnectionin classAbstractStyleSheet- Parameters:
url- the URL to connect to.referrerPolicy- the content of thereferrerpolicycontent attribute, if any, or the empty string.- Returns:
- the network connection.
- Throws:
IOException- if an I/O problem occurs opening the connection.
-
getFirstStyleRule
Get the first style rule that exactly matches the given selector list, if any.Rules inside grouping rules are also searched.
- Parameters:
selectorList- the selector list.- Returns:
- the first style rule that matches, or
nullif none.
-
getStyleRules
Get the list of style rules that match the given selector.Rules inside grouping rules are also searched.
- Parameters:
selector- the selector.- Returns:
- the list of style rule that match, or
nullif none.
-
acceptStyleRuleVisitor
Accept a style rule visitor.- Parameters:
visitor- the visitor.
-
acceptDeclarationRuleVisitor
public abstract void acceptDeclarationRuleVisitor(io.sf.carte.util.Visitor<CSSDeclarationRule> visitor) Accept a declaration rule visitor.- Parameters:
visitor- the visitor.
-
acceptDescriptorRuleVisitor
public abstract void acceptDescriptorRuleVisitor(io.sf.carte.util.Visitor<CSSDeclarationRule> visitor) Accept a descriptor rule visitor.This method scans for declaration rules that declare descriptors.
- Parameters:
visitor- the visitor.
-
setParentStyleSheet
Sets the parent style sheet.- Parameters:
parent- the parent style sheet. Cannot benull.
-
parseRelAttribute
Parses therelattribute.- Parameters:
relText- therelattribute.- Returns:
- 0 if
relrefers to a style sheet, 1 if the sheet is alternate, -1 if it is not compatible with a style sheet.
-