org.vectomatic.dom.svg
Class OMElement

java.lang.Object
  extended by org.vectomatic.dom.svg.OMNode
      extended by org.vectomatic.dom.svg.OMElement
All Implemented Interfaces:
com.google.gwt.event.shared.HasHandlers
Direct Known Subclasses:
OMSVGElement

public class OMElement
extends OMNode

Wrapper class for DOM Element

Author:
laaglu

Field Summary
 
Fields inherited from class org.vectomatic.dom.svg.OMNode
eventBus, ot
 
Constructor Summary
protected OMElement(com.google.gwt.dom.client.Element element)
          Constructor
 
Method Summary
 String getAttribute(String name)
          Retrieves an attribute value by name.
 OMAttr getAttributeNode(String attrName)
          Retrieves an attribute node by name on the specified element.
 String getAttributeNS(String namespaceURI, String localName)
          Retrieves an attribute value by local name and namespace URI.
 OMNamedNodeMap<OMAttr> getAttributes()
          Returns a OMNamedNodeMap containing the attributes of the specified element.
 com.google.gwt.dom.client.Element getElement()
          Returns the wrapped Element
<T extends OMElement>
OMNodeList<T>
getElementsByTagName(String name)
          Returns a OMNodeList of all descendant OMElements with a given tag name, in document order.
<T extends OMElement>
OMNodeList<T>
getElementsByTagNameNS(String namespaceURI, String localName)
          Returns a OMNodeList of all the descendant OMElements with a given local name and namespace URI in document order.
 String getId()
          Returns the element id
 String getTagName()
          The name of the element.
 boolean hasAttribute(String name)
          Determines whether an element has an attribute with a given name.
 boolean hasAttributeNS(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.
 void removeAttribute(String name)
          Removes an attribute by name.
 void setAttribute(String name, String value)
          Adds a new attribute.
 OMAttr setAttributeNode(OMAttr attr)
          Adds a new attribute node to the specified element.
 void setAttributeNS(String namespaceURI, String localName, String value)
          Adds a new attribute to the specified element.
 
Methods inherited from class org.vectomatic.dom.svg.OMNode
addDomHandler, addHandler, appendChild, cleanup, cloneNode, convert, convertList, dispatch, fireEvent, getChildNodes, getEventBus, getFirstChild, getLastChild, getLocalName, getNamespaceURI, getNextSibling, getNode, getNodeName, getNodeType, getNodeValue, getOwnerDocument, getParentNode, getPreviousSibling, hasChildNodes, insertBefore, normalize, removeChild, replaceChild, setNodeValue, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

OMElement

protected OMElement(com.google.gwt.dom.client.Element element)
Constructor

Parameters:
element - The wrapped element
Method Detail

getElement

public com.google.gwt.dom.client.Element getElement()
Returns the wrapped Element

Returns:
the wrapped Element

getElementsByTagName

public final <T extends OMElement> OMNodeList<T> getElementsByTagName(String name)
Returns a OMNodeList of all descendant OMElements with a given tag name, in document order.

Parameters:
name - The name of the tag to match on. The special value "*" matches all tags.
Returns:
A list of matching OMElement nodes.

getElementsByTagNameNS

public final <T extends OMElement> OMNodeList<T> getElementsByTagNameNS(String namespaceURI,
                                                                        String localName)
                                                             throws com.google.gwt.core.client.JavaScriptException
Returns a OMNodeList of all the descendant OMElements with a given local name and namespace URI in document order.

Parameters:
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 OMNodeList object containing all the matched OMElements.
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

getId

public final String getId()
Returns the element id

Returns:
the element id

getTagName

public final String getTagName()
The name of the element. If Node.localName is different from null, this attribute is a qualified name. For example, in:
 <elementExample id="demo"> ... 
 </elementExample> , 
tagName has the value "elementExample". Note that this is case-preserving in XML, as are all of the operations of the DOM. The HTML DOM returns the tagName of an HTML element in the canonical uppercase form, regardless of the case in the source HTML document.

Returns:
the name of the element

hasAttribute

public final boolean hasAttribute(String name)
Determines whether an element has an attribute with a given name.

Note that IE, prior to version 8, will return false-positives for names that collide with element properties (e.g., style, width, and so forth).

Parameters:
name - the name of the attribute
Returns:
true if this element has the specified attribute

hasAttributeNS

public final boolean hasAttributeNS(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:
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

getAttribute

public final String getAttribute(String name)
Retrieves an attribute value by name.

Parameters:
name - The name of the attribute to retrieve.
Returns:
The OMAttr value as a string, or the empty string if that attribute does not have a specified or default value.

getAttributeNode

public final OMAttr getAttributeNode(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:
attrName - The name (nodeName) of the attribute to retrieve.
Returns:
The OMAttr node with the specified name ( nodeName) or null if there is no such attribute.

getAttributeNS

public final String getAttributeNS(String namespaceURI,
                                   String localName)
                            throws com.google.gwt.core.client.JavaScriptException
Retrieves an attribute value by local 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:
namespaceURI - The namespace URI of the attribute to retrieve.
localName - The local name of the attribute to retrieve.
Returns:
The OMAttr 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

getAttributes

public final OMNamedNodeMap<OMAttr> getAttributes()
Returns a OMNamedNodeMap containing the attributes of the specified element.

Returns:
a OMNamedNodeMap containing the attributes of the specified element

setAttribute

public final void setAttribute(String name,
                               String value)
                        throws com.google.gwt.core.client.JavaScriptException
Adds a new attribute. If an attribute with that name is already present in the element, its value is changed to be that of 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.
To set an attribute with a qualified name and namespace URI, use the setAttributeNS method.

Parameters:
name - The name of the attribute to create or alter.
value - Value to set in string form.
Throws:
DOMException - INVALID_CHARACTER_ERR: Raised if the specified 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.
com.google.gwt.core.client.JavaScriptException

setAttributeNS

public final void setAttributeNS(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 OMAttr node plus any OMText 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:
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

setAttributeNode

public final OMAttr setAttributeNode(OMAttr 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:
attr - The OMAttr node to add to the attribute list.
Returns:
If the attr attribute replaces an existing attribute, the replaced OMAttr 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 OMAttr nodes to re-use them in other elements.
com.google.gwt.core.client.JavaScriptException

removeAttribute

public final void removeAttribute(String name)
                           throws com.google.gwt.core.client.JavaScriptException
Removes an attribute by name. If a default value for the removed attribute is defined in the DTD, a new attribute immediately appears with the default value as well as the corresponding namespace URI, local name, and prefix when applicable. The implementation may handle default values from other schemas similarly but applications should use OMDocument.normalizeDocument() to guarantee this information is up-to-date.
If no attribute with this name is found, this method has no effect.
To remove an attribute by local name and namespace URI, use the removeAttributeNS method.

Parameters:
name - The name of the attribute to remove.
Throws:
DOMException - NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
com.google.gwt.core.client.JavaScriptException


Copyright © 2012. All Rights Reserved.