org.exist.memtree
Class DocumentImpl

java.lang.Object
  extended byorg.exist.memtree.NodeImpl
      extended byorg.exist.memtree.DocumentImpl
All Implemented Interfaces:
java.lang.Comparable, org.w3c.dom.Document, Item, org.w3c.dom.Node, NodeValue, QNameable, Sequence

public class DocumentImpl
extends NodeImpl
implements org.w3c.dom.Document

An in-memory implementation of Document. This implementation stores all node data in the document object. Nodes from another document, i.e. a persistent document in the database, can be stored as reference nodes, i.e. the nodes are not copied into this document object. Instead a reference is inserted which will only be expanded during serialization.

Author:
wolf

Field Summary
protected  int[] alpha
           
protected  int[] alphaLen
           
protected  int[] attrName
           
protected  int[] attrParent
           
protected  java.lang.String[] attrValue
           
protected  char[] characters
           
protected  XQueryContext context
           
protected  int documentRootNode
           
protected  NamePool namePool
           
protected  int[] namespaceCode
           
protected  int[] namespaceParent
           
protected  int[] next
           
protected  int nextAttr
           
protected  int nextChar
           
protected  int nextNamespace
           
protected  int nextRef
           
protected  short[] nodeKind
           
protected  int[] nodeName
           
protected  NodeProxy[] references
           
protected  int size
           
protected  short[] treeLevel
           
 
Fields inherited from class org.exist.memtree.NodeImpl
document, NAMESPACE_NODE, nodeNumber, REFERENCE_NODE
 
Fields inherited from interface org.w3c.dom.Node
ATTRIBUTE_NODE, CDATA_SECTION_NODE, COMMENT_NODE, DOCUMENT_FRAGMENT_NODE, DOCUMENT_NODE, DOCUMENT_TYPE_NODE, ELEMENT_NODE, ENTITY_NODE, ENTITY_REFERENCE_NODE, NOTATION_NODE, PROCESSING_INSTRUCTION_NODE, TEXT_NODE
 
Fields inherited from interface org.exist.xquery.value.NodeValue
IN_MEMORY_NODE, PERSISTENT_NODE
 
Fields inherited from interface org.exist.xquery.value.Sequence
EMPTY_SEQUENCE
 
Constructor Summary
DocumentImpl(XQueryContext context)
           
 
Method Summary
 int addAttribute(int nodeNr, QName qname, java.lang.String value)
           
 void addChars(int nodeNr, char[] ch, int start, int len)
           
 void addChars(int nodeNr, java.lang.CharSequence s)
           
 int addNamespace(int nodeNr, QName qname)
           
 int addNode(short kind, short level, QName qname)
           
 void addReferenceNode(int nodeNr, NodeProxy proxy)
           
 org.w3c.dom.Node adoptNode(org.w3c.dom.Node source)
          ? @see org.w3c.dom.Document#adoptNode(org.w3c.dom.Node)
 void copyTo(NodeImpl node, DocumentBuilderReceiver receiver)
          Copy the document fragment starting at the specified node to the given document builder.
