Class StateSelector

  • All Implemented Interfaces:
    Selector

    public class StateSelector
    extends java.lang.Object
    implements Selector
    A state selector selects from a state. That means that the state of this selector is available in the widget states.

    Equivalent to pseudo-class (eg. :active) selector in CSS. Its specificity is (0,0,1,0).

    See Also:
    Widget.isInState(int), SelectorHelper
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static int ACTIVE
      Active state.
      static int CHECKED
      Checked state.
      static int EMPTY
      Empty state.
      static int FOCUS
      Focus state.
      static int INVALID
      Invalid state.
      static int VALID
      Valid state.
    • Constructor Summary

      Constructors 
      Constructor Description
      StateSelector​(int state)
      Creates a state selector with one state.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean appliesToWidget​(Widget widget)
      Checks whether or not this selector applies to the given widget.
      boolean equals​(java.lang.Object obj)  
      int getSpecificity()
      Returns the specificity of this selector.
      int getState()
      Gets the selected state.
      int hashCode()  
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • StateSelector

        public StateSelector​(int state)
        Creates a state selector with one state.
        Parameters:
        state - the state.
    • Method Detail

      • getState

        public int getState()
        Gets the selected state.
        Returns:
        the state
      • appliesToWidget

        public boolean appliesToWidget​(Widget widget)
        Description copied from interface: Selector
        Checks whether or not this selector applies to the given widget.
        Specified by:
        appliesToWidget in interface Selector
        Parameters:
        widget - the widget to test.
        Returns:
        true if this selectors applies to the given widget, false otherwise.
      • getSpecificity

        public int getSpecificity()
        Description copied from interface: Selector
        Returns 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)
        Concatenating the four numbers a-b-c-d (in a number system with a large base) gives the specificity. In this implementation, each number is stored on a byte in an integer. SelectorHelper provides a method to compute the specificity of a selector.
        Specified by:
        getSpecificity in interface Selector
        Returns:
        the specificity of this selector.
      • equals

        public boolean equals​(@Nullable
                              java.lang.Object obj)
        Specified by:
        equals in interface Selector
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object