org.exist.dom
Class DocumentImpl

java.lang.Object
  extended byorg.exist.dom.NodeImpl
      extended byorg.exist.dom.DocumentImpl
All Implemented Interfaces:
java.lang.Comparable, org.w3c.dom.Document, org.w3c.dom.Node, QNameable
Direct Known Subclasses:
BinaryDocument

public class DocumentImpl
extends NodeImpl
implements org.w3c.dom.Document, java.lang.Comparable

Represents a persistent document object in the database; it can be an XML_FILE , a BINARY_FILE, or Xquery source code.

Author:
Wolfgang Meier

Field Summary
static byte BINARY_FILE
           
static int UNKNOWN_DOCUMENT_ID
           
static byte XML_FILE
           
 
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
 
Constructor Summary
DocumentImpl(DBBroker broker)
           
DocumentImpl(DBBroker broker, Collection collection)
           
DocumentImpl(DBBroker broker, Collection collection, XmldbURI fileURI)
           
DocumentImpl(DBBroker broker, XmldbURI fileURI)
           
 
Method Summary
 org.w3c.dom.Node adoptNode(org.w3c.dom.Node node)
           
 void appendChild(StoredNode child)
           
 short compareDocumentPosition(org.w3c.dom.Node other)
          ? @see org.w3c.dom.Node#compareDocumentPosition(org.w3c.dom.Node)
 int compareTo(java.lang.Object other)
           
 void copyChildren(DocumentImpl other)
           
 void copyOf(DocumentImpl other)
          Copy the relevant internal fields from the specified document object.
 org.w3c.dom.Attr createAttribute(java.lang.String name)
           
 org.w3c.dom.Attr createAttributeNS(java.lang.String namespaceURI, java.lang.String qualifiedName)
           
 org.w3c.dom.CDATASection createCDATASection(java.lang.String data)
           
 org.w3c.dom.Comment createComment(java.lang.String data)
           
 org.w3c.dom.DocumentFragment createDocumentFragment()
           
 org.w3c.dom.Element createElement(java.lang.String tagName)
           
 org.w3c.dom.Element createElementNS(java.lang.String namespaceURI, java.lang.String qualifiedName)
           
 org.w3c.dom.EntityReference createEntityReference(java.lang.String name)
           
 org.w3c.dom.ProcessingInstruction createProcessingInstruction(java.lang.String target, java.lang.String data)
           
 org.w3c.dom.Text createTextNode(java.lang.String data)
           
 java.lang.String getBaseURI()
          ? @see org.w3c.dom.Node#getBaseURI()
 DBBroker getBroker()
           
 int getChildCount()
           
 org.w3c.dom.NodeList getChildNodes()
           
 Collection getCollection()
          Document metadata
 int getContentLength()
          Returns the estimated size of the data in this document.
 int getDocId()
           
 org.w3c.dom.DocumentType getDoctype()
          NodeImpl methods
 org.w3c.dom.Element getDocumentElement()
           
 java.lang.String getDocumentURI()
          ? @see org.w3c.dom.Document#getDocumentURI()
 org.w3c.dom.DOMConfiguration getDomConfig()
          ? @see org.w3c.dom.Document#getDomConfig()
 org.w3c.dom.Element getElementById(java.lang.String elementId)
           
 org.w3c.dom.NodeList getElementsByTagName(java.lang.String tagname)
           
 org.w3c.dom.NodeList getElementsByTagNameNS(java.lang.String namespaceURI, java.lang.String localName)
           
 java.lang.String getEncoding()
           
 java.lang.Object getFeature(java.lang.String feature, java.lang.String version)
          ? @see org.w3c.dom.Node#getFeature(java.lang.String, java.lang.String)
 XmldbURI getFileURI()
           
 org.w3c.dom.Node getFirstChild()
           
 long getFirstChildAddress()
           
 org.w3c.dom.DOMImplementation getImplementation()
           
 java.lang.String getInputEncoding()
          ? @see org.w3c.dom.Document#getInputEncoding()
 DocumentMetadata getMetadata()
           
 long getMetadataLocation()
           
 org.w3c.dom.Node getNextSibling()
           
 org.w3c.dom.Node getNode(NodeId nodeId)
           
 org.w3c.dom.Node getNode(NodeProxy p)
           
 short getNodeType()
           
 org.w3c.dom.Document getOwnerDocument()
           
 org.w3c.dom.Node getParentNode()
           
 Permission getPermissions()
           
 org.w3c.dom.Node getPreviousSibling()
           
 QName getQName()
           
 byte getResourceType()
          Returns the type of this resource, either XML_FILE or BINARY_FILE.
 boolean getStandalone()
           
 boolean getStrictErrorChecking()
           
 SymbolTable getSymbols()
           
 java.lang.String getTextContent()
          ? @see org.w3c.dom.Node#getTextContent()
 Lock getUpdateLock()
          Returns the update lock associated with this resource.
 XmldbURI getURI()
           
 java.lang.Object getUserData(java.lang.String key)
          ? @see org.w3c.dom.Node#getUserData(java.lang.String)
 User getUserLock()
           
 java.lang.String getVersion()
           
 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 importedNode, boolean deep)
           
 void insertAfter(org.w3c.dom.NodeList nodes, org.w3c.dom.Node refChild)
           
 void insertBefore(org.w3c.dom.NodeList nodes, org.w3c.dom.Node refChild)
           
 boolean isDefaultNamespace(java.lang.String namespaceURI)
          ? @see org.w3c.dom.Node#isDefaultNamespace(java.lang.String)
 boolean isEqualNode(org.w3c.dom.Node arg)
          ? @see org.w3c.dom.Node#isEqualNode(org.w3c.dom.Node)
 boolean isLockedForWrite()
          Returns true if the document is currently locked for write.
 boolean isSameNode(org.w3c.dom.Node other)
          ? @see org.w3c.dom.Node#isSameNode(org.w3c.dom.Node)
 boolean isSupported(java.lang.String type, java.lang.String value)
           
 java.lang.String lookupNamespaceURI(java.lang.String prefix)
          ? @see org.w3c.dom.Node#lookupNamespaceURI(java.lang.String)
 java.lang.String lookupPrefix(java.lang.String namespaceURI)
          ? @see org.w3c.dom.Node#lookupPrefix(java.lang.String)
 void normalizeDocument()
          ? @see org.w3c.dom.Document#normalizeDocument()
 void read(VariableByteInput istream)
           
 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 setBroker(DBBroker broker)
           
 void setChildCount(int count)
           
 void setCollection(Collection parent)
           
 void setDocId(int docId)
           
 void setDocumentType(org.w3c.dom.DocumentType docType)
           
 void setDocumentURI(java.lang.String documentURI)
          ? @see org.w3c.dom.Document#setDocumentURI(java.lang.String)
 void setEncoding(java.lang.String enc)
           
 void setFileURI(XmldbURI fileURI)
           
 void setMetadata(DocumentMetadata meta)
           
 void setMetadataLocation(long pointer)
           
 void setOwnerDocument(org.w3c.dom.Document doc)
           
 void setPermissions(int mode)
           
 void setPermissions(Permission perm)
           
 void setPermissions(java.lang.String mode)
           
 void setStandalone(boolean alone)
           
 void setStrictErrorChecking(boolean strict)
           
 void setTextContent(java.lang.String textContent)
          ? @see org.w3c.dom.Node#setTextContent(java.lang.String)
 java.lang.Object setUserData(java.lang.String key, java.lang.Object data, org.w3c.dom.UserDataHandler handler)
          ? @see org.w3c.dom.Node#setUserData(java.lang.String, java.lang.Object, org.w3c.dom.UserDataHandler)
 void setUserLock(User user)
           
 void setVersion(java.lang.String version)
           
 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)
 java.lang.String toString()
           
 void triggerDefrag()
           
 void updateChild(Txn transaction, org.w3c.dom.Node oldChild, org.w3c.dom.Node newChild)
          Update a child node.
 void write(VariableByteOutputStream ostream)
           
 