protected  void copyTo(NodeImpl node, DocumentBuilderReceiver receiver, boolean expandRefs)
           
 org.w3c.dom.Attr createAttribute(java.lang.String arg0)
           
 org.w3c.dom.Attr createAttributeNS(java.lang.String arg0, java.lang.String arg1)
           
 org.w3c.dom.CDATASection createCDATASection(java.lang.String arg0)
           
 org.w3c.dom.Comment createComment(java.lang.String arg0)
           
 org.w3c.dom.DocumentFragment createDocumentFragment()
           
 org.w3c.dom.Element createElement(java.lang.String arg0)
           
 org.w3c.dom.Element createElementNS(java.lang.String arg0, java.lang.String arg1)
           
 org.w3c.dom.EntityReference createEntityReference(java.lang.String arg0)
           
 org.w3c.dom.ProcessingInstruction createProcessingInstruction(java.lang.String arg0, java.lang.String arg1)
           
 org.w3c.dom.Text createTextNode(java.lang.String arg0)
           
 void expand()
          Expand all reference nodes in the current document, i.e.
 DocumentImpl expandRefs(NodeImpl rootNode)
           
 NodeImpl getAttribute(int nodeNr)
           
 int getAttributesCountFor(int nodeNumber)
           
 int getChildCount()
           
 int getChildCountFor(int nr)
           
 org.w3c.dom.DocumentType getDoctype()
           
 org.w3c.dom.Element getDocumentElement()
           
 java.lang.String getDocumentURI()
          ? @see org.w3c.dom.Document#getDocumentURI()
 DOMConfiguration getDomConfig()
          ? @see org.w3c.dom.Document#getDomConfig()
 org.w3c.dom.Element getElementById(java.lang.String arg0)
           
 org.w3c.dom.NodeList getElementsByTagName(java.lang.String name)
           
 org.w3c.dom.NodeList getElementsByTagNameNS(java.lang.String arg0, java.lang.String arg1)
           
 org.w3c.dom.Node getFirstChild()
           
 int getFirstChildFor(int nodeNumber)
           
 org.w3c.dom.DOMImplementation getImplementation()
           
 java.lang.String getInputEncoding()
          ? @see org.w3c.dom.Document#getInputEncoding()
 int getLastNode()
           
 NodeImpl getNamespaceNode(int nodeNr)
           
 int getNextSiblingFor(int nodeNumber)
           
 NodeImpl getNode(int nodeNr)
           
 org.w3c.dom.Document getOwnerDocument()
           
 org.w3c.dom.Node getParentNode()
           
 int getParentNodeFor(int nodeNumber)
           
 int getSize()
           
 boolean getStrictErrorChecking()
          ? @see org.w3c.dom.Document#getStrictErrorChecking()
 java.lang.String getXmlEncoding()
          ? @see org.w3c.dom.Document#getXmlEncoding()
 boolean getXmlStandalone()
          ? @see org.w3c.dom.Document#getXmlStandalone()
 java.lang.String getXmlVersion()
          ? @see org.w3c.dom.Document#getXmlVersion()
 org.w3c.dom.Node importNode(org.w3c.dom.Node arg0, boolean arg1)
           
 Int2ObjectHashMap makePersistent()
           
 void normalizeDocument()
          ? @see org.w3c.dom.Document#normalizeDocument()
 org.w3c.dom.Node renameNode(org.w3c.dom.Node n, java.lang.String namespaceURI, java.lang.String qualifiedName)
          ? @see org.w3c.dom.Document#renameNode(org.w3c.dom.Node, java.lang.String, java.lang.String)
 void reset()
           
 void setContext(XQueryContext context)
           
 void setDocumentURI(java.lang.String documentURI)
          ? @see org.w3c.dom.Document#setDocumentURI(java.lang.String)
 void setStrictErrorChecking(boolean strictErrorChecking)
          ? @see org.w3c.dom.Document#setStrictErrorChecking(boolean)
 void setXmlStandalone(boolean xmlStandalone)
          ? @see org.w3c.dom.Document#setXmlStandalone(boolean)
 void setXmlVersion(java.lang.String xmlVersion)
          ? @see org.w3c.dom.Document#setXmlVersion(java.lang.String)
 void streamTo(Serializer serializer, NodeImpl node, Receiver receiver)
          Stream the specified document fragment to a receiver.
 java.lang.String toString()
           
 
