public class BasicElementStateProvider extends AbstractNodeStateProvider
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.
Modifier and Type | Method and Description |
---|---|
DomListenerRegistration |
addEventListener(StateNode node,
String eventType,
DomEventListener listener)
Adds a DOM event listener.
|
Registration |
addPropertyChangeListener(StateNode node,
String name,
PropertyChangeListener listener)
Adds a property change listener.
|
void |
addSynchronizedProperty(StateNode node,
String property,
DisabledUpdateMode mode)
Makes the property synchronized from the client side to the server.
|
StateNode |
attachShadow(StateNode node)
Attaches the shadow root for the
node . |
static StateNode |
createStateNode(String tag)
Creates a compatible element state node using the given
tag . |
static BasicElementStateProvider |
get()
Gets the one and only instance.
|
String |
getAttribute(StateNode node,
String attribute)
Gets the value of the given attribute.
|
Stream<String> |
getAttributeNames(StateNode node)
Gets the defined attribute names.
|
ClassList |
getClassList(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
node supported by the
provider. |
Node |
getParent(StateNode node)
Gets the parent element.
|
Serializable |
getProperty(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.
|
StateNode |
getShadowRoot(StateNode node)
Gets shadow root for the
node if it has been attached. |
Style |
getStyle(StateNode node)
Returns a style instance for managing element inline styles.
|
Set<String> |
getSynchronizedProperties(StateNode node)
Gets the names of the properties to synchronize from the client side to
the server.
|
Set<String> |
getSynchronizedPropertyEvents(StateNode node)
Gets the event types which should trigger synchronization of properties
from the client side to the server.
|
String |
getTag(StateNode node)
Gets the tag name for the given node.
|
String |
getTextContent(StateNode node)
Gets the text content.
|
boolean |
hasAttribute(StateNode node,
String attribute)
Checks if the given attribute has been set.
|
boolean |
hasProperty(StateNode node,
String name)
Checks if the given property has been set.
|
boolean |
isTextNode(StateNode node)
Checks if the state node represents a text node.
|
boolean |
isVisible(StateNode node)
Gets the
node visibility. |
void |
removeAttribute(StateNode node,
String attribute)
Removes the given attribute if it has been set.
|
void |
removeProperty(StateNode node,
String name)
Removes the given property if it has been set.
|
void |
setAttribute(StateNode node,
String attribute,
AbstractStreamResource receiver)
Sets the given attribute to the given
StreamResource value. |
void |
setAttribute(StateNode node,
String attribute,
String value)
Sets the given attribute to the given value.
|
void |
setProperty(StateNode node,
String name,
Serializable value,
boolean emitChange)
Sets the given property to the given value.
|
void |
setTextContent(StateNode node,
String textContent)
Sets the text content.
|
void |
setVisible(StateNode node,
boolean visible)
Sets the
node visibility. |
boolean |
supports(StateNode node)
Checks if the element state provider supports the given state node.
|
void |
visit(StateNode node,
NodeVisitor visitor)
Visit the
node applying visitor to it and its descendants
based on the return value from the visitor. |
appendVirtualChild, attachExistingElement, getChild, getChildCount, insertChild, removeAllChildren, removeChild, removeChild, visitDescendants
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getComponent, setComponent
public static BasicElementStateProvider get()
public static StateNode createStateNode(String tag)
tag
.tag
- the tag to use for the elementpublic boolean supports(StateNode node)
ElementStateProvider
supports
in interface ElementStateProvider
supports
in class AbstractNodeStateProvider
node
- the state node to checkpublic String getTag(StateNode node)
ElementStateProvider
node
- the node containing the datapublic void setAttribute(StateNode node, String attribute, String value)
ElementStateProvider
node
- the node containing the dataattribute
- the attribute name, not nullvalue
- the attribute valuepublic String getAttribute(StateNode node, String attribute)
ElementStateProvider
node
- the node containing the dataattribute
- the attribute name, not nullpublic boolean hasAttribute(StateNode node, String attribute)
ElementStateProvider
node
- the node containing the dataattribute
- the attribute name, not nullpublic void removeAttribute(StateNode node, String attribute)
ElementStateProvider
node
- the node containing the dataattribute
- the attribute name, not nullpublic Stream<String> getAttributeNames(StateNode node)
ElementStateProvider
node
- the node containing the datapublic Node getParent(StateNode node)
ElementStateProvider
getParent
in interface ElementStateProvider
getParent
in class AbstractNodeStateProvider
node
- the node containing the datapublic DomListenerRegistration addEventListener(StateNode node, String eventType, DomEventListener listener)
ElementStateProvider
node
- the node containing the dataeventType
- the event typelistener
- the listenerpublic static Collection<Class<? extends NodeFeature>> getFeatures()
public Serializable getProperty(StateNode node, String name)
ElementStateProvider
node
- the node containing the dataname
- the property name, not nullnull
if the property has not
been setpublic void setProperty(StateNode node, String name, Serializable value, boolean emitChange)
ElementStateProvider
node
- the node containing the dataname
- the property name, not null
value
- the property valueemitChange
- true to create a change event for the client sidepublic void removeProperty(StateNode node, String name)
ElementStateProvider
node
- the node containing the dataname
- the property name, not null
public boolean hasProperty(StateNode node, String name)
ElementStateProvider
node
- the node containing the dataname
- the property name, not null
true
if the property has been set,
false
otherwisepublic Stream<String> getPropertyNames(StateNode node)
ElementStateProvider
node
- the node containing the datapublic boolean isTextNode(StateNode node)
ElementStateProvider
node
- the node to checktrue
if the state node represents a text node;
otherwise false
public String getTextContent(StateNode node)
ElementStateProvider
ElementStateProvider.isTextNode(StateNode)
returns true
.node
- the node containing the datapublic void setTextContent(StateNode node, String textContent)
ElementStateProvider
ElementStateProvider.isTextNode(StateNode)
returns true
.node
- the node containing the datatextContent
- the text content, not nullpublic ClassList getClassList(StateNode node)
ElementStateProvider
node
- the node containing the datanull
public Style getStyle(StateNode node)
ElementStateProvider
node
- the node containing the datapublic Set<String> getSynchronizedProperties(StateNode node)
ElementStateProvider
The events which trigger synchronization are defined using
ElementStateProvider.getSynchronizedPropertyEvents(StateNode)
.
node
- the node containing the datapublic Set<String> getSynchronizedPropertyEvents(StateNode node)
ElementStateProvider
node
- the node containing the datapublic void setAttribute(StateNode node, String attribute, AbstractStreamResource receiver)
ElementStateProvider
StreamResource
value.node
- the node containing the dataattribute
- the attribute name, not nullreceiver
- the attribute value, not nullpublic Registration addPropertyChangeListener(StateNode node, String name, PropertyChangeListener listener)
ElementStateProvider
node
- the node containing the propertyname
- the property name to add the listener forlistener
- listener to get notifications about property value changespublic StateNode getShadowRoot(StateNode node)
ElementStateProvider
node
if it has been attached.node
- the node having a shadow root, not null
node
, may be nullpublic StateNode attachShadow(StateNode node)
ElementStateProvider
node
.node
- the node to attach the shadow rootnode
public void visit(StateNode node, NodeVisitor visitor)
ElementStateProvider
node
applying visitor
to it and its descendants
based on the return value from the visitor.node
- the node to visitvisitor
- the visitor to apply to the nodepublic void setVisible(StateNode node, boolean visible)
ElementStateProvider
node
visibility.node
- the node containing the datavisible
- the node visibility valuepublic boolean isVisible(StateNode node)
ElementStateProvider
node
visibility.node
- the node containing the datapublic void addSynchronizedProperty(StateNode node, String property, DisabledUpdateMode mode)
ElementStateProvider
The events which trigger synchronization are defined using
ElementStateProvider.getSynchronizedPropertyEvents(StateNode)
.
node
- the node containing the dataproperty
- the property to synchronizemode
- controls RPC from the client side to the server side when the
element is disabled, not null
ElementStateProvider.getSynchronizedPropertyEvents(StateNode)
,
ElementStateProvider.getSynchronizedProperties(StateNode)
protected Node<?> getNode(StateNode node)
AbstractNodeStateProvider
node
supported by the
provider.getNode
in class AbstractNodeStateProvider
node
- the node to wrap into flyweightnode
AbstractNodeStateProvider.supports(StateNode)
protected Class<? extends NodeFeature>[] getProviderFeatures()
AbstractNodeStateProvider
getProviderFeatures
in class AbstractNodeStateProvider
Copyright © 2019. All rights reserved.