Class AbstractHasTopLevelRules

    • Field Detail

      • m_aRules

        protected final com.helger.commons.collection.impl.ICommonsList<ICSSTopLevelRule> m_aRules
    • Constructor Detail

      • AbstractHasTopLevelRules

        public AbstractHasTopLevelRules()
    • Method Detail

      • hasRules

        public boolean hasRules()
        Check if any top-level rule. This method only considers top-level rules and not @import and @namespace rules!
        Returns:
        true if at least one top-level rule is present, false if otherwise.
      • getRuleCount

        @Nonnegative
        public int getRuleCount()
        Get the number of total contained top-level rules. This method only considers top-level rules and not @import and @namespace rules!
        Returns:
        The number of total contained top-level rules. Always ≥ 0.
      • 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:
        null if 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 @import and @namespace rules!
        Parameters:
        aRule - The rule to be added. May not be null.
        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 @import and @namespace rules!
        Parameters:
        nIndex - The index where the top-level rule should be added. Must be ≥ 0.
        aRule - The rule to be added. May not be null.
        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 @import and @namespace rules!
        Parameters:
        aRule - The rule to be removed. May be null.
        Returns:
        EChange.CHANGED if the rule was successfully removed, EChange.UNCHANGED otherwise. Never null.
      • 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 @import and @namespace rules!
        Parameters:
        nRuleIndex - The index of the rule to be removed. Should be ≥ 0.
        Returns:
        EChange.CHANGED if the rule at the specified index was successfully removed, EChange.UNCHANGED otherwise. Never null.
      • 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 be null.
        Returns:
        EChange.CHANGED it at least one rule was removed, EChange.UNCHANGED otherwise.
        Since:
        5.0.0
      • removeAllRules

        @Nonnull
        public com.helger.commons.state.EChange removeAllRules()
        Remove all top-level rules.
        Returns:
        EChange.CHANGED if any rule was removed, EChange.UNCHANGED otherwise. Never null.
        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 @import and @namespace rules!
        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 @import and @namespace rules!
        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 (implementing CSSStyleRule).
        Returns:
        true if at least one style rule is contained, false otherwise.
      • getStyleRuleCount

        @Nonnegative
        public int getStyleRuleCount()
        Get the number of top-level rules that are style rules (implementing CSSStyleRule).
        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:
        null if 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 (implementing CSSStyleRule).
        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 (implementing CSSPageRule).
        Returns:
        true if at least one @page rule is contained, false otherwise.
      • getPageRuleCount

        @Nonnegative
        public int getPageRuleCount()
        Get the number of top-level rules that are page rules (implementing CSSPageRule).
        Returns:
        The number of contained @page rules. Always ≥ 0.
      • getPageRuleAtIndex

        @Nullable
        public CSSPageRule getPageRuleAtIndex​(@Nonnegative
                                              int nIndex)
        Get the @page rule at the specified index.
        Parameters:
        nIndex - The index to be resolved. Should be ≥ 0 and < getPageRuleCount().
        Returns:
        null if 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 (implementing CSSPageRule).
        Returns:
        A copy of all contained @page rules. Never null.
      • hasMediaRules

        public boolean hasMediaRules()
        Check if at least one of the top-level rules is a media rule (implementing CSSMediaRule).
        Returns:
        true if at least one @media rule is contained, false otherwise.
      • getMediaRuleCount

        @Nonnegative
        public int getMediaRuleCount()
        Get the number of top-level rules that are media rules (implementing CSSMediaRule).
        Returns:
        The number of contained @media rules. Always ≥ 0.
      • getMediaRuleAtIndex

        @Nullable
        public CSSMediaRule getMediaRuleAtIndex​(@Nonnegative
                                                int nIndex)
        Get the @media rule at the specified index.
        Parameters:
        nIndex - The index to be resolved. Should be ≥ 0 and < getMediaRuleCount().
        Returns:
        null if 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 (implementing CSSMediaRule).
        Returns:
        A copy of all contained @media rules. Never null.
      • hasFontFaceRules

        public boolean hasFontFaceRules()
        Check if at least one of the top-level rules is a font-face rule (implementing CSSFontFaceRule).
        Returns:
        true if at least one @font-face rule is contained, false otherwise.
      • getFontFaceRuleCount

        @Nonnegative
        public int getFontFaceRuleCount()
        Get the number of top-level rules that are font-face rules (implementing CSSFontFaceRule).
        Returns:
        The number of contained @font-face rules. Always ≥ 0.
      • getFontFaceRuleAtIndex

        @Nullable
        public CSSFontFaceRule getFontFaceRuleAtIndex​(@Nonnegative
                                                      int nIndex)
        Get the @font-face rule at the specified index.
        Parameters:
        nIndex - The index to be resolved. Should be ≥ 0 and < getFontFaceRuleCount().
        Returns:
        null if 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 (implementing CSSFontFaceRule).
        Returns:
        A copy of all contained @font-face rules. Never null.
      • hasKeyframesRules

        public boolean hasKeyframesRules()
        Check if at least one of the top-level rules is a keyframes rule (implementing CSSKeyframesRule).
        Returns:
        true if at least one @keyframes rule is contained, false otherwise.
      • getKeyframesRuleCount

        @Nonnegative
        public int getKeyframesRuleCount()
        Get the number of top-level rules that are keyframes rules (implementing CSSKeyframesRule).
        Returns:
        The number of contained @keyframes rules. Always ≥ 0.
      • getKeyframesRuleAtIndex

        @Nullable
        public CSSKeyframesRule getKeyframesRuleAtIndex​(@Nonnegative
                                                        int nIndex)
        Get the @keyframes rule at the specified index.
        Parameters:
        nIndex - The index to be resolved. Should be ≥ 0 and < getKeyframesRuleCount().
        Returns:
        null if 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 (implementing CSSKeyframesRule).
        Returns:
        A copy of all contained @keyframes rules. Never null.
      • hasViewportRules

        public boolean hasViewportRules()
        Check if at least one of the top-level rules is a viewport rule (implementing CSSViewportRule).
        Returns:
        true if at least one @viewport rule is contained, false otherwise.
      • getViewportRuleCount

        @Nonnegative
        public int getViewportRuleCount()
        Get the number of top-level rules that are viewport rules (implementing CSSViewportRule).
        Returns:
        The number of contained @viewport rules. Always ≥ 0.
      • getViewportRuleAtIndex

        @Nullable
        public CSSViewportRule getViewportRuleAtIndex​(@Nonnegative
                                                      int nIndex)
        Get the @viewport rule at the specified index.
        Parameters:
        nIndex - The index to be resolved. Should be ≥ 0 and < getViewportRuleCount().
        Returns:
        null if 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 (implementing CSSViewportRule).
        Returns:
        A copy of all contained @viewport rules. Never null.
      • hasSupportsRules

        public boolean hasSupportsRules()
        Check if at least one of the top-level rules is a supports rule (implementing CSSSupportsRule).
        Returns:
        true if at least one @supports rule is contained, false otherwise.
      • getSupportsRuleCount

        @Nonnegative
        public int getSupportsRuleCount()
        Get the number of top-level rules that are support rules (implementing CSSSupportsRule).
        Returns:
        The number of contained @supports rules. Always ≥ 0.
      • getSupportsRuleAtIndex

        @Nullable
        public CSSSupportsRule getSupportsRuleAtIndex​(@Nonnegative
                                                      int nIndex)
        Get the @supports rule at the specified index.
        Parameters:
        nIndex - The index to be resolved. Should be ≥ 0 and < getSupportsRuleCount().
        Returns:
        null if 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 (implementing CSSSupportsRule).
        Returns:
        A copy of all contained @supports rules. Never null.
      • hasUnknownRules

        public boolean hasUnknownRules()
        Check if at least one of the top-level rules is an unknown rule (implementing CSSUnknownRule).
        Returns:
        true if at least one unknown @ rule is contained, false otherwise.
      • getUnknownRuleCount

        @Nonnegative
        public int getUnknownRuleCount()
        Get the number of top-level rules that are unknown rules (implementing CSSUnknownRule).
        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:
        null if 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 (implementing CSSUnknownRule).
        Returns:
        A copy of all contained unknown @ rules. Never null.