- All Implemented Interfaces:
CSSStyleSheet<AbstractCSSRule>
,SheetContext
,Serializable
,Cloneable
,CSSStyleSheet
,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
-
Method Summary
Modifier and TypeMethodDescriptionabstract void
Accept a declaration rule visitor.abstract void
Accept a descriptor rule visitor.abstract void
acceptStyleRuleVisitor
(Visitor<CSSStyleRule> visitor) Accept a style rule visitor.abstract void
Adds the rules contained by the supplied style sheet, if that sheet is not disabled.abstract AbstractCSSStyleSheet
clone()
Clone this style sheet.abstract FontFaceRule
Create a CSS Font Face rule compatible with this implementation.abstract ImportRule
createImportRule
(MediaQueryList mediaList, String href) Create a CSS import rule compatible with this implementation.abstract MediaRule
createMediaRule
(MediaQueryList mediaList) Create a CSS media rule.abstract PageRule
Create a CSS page rule compatible with this implementation.abstract AbstractCSSStyleDeclaration
Create a CSS style declaration compatible with this implementation.protected abstract AbstractCSSStyleDeclaration
Create a style declaration from the given declaration rule.abstract StyleRule
Create a CSS style rule.abstract SupportsRule
Deprecated.abstract SupportsRule
createSupportsRule
(BooleanCondition condition) Create a CSSSupportsRule compatible with this implementation.abstract SupportsRule
createSupportsRule
(String conditionText) Create a CSSSupportsRule compatible with this implementation.abstract UnknownRule
Create a CSS unknown rule.abstract ViewportRule
Create a CSSViewportRule compatible with this implementation.abstract CSSRuleArrayList
Gets the collection of all CSS rules contained within the style sheet.abstract StyleRule
getFirstStyleRule
(SelectorList selectorList) Get the first style rule that exactly matches the given selector list, if any.abstract String
getNamespacePrefix
(String uri) Gets the namespace prefix associated to the given URI.abstract byte
Get the origin of this sheet.abstract AbstractCSSRule
abstract AbstractCSSStyleSheet
abstract CSSRuleArrayList
getStyleRules
(Selector selector) Get the list of style rules that match the given selector.abstract AbstractCSSStyleSheetFactory
Get the style sheet factory used to produce this sheet.abstract boolean
Has this style sheet defined a default namespace ?boolean
hasFactoryFlag
(short flag) Check whether the given factory flag is set.abstract boolean
loadStyleSheet
(URL url, String referrerPolicy) Load the styles fromurl
into this style sheet.openConnection
(URL url, String referrerPolicy) Open a non-interactive connection to the given URL.static byte
parseRelAttribute
(String relText) Parses therel
attribute.abstract boolean
parseStyleSheet
(Reader reader) Parses a style sheet.abstract boolean
parseStyleSheet
(Reader reader, short commentMode) Parses a style sheet.protected abstract void
registerNamespace
(CSSNamespaceRule nsrule) Register the namespace from the given namespace rule.abstract void
protected abstract void
Sets the parent style sheet.protected abstract void
unregisterNamespace
(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, toStyleString
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface io.sf.carte.doc.style.css.CSSStyleSheet
addRule, createCounterStyleRule, createFontFeatureValuesRule, createKeyframesRule, createMarginRule, createNamespaceRule, createPropertyRule, getErrorHandler, getMedia, getRulesForProperty, getSelectorsForProperty, hasRuleErrorsOrWarnings
Methods inherited from interface org.w3c.dom.css.CSSStyleSheet
deleteRule, insertRule
Methods inherited from interface org.w3c.dom.stylesheets.StyleSheet
getDisabled, getHref, getOwnerNode, getTitle, getType, setDisabled
-
Constructor Details
-
AbstractCSSStyleSheet
-
-
Method Details
-
getCssRules
Description copied from interface:CSSStyleSheet
Gets the collection of all CSS rules contained within the style sheet.- Specified by:
getCssRules
in interfaceCSSStyleSheet<AbstractCSSRule>
- Specified by:
getCssRules
in interfaceCSSStyleSheet
- Returns:
- the list of all CSS rules contained within the style sheet.
-
getParentStyleSheet
- Specified by:
getParentStyleSheet
in interfaceStyleSheet
-
getOwnerRule
- Specified by:
getOwnerRule
in interfaceCSSStyleSheet
-
getStyleSheetFactory
Description copied from interface:CSSStyleSheet
Get the style sheet factory used to produce this sheet.- Specified by:
getStyleSheetFactory
in 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:
parseStyleSheet
in interfaceCSSStyleSheet<AbstractCSSRule>
- Parameters:
reader
- the character stream containing the CSS sheet.- Returns:
true
if the NSAC parser reported no errors or fatal errors, false otherwise.- Throws:
DOMException
- if raised by the error handler.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
commentMode
is notCOMMENTS_IGNORE
, the comments preceding a rule shall be available throughCSSRule.getPrecedingComments()
, and ifCOMMENTS_AUTO
was 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:
parseStyleSheet
in interfaceCSSStyleSheet<AbstractCSSRule>
- Parameters:
reader
- the character stream containing the CSS sheet.commentMode
-0
if comments have to be ignored,1
if all comments are considered as preceding a rule,2
if the parser should try to figure out which comments are preceding and trailing a rule (auto mode).- Returns:
true
if the NSAC parser reported no errors or fatal errors, false otherwise.- Throws:
DOMException
- if raised by the error handler.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:
addStyleSheet
in 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 fromurl
into this style sheet.- Parameters:
url
- the url to load the style sheet from.referrerPolicy
- the content of thereferrerpolicy
content attribute, if any, or the empty string.- Returns:
true
if the NSAC parser reported no errors or fatal errors,false
otherwise.- 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:CSSStyleSheet
Create a CSS Font Face rule compatible with this implementation.- Specified by:
createFontFaceRule
in interfaceCSSStyleSheet<AbstractCSSRule>
- Returns:
- a CSS Font Face rule object.
-
createImportRule
Description copied from interface:CSSStyleSheet
Create a CSS import rule compatible with this implementation.- Specified by:
createImportRule
in 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:CSSStyleSheet
Create a CSS media rule.- Specified by:
createMediaRule
in interfaceCSSStyleSheet<AbstractCSSRule>
- Parameters:
mediaList
- a list of media types for the new rule.- Returns:
- a CSS media rule.
-
createPageRule
Description copied from interface:CSSStyleSheet
Create a CSS page rule compatible with this implementation.- Specified by:
createPageRule
in interfaceCSSStyleSheet<AbstractCSSRule>
- Returns:
- a CSS page rule.
-
createStyleRule
Description copied from interface:CSSStyleSheet
Create a CSS style rule.- Specified by:
createStyleRule
in interfaceCSSStyleSheet<AbstractCSSRule>
- Returns:
- a CSS style rule.
-
createSupportsRule
Description copied from interface:CSSStyleSheet
Create a CSSSupportsRule compatible with this implementation.- Specified by:
createSupportsRule
in interfaceCSSStyleSheet<AbstractCSSRule>
- Parameters:
conditionText
- a serialization of the@supports
condition.- Returns:
- a CSSSupportsRule object.
- Throws:
DOMException
- if the condition text could not be parsed.
-
createSupportsRule
Description copied from interface:CSSStyleSheet
Create a CSSSupportsRule compatible with this implementation.- Specified by:
createSupportsRule
in interfaceCSSStyleSheet<AbstractCSSRule>
- Parameters:
condition
- the@supports
condition.- Returns:
- a CSSSupportsRule object.
-
createSupportsRule
Deprecated.Description copied from interface:CSSStyleSheet
Create a CSSSupportsRule compatible with this implementation.- Specified by:
createSupportsRule
in interfaceCSSStyleSheet<AbstractCSSRule>
- Returns:
- a CSSSupportsRule object.
-
createUnknownRule
Description copied from interface:CSSStyleSheet
Create 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:
createUnknownRule
in interfaceCSSStyleSheet<AbstractCSSRule>
- Returns:
- a CSS unknown rule.
-
createViewportRule
Description copied from interface:CSSStyleSheet
Create a CSSViewportRule compatible with this implementation.- Specified by:
createViewportRule
in interfaceCSSStyleSheet<AbstractCSSRule>
- Returns:
- a CSSViewportRule object.
-
createStyleDeclaration
Description copied from interface:CSSStyleSheet
Create a CSS style declaration compatible with this implementation.- Specified by:
createStyleDeclaration
in 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.- Specified by:
getNamespacePrefix
in interfaceSheetContext
- Parameters:
uri
- the namespace URI string.- Returns:
- the namespace prefix.
-
hasDefaultNamespace
public abstract boolean hasDefaultNamespace()Has this style sheet defined a default namespace ?- Specified by:
hasDefaultNamespace
in interfaceSheetContext
- Returns:
true
if a default namespace was defined,false
otherwise.
-
hasFactoryFlag
public boolean hasFactoryFlag(short flag) Description copied from interface:SheetContext
Check whether the given factory flag is set.- Specified by:
hasFactoryFlag
in interfaceSheetContext
- Parameters:
flag
- the flag.- Returns:
true
if the flag is set.
-
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:
clone
in interfaceCSSStyleSheet<AbstractCSSRule>
- Specified by:
clone
in classAbstractStyleSheet
- Returns:
- the cloned style sheet.
-
openConnection
Description copied from class:AbstractStyleSheet
Open 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:
openConnection
in classAbstractStyleSheet
- Parameters:
url
- the URL to connect to.referrerPolicy
- the content of thereferrerpolicy
content 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
null
if 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
null
if none.
-
acceptStyleRuleVisitor
Accept a style rule visitor.- Parameters:
visitor
- the visitor.
-
acceptDeclarationRuleVisitor
Accept a declaration rule visitor.- Parameters:
visitor
- the visitor.
-
acceptDescriptorRuleVisitor
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 therel
attribute.- Parameters:
relText
- therel
attribute.- Returns:
- 0 if
rel
refers to a style sheet, 1 if the sheet is alternate, -1 if it is not compatible with a style sheet.
-