Package com.helger.css.decl
Class AbstractHasTopLevelRules
- java.lang.Object
-
- com.helger.css.decl.AbstractHasTopLevelRules
-
- Direct Known Subclasses:
CascadingStyleSheet,CSSMediaRule,CSSSupportsRule
@NotThreadSafe public abstract class AbstractHasTopLevelRules extends Object
Abstract base class for all classes having top-level rules.- Since:
- 5.0.5
- Author:
- Philip Helger
-
-
Field Summary
Fields Modifier and Type Field Description protected com.helger.commons.collection.impl.ICommonsList<ICSSTopLevelRule>m_aRules
-
Constructor Summary
Constructors Constructor Description AbstractHasTopLevelRules()
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description AbstractHasTopLevelRulesaddRule(int nIndex, ICSSTopLevelRule aRule)Add a new top-level rule at the specified index.AbstractHasTopLevelRulesaddRule(ICSSTopLevelRule aRule)Add a new top-level rule at the end.com.helger.commons.collection.impl.ICommonsList<CSSFontFaceRule>getAllFontFaceRules()Get a list of all top-level rules that are font-face rules (implementingCSSFontFaceRule).com.helger.commons.collection.impl.ICommonsList<CSSKeyframesRule>getAllKeyframesRules()Get a list of all top-level rules that are keyframes rules (implementingCSSKeyframesRule).com.helger.commons.collection.impl.ICommonsList<CSSMediaRule>getAllMediaRules()Get a list of all top-level rules that are media rules (implementingCSSMediaRule).com.helger.commons.collection.impl.ICommonsList<CSSPageRule>getAllPageRules()Get a list of all top-level rules that are page rules (implementingCSSPageRule).com.helger.commons.collection.impl.ICommonsList<ICSSTopLevelRule>getAllRules()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>getAllStyleRules()Get a list of all top-level rules that are style rules (implementingCSSStyleRule).com.helger.commons.collection.impl.ICommonsList<CSSSupportsRule>getAllSupportsRules()Get a list of all top-level rules that are support rules (implementingCSSSupportsRule).com.helger.commons.collection.impl.ICommonsList<CSSUnknownRule>getAllUnknownRules()Get a list of all top-level rules that are unknown rules (implementingCSSUnknownRule).com.helger.commons.collection.impl.ICommonsList<CSSViewportRule>getAllViewportRules()Get a list of all top-level rules that are viewport rules (implementingCSSViewportRule).CSSFontFaceRulegetFontFaceRuleAtIndex(int nIndex)Get the@font-facerule at the specified index.intgetFontFaceRuleCount()Get the number of top-level rules that are font-face rules (implementingCSSFontFaceRule).CSSKeyframesRulegetKeyframesRuleAtIndex(int nIndex)Get the@keyframesrule at the specified index.intgetKeyframesRuleCount()Get the number of top-level rules that are keyframes rules (implementingCSSKeyframesRule).CSSMediaRulegetMediaRuleAtIndex(int nIndex)Get the@mediarule at the specified index.intgetMediaRuleCount()Get the number of top-level rules that are media rules (implementingCSSMediaRule).CSSPageRulegetPageRuleAtIndex(int nIndex)Get the@pagerule at the specified index.intgetPageRuleCount()Get the number of top-level rules that are page rules (implementingCSSPageRule).ICSSTopLevelRulegetRule(int nIndex)Deprecated.UsegetRuleAtIndex(int)insteadICSSTopLevelRulegetRuleAtIndex(int nIndex)Get the top-level rule at the specified index.intgetRuleCount()Get the number of total contained top-level rules.CSSStyleRulegetStyleRuleAtIndex(int nIndex)Get the style rule at the specified index.intgetStyleRuleCount()Get the number of top-level rules that are style rules (implementingCSSStyleRule).CSSSupportsRulegetSupportsRuleAtIndex(int nIndex)Get the@supportsrule at the specified index.intgetSupportsRuleCount()Get the number of top-level rules that are support rules (implementingCSSSupportsRule).CSSUnknownRulegetUnknownRuleAtIndex(int nIndex)Get the unknown rule at the specified index.intgetUnknownRuleCount()Get the number of top-level rules that are unknown rules (implementingCSSUnknownRule).CSSViewportRulegetViewportRuleAtIndex(int nIndex)Get the@viewportrule at the specified index.intgetViewportRuleCount()Get the number of top-level rules that are viewport rules (implementingCSSViewportRule).booleanhasFontFaceRules()Check if at least one of the top-level rules is a font-face rule (implementingCSSFontFaceRule).booleanhasKeyframesRules()Check if at least one of the top-level rules is a keyframes rule (implementingCSSKeyframesRule).booleanhasMediaRules()Check if at least one of the top-level rules is a media rule (implementingCSSMediaRule).booleanhasPageRules()Check if at least one of the top-level rules is a page rule (implementingCSSPageRule).booleanhasRules()Check if any top-level rule.booleanhasStyleRules()Check if at least one of the top-level rules is a style rule (implementingCSSStyleRule).booleanhasSupportsRules()Check if at least one of the top-level rules is a supports rule (implementingCSSSupportsRule).booleanhasUnknownRules()Check if at least one of the top-level rules is an unknown rule (implementingCSSUnknownRule).booleanhasViewportRules()Check if at least one of the top-level rules is a viewport rule (implementingCSSViewportRule).com.helger.commons.state.EChangeremoveAllRules()Remove 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 Detail
-
m_aRules
protected final com.helger.commons.collection.impl.ICommonsList<ICSSTopLevelRule> m_aRules
-
-
Method Detail
-
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
@Nonnegative public int 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
@Nullable @Deprecated public ICSSTopLevelRule getRule(@Nonnegative int nIndex)
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
@Nullable public ICSSTopLevelRule getRuleAtIndex(@Nonnegative int nIndex)
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
@Nonnull public AbstractHasTopLevelRules addRule(@Nonnull ICSSTopLevelRule aRule)
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
@Nonnull public com.helger.commons.state.EChange removeRule(@Nullable ICSSTopLevelRule aRule)
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
@Nonnull public com.helger.commons.state.EChange removeRule(@Nonnegative int nRuleIndex)
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
@Nonnull public com.helger.commons.state.EChange 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
@Nonnegative public int getStyleRuleCount()
Get the number of top-level rules that are style rules (implementingCSSStyleRule).- Returns:
- The number of contained style rules. Always ≥ 0.
-
getStyleRuleAtIndex
@Nullable public CSSStyleRule getStyleRuleAtIndex(@Nonnegative int nIndex)
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
@Nonnegative public int getPageRuleCount()
Get the number of top-level rules that are page rules (implementingCSSPageRule).- Returns:
- The number of contained
@pagerules. Always ≥ 0.
-
getPageRuleAtIndex
@Nullable public CSSPageRule getPageRuleAtIndex(@Nonnegative int nIndex)
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
@Nonnegative public int getMediaRuleCount()
Get the number of top-level rules that are media rules (implementingCSSMediaRule).- Returns:
- The number of contained
@mediarules. Always ≥ 0.
-
getMediaRuleAtIndex
@Nullable public CSSMediaRule getMediaRuleAtIndex(@Nonnegative int nIndex)
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
@Nonnegative public int getFontFaceRuleCount()
Get the number of top-level rules that are font-face rules (implementingCSSFontFaceRule).- Returns:
- The number of contained
@font-facerules. Always ≥ 0.
-
getFontFaceRuleAtIndex
@Nullable public CSSFontFaceRule getFontFaceRuleAtIndex(@Nonnegative int nIndex)
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
@Nonnegative public int getKeyframesRuleCount()
Get the number of top-level rules that are keyframes rules (implementingCSSKeyframesRule).- Returns:
- The number of contained
@keyframesrules. Always ≥ 0.
-
getKeyframesRuleAtIndex
@Nullable public CSSKeyframesRule getKeyframesRuleAtIndex(@Nonnegative int nIndex)
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
@Nonnegative public int getViewportRuleCount()
Get the number of top-level rules that are viewport rules (implementingCSSViewportRule).- Returns:
- The number of contained
@viewportrules. Always ≥ 0.
-
getViewportRuleAtIndex
@Nullable public CSSViewportRule getViewportRuleAtIndex(@Nonnegative int nIndex)
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
@Nonnegative public int getSupportsRuleCount()
Get the number of top-level rules that are support rules (implementingCSSSupportsRule).- Returns:
- The number of contained
@supportsrules. Always ≥ 0.
-
getSupportsRuleAtIndex
@Nullable public CSSSupportsRule getSupportsRuleAtIndex(@Nonnegative int nIndex)
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
@Nonnegative public int getUnknownRuleCount()
Get the number of top-level rules that are unknown rules (implementingCSSUnknownRule).- Returns:
- The number of contained unknown
@rules. Always ≥ 0.
-
getUnknownRuleAtIndex
@Nullable public CSSUnknownRule getUnknownRuleAtIndex(@Nonnegative int nIndex)
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.
-
-