Methods inherited from class org.exist.dom.NodeImpl
appendChild, appendChildren, cloneNode, getAttributes, getAttributesCount, getLastChild, getLocalName, getNamespaceURI, getNodeName, getNodeValue, getPrefix, hasAttributes, hasChildNodes, insertAfter, insertAfter, insertBefore, insertBefore, normalize, removeChild, removeChild, replaceChild, replaceChild, setAttributes, setNodeName, setNodeValue, setPrefix, supports, updateChild
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.w3c.dom.Node
appendChild, cloneNode, getAttributes, getLastChild, getLocalName, getNamespaceURI, getNodeName, getNodeValue, getPrefix, hasAttributes, hasChildNodes, insertBefore, normalize, removeChild, replaceChild, setNodeValue, setPrefix
 

Field Detail

UNKNOWN_DOCUMENT_ID

public static final int UNKNOWN_DOCUMENT_ID
See Also:
Constant Field Values

XML_FILE

public static final byte XML_FILE
See Also:
Constant Field Values

BINARY_FILE

public static final byte BINARY_FILE
See Also:
Constant Field Values
Constructor Detail

DocumentImpl

public DocumentImpl(DBBroker broker)

DocumentImpl

public DocumentImpl(DBBroker broker,
                    Collection collection)

DocumentImpl

