Class BasicElementStateProvider

java.lang.Object
com.vaadin.flow.dom.impl.AbstractNodeStateProvider
com.vaadin.flow.dom.impl.BasicElementStateProvider
All Implemented Interfaces:
ElementStateProvider, Serializable

public class BasicElementStateProvider extends AbstractNodeStateProvider
Implementation which stores data for basic elements, i.e. elements which are not bound to any template and have no special functionality.

This should be considered a low level class focusing on performance and leaving most sanity checks to the caller.

The data is stored directly in the state node but this should be considered an implementation detail which can change.

For internal use only. May be renamed or removed in a future release.

Since:
1.0
Author:
Vaadin Ltd
See Also:
  • Method Details

    • get

      public static BasicElementStateProvider get()
      Gets the one and only instance.
      Returns:
      the instance to use for all basic elements
    • createStateNode

      public static StateNode createStateNode(String tag)
      Creates a compatible element state node using the given tag.
      Parameters:
      tag - the tag to use for the element
      Returns:
      a initialized and compatible state node
    • supports

      public boolean supports(StateNode node)
      Description copied from interface: ElementStateProvider
      Checks if the element state provider supports the given state node.
      Specified by:
      supports in interface ElementStateProvider
      Overrides:
      supports in class AbstractNodeStateProvider
      Parameters:
      node - the state node to check
      Returns:
      true if the element state provider is compatible with the given state node, false otherwise
    • getTag

      public String getTag(StateNode node)
      Description copied from interface: ElementStateProvider
      Gets the tag name for the given node.
      Parameters:
      node - the node containing the data
      Returns:
      the tag name
    • setAttribute

      public void setAttribute(StateNode node, String attribute, String value)
      Description copied from interface: ElementStateProvider
      Sets the given attribute to the given value.
      Parameters:
      node - the node containing the data
      attribute - the attribute name, not null
      value - the attribute value
    • getAttribute

      public String getAttribute(StateNode node, String attribute)
      Description copied from interface: ElementStateProvider
      Gets the value of the given attribute.
      Parameters:
      node - the node containing the data
      attribute - the attribute name, not null
      Returns:
      the attribute value or null if the attribute has not been set
    • hasAttribute

      public boolean hasAttribute(StateNode node, String attribute)
      Description copied from interface: ElementStateProvider
      Checks if the given attribute has been set.
      Parameters:
      node - the node containing the data
      attribute - the attribute name, not null
      Returns:
      true if the attribute has been set, false otherwise
    • removeAttribute

      public void removeAttribute(StateNode node, String attribute)
      Description copied from interface: ElementStateProvider
      Removes the given attribute if it has been set.
      Parameters:
      node - the node containing the data
      attribute - the attribute name, not null
    • getAttributeNames

      public Stream<String> getAttributeNames(StateNode node)
      Description copied from interface: ElementStateProvider
      Gets the defined attribute names.
      Parameters:
      node - the node containing the data
      Returns:
      the defined attribute names
    • getParent

      public Node getParent(StateNode node)
      Description copied from interface: ElementStateProvider
      Gets the parent element.
      Specified by:
      getParent in interface ElementStateProvider
      Overrides:
      getParent in class AbstractNodeStateProvider
      Parameters:
      node - the node containing the data
      Returns:
      the parent element or null if the element has no parent
    • addEventListener

      public DomListenerRegistration addEventListener(StateNode node, String eventType, DomEventListener listener)
      Description copied from interface: ElementStateProvider
      Adds a DOM event listener.
      Parameters:
      node - the node containing the data
      eventType - the event type
      listener - the listener
      Returns:
      a handle for configuring or removing the listener
    • getFeatures

      public static Collection<Class<? extends NodeFeature>> getFeatures()
      Gets all the features used by an element node.
      Returns:
      an unmodifiable collection of feature classes
    • getProperty

      public Serializable getProperty(StateNode node, String name)
      Description copied from interface: ElementStateProvider
      Gets the value of the given property.
      Parameters:
      node - the node containing the data
      name - the property name, not null
      Returns:
      the property value, or null if the property has not been set
    • setProperty

      public void setProperty(StateNode node, String name, Serializable value, boolean emitChange)
      Description copied from interface: ElementStateProvider
      Sets the given property to the given value.
      Parameters:
      node - the node containing the data
      name - the property name, not null
      value - the property value
      emitChange - true to create a change event for the client side
    • removeProperty

      public void removeProperty(StateNode node, String name)
      Description copied from interface: ElementStateProvider
      Removes the given property if it has been set.
      Parameters:
      node - the node containing the data
      name - the property name, not null
    • hasProperty

      public boolean hasProperty(StateNode node, String name)
      Description copied from interface: ElementStateProvider
      Checks if the given property has been set.
      Parameters:
      node - the node containing the data
      name - the property name, not null
      Returns:
      true if the property has been set, false otherwise
    • getPropertyNames

      public Stream<String> getPropertyNames(StateNode node)
      Description copied from interface: ElementStateProvider
      Gets the defined property names.
      Parameters:
      node - the node containing the data
      Returns:
      the defined property names
    • isTextNode

      public boolean isTextNode(StateNode node)
      Description copied from interface: ElementStateProvider
      Checks if the state node represents a text node.
      Parameters:
      node - the node to check
      Returns:
      true if the state node represents a text node; otherwise false
    • getTextContent

      public String getTextContent(StateNode node)
      Description copied from interface: ElementStateProvider
      Gets the text content. This is only valid if ElementStateProvider.isTextNode(StateNode) returns true.
      Parameters:
      node - the node containing the data
      Returns:
      the text content
    • setTextContent

      public void setTextContent(StateNode node, String textContent)
      Description copied from interface: ElementStateProvider
      Sets the text content. This is only valid if ElementStateProvider.isTextNode(StateNode) returns true.
      Parameters:
      node - the node containing the data
      textContent - the text content, not null
    • getClassList

      public ClassList getClassList(StateNode node)
      Description copied from interface: ElementStateProvider
      Gets a list representation of all CSS class names set for an element.
      Parameters:
      node - the node containing the data
      Returns:
      the class list, never null
    • getStyle

      public Style getStyle(StateNode node)
      Description copied from interface: ElementStateProvider
      Returns a style instance for managing element inline styles.
      Parameters:
      node - the node containing the data
      Returns:
      the element styles
    • setAttribute

      public void setAttribute(StateNode node, String attribute, AbstractStreamResource receiver)
      Description copied from interface: ElementStateProvider
      Sets the given attribute to the given StreamResource value.
      Parameters:
      node - the node containing the data
      attribute - the attribute name, not null
      receiver - the attribute value, not null
    • addPropertyChangeListener

      public Registration addPropertyChangeListener(StateNode node, String name, PropertyChangeListener listener)
      Description copied from interface: ElementStateProvider
      Adds a property change listener.
      Parameters:
      node - the node containing the property
      name - the property name to add the listener for
      listener - listener to get notifications about property value changes
      Returns:
      an event registration handle for removing the listener
    • getShadowRoot

      public StateNode getShadowRoot(StateNode node)
      Description copied from interface: ElementStateProvider
      Gets shadow root for the node if it has been attached.
      Parameters:
      node - the node having a shadow root, not null
      Returns:
      the shadow root of the node, may be null
    • attachShadow

      public StateNode attachShadow(StateNode node)
      Description copied from interface: ElementStateProvider
      Attaches the shadow root for the node.
      Parameters:
      node - the node to attach the shadow root
      Returns:
      the shadow root of the node
    • visit

      public void visit(StateNode node, NodeVisitor visitor)
      Description copied from interface: ElementStateProvider
      Visit the node applying visitor to it and its descendants based on the return value from the visitor.
      Parameters:
      node - the node to visit
      visitor - the visitor to apply to the node
    • setVisible

      public void setVisible(StateNode node, boolean visible)
      Description copied from interface: ElementStateProvider
      Sets the node visibility.
      Parameters:
      node - the node containing the data
      visible - the node visibility value
    • isVisible

      public boolean isVisible(StateNode node)
      Description copied from interface: ElementStateProvider
      Gets the node visibility.
      Parameters:
      node - the node containing the data
      Returns:
      the node visibility
    • getNode

      protected Node<?> getNode(StateNode node)
      Description copied from class: AbstractNodeStateProvider
      Gets the flyweight instance for the node supported by the provider.
      Specified by:
      getNode in class AbstractNodeStateProvider
      Parameters:
      node - the node to wrap into flyweight
      Returns:
      the flyweight instance for the node
      See Also:
    • getProviderFeatures

      protected Class<? extends NodeFeature>[] getProviderFeatures()
      Description copied from class: AbstractNodeStateProvider
      Returns the features supported by the provider.
      Specified by:
      getProviderFeatures in class AbstractNodeStateProvider
      Returns:
      features supported by the provider
    • readResolve

      protected Object readResolve() throws ObjectStreamException
      Throws:
      ObjectStreamException