Class AbstractCssStyleDeclaration

java.lang.Object
org.htmlunit.css.AbstractCssStyleDeclaration
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
ComputedCssStyleDeclaration, ElementCssStyleDeclaration, WrappedCssStyleDeclaration

public abstract class AbstractCssStyleDeclaration extends Object implements Serializable
A css StyleDeclaration.
See Also:
  • Field Details

    • URL_PATTERN

      private static final Pattern URL_PATTERN
    • POSITION_PATTERN

      private static final Pattern POSITION_PATTERN
    • POSITION_PATTERN2

      private static final Pattern POSITION_PATTERN2
    • POSITION_PATTERN3

      private static final Pattern POSITION_PATTERN3
  • Constructor Details

    • AbstractCssStyleDeclaration

      public AbstractCssStyleDeclaration()
  • Method Details

    • getStylePriority

      public abstract String getStylePriority(String name)
      Returns the priority of the named style attribute, or an empty string if it is not found.
      Parameters:
      name - the name of the style attribute whose value is to be retrieved
      Returns:
      the named style attribute value, or an empty string if it is not found
    • getCssText

      public abstract String getCssText()
      Returns the actual text of the style.
      Returns:
      the actual text of the style
    • getStyleAttribute

      public abstract String getStyleAttribute(String name)
      Get the value for the style attribute.
      Parameters:
      name - the name
      Returns:
      the value
    • getStyleAttribute

      public abstract String getStyleAttribute(StyleAttributes.Definition definition, boolean getDefaultValueIfEmpty)
      Get the value for the style attribute. This impl ignores the default getDefaultValueIfEmpty flag, but there is a overload in ComputedCssStyleDeclaration.
      Parameters:
      definition - the definition
      getDefaultValueIfEmpty - whether to get the default value if empty or not
      Returns:
      the value
    • hasFeature

      public abstract boolean hasFeature(BrowserVersionFeatures property)
      Indicates if the browser this is associated with has the feature.
      Parameters:
      property - the property name
      Returns:
      false if this browser doesn't have this feature
    • getBrowserVersion

      public abstract BrowserVersion getBrowserVersion()
      Returns:
      the BrowserVersion
    • getStyleAttribute

      public String getStyleAttribute(StyleAttributes.Definition definition1, StyleAttributes.Definition definition2)

      Returns the value of one of the two named style attributes. If both attributes exist, the value of the attribute that was declared last is returned. If only one of the attributes exists, its value is returned. If neither attribute exists, an empty string is returned.

      The second named attribute may be shorthand for a the actual desired property. The following formats are possible:

      1. top right bottom left: All values are explicit.
      2. top right bottom: Left is implicitly the same as right.
      3. top right: Left is implicitly the same as right, bottom is implicitly the same as top.
      4. top: Left, bottom and right are implicitly the same as top.
      Parameters:
      definition1 - the name of the first style attribute
      definition2 - the name of the second style attribute
      Returns:
      the value of one of the two named style attributes
    • setCssText

      public abstract void setCssText(String value)
      Sets the actual text of the style.
      Parameters:
      value - the new text
    • setStyleAttribute

      public abstract void setStyleAttribute(String name, String newValue, String important)
      Sets the specified style attribute.
      Parameters:
      name - the attribute name (camel-cased)
      newValue - the attribute value
      important - important value
    • removeStyleAttribute

      public abstract String removeStyleAttribute(String name)
      Removes the specified style attribute, returning the value of the removed attribute.
      Parameters:
      name - the attribute name (delimiter-separated, not camel-cased)
      Returns:
      the removed value
    • getLength

      public abstract int getLength()
      Returns the length property.
      Returns:
      the length property
    • item

      public abstract Object item(int index)
      Returns the item in the given index.
      Parameters:
      index - the index
      Returns:
      the item in the given index
    • getParentRule

      public abstract org.htmlunit.cssparser.dom.AbstractCSSRuleImpl getParentRule()
      Returns the CSSRule that is the parent of this style block or null if this CSSStyleDeclaration is not attached to a CSSRule.
      Returns:
      the CSSRule that is the parent of this style block or null if this CSSStyleDeclaration is not attached to a CSSRule
    • getStyleElement

      public abstract StyleElement getStyleElement(String name)
      Determines the StyleElement for the given name.
      Parameters:
      name - the name of the requested StyleElement
      Returns:
      the StyleElement or null if not found
    • getStyleElementCaseInSensitive

      public abstract StyleElement getStyleElementCaseInSensitive(String name)
      Determines the StyleElement for the given name. This ignores the case of the name.
      Parameters:
      name - the name of the requested StyleElement
      Returns:
      the StyleElement or null if not found
    • getStyleMap

      public abstract Map<String,StyleElement> getStyleMap()
      Returns a sorted map containing style elements, keyed on style element name. We use a LinkedHashMap map so that results are deterministic and are thus testable.
      Returns:
      a sorted map containing style elements, keyed on style element name
    • isComputed

      public boolean isComputed()
      Returns:
      true if this is a computed style declaration
    • getStyleAttribute

      protected String getStyleAttribute(StyleAttributes.Definition name, String value)
    • getBackgroundAttachment

      public String getBackgroundAttachment()
      Gets the backgroundAttachment style attribute.
      Returns:
      the style attribute
    • getBackgroundColor

      public String getBackgroundColor()
      Gets the backgroundColor style attribute.
      Returns:
      the style attribute
    • getBackgroundImage

      public String getBackgroundImage()
      Gets the backgroundImage style attribute.
      Returns:
      the style attribute
    • getBackgroundPosition

      public String getBackgroundPosition()
      Gets the backgroundPosition style attribute.
      Returns:
      the style attribute
    • getBackgroundRepeat

      public String getBackgroundRepeat()
      Gets the backgroundRepeat style attribute.
      Returns:
      the style attribute
    • getBorderBottomColor

      public String getBorderBottomColor()
      Gets the borderBottomColor style attribute.
      Returns:
      the style attribute
    • getBorderBottomStyle

      public String getBorderBottomStyle()
      Gets the borderBottomStyle style attribute.
      Returns:
      the style attribute
    • getBorderBottomWidth

      public String getBorderBottomWidth()
      Gets the borderBottomWidth style attribute.
      Returns:
      the style attribute
    • getBorderLeftColor

      public String getBorderLeftColor()
      Gets the borderLeftColor style attribute.
      Returns:
      the style attribute
    • getBorderLeftStyle

      public String getBorderLeftStyle()
      Gets the borderLeftStyle style attribute.
      Returns:
      the style attribute
    • getBorderLeftWidth

      public String getBorderLeftWidth()
      Gets the borderLeftWidth style attribute.
      Returns:
      the style attribute
    • getBorderWidth

      private String getBorderWidth(StyleAttributes.Definition borderSideWidth, StyleAttributes.Definition borderSide)
      Gets the border width for the specified side
      Parameters:
      borderSideWidth - the border side width Definition
      borderSide - the border side Definition
      Returns:
      the width, "" if not defined
    • getBorderRightColor

      public String getBorderRightColor()
      Gets the borderRightColor style attribute.
      Returns:
      the style attribute
    • getBorderRightStyle

      public String getBorderRightStyle()
      Gets the borderRightStyle style attribute.
      Returns:
      the style attribute
    • getBorderRightWidth

      public String getBorderRightWidth()
      Gets the borderRightWidth style attribute.
      Returns:
      the style attribute
    • getBorderTop

      public String getBorderTop()
      Gets the borderTop style attribute.
      Returns:
      the style attribute
    • getBorderTopColor

      public String getBorderTopColor()
      Gets the borderTopColor style attribute.
      Returns:
      the style attribute
    • getBorderTopStyle

      public String getBorderTopStyle()
      Gets the borderTopStyle style attribute.
      Returns:
      the style attribute
    • getBorderTopWidth

      public String getBorderTopWidth()
      Gets the borderTopWidth style attribute.
      Returns:
      the style attribute
    • getBottom

      public String getBottom()
      Gets the bottom style attribute.
      Returns:
      the style attribute
    • getColor

      public String getColor()
      Gets the color style attribute.
      Returns:
      the style attribute
    • getCssFloat

      public String getCssFloat()
      Gets the cssFloat style attribute.
      Returns:
      the style attribute
    • getDisplay

      public String getDisplay()
      Gets the display style attribute.
      Returns:
      the style attribute
    • getFont

      public String getFont()
      Gets the font style attribute.
      Returns:
      the style attribute
    • getFontFamily

      public String getFontFamily()
      Gets the fontFamily style attribute.
      Returns:
      the style attribute
    • getFontSize

      public String getFontSize()
      Gets the fontSize style attribute.
      Returns:
      the style attribute
    • getHeight

      public String getHeight()
      Gets the height style attribute.
      Returns:
      the style attribute
    • getLeft

      public String getLeft()
      Returns:
      the style attribute left
    • getLetterSpacing

      public String getLetterSpacing()
      Returns:
      the style attribute letterSpacing
    • getLineHeight

      public String getLineHeight()
      Returns:
      the style attribute lineHeight
    • getMargin

      public String getMargin()
      Returns:
      the style attribute margin
    • getMarginBottom

      public String getMarginBottom()
      Gets the marginBottom style attribute.
      Returns:
      the style attribute
    • getMarginLeft

      public String getMarginLeft()
      Gets the marginLeft style attribute.
      Returns:
      the style attribute
    • getMarginRight

      public String getMarginRight()
      Gets the marginRight style attribute.
      Returns:
      the style attribute
    • getMarginTop

      public String getMarginTop()
      Gets the marginTop style attribute.
      Returns:
      the style attribute
    • getMaxHeight

      public String getMaxHeight()
      Returns:
      the style attribute maxHeight
    • getMaxWidth

      public String getMaxWidth()
      Returns:
      the style attribute maxWidth
    • getMinHeight

      public String getMinHeight()
      Returns:
      the style attribute minHeight
    • getMinWidth

      public String getMinWidth()
      Returns:
      the style attribute minWidth
    • getOpacity

      public String getOpacity()
      Gets the opacity style attribute.
      Returns:
      the style attribute
    • getOrphans

      public String getOrphans()
      Returns:
      the style attribute orphans
    • getOutline

      public String getOutline()
      Returns:
      the style attribute outline
    • getOutlineWidth

      public String getOutlineWidth()
      Returns:
      the style attribute outlineWidth
    • getPadding

      public String getPadding()
      Returns:
      the style attribute padding
    • getPaddingBottom

      public String getPaddingBottom()
      Returns:
      the style attribute paddingBottom
    • getPaddingLeft

      public String getPaddingLeft()
      Returns:
      the style attribute paddingLeft
    • getPaddingRight

      public String getPaddingRight()
      Returns:
      the style attribute paddingRight
    • getPaddingTop

      public String getPaddingTop()
      Returns:
      the style attribute paddingTop
    • getPosition

      public String getPosition()
      Returns:
      the style attribute position
    • getRight

      public String getRight()
      Returns:
      the style attribute right
    • getRubyAlign

      public String getRubyAlign()
      Returns:
      the style attribute rubyAlign
    • getSize

      public String getSize()
      Returns:
      the style attribute size
    • getTextIndent

      public String getTextIndent()
      Returns:
      the style attribute textIndent
    • getTop

      public String getTop()
      Returns:
      the style attribute top
    • getVerticalAlign

      public String getVerticalAlign()
      Returns:
      the style attribute verticalAlign
    • getWidows

      public String getWidows()
      Returns:
      the style attribute widows
    • getWidth

      public String getWidth()
      Returns:
      the style attribute width
    • getWordSpacing

      public String getWordSpacing()
      Returns:
      the style attribute wordSpacing
    • getZIndex

      public Object getZIndex()
      Gets the zIndex style attribute.
      Returns:
      the style attribute
    • findAttachment

      private static String findAttachment(String text)
      Searches for any attachment notation in the specified text.
      Parameters:
      text - the string to search in
      Returns:
      the string of the attachment if found, null otherwise
    • findColor

      private static String findColor(String text)
      Searches for any color notation in the specified text.
      Parameters:
      text - the string to search in
      Returns:
      the string of the color if found, null otherwise
    • findImageUrl

      private static String findImageUrl(String text)
      Searches for any URL notation in the specified text.
      Parameters:
      text - the string to search in
      Returns:
      the string of the URL if found, null otherwise
    • findPosition

      private static String findPosition(String text)
      Searches for any position notation in the specified text.
      Parameters:
      text - the string to search in
      Returns:
      the string of the position if found, null otherwise
    • findRepeat

      private static String findRepeat(String text)
      Searches for any repeat notation in the specified text.
      Parameters:
      text - the string to search in
      Returns:
      the string of the repeat if found, null otherwise
    • findBorderStyle

      private static String findBorderStyle(String text)
      Searches for a border style in the specified text.
      Parameters:
      text - the string to search in
      Returns:
      the border style if found, null otherwise
    • isBorderStyle

      private static boolean isBorderStyle(String token)
      Returns if the specified token is a border style.
      Parameters:
      token - the token to check
      Returns:
      whether the token is a border style or not
    • findBorderWidth

      private static String findBorderWidth(String text)
      Searches for a border width in the specified text.
      Parameters:
      text - the string to search in
      Returns:
      the border width if found, null otherwise
    • isBorderWidth

      private static boolean isBorderWidth(String token)
      Returns if the specified token is a border width.
      Parameters:
      token - the token to check
      Returns:
      whether the token is a border width or not
    • isLength

      static boolean isLength(String token)
      Returns if the specified token is a length.
      Parameters:
      token - the token to check
      Returns:
      whether the token is a length or not