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(@NonNull Element elem, javafx.css.StyleOrigin origin, @Nullable String namespacePattern, @NonNull String name)
    • getAttribute

      public @Nullable List<CssToken> getAttribute(@NonNull Element element, @Nullable javafx.css.StyleOrigin origin, @Nullable String namespacePattern, @NonNull String name)
    • hasId

      public boolean hasId(@NonNull Element elem, @NonNull 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(@NonNull 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(@NonNull Element elem, @Nullable String namespacePattern, @NonNull 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(@NonNull 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(@NonNull Element elem, @NonNull 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 @NonNull ReadOnlySet<String> getStyleClasses(@NonNull 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 @NonNull ReadOnlySet<String> getPseudoClasses(@NonNull 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(@NonNull Element element, @NonNull 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 @NonNull Element getParent(@NonNull 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 @NonNull Element getPreviousSibling(@NonNull 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(@NonNull Element element, @Nullable String namespace, @NonNull 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(@NonNull Element element, @Nullable String namespacePattern, @NonNull String attributeName, @NonNull 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 - The attribute 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(@NonNull Element element, @Nullable String namespacePattern, @NonNull 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 @NonNull Set<QualifiedName> getAttributeNames(@NonNull 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 @NonNull Set<QualifiedName> getComposedAttributeNames(@NonNull 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 @NonNull Set<QualifiedName> getDecomposedAttributeNames(@NonNull 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(@NonNull Element element, @NonNull javafx.css.StyleOrigin origin, @Nullable String namespace, @NonNull 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".