Methods inherited from class org.exist.memtree.NodeImpl
add, addAll, addContextNode, after, appendChild, atomize, before, clearContext, cloneNode, compareDocumentPosition, compareTo, conversionPreference, convertTo, copyTo, deepCopy, effectiveBooleanValue, equals, equals, getAttributes, getBaseURI, getCardinality, getChildNodes, getDocument, getDocumentSet, getFeature, getImplementationType, getItemType, getLastChild, getLength, getLocalName, getNamespaceURI, getNextSibling, getNode, getNodeName, getNodeNumber, getNodeType, getNodeValue, getPrefix, getPreviousSibling, getQName, getStringValue, getTextContent, getType, getUserData, hasAttributes, hasChildNodes, insertBefore, isCached, isDefaultNamespace, isEqualNode, isPersistentSet, isSameNode, isSupported, itemAt, iterate, lookupNamespaceURI, lookupPrefix, normalize, removeChild, removeDuplicates, replaceChild, setIsCached, setNodeValue, setPrefix, setSelfAsContext, setTextContent, setUserData, streamTo, toJavaObject, toNodeSet, toSAX, toSequence, unorderedIterator
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.w3c.dom.Node
appendChild, cloneNode, getAttributes, getChildNodes, getLastChild, getLocalName, getNamespaceURI, getNextSibling, getNodeName, getNodeType, getNodeValue, getPrefix, getPreviousSibling, hasAttributes, hasChildNodes, insertBefore, isSupported, normalize, removeChild, replaceChild, setNodeValue, setPrefix
 

Field Detail

context

protected XQueryContext context

namePool

protected NamePool namePool

nodeKind

protected short[] nodeKind

treeLevel

protected short[] treeLevel

next

protected int[] next

nodeName

protected int[] nodeName

alpha

protected int[] alpha

alphaLen

protected int[] alphaLen

characters

protected char[] characters

nextChar

protected int nextChar

attrName

protected int[] attrName

attrParent

protected int[] attrParent

attrValue

protected java.lang.String[] attrValue

nextAttr

protected int nextAttr

namespaceParent

protected int[] namespaceParent

namespaceCode

protected int[] namespaceCode

nextNamespace

protected int nextNamespace

size

protected int size

documentRootNode

protected int documentRootNode

references

protected NodeProxy[] references

nextRef

protected int nextRef
Constructor Detail

DocumentImpl

public DocumentImpl(XQueryContext context)
Method Detail

reset

public void reset()

getSize

public int getSize()

addNode

public int addNode(short kind,
                   short level,
                   QName qname)

addChars

public void addChars(int nodeNr,
                     char[] ch,
                     int start,
                     int len)

addChars

public void addChars(int nodeNr,
                     java.lang.CharSequence s)

addReferenceNode

public void addReferenceNode(int nodeNr,
                             NodeProxy proxy)

addAttribute

public int addAttribute(int nodeNr,
                        QName qname,
                        java.lang.String value)
                 throws org.w3c.dom.DOMException
Throws:
org.w3c.dom.DOMException

addNamespace

public int addNamespace(int nodeNr,
                        QName qname)

getLastNode

public int getLastNode()

getAttribute

public NodeImpl getAttribute(int nodeNr)
                      throws org.w3c.dom.DOMException
Throws:
org.w3c.dom.DOMException

getNamespaceNode

public NodeImpl getNamespaceNode(int nodeNr)
                          throws org.w3c.dom.DOMException
Throws:
org.w3c.dom.DOMException

getNode

public NodeImpl getNode(int nodeNr)
                 throws org.w3c.dom.DOMException
Throws:
org.w3c.dom.DOMException

getParentNode

public org.w3c.dom.Node getParentNode()
Specified by:
getParentNode in interface org.w3c.dom.Node
Overrides:
getParentNode in class NodeImpl

getDoctype

public org.w3c.dom.DocumentType getDoctype()
Specified by:
getDoctype in interface org.w3c.dom.Document

getImplementation

public org.w3c.dom.DOMImplementation getImplementation()
Specified by:
getImplementation in interface org.w3c.dom.Document

getDocumentElement

public org.w3c.dom.Element getDocumentElement()
Specified by:
getDocumentElement in interface org.w3c.dom.Document

getFirstChild

public org.w3c.dom.Node getFirstChild()
Specified by:
getFirstChild in interface org.w3c.dom.Node
Overrides:
getFirstChild in class NodeImpl

getAttributesCountFor

public int getAttributesCountFor(int nodeNumber)

