com.vaadin.flow.dom.impl.
Class BasicElementStateProvider
- java.lang.Object
 - 
- com.vaadin.flow.dom.impl.AbstractNodeStateProvider
 - 
- com.vaadin.flow.dom.impl.BasicElementStateProvider
 
 
 
- 
All Implemented Interfaces:
public class BasicElementStateProvider extends AbstractNodeStateProviderImplementation 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.
Since:
1.0
Author:
Vaadin Ltd
See Also:
 
- 
- 
Method Summary
All Methods Modifier and Type Method and Description DomListenerRegistrationaddEventListener(StateNode node, String eventType, DomEventListener listener)Adds a DOM event listener.
RegistrationaddPropertyChangeListener(StateNode node, String name, PropertyChangeListener listener)Adds a property change listener.
StateNodeattachShadow(StateNode node)Attaches the shadow root for the
node.static StateNodecreateStateNode(String tag)Creates a compatible element state node using the given
tag.static BasicElementStateProviderget()Gets the one and only instance.
StringgetAttribute(StateNode node, String attribute)Gets the value of the given attribute.
Stream<String>getAttributeNames(StateNode node)Gets the defined attribute names.
ClassListgetClassList(StateNode node)Gets a list representation of all CSS class names set for an element.
static Collection<Class<? extends NodeFeature>>getFeatures()Gets all the features used by an element node.
protected Node<?>getNode(StateNode node)Gets the flyweight instance for the
nodesupported by the provider.NodegetParent(StateNode node)Gets the parent element.
SerializablegetProperty(StateNode node, String name)Gets the value of the given property.
Stream<String>getPropertyNames(StateNode node)Gets the defined property names.
protected Class<? extends NodeFeature>[]getProviderFeatures()Returns the features supported by the provider.
StateNodegetShadowRoot(StateNode node)Gets shadow root for the
nodeif it has been attached.StylegetStyle(StateNode node)Returns a style instance for managing element inline styles.
StringgetTag(StateNode node)Gets the tag name for the given node.
StringgetTextContent(StateNode node)Gets the text content.
booleanhasAttribute(StateNode node, String attribute)Checks if the given attribute has been set.
booleanhasProperty(StateNode node, String name)Checks if the given property has been set.
booleanisTextNode(StateNode node)Checks if the state node represents a text node.
booleanisVisible(StateNode node)Gets the
nodevisibility.protected ObjectreadResolve()voidremoveAttribute(StateNode node, String attribute)Removes the given attribute if it has been set.
voidremoveProperty(StateNode node, String name)Removes the given property if it has been set.
voidsetAttribute(StateNode node, String attribute, AbstractStreamResource receiver)Sets the given attribute to the given
StreamResourcevalue.voidsetAttribute(StateNode node, String attribute, String value)Sets the given attribute to the given value.
voidsetProperty(StateNode node, String name, Serializable value, boolean emitChange)Sets the given property to the given value.
voidsetTextContent(StateNode node, String textContent)Sets the text content.
voidsetVisible(StateNode node, boolean visible)Sets the
nodevisibility.booleansupports(StateNode node)Checks if the element state provider supports the given state node.
voidvisit(StateNode node, NodeVisitor visitor)Visit the
nodeapplyingvisitorto it and its descendants based on the return value from the visitor.- 
Methods inherited from class com.vaadin.flow.dom.impl.AbstractNodeStateProvider
appendVirtualChild, attachExistingElement, getChild, getChildCount, insertChild, removeAllChildren, removeChild, removeChild, visitDescendants 
- 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait 
- 
Methods inherited from interface com.vaadin.flow.dom.ElementStateProvider
getComponent, setComponent 
 - 
 
 - 
 
- 
- 
Method Detail
- 
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 elementReturns:
a initialized and compatible state node
 
- 
supports
public boolean supports(StateNode node)Description copied from interface:
ElementStateProviderChecks if the element state provider supports the given state node.
Specified by:
supportsin interfaceElementStateProviderOverrides:
supportsin classAbstractNodeStateProviderParameters:
node- the state node to checkReturns:
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:
ElementStateProviderGets the tag name for the given node.
Parameters:
node- the node containing the dataReturns:
the tag name
 
- 
setAttribute
public void setAttribute(StateNode node, String attribute, String value)Description copied from interface:
ElementStateProviderSets the given attribute to the given value.
Parameters:
node- the node containing the dataattribute- the attribute name, not nullvalue- the attribute value 
- 
getAttribute
public String getAttribute(StateNode node, String attribute)Description copied from interface:
ElementStateProviderGets the value of the given attribute.
Parameters:
node- the node containing the dataattribute- the attribute name, not nullReturns:
the attribute value or null if the attribute has not been set
 
- 
hasAttribute
public boolean hasAttribute(StateNode node, String attribute)Description copied from interface:
ElementStateProviderChecks if the given attribute has been set.
Parameters:
node- the node containing the dataattribute- the attribute name, not nullReturns:
true if the attribute has been set, false otherwise
 
- 
removeAttribute
public void removeAttribute(StateNode node, String attribute)Description copied from interface:
ElementStateProviderRemoves the given attribute if it has been set.
Parameters:
node- the node containing the dataattribute- the attribute name, not null 
- 
getAttributeNames
public Stream<String> getAttributeNames(StateNode node)Description copied from interface:
ElementStateProviderGets the defined attribute names.
Parameters:
node- the node containing the dataReturns:
the defined attribute names
 
