org.vectomatic.dom.svg.utils
Class DOMHelper

java.lang.Object
  extended by org.vectomatic.dom.svg.utils.DOMHelper

public class DOMHelper
extends Object

Class to group miscellaneous DOM level 2 methods. These methods are missing from the GWT DOM overlay types (such as Element or Node) but exist in almost all browsers and are sometimes required to develop an SVG application.

Author:
laaglu

Constructor Summary
DOMHelper()
           
 
Method Summary
static void appendData(com.google.gwt.dom.client.Text text, String arg)
          Append the string to the end of the character data of the node.
static String base64encode(String str)
          Returns a base64 encoding of the specified binary string
static void bindEventListener(com.google.gwt.dom.client.Element elem, String eventName)
          Makes a node sink the events emitted by the specified element
static com.google.gwt.dom.client.Document createDocument(String uri, String qname)
          Creates a new empty SVG document
static com.google.gwt.dom.client.Element createElementNS(com.google.gwt.dom.client.Document document, String namespaceURI, String qualifiedName)
          Creates an element of the given qualified name and namespace URI.
static boolean evaluateBooleanXPath(com.google.gwt.dom.client.Element root, String expr, XPathPrefixResolver resolver)
          Evaluates the specified XPath expression and returns the matching boolean.
static
<T extends com.google.gwt.dom.client.Node>
Iterator<T>
evaluateNodeListXPath(com.google.gwt.dom.client.Element root, String expr, XPathPrefixResolver resolver)
          Evaluates the specified XPath expression and returns a iterator for the selected Node node list.
static
<T extends com.google.gwt.dom.client.Node>
T
evaluateNodeXPath(com.google.gwt.dom.client.Element root, String expr, XPathPrefixResolver resolver)
          Evaluates the specified XPath expression and returns the matching Node node.
static float evaluateNumberXPath(com.google.gwt.dom.client.Element root, String expr, XPathPrefixResolver resolver)
          Evaluates the specified XPath expression and returns the matching float.
static String evaluateStringXPath(com.google.gwt.dom.client.Element root, String expr, XPathPrefixResolver resolver)
          Evaluates the specified XPath expression and returns the matching String.
static
<T extends OMNode>
Iterator<T>
evaluateXPath(OMElement root, String expr, XPathPrefixResolver resolver)
          Evaluates the specified XPath expression and returns a iterator for the selected OMNode node list.
static Attr getAttributeNode(com.google.gwt.dom.client.Element elt, String attrName)
          Retrieves an attribute node by name on the specified element.
static String getAttributeNS(com.google.gwt.dom.client.Element elem, String namespaceURI, String localName)
          Retrieves an attribute value by local name and namespace URI on the specified element.
static NamedNodeMap<Attr> getAttributes(com.google.gwt.dom.client.Element elem)
          Returns a NamedNodeMap containing the attributes of the specified element.
static OMSVGElement getCaptureElement()
          Returns the element which currently captures all the events after a call to setCaptureElement(OMSVGElement, LoseCaptureHandler) or null if element is set to capture events
static com.google.gwt.dom.client.Document getCurrentDocument()
          Returns the current document
static com.google.gwt.dom.client.NodeList<? extends com.google.gwt.dom.client.Node> getElementsByTagNameNS(com.google.gwt.dom.client.Document doc, String namespaceURI, String localName)
          Returns a NodeList of all the Elements in the specified document with a given local name and namespace URI in document order.
static com.google.gwt.dom.client.NodeList<? extends com.google.gwt.dom.client.Node> getElementsByTagNameNS(com.google.gwt.dom.client.Element elem, String namespaceURI, String localName)
          Returns a NodeList of all the descendant Elements of the specified element with a given local name and namespace URI in document order.
static String getLocalName(com.google.gwt.dom.client.Node node)
          Returns the local part of the qualified name of this node.