public DocumentImpl(DBBroker broker,
                    XmldbURI fileURI)

DocumentImpl

public DocumentImpl(DBBroker broker,
                    Collection collection,
                    XmldbURI fileURI)
Method Detail

getCollection

public Collection getCollection()
Document metadata


setCollection

public void setCollection(Collection parent)

getDocId

public int getDocId()

setDocId

public void setDocId(int docId)

getResourceType

public byte getResourceType()
Returns the type of this resource, either XML_FILE or BINARY_FILE.


getFileURI

public XmldbURI getFileURI()

setFileURI

public void setFileURI(XmldbURI fileURI)

getURI

public XmldbURI getURI()

getPermissions

public Permission getPermissions()

setPermissions

public void setPermissions(int mode)

setPermissions

public void setPermissions(java.lang.String mode)
                    throws SyntaxException
Throws:
SyntaxException

setPermissions

public void setPermissions(Permission perm)

setMetadata

public void setMetadata(DocumentMetadata meta)

getMetadata

public DocumentMetadata getMetadata()

setMetadataLocation

public void setMetadataLocation(long pointer)

getMetadataLocation

public long getMetadataLocation()

copyOf

public void copyOf(DocumentImpl other)
Copy the relevant internal fields from the specified document object. This is called by Collection when replacing a document.

Parameters:
other -

copyChildren

public void copyChildren(DocumentImpl other)

isLockedForWrite

public boolean isLockedForWrite()
Returns true if the document is currently locked for write.


getUpdateLock

public final Lock getUpdateLock()
Returns the update lock associated with this resource.


setUserLock

public void setUserLock(User user)

getUserLock

public User getUserLock()

getContentLength

public int getContentLength()
Returns the estimated size of the data in this document. As an estimation, the number of pages occupied by the document is multiplied with the current page size.


triggerDefrag

public void triggerDefrag()

getSymbols

public SymbolTable getSymbols()

getNode

public org.w3c.dom.Node getNode(NodeId nodeId)

getNode

public org.w3c.dom.Node getNode(NodeProxy p)

appendChild

public void appendChild(StoredNode child)
                 throws org.w3c.dom.DOMException
Throws:
org.w3c.dom.DOMException

write

public void write(VariableByteOutputStream ostream)
           throws java.io.IOException
Throws:
java.io.IOException

read

public void read(VariableByteInput istream)
          throws java.io.IOException,
                 java.io.EOFException
Throws:
java.io.IOException
java.io.EOFException

compareTo

public final int compareTo(java.lang.Object other)
Specified by:
compareTo in interface java.lang.Comparable

getBroker

public DBBroker getBroker()

setBroker

public void setBroker(DBBroker broker)

updateChild

public void updateChild(Txn transaction,
                        org.w3c.dom.Node oldChild,
                        org.w3c.dom.Node newChild)
                 throws org.w3c.dom.DOMException
Description copied from class: NodeImpl
Update a child node. This method will only update the child node but not its potential descendant nodes.

Overrides:
updateChild in class NodeImpl
Parameters:
oldChild -
newChild -
Throws:
org.w3c.dom.DOMException

insertBefore

public void insertBefore(org.w3c.dom.NodeList nodes,
                         org.w3c.dom.Node refChild)
                  throws org.w3c.dom.DOMException
Throws:
org.w3c.dom.DOMException

insertAfter

public void insertAfter(org.w3c.dom.NodeList nodes,
                        org.w3c.dom.Node refChild)
                 throws org.w3c.dom.DOMException
Throws:
org.w3c.dom.DOMException

getFirstChild

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

getFirstChildAddress

public long getFirstChildAddress()

getChildNodes

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

getDoctype

public org.w3c.dom.DocumentType getDoctype()
NodeImpl methods

Specified by:
getDoctype in interface org.w3c.dom.Document

setDocumentType

public void setDocumentType(org.w3c.dom.DocumentType docType)

getOwnerDocument

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

setOwnerDocument

public void setOwnerDocument(org.w3c.dom.Document doc)

getQName

public QName getQName()
Specified by:
getQName in interface QNameable

getNodeType

