Package org.htmlunit.css
Class AbstractCssStyleDeclaration
- java.lang.Object
-
- org.htmlunit.css.AbstractCssStyleDeclaration
-
- All Implemented Interfaces:
java.io.Serializable
- Direct Known Subclasses:
ComputedCssStyleDeclaration
,ElementCssStyleDeclaration
,WrappedCssStyleDeclaration
public abstract class AbstractCssStyleDeclaration extends java.lang.Object implements java.io.Serializable
A css StyleDeclaration.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description private static java.util.regex.Pattern
POSITION_PATTERN
private static java.util.regex.Pattern
POSITION_PATTERN2
private static java.util.regex.Pattern
POSITION_PATTERN3
private static java.util.regex.Pattern
URL_PATTERN
-
Constructor Summary
Constructors Constructor Description AbstractCssStyleDeclaration()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description private static java.lang.String
findAttachment(java.lang.String text)
Searches for any attachment notation in the specified text.private static java.lang.String
findBorderStyle(java.lang.String text)
Searches for a border style in the specified text.private static java.lang.String
findBorderWidth(java.lang.String text)
Searches for a border width in the specified text.private static java.lang.String
findColor(java.lang.String text)
Searches for any color notation in the specified text.private static java.lang.String
findImageUrl(java.lang.String text)
Searches for any URL notation in the specified text.private static java.lang.String
findPosition(java.lang.String text)
Searches for any position notation in the specified text.private static java.lang.String
findRepeat(java.lang.String text)
Searches for any repeat notation in the specified text.java.lang.String
getBackgroundAttachment()
Gets thebackgroundAttachment
style attribute.java.lang.String
getBackgroundColor()
Gets thebackgroundColor
style attribute.java.lang.String
getBackgroundImage()
Gets thebackgroundImage
style attribute.java.lang.String
getBackgroundPosition()
Gets thebackgroundPosition
style attribute.java.lang.String
getBackgroundRepeat()
Gets thebackgroundRepeat
style attribute.java.lang.String
getBorderBottomColor()
Gets theborderBottomColor
style attribute.java.lang.String
getBorderBottomStyle()
Gets theborderBottomStyle
style attribute.java.lang.String
getBorderBottomWidth()
Gets theborderBottomWidth
style attribute.java.lang.String
getBorderLeftColor()
Gets theborderLeftColor
style attribute.java.lang.String
getBorderLeftStyle()
Gets theborderLeftStyle
style attribute.java.lang.String
getBorderLeftWidth()
Gets theborderLeftWidth
style attribute.java.lang.String
getBorderRightColor()
Gets theborderRightColor
style attribute.java.lang.String
getBorderRightStyle()
Gets theborderRightStyle
style attribute.java.lang.String
getBorderRightWidth()
Gets theborderRightWidth
style attribute.java.lang.String
getBorderTop()
Gets theborderTop
style attribute.java.lang.String
getBorderTopColor()
Gets theborderTopColor
style attribute.java.lang.String
getBorderTopStyle()
Gets theborderTopStyle
style attribute.java.lang.String
getBorderTopWidth()
Gets theborderTopWidth
style attribute.private java.lang.String
getBorderWidth(StyleAttributes.Definition borderSideWidth, StyleAttributes.Definition borderSide)
Gets the border width for the specified sidejava.lang.String
getBottom()
Gets thebottom
style attribute.abstract BrowserVersion
getBrowserVersion()
java.lang.String
getColor()
Gets thecolor
style attribute.java.lang.String
getCssFloat()
Gets thecssFloat
style attribute.abstract java.lang.String
getCssText()
Returns the actual text of the style.java.lang.String
getDisplay()
Gets thedisplay
style attribute.java.lang.String
getFont()
Gets thefont
style attribute.java.lang.String
getFontFamily()
Gets thefontFamily
style attribute.java.lang.String
getFontSize()
Gets thefontSize
style attribute.java.lang.String
getHeight()
Gets theheight
style attribute.java.lang.String
getLeft()
abstract int
getLength()
Returns thelength
property.java.lang.String
getLetterSpacing()
java.lang.String
getLineHeight()
java.lang.String
getMargin()
java.lang.String
getMarginBottom()
Gets themarginBottom
style attribute.java.lang.String
getMarginLeft()
Gets themarginLeft
style attribute.java.lang.String
getMarginRight()
Gets themarginRight
style attribute.java.lang.String
getMarginTop()
Gets themarginTop
style attribute.java.lang.String
getMaxHeight()
java.lang.String
getMaxWidth()
java.lang.String
getMinHeight()
java.lang.String
getMinWidth()
java.lang.String
getOpacity()
Gets theopacity
style attribute.java.lang.String
getOrphans()
java.lang.String
getOutline()
java.lang.String
getOutlineWidth()
java.lang.String
getPadding()
java.lang.String
getPaddingBottom()
java.lang.String
getPaddingLeft()
java.lang.String
getPaddingRight()
java.lang.String
getPaddingTop()
abstract org.htmlunit.cssparser.dom.AbstractCSSRuleImpl
getParentRule()
Returns the CSSRule that is the parent of this style block ornull
if this CSSStyleDeclaration is not attached to a CSSRule.java.lang.String
getPosition()
java.lang.String
getRight()
java.lang.String
getRubyAlign()
java.lang.String
getSize()
abstract java.lang.String
getStyleAttribute(java.lang.String name)
Get the value for the style attribute.abstract java.lang.String
getStyleAttribute(StyleAttributes.Definition definition, boolean getDefaultValueIfEmpty)
Get the value for the style attribute.protected java.lang.String
getStyleAttribute(StyleAttributes.Definition name, java.lang.String value)
java.lang.String
getStyleAttribute(StyleAttributes.Definition definition1, StyleAttributes.Definition definition2)
Returns the value of one of the two named style attributes.abstract StyleElement
getStyleElement(java.lang.String name)
Determines the StyleElement for the given name.abstract StyleElement
getStyleElementCaseInSensitive(java.lang.String name)
Determines the StyleElement for the given name.abstract java.util.Map<java.lang.String,StyleElement>
getStyleMap()
Returns a sorted map containing style elements, keyed on style element name.abstract java.lang.String
getStylePriority(java.lang.String name)
Returns the priority of the named style attribute, or an empty string if it is not found.java.lang.String
getTextIndent()
java.lang.String
getTop()
java.lang.String
getVerticalAlign()
java.lang.String
getWidows()
java.lang.String
getWidth()
java.lang.String
getWordSpacing()
java.lang.Object
getZIndex()
Gets thezIndex
style attribute.abstract boolean
hasFeature(BrowserVersionFeatures property)
Indicates if the browser this is associated with has the feature.private static boolean
isBorderStyle(java.lang.String token)
Returns if the specified token is a border style.private static boolean
isBorderWidth(java.lang.String token)
Returns if the specified token is a border width.boolean
isComputed()
(package private) static boolean
isLength(java.lang.String token)
Returns if the specified token is a length.abstract java.lang.Object
item(int index)
Returns the item in the given index.abstract java.lang.String
removeStyleAttribute(java.lang.String name)
Removes the specified style attribute, returning the value of the removed attribute.abstract void
setCssText(java.lang.String value)
Sets the actual text of the style.abstract void
setStyleAttribute(java.lang.String name, java.lang.String newValue, java.lang.String important)
Sets the specified style attribute.
-
-
-
Field Detail
-
URL_PATTERN
private static final java.util.regex.Pattern URL_PATTERN
-
POSITION_PATTERN
private static final java.util.regex.Pattern POSITION_PATTERN
-
POSITION_PATTERN2
private static final java.util.regex.Pattern POSITION_PATTERN2
-
POSITION_PATTERN3
private static final java.util.regex.Pattern POSITION_PATTERN3
-
-
Method Detail
-
getStylePriority
public abstract java.lang.String getStylePriority(java.lang.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 java.lang.String getCssText()
Returns the actual text of the style.- Returns:
- the actual text of the style
-
getStyleAttribute
public abstract java.lang.String getStyleAttribute(java.lang.String name)
Get the value for the style attribute.- Parameters:
name
- the name- Returns:
- the value
-
getStyleAttribute
public abstract java.lang.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 inComputedCssStyleDeclaration
.- Parameters:
definition
- the definitiongetDefaultValueIfEmpty
- 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 java.lang.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:
top right bottom left
: All values are explicit.top right bottom
: Left is implicitly the same as right.top right
: Left is implicitly the same as right, bottom is implicitly the same as top.top
: Left, bottom and right are implicitly the same as top.
- Parameters:
definition1
- the name of the first style attributedefinition2
- the name of the second style attribute- Returns:
- the value of one of the two named style attributes
-
setCssText
public abstract void setCssText(java.lang.String value)
Sets the actual text of the style.- Parameters:
value
- the new text
-
setStyleAttribute
public abstract void setStyleAttribute(java.lang.String name, java.lang.String newValue, java.lang.String important)
Sets the specified style attribute.- Parameters:
name
- the attribute name (camel-cased)newValue
- the attribute valueimportant
- important value
-
removeStyleAttribute
public abstract java.lang.String removeStyleAttribute(java.lang.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 thelength
property.- Returns:
- the
length
property
-
item
public abstract java.lang.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 ornull
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(java.lang.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(java.lang.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 java.util.Map<java.lang.String,StyleElement> getStyleMap()
Returns a sorted map containing style elements, keyed on style element name. We use aLinkedHashMap
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 java.lang.String getStyleAttribute(StyleAttributes.Definition name, java.lang.String value)
-
getBackgroundAttachment
public java.lang.String getBackgroundAttachment()
Gets thebackgroundAttachment
style attribute.- Returns:
- the style attribute
-
getBackgroundColor
public java.lang.String getBackgroundColor()
Gets thebackgroundColor
style attribute.- Returns:
- the style attribute
-
getBackgroundImage
public java.lang.String getBackgroundImage()
Gets thebackgroundImage
style attribute.- Returns:
- the style attribute
-
getBackgroundPosition
public java.lang.String getBackgroundPosition()
Gets thebackgroundPosition
style attribute.- Returns:
- the style attribute
-
getBackgroundRepeat
public java.lang.String getBackgroundRepeat()
Gets thebackgroundRepeat
style attribute.- Returns:
- the style attribute
-
getBorderBottomColor
public java.lang.String getBorderBottomColor()
Gets theborderBottomColor
style attribute.- Returns:
- the style attribute
-
getBorderBottomStyle
public java.lang.String getBorderBottomStyle()
Gets theborderBottomStyle
style attribute.- Returns:
- the style attribute
-
getBorderBottomWidth
public java.lang.String getBorderBottomWidth()
Gets theborderBottomWidth
style attribute.- Returns:
- the style attribute
-
getBorderLeftColor
public java.lang.String getBorderLeftColor()
Gets theborderLeftColor
style attribute.- Returns:
- the style attribute
-
getBorderLeftStyle
public java.lang.String getBorderLeftStyle()
Gets theborderLeftStyle
style attribute.- Returns:
- the style attribute
-
getBorderLeftWidth
public java.lang.String getBorderLeftWidth()
Gets theborderLeftWidth
style attribute.- Returns:
- the style attribute
-
getBorderWidth
private java.lang.String getBorderWidth(StyleAttributes.Definition borderSideWidth, StyleAttributes.Definition borderSide)
Gets the border width for the specified side- Parameters:
borderSideWidth
- the border side width DefinitionborderSide
- the border side Definition- Returns:
- the width, "" if not defined
-
getBorderRightColor
public java.lang.String getBorderRightColor()
Gets theborderRightColor
style attribute.- Returns:
- the style attribute
-
getBorderRightStyle
public java.lang.String getBorderRightStyle()
Gets theborderRightStyle
style attribute.- Returns:
- the style attribute
-
getBorderRightWidth
public java.lang.String getBorderRightWidth()
Gets theborderRightWidth
style attribute.- Returns:
- the style attribute
-
getBorderTop
public java.lang.String getBorderTop()
Gets theborderTop
style attribute.- Returns:
- the style attribute
-
getBorderTopColor
public java.lang.String getBorderTopColor()
Gets theborderTopColor
style attribute.- Returns:
- the style attribute
-
getBorderTopStyle
public java.lang.String getBorderTopStyle()
Gets theborderTopStyle
style attribute.- Returns:
- the style attribute
-
getBorderTopWidth
public java.lang.String getBorderTopWidth()
Gets theborderTopWidth
style attribute.- Returns:
- the style attribute
-
getBottom
public java.lang.String getBottom()
Gets thebottom
style attribute.- Returns:
- the style attribute
-
getColor
public java.lang.String getColor()
Gets thecolor
style attribute.- Returns:
- the style attribute
-
getCssFloat
public java.lang.String getCssFloat()
Gets thecssFloat
style attribute.- Returns:
- the style attribute
-
getDisplay
public java.lang.String getDisplay()
Gets thedisplay
style attribute.- Returns:
- the style attribute
-
getFont
public java.lang.String getFont()
Gets thefont
style attribute.- Returns:
- the style attribute
-
getFontFamily
public java.lang.String getFontFamily()
Gets thefontFamily
style attribute.- Returns:
- the style attribute
-
getFontSize
public java.lang.String getFontSize()
Gets thefontSize
style attribute.- Returns:
- the style attribute
-
getHeight
public java.lang.String getHeight()
Gets theheight
style attribute.- Returns:
- the style attribute
-
getLeft
public java.lang.String getLeft()
- Returns:
- the style attribute
left
-
getLetterSpacing
public java.lang.String getLetterSpacing()
- Returns:
- the style attribute
letterSpacing
-
getLineHeight
public java.lang.String getLineHeight()
- Returns:
- the style attribute
lineHeight
-
getMargin
public java.lang.String getMargin()
- Returns:
- the style attribute
margin
-
getMarginBottom
public java.lang.String getMarginBottom()
Gets themarginBottom
style attribute.- Returns:
- the style attribute
-
getMarginLeft
public java.lang.String getMarginLeft()
Gets themarginLeft
style attribute.- Returns:
- the style attribute
-
getMarginRight
public java.lang.String getMarginRight()
Gets themarginRight
style attribute.- Returns:
- the style attribute
-
getMarginTop
public java.lang.String getMarginTop()
Gets themarginTop
style attribute.- Returns:
- the style attribute
-
getMaxHeight
public java.lang.String getMaxHeight()
- Returns:
- the style attribute
maxHeight
-
getMaxWidth
public java.lang.String getMaxWidth()
- Returns:
- the style attribute
maxWidth
-
getMinHeight
public java.lang.String getMinHeight()
- Returns:
- the style attribute
minHeight
-
getMinWidth
public java.lang.String getMinWidth()
- Returns:
- the style attribute
minWidth
-
getOpacity
public java.lang.String getOpacity()
Gets theopacity
style attribute.- Returns:
- the style attribute
-
getOrphans
public java.lang.String getOrphans()
- Returns:
- the style attribute
orphans
-
getOutline
public java.lang.String getOutline()
- Returns:
- the style attribute
outline
-
getOutlineWidth
public java.lang.String getOutlineWidth()
- Returns:
- the style attribute
outlineWidth
-
getPadding
public java.lang.String getPadding()
- Returns:
- the style attribute
padding
-
getPaddingBottom
public java.lang.String getPaddingBottom()
- Returns:
- the style attribute
paddingBottom
-
getPaddingLeft
public java.lang.String getPaddingLeft()
- Returns:
- the style attribute
paddingLeft
-
getPaddingRight
public java.lang.String getPaddingRight()
- Returns:
- the style attribute
paddingRight
-
getPaddingTop
public java.lang.String getPaddingTop()
- Returns:
- the style attribute
paddingTop
-
getPosition
public java.lang.String getPosition()
- Returns:
- the style attribute
position
-
getRight
public java.lang.String getRight()
- Returns:
- the style attribute
right
-
getRubyAlign
public java.lang.String getRubyAlign()
- Returns:
- the style attribute
rubyAlign
-
getSize
public java.lang.String getSize()
- Returns:
- the style attribute
size
-
getTextIndent
public java.lang.String getTextIndent()
- Returns:
- the style attribute
textIndent
-
getTop
public java.lang.String getTop()
- Returns:
- the style attribute
top
-
getVerticalAlign
public java.lang.String getVerticalAlign()
- Returns:
- the style attribute
verticalAlign
-
getWidows
public java.lang.String getWidows()
- Returns:
- the style attribute
widows
-
getWidth
public java.lang.String getWidth()
- Returns:
- the style attribute
width
-
getWordSpacing
public java.lang.String getWordSpacing()
- Returns:
- the style attribute
wordSpacing
-
getZIndex
public java.lang.Object getZIndex()
Gets thezIndex
style attribute.- Returns:
- the style attribute
-
findAttachment
private static java.lang.String findAttachment(java.lang.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 java.lang.String findColor(java.lang.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 java.lang.String findImageUrl(java.lang.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 java.lang.String findPosition(java.lang.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 java.lang.String findRepeat(java.lang.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 java.lang.String findBorderStyle(java.lang.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(java.lang.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 java.lang.String findBorderWidth(java.lang.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(java.lang.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(java.lang.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
-
-