org.vectomatic.dom.svg
Class OMDocument

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

public class OMDocument
extends OMNode

Wrapper class for DOM Document

Author:
laaglu

Field Summary
 
Fields inherited from class org.vectomatic.dom.svg.OMNode
eventBus, ot
 
Constructor Summary
protected OMDocument(com.google.gwt.dom.client.Document document)
          Constructor
 
Method Summary
 OMElement createElementNS(String namespaceURI, String qualifiedName)
          Creates an OMElement of the given qualified name and namespace URI.
 OMText createTextNode(String data)
          Creates a new OMText node and initializes it with the specified data.
 com.google.gwt.dom.client.Document getDocument()
          Returns the wrapped Document
 OMElement getDocumentElement()
          This is a convenience attribute that allows direct access to the child node that is the document element of the document.
<T extends OMElement>
T
getElementById(String elementId)
          Returns the OMElement that has an ID attribute with the given value.
<T extends OMElement>
OMNodeList<T>
getElementsByTagName(String tagname)
          Returns a OMNodeList of all the OMElements in document order with a given tag name and are contained in the document.
<T extends OMElement>
OMNodeList<T>
getElementsByTagNameNS(String namespaceURI, String localName)
          Returns a OMNodeList of all the OMElements with a given local name and namespace URI in document order.
 OMNode importNode(OMNode 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.
 
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

OMDocument

protected OMDocument(com.google.gwt.dom.client.Document document)
Constructor

Parameters:
document - The wrapped document
Method Detail

getDocument

public com.google.gwt.dom.client.Document getDocument()
Returns the wrapped Document

Returns:
the wrapped Document

createElementNS

public final OMElement createElementNS(String namespaceURI,
                                       String qualifiedName)
                                throws com.google.gwt.core.client.JavaScriptException
Creates an OMElement 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:
namespaceURI - The namespace URI of the element to create.
qualifiedName - The qualified name of the element type to instantiate.
Returns:
A new OMElement 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

createTextNode

public final OMText createTextNode(String data)
Creates a new OMText node and initializes it with the specified data. The node is not attached to the DOM tree.

Parameters:
data - The string to initialize the text node
Returns:
The newly created OMText node

getElementsByTagName

public final <T extends OMElement> OMNodeList<T> getElementsByTagName(String tagname)
Returns a OMNodeList of all the OMElements in document order with a given tag name and are contained in the document.

Parameters:
tagname - The name of the tag to match on. The special value "*" matches all tags. For XML, the tagname parameter is case-sensitive, otherwise it depends on the case-sensitivity of the markup language in use.
Returns:
A new OMNodeList object containing all the matched Elements.

getElementsByTagNameNS

public final <T extends OMElement> OMNodeList<T> getElementsByTagNameNS(String namespaceURI,
                                                                        String localName)
Returns a OMNodeList of all the 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 Elements.

getElementById

public final <T extends OMElement> T getElementById(String elementId)
Returns the OMElement that has an ID attribute with the given value. If no such element exists, this returns null . If more than one element has an ID attribute with that value, what is returned is undefined.
The DOM implementation is expected to use the attribute Attr.isId to determine if an attribute is of type ID.

Note: Attributes with the name "ID" or "id" are not of type ID unless so defined.

Parameters:
elementId - The unique id value for an element.
Returns:
The matching element or null if there is none.

getDocumentElement

public final OMElement getDocumentElement()
This is a convenience attribute that allows direct access to the child node that is the document element of the document.


importNode

public final OMNode importNode(OMNode 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 OMAttr. The descendants of the source OMAttr are recursively imported and the resulting nodes reassembled to form the corresponding subtree. Note that the deep parameter has no effect on OMAttr 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 OMAttr nodes are attached to the generated OMElement. 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:
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 OMAttr, 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.


Copyright © 2012. All Rights Reserved.