public short getNodeType()
Specified by:
getNodeType in interface org.w3c.dom.Node

getPreviousSibling

public org.w3c.dom.Node getPreviousSibling()
Specified by:
getPreviousSibling in interface org.w3c.dom.Node

getNextSibling

public org.w3c.dom.Node getNextSibling()
Specified by:
getNextSibling in interface org.w3c.dom.Node

createAttribute

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

createAttributeNS

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

createElement

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

createElementNS

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

createTextNode

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

getDocumentElement

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

getElementsByTagName

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

getElementsByTagNameNS

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

getParentNode

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

getChildCount

public int getChildCount()
Overrides:
getChildCount in class NodeImpl

setChildCount

public void setChildCount(int count)
Parameters:
count - The new childCount value

getEncoding

public java.lang.String getEncoding()

setEncoding

public void setEncoding(java.lang.String enc)

getVersion

public java.lang.String getVersion()

setVersion

public void setVersion(java.lang.String version)

getStandalone

public boolean getStandalone()

setStandalone

public void setStandalone(boolean alone)

createCDATASection

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

createComment

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

createDocumentFragment

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

createEntityReference

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

createProcessingInstruction

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

getElementById

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

getImplementation

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

getStrictErrorChecking

public boolean getStrictErrorChecking()

adoptNode

public org.w3c.dom.Node adoptNode(org.w3c.dom.Node node)
                           throws org.w3c.dom.DOMException
Throws:
org.w3c.dom.DOMException

importNode

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

isSupported

public boolean isSupported(java.lang.String type,
                           java.lang.String value)
Specified by:
isSupported in interface org.w3c.dom.Node
Overrides:
isSupported in class NodeImpl
See Also:
Node.isSupported(java.lang.String, java.lang.String)

setStrictErrorChecking

public void setStrictErrorChecking(boolean strict)

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

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)


getDomConfig

public org.w3c.dom.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

getBaseURI

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

Overrides:
getBaseURI in class NodeImpl

compareDocumentPosition

public short compareDocumentPosition(org.w3c.dom.Node other)
                              throws org.w3c.dom.DOMException
? @see org.w3c.dom.Node#compareDocumentPosition(org.w3c.dom.Node)

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

getTextContent

public java.lang.String getTextContent()
                                throws org.w3c.dom.DOMException
? @see org.w3c.dom.Node#getTextContent()

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

setTextContent

public void setTextContent(java.lang.String textContent)
                    throws org.w3c.dom.DOMException
? @see org.w3c.dom.Node#setTextContent(java.lang.String)

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

isSameNode

public boolean isSameNode(org.w3c.dom.Node other)
? @see org.w3c.dom.Node#isSameNode(org.w3c.dom.Node)

Overrides:
isSameNode in class NodeImpl

lookupPrefix

public java.lang.String lookupPrefix(java.lang.String namespaceURI)
? @see org.w3c.dom.Node#lookupPrefix(java.lang.String)

Overrides:
lookupPrefix in class NodeImpl

isDefaultNamespace

public boolean isDefaultNamespace(java.lang.String namespaceURI)
? @see org.w3c.dom.Node#isDefaultNamespace(java.lang.String)

Overrides:
isDefaultNamespace in class NodeImpl

lookupNamespaceURI

public java.lang.String lookupNamespaceURI(java.lang.String prefix)
? @see org.w3c.dom.Node#lookupNamespaceURI(java.lang.String)

Overrides:
lookupNamespaceURI in class NodeImpl

isEqualNode

public boolean isEqualNode(org.w3c.dom.Node arg)
? @see org.w3c.dom.Node#isEqualNode(org.w3c.dom.Node)

Overrides:
isEqualNode in class NodeImpl

getFeature

public java.lang.Object getFeature(java.lang.String feature,
                                   java.lang.String version)
? @see org.w3c.dom.Node#getFeature(java.lang.String, java.lang.String)

Overrides:
getFeature in class NodeImpl

setUserData

public java.lang.Object setUserData(java.lang.String key,
                                    java.lang.Object data,
                                    org.w3c.dom.UserDataHandler handler)
? @see org.w3c.dom.Node#setUserData(java.lang.String, java.lang.Object, org.w3c.dom.UserDataHandler)

Overrides:
setUserData in class NodeImpl

getUserData

public java.lang.Object getUserData(java.lang.String key)
? @see org.w3c.dom.Node#getUserData(java.lang.String)

Overrides:
getUserData in class NodeImpl

toString

public java.lang.String toString()


Copyright (C) Wolfgang Meier. All rights reserved.