- All Implemented Interfaces:
ExtendedCSSStyleSheet<AbstractCSSRule>
,Cloneable
,CSSStyleSheet
,StyleSheet
- Direct Known Subclasses:
BaseCSSStyleSheet
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionabstract 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
abstract CSSStyleDeclarationRule
Create a CSS style rule.abstract SupportsRule
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.protected 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 AbstractCSSStyleSheetFactory
Get the style sheet factory used to produce this sheet.protected abstract boolean
Has this style sheet defined a default namespace ?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
(InputSource source) Parses a style sheet.abstract boolean
parseStyleSheet
(InputSource source, boolean ignoreComments) Parses a style sheet.protected abstract void
registerNamespace
(CSSNamespaceRule nsrule) abstract void
protected abstract void
protected abstract void
unregisterNamespace
(String namespaceURI) 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 org.w3c.dom.css.CSSStyleSheet
deleteRule, insertRule
Methods inherited from interface io.sf.carte.doc.style.css.ExtendedCSSStyleSheet
addRule, createCounterStyleRule, createFontFeatureValuesRule, createKeyframesRule, createMarginRule, createNamespaceRule, getErrorHandler, getMedia, getRulesForProperty, getSelectorsForProperty, hasRuleErrorsOrWarnings
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:ExtendedCSSStyleSheet
Gets the collection of all CSS rules contained within the style sheet.- Specified by:
getCssRules
in interfaceCSSStyleSheet
- Specified by:
getCssRules
in interfaceExtendedCSSStyleSheet<AbstractCSSRule>
- 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:ExtendedCSSStyleSheet
Get the style sheet factory used to produce this sheet.- Specified by:
getStyleSheetFactory
in interfaceExtendedCSSStyleSheet<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 preceding a rule will be available through
AbstractCSSRule.getPrecedingComments()
.To create a sheet, see
CSSStyleSheetFactory.createStyleSheet(String,MediaQueryList)
- Specified by:
parseStyleSheet
in interfaceExtendedCSSStyleSheet<AbstractCSSRule>
- Parameters:
source
- the SAC input source.- Returns:
true
if the SAC 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(InputSource source, boolean ignoreComments) 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
ignoreComments
is false, the comments preceding a rule will be available throughAbstractCSSRule.getPrecedingComments()
.This method resets the state of this sheet's error handler.
To create a sheet, see
CSSStyleSheetFactory.createStyleSheet(String,MediaQueryList)
- Specified by:
parseStyleSheet
in interfaceExtendedCSSStyleSheet<AbstractCSSRule>
- Parameters:
source
- the SAC input source.ignoreComments
- true if comments have to be ignored.- Returns:
true
if the SAC 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:
addStyleSheet
in interfaceExtendedCSSStyleSheet<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 SAC parser reported no errors or fatal errors,false
otherwise.- Throws:
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:ExtendedCSSStyleSheet
Create a CSS Font Face rule compatible with this implementation.- Specified by:
createFontFaceRule
in interfaceExtendedCSSStyleSheet<AbstractCSSRule>
- Returns:
- a CSS Font Face rule object.
-
createImportRule
Description copied from interface:ExtendedCSSStyleSheet
Create a CSS import rule compatible with this implementation.- Specified by:
createImportRule
in interfaceExtendedCSSStyleSheet<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:ExtendedCSSStyleSheet
Create a CSS media rule.- Specified by:
createMediaRule
in interfaceExtendedCSSStyleSheet<AbstractCSSRule>
- Parameters:
mediaList
- a list of media types for the new rule.- Returns:
- a CSS media rule.
-
createPageRule
Description copied from interface:ExtendedCSSStyleSheet
Create a CSS page rule compatible with this implementation.- Specified by:
createPageRule
in interfaceExtendedCSSStyleSheet<AbstractCSSRule>
- Returns:
- a CSS page rule.
-
createStyleRule
Description copied from interface:ExtendedCSSStyleSheet
Create a CSS style rule.- Specified by:
createStyleRule
in interfaceExtendedCSSStyleSheet<AbstractCSSRule>
- Returns:
- a CSS style rule.
-
createSupportsRule
Description copied from interface:ExtendedCSSStyleSheet
Create a CSSSupportsRule compatible with this implementation.- Specified by:
createSupportsRule
in interfaceExtendedCSSStyleSheet<AbstractCSSRule>
- Returns:
- a CSSSupportsRule object.
-
createUnknownRule
Description copied from interface:ExtendedCSSStyleSheet
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 interfaceExtendedCSSStyleSheet<AbstractCSSRule>
- Returns:
- a CSS unknown rule.
-
createViewportRule
Description copied from interface:ExtendedCSSStyleSheet
Create a CSSViewportRule compatible with this implementation.- Specified by:
createViewportRule
in interfaceExtendedCSSStyleSheet<AbstractCSSRule>
- Returns:
- a CSSViewportRule object.
-
createStyleDeclaration
Description copied from interface:ExtendedCSSStyleSheet
Create a CSS style declaration compatible with this implementation.- Specified by:
createStyleDeclaration
in interfaceExtendedCSSStyleSheet<AbstractCSSRule>
- Returns:
- a CSS style declaration.
-
createStyleDeclaration
-
registerNamespace
-
unregisterNamespace
-
getNamespacePrefix
Gets the namespace prefix associated to the given URI.- Parameters:
uri
- the namespace URI string.- Returns:
- the namespace prefix, or null if the URI is not known.
-
hasDefaultNamespace
protected abstract boolean hasDefaultNamespace()Has this style sheet defined a default namespace ?- Returns:
true
if a default namespace was defined,false
otherwise.
-
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 interfaceExtendedCSSStyleSheet<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.
-
setParentStyleSheet
-
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.
-