- 
getParent
public Node getParent(StateNode node)Description copied from interface:
ElementStateProviderGets the parent element.
Specified by:
getParentin interfaceElementStateProviderOverrides:
getParentin classAbstractNodeStateProviderParameters:
node- the node containing the dataReturns:
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:
ElementStateProviderAdds a DOM event listener.
Parameters:
node- the node containing the dataeventType- the event typelistener- the listenerReturns:
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:
ElementStateProviderGets the value of the given property.
Parameters:
node- the node containing the dataname- the property name, not nullReturns:
the property value, or
nullif the property has not been set 
- 
setProperty
public void setProperty(StateNode node, String name, Serializable value, boolean emitChange)Description copied from interface:
ElementStateProviderSets the given property to the given value.
Parameters:
node- the node containing the dataname- the property name, notnullvalue- the property valueemitChange- true to create a change event for the client side 
- 
removeProperty
public void removeProperty(StateNode node, String name)Description copied from interface:
ElementStateProviderRemoves the given property if it has been set.
Parameters:
node- the node containing the dataname- the property name, notnull 
- 
hasProperty
public boolean hasProperty(StateNode node, String name)Description copied from interface:
ElementStateProviderChecks if the given property has been set.
Parameters:
node- the node containing the dataname- the property name, notnullReturns:
trueif the property has been set,falseotherwise 
- 
getPropertyNames
public Stream<String> getPropertyNames(StateNode node)Description copied from interface:
ElementStateProviderGets the defined property names.
Parameters:
node- the node containing the dataReturns:
the defined property names
 
- 
isTextNode
public boolean isTextNode(StateNode node)Description copied from interface:
ElementStateProviderChecks if the state node represents a text node.
Parameters:
node- the node to checkReturns:
trueif the state node represents a text node; otherwisefalse 
- 
getTextContent
public String getTextContent(StateNode node)Description copied from interface:
ElementStateProviderGets the text content. This is only valid if
ElementStateProvider.isTextNode(StateNode)returnstrue.Parameters:
node- the node containing the dataReturns:
the text content
 
- 
setTextContent
public void setTextContent(StateNode node, String textContent)Description copied from interface:
ElementStateProviderSets the text content. This is only valid if
ElementStateProvider.isTextNode(StateNode)returnstrue.Parameters:
node- the node containing the datatextContent- the text content, not null 
- 
getClassList
public ClassList getClassList(StateNode node)Description copied from interface:
ElementStateProviderGets a list representation of all CSS class names set for an element.
Parameters:
node- the node containing the dataReturns:
the class list, never
null 
- 
getStyle
public Style getStyle(StateNode node)Description copied from interface:
ElementStateProviderReturns a style instance for managing element inline styles.
Parameters:
node- the node containing the dataReturns:
the element styles
 
- 
setAttribute
public void setAttribute(StateNode node, String attribute, AbstractStreamResource receiver)Description copied from interface:
ElementStateProviderSets the given attribute to the given
StreamResourcevalue.Parameters:
node- the node containing the dataattribute- the attribute name, not nullreceiver- the attribute value, not null 
- 
addPropertyChangeListener
public Registration addPropertyChangeListener(StateNode node, String name, PropertyChangeListener listener)Description copied from interface:
ElementStateProviderAdds a property change listener.
Parameters:
node- the node containing the propertyname- the property name to add the listener forlistener- listener to get notifications about property value changesReturns:
an event registration handle for removing the listener
 
- 
getShadowRoot
public StateNode getShadowRoot(StateNode node)Description copied from interface:
ElementStateProviderGets shadow root for the
nodeif it has been attached.Parameters:
node- the node having a shadow root, notnullReturns:
the shadow root of the
node, may be null 
- 
attachShadow
public StateNode attachShadow(StateNode node)Description copied from interface:
ElementStateProviderAttaches the shadow root for the
node.Parameters:
node- the node to attach the shadow rootReturns:
the shadow root of the
node 
- 
visit
public void visit(StateNode node, NodeVisitor visitor)Description copied from interface:
ElementStateProviderVisit the
nodeapplyingvisitorto it and its descendants based on the return value from the visitor.Parameters:
node- the node to visitvisitor- the visitor to apply to the node 
- 
setVisible
public void setVisible(StateNode node, boolean visible)Description copied from interface:
ElementStateProviderSets the
nodevisibility.Parameters:
node- the node containing the datavisible- the node visibility value 
- 
isVisible
public boolean isVisible(StateNode node)Description copied from interface:
ElementStateProviderGets the
nodevisibility.Parameters:
node- the node containing the dataReturns:
the node visibility
 
- 
getNode
protected Node<?> getNode(StateNode node)Description copied from class:
AbstractNodeStateProviderGets the flyweight instance for the
nodesupported by the provider.Specified by:
getNodein classAbstractNodeStateProviderParameters:
node- the node to wrap into flyweightReturns:
the flyweight instance for the
nodeSee Also:
 
- 
getProviderFeatures
protected Class<? extends NodeFeature>[] getProviderFeatures()Description copied from class:
AbstractNodeStateProviderReturns the features supported by the provider.
Specified by:
getProviderFeaturesin classAbstractNodeStateProviderReturns:
features supported by the provider
 
- 
readResolve
protected Object readResolve() throws ObjectStreamExceptionThrows:
 
 - 
 
 -