getChildCountFor

public int getChildCountFor(int nr)

getFirstChildFor

public int getFirstChildFor(int nodeNumber)

getNextSiblingFor

public int getNextSiblingFor(int nodeNumber)

getParentNodeFor

public int getParentNodeFor(int nodeNumber)

createElement

public org.w3c.dom.Element createElement(java.lang.String arg0)
                                  throws org.w3c.dom.DOMException
Specified by:
createElement in interface org.w3c.dom.Document
Throws:
org.w3c.dom.DOMException

createDocumentFragment

public org.w3c.dom.DocumentFragment createDocumentFragment()
Specified by:
createDocumentFragment in interface org.w3c.dom.Document

createTextNode

public org.w3c.dom.Text createTextNode(java.lang.String arg0)
Specified by:
createTextNode in interface org.w3c.dom.Document

createComment

public org.w3c.dom.Comment createComment(java.lang.String arg0)
Specified by:
createComment in interface org.w3c.dom.Document

createCDATASection

public org.w3c.dom.CDATASection createCDATASection(java.lang.String arg0)
                                            throws org.w3c.dom.DOMException
Specified by:
createCDATASection in interface org.w3c.dom.Document
Throws:
org.w3c.dom.DOMException

createProcessingInstruction

public org.w3c.dom.ProcessingInstruction createProcessingInstruction(java.lang.String arg0,
                                                                     java.lang.String arg1)
                                                              throws org.w3c.dom.DOMException
Specified by:
createProcessingInstruction in interface org.w3c.dom.Document
Throws:
org.w3c.dom.DOMException

createAttribute

public org.w3c.dom.Attr createAttribute(java.lang.String arg0)
                                 throws org.w3c.dom.DOMException
Specified by:
createAttribute in interface org.w3c.dom.Document
Throws:
org.w3c.dom.DOMException

createEntityReference

public org.w3c.dom.EntityReference createEntityReference(java.lang.String arg0)
                                                  throws org.w3c.dom.DOMException
Specified by:
createEntityReference in interface org.w3c.dom.Document
Throws:
org.w3c.dom.DOMException

getElementsByTagName

public org.w3c.dom.NodeList getElementsByTagName(java.lang.String name)
Specified by:
getElementsByTagName in interface org.w3c.dom.Document

importNode

public org.w3c.dom.Node importNode(org.w3c.dom.Node arg0,
                                   boolean arg1)
                            throws org.w3c.dom.DOMException
Specified by:
importNode in interface org.w3c.dom.Document
Throws:
org.w3c.dom.DOMException

createElementNS

public org.w3c.dom.Element createElementNS(java.lang.String arg0,
                                           java.lang.String arg1)
                                    throws org.w3c.dom.DOMException
Specified by:
createElementNS in interface org.w3c.dom.Document
Throws:
org.w3c.dom.DOMException

createAttributeNS

public org.w3c.dom.Attr createAttributeNS(java.lang.String arg0,
                                          java.lang.String arg1)
                                   throws org.w3c.dom.DOMException
Specified by:
createAttributeNS in interface org.w3c.dom.Document
Throws:
org.w3c.dom.DOMException

getElementsByTagNameNS

public org.w3c.dom.NodeList getElementsByTagNameNS(java.lang.String arg0,
                                                   java.lang.String arg1)
Specified by:
getElementsByTagNameNS in interface org.w3c.dom.Document

getElementById

public org.w3c.dom.Element getElementById(java.lang.String arg0)
Specified by:
getElementById in interface org.w3c.dom.Document

getOwnerDocument

public org.w3c.dom.Document getOwnerDocument()
Specified by:
getOwnerDocument in interface org.w3c.dom.Node
Overrides:
getOwnerDocument in class NodeImpl

copyTo

public void copyTo(NodeImpl node,
                   DocumentBuilderReceiver receiver)
            throws org.xml.sax.SAXException
Copy the document fragment starting at the specified node to the given document builder.

Parameters:
node -
receiver -
Throws:
org.xml.sax.SAXException

