org.exist.memtree
Class DocumentImpl

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

public class DocumentImpl
extends NodeImpl
implements 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
 
Fields inherited from class org.exist.memtree.NodeImpl
NAMESPACE_NODE, REFERENCE_NODE
 
Fields inherited from interface org.w3c.dom.Node
ATTRIBUTE_NODE, CDATA_SECTION_NODE, COMMENT_NODE, DOCUMENT_FRAGMENT_NODE, DOCUMENT_NODE, DOCUMENT_POSITION_CONTAINED_BY, DOCUMENT_POSITION_CONTAINS, DOCUMENT_POSITION_DISCONNECTED, DOCUMENT_POSITION_FOLLOWING, DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC, DOCUMENT_POSITION_PRECEDING, 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, String value)
           
 void addChars(int nodeNr, char[] ch, int start, int len)
           
 void addChars(int nodeNr, CharSequence s)
           
 int addNamespace(int nodeNr, QName qname)
           
 int addNode(short kind, short level, QName qname)
           
 void addReferenceNode(int nodeNr, NodeProxy proxy)
           
 Node adoptNode(Node source)
          ? @see org.w3c.dom.Document#adoptNode(org.w3c.dom.Node)
 void appendChars(int nodeNr, char[] ch, int start, int len)
           
 void appendChars(int nodeNr, CharSequence s)
           
 void copyTo(NodeImpl node, DocumentBuilderReceiver receiver)
          Copy the document fragment starting at the specified node to the given document builder.
 Attr createAttribute(String arg0)
           
 Attr createAttributeNS(String arg0, String arg1)
           
 CDATASection createCDATASection(String arg0)
           
 Comment createComment(String arg0)
           
 DocumentFragment createDocumentFragment()
           
 Element createElement(String arg0)
           
 Element createElementNS(String arg0, String arg1)
           
 EntityReference createEntityReference(String arg0)
           
 ProcessingInstruction createProcessingInstruction(String arg0, String arg1)
           
 Text createTextNode(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)
           
 String getBaseURI()
          ? @see org.w3c.dom.Node#getBaseURI()
 int getChildCount()
           
 int getChildCountFor(int nr)
           
 DocumentType getDoctype()
           
 Element getDocumentElement()
           
 String getDocumentURI()
          ? @see org.w3c.dom.Document#getDocumentURI()
 DOMConfiguration getDomConfig()
          ? @see org.w3c.dom.Document#getDomConfig()
 Element getElementById(String arg0)
           
 NodeList getElementsByTagName(String name)
           
 NodeList getElementsByTagNameNS(String arg0, String arg1)
           
 Node getFirstChild()
           
 int getFirstChildFor(int nodeNumber)
           
 DOMImplementation getImplementation()
           
 String getInputEncoding()
          ? @see org.w3c.dom.Document#getInputEncoding()
 int getItemType()
          Return the primary type to which all items in this sequence belong.
 NodeImpl getLastAttr()
           
 int getLastNode()
           
 String getLocalName()
           
 NodeImpl getNamespaceNode(int nodeNr)
           
 int getNamespacesCountFor(int nodeNumber)
           
 String getNamespaceURI()
           
 int getNextSiblingFor(int nodeNumber)
           
 NodeImpl getNode(int nodeNr)
           
 short getNodeType(int nodeNr)
           
 Document getOwnerDocument()
           
 Node getParentNode()
           
 int getParentNodeFor(int nodeNumber)
          The method getParentNodeFor
 int getSize()
           
 boolean getStrictErrorChecking()
          ? @see org.w3c.dom.Document#getStrictErrorChecking()
 short getTreeLevel(int nodeNr)
           
 String getXmlEncoding()
          ? @see org.w3c.dom.Document#getXmlEncoding()
 boolean getXmlStandalone()
          ? @see org.w3c.dom.Document#getXmlStandalone()
 String getXmlVersion()
          ? @see org.w3c.dom.Document#getXmlVersion()
 Node importNode(Node arg0, boolean arg1)
           
 Int2ObjectHashMap makePersistent()
           
 void normalizeDocument()
          ? @see org.w3c.dom.Document#normalizeDocument()
 Node renameNode(Node n, String namespaceURI, String qualifiedName)
          ? @see org.w3c.dom.Document#renameNode(org.w3c.dom.Node, java.lang.String, java.lang.String)
 void replaceReferenceNode(int nodeNr, CharSequence ch)
           
 void reset()
           
 void setContext(XQueryContext context)
           
 void setDocumentURI(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(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.
 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, getCardinality, getChildNodes, getCollectionIterator, getDocument, getDocumentSet, getFeature, getImplementationType, getItemCount, getLastChild, getLength, getNextSibling, getNode, getNodeName, getNodeNumber, getNodeType, getNodeValue, getPrefix, getPreviousSibling, getQName, getState, getStringValue, getTextContent, getType, getUserData, hasAttributes, hasChanged, hasChildNodes, hasMany, hasOne, insertBefore, isCacheable, isCached, isDefaultNamespace, isEmpty, isEqualNode, isPersistentSet, isSameNode, isSupported, itemAt, iterate, lookupNamespaceURI, lookupPrefix, nodeMoved, normalize, removeChild, removeDuplicates, replaceChild, setIsCached, setNodeValue, setPrefix, setSelfAsContext, setTextContent, setUserData, streamTo, toJavaObject, toNodeSet, toSAX, toSequence, unorderedIterator
 
Methods inherited from class java.lang.Object
getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.w3c.dom.Node
appendChild, cloneNode, compareDocumentPosition, getAttributes, getChildNodes, getFeature, getLastChild, getNextSibling, getNodeName, getNodeType, getNodeValue, getPrefix, getPreviousSibling, getTextContent, getUserData, hasAttributes, hasChildNodes, insertBefore, isDefaultNamespace, isEqualNode, isSameNode, isSupported, lookupNamespaceURI, lookupPrefix, normalize, removeChild, replaceChild, setNodeValue, setPrefix, setTextContent, setUserData
 

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,
                     CharSequence s)

appendChars

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

appendChars

public void appendChars(int nodeNr,
                        CharSequence s)

addReferenceNode

public void addReferenceNode(int nodeNr,
                             NodeProxy proxy)

replaceReferenceNode

public void replaceReferenceNode(int nodeNr,
                                 CharSequence ch)

addAttribute

public int addAttribute(int nodeNr,
                        QName qname,
                        String value)
                 throws DOMException
Throws:
DOMException

addNamespace

public int addNamespace(int nodeNr,
                        QName qname)

getTreeLevel

public short getTreeLevel(int nodeNr)

getLastNode

public int getLastNode()

getNodeType

public short getNodeType(int nodeNr)

getAttribute

public NodeImpl getAttribute(int nodeNr)
                      throws DOMException
Throws:
DOMException

getNamespaceNode

public NodeImpl getNamespaceNode(int nodeNr)
                          throws DOMException
Throws:
DOMException

getNode

public NodeImpl getNode(int nodeNr)
                 throws DOMException
Throws:
DOMException

getLastAttr

public NodeImpl getLastAttr()

getParentNode

public Node getParentNode()
Specified by:
getParentNode in interface Node
Overrides:
getParentNode in class NodeImpl

getDoctype

public DocumentType getDoctype()
Specified by:
getDoctype in interface Document

getImplementation

public DOMImplementation getImplementation()
Specified by:
getImplementation in interface Document

getDocumentElement

public Element getDocumentElement()
Specified by:
getDocumentElement in interface Document

getFirstChild

public Node getFirstChild()
Specified by:
getFirstChild in interface Node
Overrides:
getFirstChild in class NodeImpl

getAttributesCountFor

public int getAttributesCountFor(int nodeNumber)

getNamespacesCountFor

public int getNamespacesCountFor(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)
The method getParentNodeFor

Parameters:
nodeNumber - an int value
Returns:
an int value

createElement

public Element createElement(String arg0)
                      throws DOMException
Specified by:
createElement in interface Document
Throws:
DOMException

createDocumentFragment

public DocumentFragment createDocumentFragment()
Specified by:
createDocumentFragment in interface Document

createTextNode

public Text createTextNode(String arg0)
Specified by:
createTextNode in interface Document

createComment

public Comment createComment(String arg0)
Specified by:
createComment in interface Document

createCDATASection

public CDATASection createCDATASection(String arg0)
                                throws DOMException
Specified by:
createCDATASection in interface Document
Throws:
DOMException

createProcessingInstruction

public ProcessingInstruction createProcessingInstruction(String arg0,
                                                         String arg1)
                                                  throws DOMException
Specified by:
createProcessingInstruction in interface Document
Throws:
DOMException

createAttribute

public Attr createAttribute(String arg0)
                     throws DOMException
Specified by:
createAttribute in interface Document
Throws:
DOMException

createEntityReference

public EntityReference createEntityReference(String arg0)
                                      throws DOMException
Specified by:
createEntityReference in interface Document
Throws:
DOMException

getElementsByTagName

public NodeList getElementsByTagName(String name)
Specified by:
getElementsByTagName in interface Document

importNode

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

createElementNS

public Element createElementNS(String arg0,
                               String arg1)
                        throws DOMException
Specified by:
createElementNS in interface Document
Throws:
DOMException

createAttributeNS

public Attr createAttributeNS(String arg0,
                              String arg1)
                       throws DOMException
Specified by:
createAttributeNS in interface Document
Throws:
DOMException

getElementsByTagNameNS

public NodeList getElementsByTagNameNS(String arg0,
                                       String arg1)
Specified by:
getElementsByTagNameNS in interface Document

getElementById

public Element getElementById(String arg0)
Specified by:
getElementById in interface Document

getOwnerDocument

public Document getOwnerDocument()
Specified by:
getOwnerDocument in interface NodeValue
Specified by:
getOwnerDocument in interface Node
Overrides:
getOwnerDocument in class NodeImpl

copyTo

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

Parameters:
node -
receiver -
Throws:
SAXException

expand

public void expand()
            throws 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:
DOMException

expandRefs

public DocumentImpl expandRefs(NodeImpl rootNode)
                        throws DOMException
Throws:
DOMException

streamTo

public void streamTo(Serializer serializer,
                     NodeImpl node,
                     Receiver receiver)
              throws 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:
SAXException

makePersistent

public Int2ObjectHashMap makePersistent()
                                 throws XPathException
Throws:
XPathException

getChildCount

public int getChildCount()

getLocalName

public String getLocalName()
Specified by:
getLocalName in interface Node
Overrides:
getLocalName in class NodeImpl

getNamespaceURI

public String getNamespaceURI()
Specified by:
getNamespaceURI in interface Node
Overrides:
getNamespaceURI in class NodeImpl

getInputEncoding

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

Specified by:
getInputEncoding in interface Document

getXmlEncoding

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

Specified by:
getXmlEncoding in interface Document

getXmlStandalone

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

Specified by:
getXmlStandalone in interface Document

setXmlStandalone

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

Specified by:
setXmlStandalone in interface Document
Throws:
DOMException

getXmlVersion

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

Specified by:
getXmlVersion in interface Document

setXmlVersion

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

Specified by:
setXmlVersion in interface Document
Throws:
DOMException

getStrictErrorChecking

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

Specified by:
getStrictErrorChecking in interface Document

setStrictErrorChecking

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

Specified by:
setStrictErrorChecking in interface Document

getDocumentURI

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

Specified by:
getDocumentURI in interface Document

setDocumentURI

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

Specified by:
setDocumentURI in interface Document

adoptNode

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

Specified by:
adoptNode in interface Document
Throws:
DOMException

getDomConfig

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

Specified by:
getDomConfig in interface Document

normalizeDocument

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

Specified by:
normalizeDocument in interface Document

renameNode

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

Specified by:
renameNode in interface Document
Throws:
DOMException

setContext

public void setContext(XQueryContext context)

getBaseURI

public String getBaseURI()
? @see org.w3c.dom.Node#getBaseURI()

Specified by:
getBaseURI in interface Node
Overrides:
getBaseURI in class NodeImpl

getItemType

public int getItemType()
Description copied from interface: Sequence
Return the primary type to which all items in this sequence belong. This is Type.NODE for node sets, Type.ITEM for other sequences with mixed items.

Specified by:
getItemType in interface Sequence
Overrides:
getItemType in class NodeImpl
Returns:
the primary type of the items in this sequence.

toString

public String toString()
Overrides:
toString in class Object


Copyright (C) Wolfgang Meier. All rights reserved.