Package com.helger.css.decl
Class AbstractHasTopLevelRules
java.lang.Object
com.helger.css.decl.AbstractHasTopLevelRules
- Direct Known Subclasses:
CascadingStyleSheet,CSSMediaRule,CSSSupportsRule
Abstract base class for all classes having top-level rules.
- Since:
- 5.0.5
- Author:
- Philip Helger
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final com.helger.commons.collection.impl.ICommonsList<ICSSTopLevelRule> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddRule(int nIndex, ICSSTopLevelRule aRule) Add a new top-level rule at the specified index.addRule(ICSSTopLevelRule aRule) Add a new top-level rule at the end.com.helger.commons.collection.impl.ICommonsList<CSSFontFaceRule> Get a list of all top-level rules that are font-face rules (implementingCSSFontFaceRule).com.helger.commons.collection.impl.ICommonsList<CSSKeyframesRule> Get a list of all top-level rules that are keyframes rules (implementingCSSKeyframesRule).com.helger.commons.collection.impl.ICommonsList<CSSMediaRule> Get a list of all top-level rules that are media rules (implementingCSSMediaRule).com.helger.commons.collection.impl.ICommonsList<CSSPageRule> Get a list of all top-level rules that are page rules (implementingCSSPageRule).com.helger.commons.collection.impl.ICommonsList<ICSSTopLevelRule> Get a copy of all contained top-level rules.com.helger.commons.collection.impl.ICommonsList<ICSSTopLevelRule> getAllRules(Predicate<? super ICSSTopLevelRule> aFilter) Get a copy of all contained top-level rules.com.helger.commons.collection.impl.ICommonsList<CSSStyleRule> Get a list of all top-level rules that are style rules (implementingCSSStyleRule).com.helger.commons.collection.impl.ICommonsList<CSSSupportsRule> Get a list of all top-level rules that are support rules (implementingCSSSupportsRule).com.helger.commons.collection.impl.ICommonsList<CSSUnknownRule> Get a list of all top-level rules that are unknown rules (implementingCSSUnknownRule).com.helger.commons.collection.impl.ICommonsList<CSSViewportRule> Get a list of all top-level rules that are viewport rules (implementingCSSViewportRule).getFontFaceRuleAtIndex(int nIndex) Get the@font-facerule at the specified index.intGet the number of top-level rules that are font-face rules (implementingCSSFontFaceRule).getKeyframesRuleAtIndex(int nIndex) Get the@keyframesrule at the specified index.intGet the number of top-level rules that are keyframes rules (implementingCSSKeyframesRule).getMediaRuleAtIndex(int nIndex) Get the@mediarule at the specified index.intGet the number of top-level rules that are media rules (implementingCSSMediaRule).getPageRuleAtIndex(int nIndex) Get the@pagerule at the specified index.intGet the number of top-level rules that are page rules (implementingCSSPageRule).getRule(int nIndex) Deprecated.getRuleAtIndex(int nIndex) Get the top-level rule at the specified index.intGet the number of total contained top-level rules.getStyleRuleAtIndex(int nIndex) Get the style rule at the specified index.intGet the number of top-level rules that are style rules (implementingCSSStyleRule).getSupportsRuleAtIndex(int nIndex) Get the@supportsrule at the specified index.intGet the number of top-level rules that are support rules (implementingCSSSupportsRule).getUnknownRuleAtIndex(int nIndex) Get the unknown rule at the specified index.intGet the number of top-level rules that are unknown rules (implementingCSSUnknownRule).getViewportRuleAtIndex(int nIndex) Get the@viewportrule at the specified index.intGet the number of top-level rules that are viewport rules (implementingCSSViewportRule).booleanCheck if at least one of the top-level rules is a font-face rule (implementingCSSFontFaceRule).booleanCheck if at least one of the top-level rules is a keyframes rule (implementingCSSKeyframesRule).booleanCheck if at least one of the top-level rules is a media rule (implementingCSSMediaRule).booleanCheck if at least one of the top-level rules is a page rule (implementingCSSPageRule).booleanhasRules()Check if any top-level rule.booleanCheck if at least one of the top-level rules is a style rule (implementingCSSStyleRule).booleanCheck if at least one of the top-level rules is a supports rule (implementingCSSSupportsRule).booleanCheck if at least one of the top-level rules is an unknown rule (implementingCSSUnknownRule).booleanCheck if at least one of the top-level rules is a viewport rule (implementingCSSViewportRule).com.helger.commons.state.EChangeRemove all top-level rules.com.helger.commons.state.EChangeremoveRule(int nRuleIndex) Remove the rule at the specified index.com.helger.commons.state.EChangeremoveRule(ICSSTopLevelRule aRule) Remove the specified top-level rule.com.helger.commons.state.EChangeremoveRules(Predicate<? super ICSSTopLevelRule> aFilter) Remove all rules matching the passed predicate.
-
Field Details
-
m_aRules
-
-
Constructor Details
-
AbstractHasTopLevelRules
public AbstractHasTopLevelRules()
-
-
Method Details
-
hasRules
public boolean hasRules()Check if any top-level rule. This method only considers top-level rules and not@importand@namespacerules!- Returns:
trueif at least one top-level rule is present,falseif otherwise.
-
getRuleCount
Get the number of total contained top-level rules. This method only considers top-level rules and not@importand@namespacerules!- Returns:
- The number of total contained top-level rules. Always ≥ 0.
-
getRule
Deprecated.UsegetRuleAtIndex(int)insteadGet the top-level rule at the specified index.- Parameters:
nIndex- The index to be resolved. Should be ≥ 0 and <getRuleCount().- Returns:
nullif an invalid index was specified.- Since:
- 3.7.4
-
getRuleAtIndex
Get the top-level rule at the specified index.- Parameters:
nIndex- The index to be resolved. Should be ≥ 0 and <getRuleCount().- Returns:
nullif an invalid index was specified.- Since:
- 3.7.4
-
addRule
Add a new top-level rule at the end. This method only considers top-level rules and not@importand@namespacerules!- Parameters:
aRule- The rule to be added. May not benull.- Returns:
- this
-
addRule
@Nonnull public AbstractHasTopLevelRules addRule(@Nonnegative int nIndex, @Nonnull ICSSTopLevelRule aRule) Add a new top-level rule at the specified index. This method only considers top-level rules and not@importand@namespacerules!- Parameters:
nIndex- The index where the top-level rule should be added. Must be ≥ 0.aRule- The rule to be added. May not benull.- Returns:
- this
-
removeRule
Remove the specified top-level rule. This method only considers top-level rules and not@importand@namespacerules!- Parameters:
aRule- The rule to be removed. May benull.- Returns:
EChange.CHANGEDif the rule was successfully removed,EChange.UNCHANGEDotherwise. Nevernull.
-
removeRule
Remove the rule at the specified index. This method only considers top-level rules and not@importand@namespacerules!- Parameters:
nRuleIndex- The index of the rule to be removed. Should be ≥ 0.- Returns:
EChange.CHANGEDif the rule at the specified index was successfully removed,EChange.UNCHANGEDotherwise. Nevernull.
-
removeRules
@Nonnull public com.helger.commons.state.EChange removeRules(@Nonnull Predicate<? super ICSSTopLevelRule> aFilter) Remove all rules matching the passed predicate.- Parameters:
aFilter- The predicate to apply for deletion. May not benull.- Returns:
EChange.CHANGEDit at least one rule was removed,EChange.UNCHANGEDotherwise.- Since:
- 5.0.0
-
removeAllRules
Remove all top-level rules.- Returns:
EChange.CHANGEDif any rule was removed,EChange.UNCHANGEDotherwise. Nevernull.- Since:
- 3.7.3
-
getAllRules
@Nonnull @ReturnsMutableCopy public com.helger.commons.collection.impl.ICommonsList<ICSSTopLevelRule> getAllRules()Get a copy of all contained top-level rules. This method only considers top-level rules and not@importand@namespacerules!- Returns:
- A copy of all contained top-level rules. Never
null.
-
getAllRules
@Nonnull @ReturnsMutableCopy public com.helger.commons.collection.impl.ICommonsList<ICSSTopLevelRule> getAllRules(@Nonnull Predicate<? super ICSSTopLevelRule> aFilter) Get a copy of all contained top-level rules. This method only considers top-level rules and not@importand@namespacerules!- Parameters:
aFilter- The predicate to be applied- Returns:
- A copy of all contained top-level rules. Never
null.
-
hasStyleRules
public boolean hasStyleRules()Check if at least one of the top-level rules is a style rule (implementingCSSStyleRule).- Returns:
trueif at least one style rule is contained,falseotherwise.
-
getStyleRuleCount
Get the number of top-level rules that are style rules (implementingCSSStyleRule).- Returns:
- The number of contained style rules. Always ≥ 0.
-
getStyleRuleAtIndex
Get the style rule at the specified index.- Parameters:
nIndex- The index to be resolved. Should be ≥ 0 and <getStyleRuleCount().- Returns:
nullif an invalid index was specified.- Since:
- 3.7.4
-
getAllStyleRules
@Nonnull @ReturnsMutableCopy public com.helger.commons.collection.impl.ICommonsList<CSSStyleRule> getAllStyleRules()Get a list of all top-level rules that are style rules (implementingCSSStyleRule).- Returns:
- A copy of all contained style rules. Never
null.
-
hasPageRules
public boolean hasPageRules()Check if at least one of the top-level rules is a page rule (implementingCSSPageRule).- Returns:
trueif at least one@pagerule is contained,falseotherwise.
-
getPageRuleCount
Get the number of top-level rules that are page rules (implementingCSSPageRule).- Returns:
- The number of contained
@pagerules. Always ≥ 0.
-
getPageRuleAtIndex
Get the@pagerule at the specified index.- Parameters:
nIndex- The index to be resolved. Should be ≥ 0 and <getPageRuleCount().- Returns:
nullif an invalid index was specified.- Since:
- 3.7.4
-
getAllPageRules
@Nonnull @ReturnsMutableCopy public com.helger.commons.collection.impl.ICommonsList<CSSPageRule> getAllPageRules()Get a list of all top-level rules that are page rules (implementingCSSPageRule).- Returns:
- A copy of all contained
@pagerules. Nevernull.
-
hasMediaRules
public boolean hasMediaRules()Check if at least one of the top-level rules is a media rule (implementingCSSMediaRule).- Returns:
trueif at least one@mediarule is contained,falseotherwise.
-
getMediaRuleCount
Get the number of top-level rules that are media rules (implementingCSSMediaRule).- Returns:
- The number of contained
@mediarules. Always ≥ 0.
-
getMediaRuleAtIndex
Get the@mediarule at the specified index.- Parameters:
nIndex- The index to be resolved. Should be ≥ 0 and <getMediaRuleCount().- Returns:
nullif an invalid index was specified.- Since:
- 3.7.4
-
getAllMediaRules
@Nonnull @ReturnsMutableCopy public com.helger.commons.collection.impl.ICommonsList<CSSMediaRule> getAllMediaRules()Get a list of all top-level rules that are media rules (implementingCSSMediaRule).- Returns:
- A copy of all contained
@mediarules. Nevernull.
-
hasFontFaceRules
public boolean hasFontFaceRules()Check if at least one of the top-level rules is a font-face rule (implementingCSSFontFaceRule).- Returns:
trueif at least one@font-facerule is contained,falseotherwise.
-
getFontFaceRuleCount
Get the number of top-level rules that are font-face rules (implementingCSSFontFaceRule).- Returns:
- The number of contained
@font-facerules. Always ≥ 0.
-
getFontFaceRuleAtIndex
Get the@font-facerule at the specified index.- Parameters:
nIndex- The index to be resolved. Should be ≥ 0 and <getFontFaceRuleCount().- Returns:
nullif an invalid index was specified.- Since:
- 3.7.4
-
getAllFontFaceRules
@Nonnull @ReturnsMutableCopy public com.helger.commons.collection.impl.ICommonsList<CSSFontFaceRule> getAllFontFaceRules()Get a list of all top-level rules that are font-face rules (implementingCSSFontFaceRule).- Returns:
- A copy of all contained
@font-facerules. Nevernull.
-
hasKeyframesRules
public boolean hasKeyframesRules()Check if at least one of the top-level rules is a keyframes rule (implementingCSSKeyframesRule).- Returns:
trueif at least one@keyframesrule is contained,falseotherwise.
-
getKeyframesRuleCount
Get the number of top-level rules that are keyframes rules (implementingCSSKeyframesRule).- Returns:
- The number of contained
@keyframesrules. Always ≥ 0.
-
getKeyframesRuleAtIndex
Get the@keyframesrule at the specified index.- Parameters:
nIndex- The index to be resolved. Should be ≥ 0 and <getKeyframesRuleCount().- Returns:
nullif an invalid index was specified.- Since:
- 3.7.4
-
getAllKeyframesRules
@Nonnull @ReturnsMutableCopy public com.helger.commons.collection.impl.ICommonsList<CSSKeyframesRule> getAllKeyframesRules()Get a list of all top-level rules that are keyframes rules (implementingCSSKeyframesRule).- Returns:
- A copy of all contained
@keyframesrules. Nevernull.
-
hasViewportRules
public boolean hasViewportRules()Check if at least one of the top-level rules is a viewport rule (implementingCSSViewportRule).- Returns:
trueif at least one@viewportrule is contained,falseotherwise.
-
getViewportRuleCount
Get the number of top-level rules that are viewport rules (implementingCSSViewportRule).- Returns:
- The number of contained
@viewportrules. Always ≥ 0.
-
getViewportRuleAtIndex
Get the@viewportrule at the specified index.- Parameters:
nIndex- The index to be resolved. Should be ≥ 0 and <getViewportRuleCount().- Returns:
nullif an invalid index was specified.- Since:
- 3.7.4
-
getAllViewportRules
@Nonnull @ReturnsMutableCopy public com.helger.commons.collection.impl.ICommonsList<CSSViewportRule> getAllViewportRules()Get a list of all top-level rules that are viewport rules (implementingCSSViewportRule).- Returns:
- A copy of all contained
@viewportrules. Nevernull.
-
hasSupportsRules
public boolean hasSupportsRules()Check if at least one of the top-level rules is a supports rule (implementingCSSSupportsRule).- Returns:
trueif at least one@supportsrule is contained,falseotherwise.
-
getSupportsRuleCount
Get the number of top-level rules that are support rules (implementingCSSSupportsRule).- Returns:
- The number of contained
@supportsrules. Always ≥ 0.
-
getSupportsRuleAtIndex
Get the@supportsrule at the specified index.- Parameters:
nIndex- The index to be resolved. Should be ≥ 0 and <getSupportsRuleCount().- Returns:
nullif an invalid index was specified.- Since:
- 3.7.4
-
getAllSupportsRules
@Nonnull @ReturnsMutableCopy public com.helger.commons.collection.impl.ICommonsList<CSSSupportsRule> getAllSupportsRules()Get a list of all top-level rules that are support rules (implementingCSSSupportsRule).- Returns:
- A copy of all contained
@supportsrules. Nevernull.
-
hasUnknownRules
public boolean hasUnknownRules()Check if at least one of the top-level rules is an unknown rule (implementingCSSUnknownRule).- Returns:
trueif at least one unknown@rule is contained,falseotherwise.
-
getUnknownRuleCount
Get the number of top-level rules that are unknown rules (implementingCSSUnknownRule).- Returns:
- The number of contained unknown
@rules. Always ≥ 0.
-
getUnknownRuleAtIndex
Get the unknown rule at the specified index.- Parameters:
nIndex- The index to be resolved. Should be ≥ 0 and <getUnknownRuleCount().- Returns:
nullif an invalid index was specified.- Since:
- 3.7.4
-
getAllUnknownRules
@Nonnull @ReturnsMutableCopy public com.helger.commons.collection.impl.ICommonsList<CSSUnknownRule> getAllUnknownRules()Get a list of all top-level rules that are unknown rules (implementingCSSUnknownRule).- Returns:
- A copy of all contained unknown
@rules. Nevernull.
-
getRuleAtIndex(int)instead