static String getNamespaceURI(com.google.gwt.dom.client.Node node)
          The namespace URI of the specified node, or null if it is unspecified (see ).
static String getType(com.google.gwt.core.client.JavaScriptObject x)
          Returns the JavaScript type of an object.
static String getXPath(com.google.gwt.dom.client.Node node, com.google.gwt.dom.client.Node root)
          Returns an XPath expression which enables reaching the specified node from the root node
static boolean hasAttributeNS(com.google.gwt.dom.client.Element elem, String namespaceURI, String localName)
          Returns true when an attribute with a given local name and namespace URI is specified on the specified element or has a default value, false otherwise.
static boolean hasFeature(String featureName)
          Tests if the underlying DOM implementation supports the specified feature
static com.google.gwt.dom.client.Node importNode(com.google.gwt.dom.client.Document document, com.google.gwt.dom.client.Node importedNode, boolean deep)
          Imports a node from another document to this document, without altering or removing the source node from the original document; this method creates a new copy of the source node.
static void normalize(com.google.gwt.dom.client.Node node)
          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.
static void releaseCaptureElement()
          Stops the forwarding of all events to the capturing element specified by setCaptureElement(OMSVGElement, LoseCaptureHandler)
static Attr setAttributeNode(com.google.gwt.dom.client.Element elt, Attr attr)
          Adds a new attribute node to the specified element.
static void setAttributeNS(com.google.gwt.dom.client.Element elem, String namespaceURI, String localName, String value)
          Adds a new attribute to the specified element.
static com.google.gwt.event.shared.HandlerRegistration setCaptureElement(OMSVGElement element, com.google.gwt.event.dom.client.LoseCaptureHandler loseCaptureHandler)
          Makes the specified element capture all the events, until a call to releaseCaptureElement() terminates the capture
static String substringData(com.google.gwt.dom.client.Text text, int offset, int count)
          Extracts a range of data from the node.
static boolean supportsSvgTouchEvents()
          Deprecated. Use the hasFeature(String) method with the SVGConstants.SVG_FEATURE_TOUCH_EVENTS parameter instead.
static String toUrl(String s)
          Creates a value of the formed expected by SVG href attribtues.
static void unbindEventListener(com.google.gwt.dom.client.Element elem, String eventName)
          Stops making a node sink the events emitted by the specified element
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DOMHelper

public DOMHelper()
Method Detail

createElementNS

public static final com.google.gwt.dom.client.Element createElementNS(com.google.gwt.dom.client.Document document,
                                                                      String namespaceURI,
                                                                      String qualifiedName)
                                                               throws com.google.gwt.core.client.JavaScriptException
Creates an element of the given qualified name and namespace URI.
Per [XML Namespaces] , applications must use the value null as the namespaceURI parameter for methods if they wish to have no namespace.

Parameters:
document - The document in which the element is to be created.
namespaceURI - The namespace URI of the element to create.
qualifiedName - The qualified name of the element type to instantiate.
Returns:
A new Element object with the following attributes:
Attribute Value
Node.nodeName qualifiedName
Node.namespaceURI namespaceURI
Node.prefix prefix, extracted from qualifiedName, or null if there is no prefix
Node.localName local name, extracted from qualifiedName
Element.tagName qualifiedName
Throws:
DOMException - INVALID_CHARACTER_ERR: Raised if the specified qualifiedName is not an XML name according to the XML version in use specified in the Document.xmlVersion attribute.
NAMESPACE_ERR: Raised if the qualifiedName is a malformed qualified name, if the qualifiedName has a prefix and the namespaceURI is null, or if the qualifiedName has a prefix that is "xml" and the namespaceURI is different from " http://www.w3.org/XML/1998/namespace" [XML Namespaces] , or if the qualifiedName or its prefix is "xmlns" and the namespaceURI is different from "http://www.w3.org/2000/xmlns/", or if the namespaceURI is "http://www.w3.org/2000/xmlns/" and neither the qualifiedName nor its prefix is "xmlns".
NOT_SUPPORTED_ERR: Always thrown if the current document does not support the "XML" feature, since namespaces were defined by XML.
com.google.gwt.core.client.JavaScriptException

