Class DocumentSelectorModel

java.lang.Object
org.jhotdraw8.css.model.AbstractSelectorModel<Element>
org.jhotdraw8.css.model.DocumentSelectorModel
All Implemented Interfaces:
SelectorModel<Element>

public class DocumentSelectorModel extends AbstractSelectorModel<Element>
DocumentSelectorModel provides an API for CSS SelectorGroup's.
Author:
Werner Randelshofer
  • Constructor Details

    • DocumentSelectorModel

      public DocumentSelectorModel()
  • Method Details

    • getAttributeAsString

      public String getAttributeAsString(Element elem, javafx.css.StyleOrigin origin, @Nullable String namespacePattern, String name)
      Description copied from interface: SelectorModel
      Returns the attribute value with the given name from the specified style origin.
      Parameters:
      elem - The element
      origin - The style origin
      namespacePattern - an optional namespace ("*" means any namespace, null means no namespace)
      name - The attribute name
      Returns:
      The attribute value. Returns "initial" if the element does not have an attribute with this name.
    • getAttribute

      public @Nullable List<CssToken> getAttribute(Element element, @Nullable javafx.css.StyleOrigin origin, @Nullable String namespacePattern, String name)
      Description copied from interface: SelectorModel
      Returns the attribute value with the given name from the specified style origin.
      Parameters:
      element - The element
      origin - The style origin
      namespacePattern - an optional namespace ("*" means any namespace, null means no namespace)
      name - The attribute name
      Returns:
      The attribute value as a list of CssTokens.
    • hasId

      public boolean hasId(Element elem, String id)
      Description copied from interface: SelectorModel
      Returns true if the element has the specified id.
      Parameters:
      elem - An element of the document
      id - an id
      Returns:
      true if the element has the id
    • getId

      public String getId(Element elem)
      Description copied from interface: SelectorModel
      Returns the id of the element.
      Parameters:
      elem - the element
      Returns:
      the id or null if the element does not have an id.
    • hasType

      public boolean hasType(Element elem, @Nullable String namespacePattern, String type)
      Description copied from interface: SelectorModel
      Returns true if the element has the specified type.
      Parameters:
      elem - An element of the document
      namespacePattern - a namespace pattern ("*" means any namespace, null means no namespace)
      type - an id
      Returns:
      true if the element has the id
    • reset

      public void reset(Element elem)
      Description copied from interface: SelectorModel
      Resets all values with non-StyleOrigin.USER origin.
    • getType

      public @Nullable QualifiedName getType(Element elem)
      Description copied from interface: SelectorModel
      Returns the style type of the element.
      Parameters:
      elem - the element
      Returns:
      the style type of the element, return null if the element is not styleable by type.
    • hasStyleClass

      public boolean hasStyleClass(Element elem, String clazz)
      Description copied from interface: SelectorModel
      Returns true if the element has the specified style class.
      Parameters:
      elem - An element of the document
      clazz - a style class
      Returns:
      true if the element has the id
    • getStyleClasses

      public ReadOnlySet<String> getStyleClasses(Element elem)
      Description copied from interface: SelectorModel
      Returns the style classes of the element.
      Parameters:
      elem - the element
      Returns:
      the style classes or an empty set.
    • getPseudoClasses

      public ReadOnlySet<String> getPseudoClasses(Element elem)
      Description copied from interface: SelectorModel
      Returns the pseudo classes of the element.
      Parameters:
      elem - the element
      Returns:
      the pseudo classes or an empty set.
    • hasPseudoClass

      public boolean hasPseudoClass(Element element, String pseudoClass)
      Supports the following pseudo classes:
      • root
      • nth-child(odd)
      • nth-child(even)
      • first-child
      • last-child
      Does not support the following pseudo classes:
      • nth-child(2n+1)
      • nth-last-child(2n+1)
      • nth-last-child(odd)
      • nth-last-child(even)
      • nth-of-type(2n+1)
      • nth-of-type(even)
      • nth-of-type(odd)
      • nth-last-of-type(2n+1)
      • nth-last-of-type(even)
      • nth-last-of-type(odd)
      • first-of-type()
      • last-of-type()
      • only-child()
      • only-of-type()
      • empty
      • not(...)
      Parameters:
      element - the element
      pseudoClass - the desired pseudo clas
      Returns:
      true if the element has the pseudo class
    • getParent

      public Element getParent(Element elem)
      Description copied from interface: SelectorModel
      Gets the parent of the element.
      Parameters:
      elem - An element of the document
      Returns:
      The parent element. Returns null if the element has no parent.
    • getPreviousSibling

      public Element getPreviousSibling(Element element)
      Description copied from interface: SelectorModel
      Gets the previous sibling of the element.
      Parameters:
      element - An element of the document
      Returns:
      The previous sibling. Returns null if the element has no previous sibling.
    • hasAttribute

      public boolean hasAttribute(Element element, @Nullable String namespace, String attributeName)
      Description copied from interface: SelectorModel
      Returns true if the element has the specified attribute.
      Parameters:
      element - An element of the document
      namespace - an optional namespace (null means any namespace , an empty String means no namespace)
      attributeName - an attribute name
      Returns:
      true if the element has an attribute with the specified name
    • attributeValueStartsWith

      public boolean attributeValueStartsWith(Element element, @Nullable String namespacePattern, String attributeName, String substring)
      Description copied from interface: SelectorModel
      Returns true if the element has an attribute with the specified name and the attribute value starts with the specified substring.
      Parameters:
      element - An element of the document
      namespacePattern - an optional namespace ("*" means any namespace, null means no namespace)
      attributeName - an attribute name
      substring - the substring
      Returns:
      true if the element has an attribute with the specified name and the value starts with the specified substring.
    • getAttributeAsString

      public @Nullable String getAttributeAsString(Element element, @Nullable String namespacePattern, String attributeName)
      Description copied from interface: SelectorModel
      Returns the attribute value with the given name from the USER style origin.
      Parameters:
      element - The element
      namespacePattern - an optional namespace ("*" means any namespace, null means no namespace)
      attributeName - The attribute name
      Returns:
      The attribute value. Returns "initial" if the element does not have an attribute with this name.
    • getAttributeNames

      public Set<QualifiedName> getAttributeNames(Element element)
      Description copied from interface: SelectorModel
      Returns all styleable attributes of the element.
      Parameters:
      element - An element of the document
      Returns:
      a set of styleable attributes.
    • getComposedAttributeNames

      public Set<QualifiedName> getComposedAttributeNames(Element element)
      Description copied from interface: SelectorModel
      Returns all non-decomposed styleable attributes of the element.

      If an attribute can be decomposed, only the composite attribute is returned.

      Parameters:
      element - An element of the document
      Returns:
      a set of styleable attributes.
    • getDecomposedAttributeNames

      public Set<QualifiedName> getDecomposedAttributeNames(Element element)
      Description copied from interface: SelectorModel
      Returns all decomposed styleable attributes of the element.

      If an attribute can be composed, only the decomposed attributes are returned.

      Parameters:
      element - An element of the document
      Returns:
      a set of styleable attributes.
    • setAttribute

      public void setAttribute(Element element, javafx.css.StyleOrigin origin, @Nullable String namespace, String name, @Nullable ReadOnlyList<CssToken> value)
      Description copied from interface: SelectorModel
      Sets an attribute value.
      Parameters:
      element - The element
      origin - The style origin
      namespace - an optional namespace ("*" means any namespace, null means no namespace)
      name - The attribute name
      value - The attribute value. null removes the attribute from the element. That is, null has the same effect like the keyword "unset".