public class OMNode extends Object implements com.google.gwt.event.shared.HasHandlers
Modifier and Type | Field and Description |
---|---|
protected static com.google.gwt.event.shared.EventBus |
eventBus
The event bus shared by all SVG objects
|
protected com.google.gwt.dom.client.Node |
ot
The DOM native overlay type wrapped by this object
|
Modifier | Constructor and Description |
---|---|
protected |
OMNode(com.google.gwt.dom.client.Node node)
Constructor
|
Modifier and Type | Method and Description |
---|---|
<H extends com.google.gwt.event.shared.EventHandler> |
addDomHandler(H handler,
com.google.gwt.event.dom.client.DomEvent.Type<H> type)
Adds a DOM handler to this node's list of handlers
|
<H extends com.google.gwt.event.shared.EventHandler> |
addHandler(H handler,
com.google.gwt.event.shared.GwtEvent.Type<H> type)
Adds a handler to this node's list of handlers
|
OMNode |
appendChild(OMNode newChild)
Adds the node
newChild to the end of the list of children
of this node. |
void |
cleanup()
Cleanup method for wrapper objects which are
not needed by the application any more.
|
OMNode |
cloneNode(boolean deep)
Returns a duplicate of this node, i.e., serves as a generic copy
constructor for nodes.
|
static <T extends OMNode> |
convert(com.google.gwt.dom.client.Node obj)
Returns the wrapper for the specified overlay type node, automatically constructing
a new wrapper if the node was previously unwrapped.
|
static <T extends Iterable<? extends OMNode>> |
convertList(com.google.gwt.core.client.JavaScriptObject obj)
Generates a wrapper around an overlay type list
|
void |
dispatch(com.google.gwt.dom.client.NativeEvent event)
Dispatches the specified event to this node
event handlers
|
void |
fireEvent(com.google.gwt.event.shared.GwtEvent<?> event)
Fires the given event to the handlers listening to the event's type.
|
<T extends OMNode> |
getChildNodes()
A
OMNodeList that contains all children of this node. |
static com.google.gwt.event.shared.EventBus |
getEventBus()
Returns the event bus shared by all SVG objects
|
OMNode |
getFirstChild()
The first child of this node.
|
OMNode |
getLastChild()
The last child of this node.
|
String |
getLocalName()
Returns the local part of the qualified name of this node.
|
String |
getNamespaceURI()
The namespace URI of the specified node, or
null if it is
unspecified (see ). |
OMNode |
getNextSibling()
The node immediately following this node.
|
com.google.gwt.dom.client.Node |
getNode()
Returns the wrapped node
|
String |
getNodeName()
The name of this node, depending on its type.
|
short |
getNodeType()
A code representing the type of the underlying object.
|
String |
getNodeValue()
The value of this node, depending on its type.
|
OMDocument |
getOwnerDocument()
The
OMDocument object associated with this node. |
OMNode |
getParentNode()
The parent of this node.
|
OMNode |
getPreviousSibling()
The node immediately preceding this node.
|
boolean |
hasChildNodes()
Returns whether this node has any children.
|
OMNode |
insertBefore(OMNode newChild,
OMNode refChild)
Inserts the node
newChild before the existing child node
refChild . |
void |
normalize()
Puts all
Text nodes in the full depth of the sub-tree
underneath this Node , including attribute nodes, into a
"normal" form where only structure (e.g., elements, comments,
processing instructions, CDATA sections, and entity references)
separates Text nodes, i.e., there are neither adjacent
Text nodes nor empty Text nodes. |
OMNode |
removeChild(OMNode oldChild)
Removes the child node indicated by
oldChild from the list
of children, and returns it. |
OMNode |
replaceChild(OMNode newChild,
OMNode oldChild)
Replaces the child node
oldChild with newChild
in the list of children, and returns the oldChild node. |
void |
setNodeValue(String value)
The value of this node, depending on its type; see the table above.
|
String |
toString() |
protected final com.google.gwt.dom.client.Node ot
protected static com.google.gwt.event.shared.EventBus eventBus
protected OMNode(com.google.gwt.dom.client.Node node)
node
- The node to wrappublic void cleanup()
public static com.google.gwt.event.shared.EventBus getEventBus()
public void fireEvent(com.google.gwt.event.shared.GwtEvent<?> event)
Any exceptions thrown by handlers will be bundled into a
UmbrellaException
and then re-thrown after all handlers have
completed. An exception thrown by a handler will not prevent other handlers
from executing.
fireEvent
in interface com.google.gwt.event.shared.HasHandlers
event
- the eventpublic void dispatch(com.google.gwt.dom.client.NativeEvent event)
event
- The event to dispatchpublic final <H extends com.google.gwt.event.shared.EventHandler> com.google.gwt.event.shared.HandlerRegistration addDomHandler(H handler, com.google.gwt.event.dom.client.DomEvent.Type<H> type)
H
- The handler typehandler
- The DOM handlertype
- The event typeHandlerRegistration
used to remove this handlerpublic final <H extends com.google.gwt.event.shared.EventHandler> com.google.gwt.event.shared.HandlerRegistration addHandler(H handler, com.google.gwt.event.shared.GwtEvent.Type<H> type)
H
- The handler typehandler
- The handlertype
- The event typeHandlerRegistration
used to remove this handlerpublic static <T extends OMNode> T convert(com.google.gwt.dom.client.Node obj)
T
- the node typeobj
- The overlay type nodepublic static <T extends Iterable<? extends OMNode>> T convertList(com.google.gwt.core.client.JavaScriptObject obj)
T
- the list typeobj
- The overlay type listpublic com.google.gwt.dom.client.Node getNode()
public final String getNodeName()
public final String getNodeValue()
null
, setting it has no effect,
including if the node is read-only.public final void setNodeValue(String value) throws com.google.gwt.core.client.JavaScriptException
null
, setting it has no effect,
including if the node is read-only.value
- The node valueDOMException
- NO_MODIFICATION_ALLOWED_ERR: Raised when the node is readonly and if
it is not defined to be null
.com.google.gwt.core.client.JavaScriptException
public final short getNodeType()
public final OMNode getParentNode()
OMAttr
,
OMDocument
may have a parent.
However, if a node has just been created and not yet added to the
tree, or if it has been removed from the tree, this is
null
.public final <T extends OMNode> OMNodeList<T> getChildNodes()
OMNodeList
that contains all children of this node. If
there are no children, this is a OMNodeList
containing no
nodes.OMNodeList
that contains all children of this node. Ifpublic final OMNode getFirstChild()
null
.public final OMNode getLastChild()
null
.public final String getLocalName()
ELEMENT_NODE
and
ATTRIBUTE_NODE
and nodes created with a DOM Level 1
method, such as Document.createElement()
, this is always
null
.public final OMNode getPreviousSibling()
null
.public String getNamespaceURI()
null
if it is
unspecified (see ).
ELEMENT_NODE
and
ATTRIBUTE_NODE
and nodes created with a DOM Level 1
method, such as Document.createElement()
, this is always
null
.
Note: Per the Namespaces in XML Specification [XML Namespaces] an attribute does not inherit its namespace from the element it is attached to. If an attribute is not explicitly given a namespace, it simply has no namespace.
public final OMNode getNextSibling()
null
.public final OMDocument getOwnerDocument()
OMDocument
object associated with this node. This is
also the OMDocument
object used to create new nodes. When
this node is a OMNode
which is not used with any OMDocument
yet, this is
null
.OMDocument
object associated with this node.public final OMNode insertBefore(OMNode newChild, OMNode refChild) throws com.google.gwt.core.client.JavaScriptException
newChild
before the existing child node
refChild
. If refChild
is null
,
insert newChild
at the end of the list of children.
newChild
is a DocumentFragment
object,
all of its children are inserted, in the same order, before
refChild
. If the newChild
is already in the
tree, it is first removed.
Note: Inserting a node before itself is implementation dependent.
newChild
- The node to insert.refChild
- The reference node, i.e., the node before which the
new node must be inserted.DOMException
- HIERARCHY_REQUEST_ERR: Raised if this node is of a type that does not
allow children of the type of the newChild
node, or if
the node to insert is one of this node's ancestors or this node
itself, or if this node is of type Document
and the
DOM application attempts to insert a second
DocumentType
or Element
node.
newChild
was created
from a different document than the one that created this node.
refChild
is not a child of
this node.
Document
,
this exception might be raised if the DOM implementation doesn't
support the insertion of a DocumentType
or
Element
node.com.google.gwt.core.client.JavaScriptException
public final OMNode replaceChild(OMNode newChild, OMNode oldChild) throws com.google.gwt.core.client.JavaScriptException
oldChild
with newChild
in the list of children, and returns the oldChild
node.
newChild
is a DocumentFragment
object,
oldChild
is replaced by all of the
DocumentFragment
children, which are inserted in the
same order. If the newChild
is already in the tree, it
is first removed.
Note: Replacing a node with itself is implementation dependent.
newChild
- The new node to put in the child list.oldChild
- The node being replaced in the list.DOMException
- HIERARCHY_REQUEST_ERR: Raised if this node is of a type that does not
allow children of the type of the newChild
node, or if
the node to put in is one of this node's ancestors or this node
itself, or if this node is of type Document
and the
result of the replacement operation would add a second
DocumentType
or Element
on the
Document
node.
newChild
was created
from a different document than the one that created this node.
oldChild
is not a child of
this node.
Document
,
this exception might be raised if the DOM implementation doesn't
support the replacement of the DocumentType
child or
Element
child.com.google.gwt.core.client.JavaScriptException
public final OMNode removeChild(OMNode oldChild) throws com.google.gwt.core.client.JavaScriptException
oldChild
from the list
of children, and returns it.oldChild
- The node being removed.DOMException
- NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
oldChild
is not a child of
this node.
Document
,
this exception might be raised if the DOM implementation doesn't
support the removal of the DocumentType
child or the
Element
child.com.google.gwt.core.client.JavaScriptException
public final OMNode appendChild(OMNode newChild) throws com.google.gwt.core.client.JavaScriptException
newChild
to the end of the list of children
of this node. If the newChild
is already in the tree, it
is first removed.newChild
- The node to add.If it is a
DocumentFragment
object, the entire contents of the
document fragment are moved into the child list of this nodeDOMException
- HIERARCHY_REQUEST_ERR: Raised if this node is of a type that does not
allow children of the type of the newChild
node, or if
the node to append is one of this node's ancestors or this node
itself, or if this node is of type Document
and the
DOM application attempts to append a second
DocumentType
or Element
node.
newChild
was created
from a different document than the one that created this node.
newChild
node is a child
of the Document
node, this exception might be raised
if the DOM implementation doesn't support the removal of the
DocumentType
child or Element
child.com.google.gwt.core.client.JavaScriptException
public final boolean hasChildNodes()
true
if this node has any children,
false
otherwise.public final OMNode cloneNode(boolean deep)
parentNode
is null
) and no user data. User
data associated to the imported node is not carried over. However, if
any UserDataHandlers
has been specified along with the
associated data these handlers will be called with the appropriate
parameters before this method returns.
Element
copies all attributes and their
values, including those generated by the XML processor to represent
defaulted attributes, but this method does not copy any children it
contains unless it is a deep clone. This includes text contained in
an the Element
since the text is contained in a child
Text
node. Cloning an Attr
directly, as
opposed to be cloned as part of an Element
cloning
operation, returns a specified attribute (specified
is
true
). Cloning an Attr
always clones its
children, since they represent its value, no matter whether this is a
deep clone or not. Cloning an EntityReference
automatically constructs its subtree if a corresponding
Entity
is available, no matter whether this is a deep
clone or not. Cloning any other type of node simply returns a copy of
this node.
EntityReference
clone are readonly
. In addition, clones of unspecified Attr
nodes are
specified. And, cloning Document
,
DocumentType
, Entity
, and
Notation
nodes is implementation dependent.deep
- If true
, recursively clone the subtree under
the specified node; if false
, clone only the node
itself (and its attributes, if it is an Element
).public final void normalize()
Text
nodes in the full depth of the sub-tree
underneath this Node
, including attribute nodes, into a
"normal" form where only structure (e.g., elements, comments,
processing instructions, CDATA sections, and entity references)
separates Text
nodes, i.e., there are neither adjacent
Text
nodes nor empty Text
nodes. This can
be used to ensure that the DOM view of a document is the same as if
it were saved and re-loaded, and is useful when operations (such as
XPointer [XPointer]
lookups) that depend on a particular document tree structure are to
be used. If the parameter "normalize-characters" of the
DOMConfiguration
object attached to the
Node.ownerDocument
is true
, this method
will also fully normalize the characters of the Text
nodes.
Note: In cases where the document contains
CDATASections
, the normalize operation alone may not be
sufficient, since XPointers do not differentiate between
Text
nodes and CDATASection
nodes.
Copyright © 2018. All Rights Reserved.