createDocument

public static final com.google.gwt.dom.client.Document createDocument(String uri,
                                                                      String qname)
Creates a new empty SVG document

Returns:
a new empty SVG document

importNode

public static final com.google.gwt.dom.client.Node importNode(com.google.gwt.dom.client.Document document,
                                                              com.google.gwt.dom.client.Node importedNode,
                                                              boolean deep)
Imports a node from another document to this document, without altering or removing the source node from the original document; this method creates a new copy of the source node. The returned node has no parent; (parentNode is null).
For all nodes, importing a node creates a node object owned by the importing document, with attribute values identical to the source node's nodeName and nodeType, plus the attributes related to namespaces (prefix, localName, and namespaceURI). As in the cloneNode operation, the source node is not altered. 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.
Additional information is copied as appropriate to the nodeType, attempting to mirror the behavior expected if a fragment of XML or HTML source was copied from one document to another, recognizing that the two documents may have different DTDs in the XML case. The following list describes the specifics for each type of node.
ATTRIBUTE_NODE
The ownerElement attribute is set to null and the specified flag is set to true on the generated Attr. The descendants of the source Attr are recursively imported and the resulting nodes reassembled to form the corresponding subtree. Note that the deep parameter has no effect on Attr nodes; they always carry their children with them when imported.
DOCUMENT_FRAGMENT_NODE
If the deep option was set to true, the descendants of the source DocumentFragment are recursively imported and the resulting nodes reassembled under the imported DocumentFragment to form the corresponding subtree. Otherwise, this simply generates an empty DocumentFragment.
DOCUMENT_NODE
Document nodes cannot be imported.
DOCUMENT_TYPE_NODE
DocumentType nodes cannot be imported.
ELEMENT_NODE
Specified attribute nodes of the source element are imported, and the generated Attr nodes are attached to the generated Element. Default attributes are not copied, though if the document being imported into defines default attributes for this element name, those are assigned. If the importNode deep parameter was set to true, the descendants of the source element are recursively imported and the resulting nodes reassembled to form the corresponding subtree.
ENTITY_NODE
Entity nodes can be imported, however in the current release of the DOM the DocumentType is readonly. Ability to add these imported nodes to a DocumentType will be considered for addition to a future release of the DOM.On import, the publicId, systemId, and notationName attributes are copied. If a deep import is requested, the descendants of the the source Entity are recursively imported and the resulting nodes reassembled to form the corresponding subtree.
ENTITY_REFERENCE_NODE
Only the EntityReference itself is copied, even if a deep import is requested, since the source and destination documents might have defined the entity differently. If the document being imported into provides a definition for this entity name, its value is assigned.
NOTATION_NODE
Notation nodes can be imported, however in the current release of the DOM the DocumentType is readonly. Ability to add these imported nodes to a DocumentType will be considered for addition to a future release of the DOM.On import, the publicId and systemId attributes are copied. Note that the deep parameter has no effect on this type of nodes since they cannot have any children.
PROCESSING_INSTRUCTION_NODE
The imported node copies its target and data values from those of the source node.Note that the deep parameter has no effect on this type of nodes since they cannot have any children.
TEXT_NODE, CDATA_SECTION_NODE, COMMENT_NODE
These three types of nodes inheriting from CharacterData copy their data and length attributes from those of the source node.Note that the deep parameter has no effect on these types of nodes since they cannot have any children.

