Class StyleRule

All Implemented Interfaces:
CSSDeclarationRule, CSSRule, CSSStyleRule, Serializable, CSSRule

public class StyleRule extends CSSStyleDeclarationRule implements CSSStyleRule
CSS style rule.
See Also:
  • Constructor Details

    • StyleRule

      public StyleRule(AbstractCSSStyleSheet parentSheet, byte origin)
    • StyleRule

      public StyleRule()
      Constructor used for stand-alone style rules.

      Useful for testing.

  • Method Details

    • setSelectorText

      public void setSelectorText(String selectorText) throws DOMException
      Description copied from interface: CSSStyleRule
      Parse the given string and set the selector list according to it.
      Specified by:
      setSelectorText in interface CSSStyleRule
      Parameters:
      selectorText - a text representation of a selector list, according to CSS syntax.
      Throws:
      DOMException
    • getSelectorList

      public SelectorList getSelectorList()
      Description copied from interface: CSSStyleRule
      The selectors of this style rule.
      Specified by:
      getSelectorList in interface CSSStyleRule
      Returns:
      the selector list.
    • getType

      public short getType()
      Specified by:
      getType in interface CSSRule
      Specified by:
      getType in class AbstractCSSRule
    • getParentStyleSheet

      public AbstractCSSStyleSheet getParentStyleSheet()
      Description copied from interface: CSSRule
      Get the style sheet that contains this rule.
      Specified by:
      getParentStyleSheet in interface CSSRule
      Specified by:
      getParentStyleSheet in interface CSSRule
      Specified by:
      getParentStyleSheet in class AbstractCSSRule
      Returns:
      the style sheet, or null if no sheet contains this rule.
    • createSACParser

      protected Parser createSACParser() throws DOMException
      Throws:
      DOMException
    • getParentRule

      public AbstractCSSRule getParentRule()
      Description copied from interface: CSSRule
      If this rule is contained inside another rule, return that rule. If it is not nested inside any other rules, return null.
      Specified by:
      getParentRule in interface CSSRule
      Specified by:
      getParentRule in interface CSSRule
      Specified by:
      getParentRule in class AbstractCSSRule
      Returns:
      the containing rule, if any, otherwise null.
    • setParentRule

      public void setParentRule(AbstractCSSRule parent)
      Sets the parent CSS rule, in case this rule is contained by another.
      Specified by:
      setParentRule in class AbstractCSSRule
      Parameters:
      parent - the parent rule.
    • getOrigin

      public byte getOrigin()
      Description copied from class: AbstractCSSRule
      Get the origin of this rule (user agent sheet, author, user).
      Specified by:
      getOrigin in class AbstractCSSRule
      Returns:
      the origin of this rule.
    • enablePrecedingComments

      public void enablePrecedingComments()
      Description copied from class: AbstractCSSRule
      If this rule does not contain a preceding comment list, create one.

      If this rule already has a preceding comment list, does nothing.

      Specified by:
      enablePrecedingComments in class AbstractCSSRule
    • getPrecedingComments

      public StringList getPrecedingComments()
      Description copied from interface: CSSRule
      Get a list of the comments that preceded this rule, if any.
      Returns:
      the list of comments, or null if there were no preceding comments or the parsing was specified to ignore comments.
      See Also:
    • enableTrailingComments

      public void enableTrailingComments()
      Description copied from class: AbstractCSSRule
      If this rule does not contain a trailing comment list, create one.

      If this rule already has a trailing comment list, does nothing.

      Specified by:
      enableTrailingComments in class AbstractCSSRule
    • getTrailingComments

      public StringList getTrailingComments()
      Description copied from interface: CSSRule
      Get a list of the comments that immediately follow this rule, if any.

      If the parsing mode was COMMENTS_PRECEDING, or was COMMENTS_AUTO and the next comment happens after a newline character, it shall be assigned to the next rule as a preceding comment.

      Returns:
      the list of comments, or null if there were no trailing comments or the parsing was specified to ignore comments.
      See Also:
    • getStyleFormattingContext

      protected StyleFormattingContext getStyleFormattingContext()
    • getURL

      protected URL getURL(String uri) throws MalformedURLException
      Gets an URL for the given URI, taking into account the parent CSS Base URL if appropriate.
      Parameters:
      uri - the uri.
      Returns:
      the absolute URL.
      Throws:
      MalformedURLException - if the uri was wrong.