Package ej.mwt.stylesheet.selector
Class OddChildSelector
- java.lang.Object
-
- ej.mwt.stylesheet.selector.OddChildSelector
-
- All Implemented Interfaces:
Selector
public class OddChildSelector extends java.lang.Object implements Selector
An odd child selector selects by checking if a widget is at an odd position in its parent (0, 2, 4,…).Equivalent to
:nth-child(odd)selector in CSS. Its specificity is (0,0,1,0).- See Also:
Widget.getParent(),SelectorHelper
-
-
Field Summary
Fields Modifier and Type Field Description static OddChildSelectorODD_CHILD_SELECTOROdd child selector singleton to avoid creating several ones.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanappliesToWidget(Widget widget)Checks whether or not this selector applies to the given widget.booleanequals(java.lang.Object obj)intgetSpecificity()Returns the specificity of this selector.inthashCode()
-
-
-
Field Detail
-
ODD_CHILD_SELECTOR
public static final OddChildSelector ODD_CHILD_SELECTOR
Odd child selector singleton to avoid creating several ones.
-
-
Method Detail
-
appliesToWidget
public boolean appliesToWidget(Widget widget)
Description copied from interface:SelectorChecks whether or not this selector applies to the given widget.- Specified by:
appliesToWidgetin interfaceSelector- Parameters:
widget- the widget to test.- Returns:
trueif this selectors applies to the given widget,falseotherwise.
-
getSpecificity
public int getSpecificity()
Description copied from interface:SelectorReturns the specificity of this selector.The specificity allows to determine in which order the rules of a stylesheet should be applied.
A specificity is composed of four numbers (defined by CSS2 specification):
- count 1 if the declaration is from is a 'style' attribute rather than a rule with a selector, 0 otherwise (= a)
- count the number of ID attributes in the selector (= b)
- count the number of other attributes and pseudo-classes in the selector (= c)
- count the number of widget names and pseudo-widgets in the selector (= d)
SelectorHelperprovides a method to compute the specificity of a selector.- Specified by:
getSpecificityin interfaceSelector- Returns:
- the specificity of this selector.
-
equals
public boolean equals(@Nullable java.lang.Object obj)
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
-