Parameters:
document - The document in which to import the node.
importedNode - The node to import.
deep - If true, recursively import the subtree under the specified node; if false, import only the node itself, as explained above. This has no effect on nodes that cannot have any children, and on Attr, and EntityReference nodes.
Returns:
The imported node that belongs to this Document.
Throws:
DOMException - NOT_SUPPORTED_ERR: Raised if the type of node being imported is not supported.
INVALID_CHARACTER_ERR: Raised if one of the imported names is not an XML name according to the XML version in use specified in the Document.xmlVersion attribute. This may happen when importing an XML 1.1 [XML 1.1] element into an XML 1.0 document, for instance.

normalize

public static final void normalize(com.google.gwt.dom.client.Node node)
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. 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.

Parameters:
node - the node to normalize

substringData

public static final String substringData(com.google.gwt.dom.client.Text text,
                                         int offset,
                                         int count)
                                  throws com.google.gwt.core.client.JavaScriptException
Extracts a range of data from the node.

Parameters:
text - the text node
offset - Start offset of substring to extract.
count - The number of 16-bit units to extract.
Returns:
The specified substring. If the sum of offset and count exceeds the length, then all 16-bit units to the end of the data are returned.
Throws:
DOMException - INDEX_SIZE_ERR: Raised if the specified offset is negative or greater than the number of 16-bit units in data, or if the specified count is negative.
DOMSTRING_SIZE_ERR: Raised if the specified range of text does not fit into a String.
com.google.gwt.core.client.JavaScriptException

appendData

public static final void appendData(com.google.gwt.dom.client.Text text,
                                    String arg)
                             throws com.google.gwt.core.client.JavaScriptException
Append the string to the end of the character data of the node. Upon success, data provides access to the concatenation of data and the String specified.

Parameters:
text - the text node
arg - The String to append.
Throws:
DOMException - NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
com.google.gwt.core.client.JavaScriptException

getAttributeNS

public static final String getAttributeNS(com.google.gwt.dom.client.Element elem,
                                          String namespaceURI,
                                          String localName)
                                   throws com.google.gwt.core.client.JavaScriptException
Retrieves an attribute value by local name and namespace URI on the specified element.
Per [XML Namespaces] , applications must use the value null as the namespaceURI parameter for methods if they wish to have no namespace.

Parameters:
elem - the element
namespaceURI - The namespace URI of the attribute to retrieve.
localName - The local name of the attribute to retrieve.
Returns:
The Attr value as a string, or the empty string if that attribute does not have a specified or default value.
Throws:
DOMException - NOT_SUPPORTED_ERR: May be raised if the implementation does not support the feature "XML" and the language exposed through the Document does not support XML Namespaces (such as [HTML 4.01]).
com.google.gwt.core.client.JavaScriptException
Since:
DOM Level 2

getElementsByTagNameNS

public static final com.google.gwt.dom.client.NodeList<? extends com.google.gwt.dom.client.Node> getElementsByTagNameNS(com.google.gwt.dom.client.Element elem,
                                                                                                                        String namespaceURI,
                                                                                                                        String localName)
                                                                                                                 throws com.google.gwt.core.client.JavaScriptException
Returns a NodeList of all the descendant Elements of the specified element with a given local name and namespace URI in document order.

Parameters:
elem - The element
namespaceURI - The namespace URI of the elements to match on. The special value "*" matches all namespaces.
localName - The local name of the elements to match on. The special value "*" matches all local names.
Returns:
A new NodeList object containing all the matched Elements.
Throws:
DOMException - NOT_SUPPORTED_ERR: May be raised if the implementation does not support the feature "XML" and the language exposed through the Document does not support XML Namespaces (such as [HTML 4.01]).
com.google.gwt.core.client.JavaScriptException
Since:
DOM Level 2

getElementsByTagNameNS

public static final com.google.gwt.dom.client.NodeList<? extends com.google.gwt.dom.client.Node> getElementsByTagNameNS(com.google.gwt.dom.client.Document doc,
                                                                                                                        String namespaceURI,
                                                                                                                        String localName)
                                                                                                                 throws com.google.gwt.core.client.JavaScriptException
Returns a NodeList of all the Elements in the specified document with a given local name and namespace URI in document order.