copyTo

protected void copyTo(NodeImpl node,
                      DocumentBuilderReceiver receiver,
                      boolean expandRefs)
               throws org.xml.sax.SAXException
Throws:
org.xml.sax.SAXException

expand

public void expand()
            throws org.w3c.dom.DOMException
Expand all reference nodes in the current document, i.e. replace them by real nodes. Reference nodes are just pointers to nodes from other documents stored in the database. The XQuery engine uses reference nodes to speed up the creation of temporary doc fragments. This method creates a new copy of the document contents and expands all reference nodes.

Overrides:
expand in class NodeImpl
Throws:
org.w3c.dom.DOMException

expandRefs

public DocumentImpl expandRefs(NodeImpl rootNode)
                        throws org.w3c.dom.DOMException
Throws:
org.w3c.dom.DOMException

streamTo

public void streamTo(Serializer serializer,
                     NodeImpl node,
                     Receiver receiver)
              throws org.xml.sax.SAXException
Stream the specified document fragment to a receiver. This method is called by the serializer to output in-memory nodes.

Parameters:
serializer -
node -
receiver -
Throws:
org.xml.sax.SAXException

makePersistent

public Int2ObjectHashMap makePersistent()
                                 throws XPathException
Throws:
XPathException

getChildCount

public int getChildCount()

getInputEncoding

public java.lang.String getInputEncoding()
? @see org.w3c.dom.Document#getInputEncoding()


getXmlEncoding

public java.lang.String getXmlEncoding()
? @see org.w3c.dom.Document#getXmlEncoding()


getXmlStandalone

public boolean getXmlStandalone()
? @see org.w3c.dom.Document#getXmlStandalone()


setXmlStandalone

public void setXmlStandalone(boolean xmlStandalone)
                      throws org.w3c.dom.DOMException
? @see org.w3c.dom.Document#setXmlStandalone(boolean)

Throws:
org.w3c.dom.DOMException

getXmlVersion

public java.lang.String getXmlVersion()
? @see org.w3c.dom.Document#getXmlVersion()


setXmlVersion

public void setXmlVersion(java.lang.String xmlVersion)
                   throws org.w3c.dom.DOMException
? @see org.w3c.dom.Document#setXmlVersion(java.lang.String)

Throws:
org.w3c.dom.DOMException

getStrictErrorChecking

public boolean getStrictErrorChecking()
? @see org.w3c.dom.Document#getStrictErrorChecking()


setStrictErrorChecking

public void setStrictErrorChecking(boolean strictErrorChecking)
? @see org.w3c.dom.Document#setStrictErrorChecking(boolean)


getDocumentURI

public java.lang.String getDocumentURI()
? @see org.w3c.dom.Document#getDocumentURI()


setDocumentURI

public void setDocumentURI(java.lang.String documentURI)
? @see org.w3c.dom.Document#setDocumentURI(java.lang.String)


adoptNode

public org.w3c.dom.Node adoptNode(org.w3c.dom.Node source)
                           throws org.w3c.dom.DOMException
? @see org.w3c.dom.Document#adoptNode(org.w3c.dom.Node)

Throws:
org.w3c.dom.DOMException

getDomConfig

public DOMConfiguration getDomConfig()
? @see org.w3c.dom.Document#getDomConfig()


normalizeDocument

public void normalizeDocument()
? @see org.w3c.dom.Document#normalizeDocument()


renameNode

public org.w3c.dom.Node renameNode(org.w3c.dom.Node n,
                                   java.lang.String namespaceURI,
                                   java.lang.String qualifiedName)
                            throws org.w3c.dom.DOMException
? @see org.w3c.dom.Document#renameNode(org.w3c.dom.Node, java.lang.String, java.lang.String)

Throws:
org.w3c.dom.DOMException

setContext

public void setContext(XQueryContext context)

toString

public java.lang.String toString()


<oXygen/> XML Editor provides support for editing and debugging XQuery expressions against the eXist XML Database.