Parameters:
doc - The document
namespaceURI - The namespace URI of the elements to match on. The special value "*" matches all namespaces.
localName - The local name of the elements to match on. The special value "*" matches all local names.
Returns:
A new NodeList object containing all the matched Elements.
Throws:
com.google.gwt.core.client.JavaScriptException
Since:
DOM Level 2

getCurrentDocument

public static final com.google.gwt.dom.client.Document getCurrentDocument()
Returns the current document

Returns:
the current document

getAttributes

public static final NamedNodeMap<Attr> getAttributes(com.google.gwt.dom.client.Element elem)
Returns a NamedNodeMap containing the attributes of the specified element.

Parameters:
elem - The element
Returns:
a NamedNodeMap containing the attributes of the specified element

getAttributeNode

public static final Attr getAttributeNode(com.google.gwt.dom.client.Element elt,
                                          String attrName)
Retrieves an attribute node by name on the specified element.
To retrieve an attribute node by qualified name and namespace URI, use the getAttributeNodeNS method.

Parameters:
elt - The element
attrName - The name (nodeName) of the attribute to retrieve.
Returns:
The Attr node with the specified name ( nodeName) or null if there is no such attribute.

setAttributeNode

public static final Attr setAttributeNode(com.google.gwt.dom.client.Element elt,
                                          Attr attr)
                                   throws com.google.gwt.core.client.JavaScriptException
Adds a new attribute node to the specified element. If an attribute with that name ( nodeName) is already present in the element, it is replaced by the new one. Replacing an attribute node by itself has no effect.
To add a new attribute node with a qualified name and namespace URI, use the setAttributeNodeNS method.

Parameters:
elt - The element
attr - The Attr node to add to the attribute list.
Returns:
If the attr attribute replaces an existing attribute, the replaced Attr node is returned, otherwise null is returned.
Throws:
DOMException - WRONG_DOCUMENT_ERR: Raised if attr was created from a different document than the one that created the element.
NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
INUSE_ATTRIBUTE_ERR: Raised if attr is already an attribute of another Element object. The DOM user must explicitly clone Attr nodes to re-use them in other elements.
com.google.gwt.core.client.JavaScriptException

hasAttributeNS

public static final boolean hasAttributeNS(com.google.gwt.dom.client.Element elem,
                                           String namespaceURI,
                                           String localName)
                                    throws com.google.gwt.core.client.JavaScriptException
Returns true when an attribute with a given local name and namespace URI is specified on the specified element or has a default value, false otherwise.
Per [XML Namespaces] , applications must use the value null as the namespaceURI parameter for methods if they wish to have no namespace.

Parameters:
elem - The element
namespaceURI - The namespace URI of the attribute to look for.
localName - The local name of the attribute to look for.
Returns:
true if an attribute with the given local name and namespace URI is specified or has a default value on this element, false otherwise.
Throws:
DOMException - NOT_SUPPORTED_ERR: May be raised if the implementation does not support the feature "XML" and the language exposed through the Document does not support XML Namespaces (such as [HTML 4.01]).
com.google.gwt.core.client.JavaScriptException

setAttributeNS

public static final void setAttributeNS(com.google.gwt.dom.client.Element elem,
                                        String namespaceURI,
                                        String localName,
                                        String value)
                                 throws com.google.gwt.core.client.JavaScriptException
Adds a new attribute to the specified element. If an attribute with the same local name and namespace URI is already present on the element, its prefix is changed to be the prefix part of the qualifiedName, and its value is changed to be the value parameter. This value is a simple string; it is not parsed as it is being set. So any markup (such as syntax to be recognized as an entity reference) is treated as literal text, and needs to be appropriately escaped by the implementation when it is written out. In order to assign an attribute value that contains entity references, the user must create an Attr node plus any Text and EntityReference nodes, build the appropriate subtree, and use setAttributeNodeNS or setAttributeNode to assign it as the value of an attribute.
Per [XML Namespaces] , applications must use the value null as the namespaceURI parameter for methods if they wish to have no namespace.

Parameters:
elem - The element
namespaceURI - The namespace URI of the attribute to create or alter.
localName - The local name of the attribute to create or alter.
value - The value to set in string form.
Throws:
DOMException - INVALID_CHARACTER_ERR: Raised if the specified qualified name is not an XML name according to the XML version in use specified in the Document.xmlVersion attribute.
NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
NAMESPACE_ERR: Raised if the qualifiedName is malformed per the Namespaces in XML specification, if the qualifiedName has a prefix and the namespaceURI is null, if the qualifiedName has a prefix that is "xml" and the namespaceURI is different from " http://www.w3.org/XML/1998/namespace", if the qualifiedName or its prefix is "xmlns" and the namespaceURI is different from "http://www.w3.org/2000/xmlns/", or if the namespaceURI is "http://www.w3.org/2000/xmlns/" and neither the qualifiedName nor its prefix is "xmlns".
NOT_SUPPORTED_ERR: May be raised if the implementation does not support the feature "XML" and the language exposed through the Document does not support XML Namespaces (such as [HTML 4.01]).
com.google.gwt.core.client.JavaScriptException

getNamespaceURI

public static String getNamespaceURI(com.google.gwt.dom.client.Node node)
The namespace URI of the specified node, or null if it is unspecified (see ).
This is not a computed value that is the result of a namespace lookup based on an examination of the namespace declarations in scope. It is merely the namespace URI given at creation time.
For nodes of any type other than 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.

Parameters:
node - a DOM node
Returns:
The namespace URI of this node

getLocalName

public static String getLocalName(com.google.gwt.dom.client.Node node)
Returns the local part of the qualified name of this node.
For nodes of any type other than ELEMENT_NODE and ATTRIBUTE_NODE and nodes created with a DOM Level 1 method, such as Document.createElement(), this is always null.

Parameters:
node - a DOM node
Returns:
The local part of the qualified name of this node

bindEventListener

public static void bindEventListener(com.google.gwt.dom.client.Element elem,
                                     String eventName)
Makes a node sink the events emitted by the specified element

Parameters:
elem - The element emitting the events
eventName - The event name

unbindEventListener

public static void unbindEventListener(com.google.gwt.dom.client.Element elem,
                                       String eventName)
Stops making a node sink the events emitted by the specified element

Parameters:
elem - The element emitting the events
eventName - The event name

getCaptureElement

public static OMSVGElement getCaptureElement()
Returns the element which currently captures all the events after a call to setCaptureElement(OMSVGElement, LoseCaptureHandler) or null if element is set to capture events

Returns:
The event capturing element

setCaptureElement

public static com.google.gwt.event.shared.HandlerRegistration setCaptureElement(OMSVGElement element,
                                                                                com.google.gwt.event.dom.client.LoseCaptureHandler loseCaptureHandler)
Makes the specified element capture all the events, until a call to releaseCaptureElement() terminates the capture

Parameters:
element - The capturing element
loseCaptureHandler - A handler which will be invoked if the element loses capture
Returns:
HandlerRegistration used to remove this handler

releaseCaptureElement

public static void releaseCaptureElement()
Stops the forwarding of all events to the capturing element specified by setCaptureElement(OMSVGElement, LoseCaptureHandler)


getType

public static final String getType(com.google.gwt.core.client.JavaScriptObject x)
Returns the JavaScript type of an object. The function getType is borrowed from: JavaScript: The Definitive Guide, 5th Edition By David Flanagan


toUrl

public static final String toUrl(String s)
Creates a value of the formed expected by SVG href attribtues.

Parameters:
s - the identifier of the data pointed by the href.
Returns:
a value of the formed expected by SVG href attribtues.

hasFeature

public static boolean hasFeature(String featureName)
Tests if the underlying DOM implementation supports the specified feature

Parameters:
featureName - The name of the feature to test
Returns:
true if the feature is supported, false otherwise

evaluateXPath

public static <T extends OMNode> Iterator<T> evaluateXPath(OMElement root,
                                                           String expr,
                                                           XPathPrefixResolver resolver)
Evaluates the specified XPath expression and returns a iterator for the selected OMNode node list. The expression must evaluate to a node list.

Parameters:
root - The element the expression is rooted at
expr - The XPath expression
resolver - A prefix resolver if the expression has prefix
Returns:
A node iterator for the selected nodes.

evaluateNodeListXPath

public static <T extends com.google.gwt.dom.client.Node> Iterator<T> evaluateNodeListXPath(com.google.gwt.dom.client.Element root,
                                                                                           String expr,
                                                                                           XPathPrefixResolver resolver)
Evaluates the specified XPath expression and returns a iterator for the selected Node node list. The expression must evaluate to a node list.

Parameters:
root - The element the expression is rooted at
expr - The XPath expression
resolver - A prefix resolver if the expression has prefix
Returns:
A node iterator for the selected nodes.

evaluateNodeXPath

public static <T extends com.google.gwt.dom.client.Node> T evaluateNodeXPath(com.google.gwt.dom.client.Element root,
                                                                             String expr,
                                                                             XPathPrefixResolver resolver)
Evaluates the specified XPath expression and returns the matching Node node. The expression must evaluate to a single node.

Parameters:
root - The element the expression is rooted at
expr - The XPath expression
resolver - A prefix resolver if the expression has prefix
Returns:
The selected node, or null if no such node exists.

evaluateStringXPath

public static String evaluateStringXPath(com.google.gwt.dom.client.Element root,
                                         String expr,
                                         XPathPrefixResolver resolver)
Evaluates the specified XPath expression and returns the matching String. The expression must evaluate to a string.

Parameters:
root - The element the expression is rooted at
expr - The XPath expression
resolver - A prefix resolver if the expression has prefix
Returns:
The matching string, or null if no such string exists.

evaluateNumberXPath

public static float evaluateNumberXPath(com.google.gwt.dom.client.Element root,
                                        String expr,
                                        XPathPrefixResolver resolver)
Evaluates the specified XPath expression and returns the matching float. The expression must evaluate to a number.

Parameters:
root - The element the expression is rooted at
expr - The XPath expression
resolver - A prefix resolver if the expression has prefix
Returns:
The matching float, or NaN if no such number exists.

evaluateBooleanXPath

public static boolean evaluateBooleanXPath(com.google.gwt.dom.client.Element root,
                                           String expr,
                                           XPathPrefixResolver resolver)
Evaluates the specified XPath expression and returns the matching boolean. The expression must evaluate to a boolean.

Parameters:
root - The element the expression is rooted at
expr - The XPath expression
resolver - A prefix resolver if the expression has prefix
Returns:
The matching boolean.

getXPath

public static String getXPath(com.google.gwt.dom.client.Node node,
                              com.google.gwt.dom.client.Node root)
Returns an XPath expression which enables reaching the specified node from the root node

Parameters:
node - The node to reach
root - The root node, or null to specify the document root
Returns:
An XPath expression which enables reaching the specified node from the root node

supportsSvgTouchEvents

public static boolean supportsSvgTouchEvents()
Deprecated. Use the hasFeature(String) method with the SVGConstants.SVG_FEATURE_TOUCH_EVENTS parameter instead.

Returns whether touch events on SVG elements are supported on the current platform.

Returns:
true if touch events on SVG elements are supported on the current platform, false otherwise

base64encode

public static String base64encode(String str)
Returns a base64 encoding of the specified binary string

Parameters:
str - A binary string (obtained for instance by the FileReader API)
Returns:
a base64 encoded string.


Copyright © 2012. All Rights Reserved.