http://xml.apache.org/http://www.apache.org/http://www.w3.org/

Home

Readme
Installation
Build

API Docs
Samples
Programming
Migration
FAQs

Releases
Feedback
Bug-Todo

Download
CVS Repository
Mail Archive

API Docs for SAX and DOM
 

Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

ParentNode Class Reference

ParentNode inherits from ChildImpl and adds the capability of having child nodes. More...

#include <ParentNode.hpp>

Inheritance diagram for ParentNode

Inheritance graph
[legend]
Collaboration diagram for ParentNode:

Collaboration graph
[legend]
List of all members.

Public Methods

 ParentNode (DocumentImpl *ownerDocument)
 ParentNode (const ParentNode &other)
virtual DocumentImpl* getOwnerDocument ()
virtual void setOwnerDocument (DocumentImpl *doc)
virtual NodeListImpl* getChildNodes ()
virtual NodeImpl* getFirstChild ()
virtual NodeImpl* getLastChild ()
virtual unsigned int getLength ()
virtual bool hasChildNodes ()
virtual NodeImpl* insertBefore (NodeImpl *newChild, NodeImpl *refChild)
virtual NodeImpl* item (unsigned int index)
virtual NodeImpl* removeChild (NodeImpl *oldChild)
virtual NodeImpl* replaceChild (NodeImpl *newChild, NodeImpl *oldChild)
virtual void setReadOnly (bool isReadOnly, bool deep)
virtual void normalize ()
virtual DocumentImpl* getDocument ()

Public Attributes

DocumentImpl* ownerDocument
ChildNodefirstChild

Protected Methods

void cloneChildren (const NodeImpl &other)
ChildNodelastChild ()
void lastChild (ChildNode *)

Protected Attributes

int fCachedLength
 Cached node list length.

ChildNodefCachedChild
 Last requested child.

int fCachedChildIndex
 Last requested child index.


Detailed Description

ParentNode inherits from ChildImpl and adds the capability of having child nodes.

Not every node in the DOM can have children, so only nodes that can should inherit from this class and pay the price for it.

ParentNode, just like NodeImpl, also implements NodeList, so it can return itself in response to the getChildNodes() query. This eliminiates the need for a separate ChildNodeList object. Note that this is an IMPLEMENTATION DETAIL; applications should _never_ assume that this identity exists.

While we have a direct reference to the first child, the last child is stored as the previous sibling of the first child. First child nodes are marked as being so, and getNextSibling hides this fact.

Note: Not all parent nodes actually need to also be a child. At some point we used to have ParentNode inheriting from NodeImpl and another class called ChildAndParentNode that inherited from ChildNode. But due to the lack of multiple inheritance a lot of code had to be duplicated which led to a maintenance nightmare. At the same time only a few nodes (Document, DocumentFragment, Entity, and Attribute) cannot be a child so the gain is memory wasn't really worth it. The only type for which this would be the case is Attribute, but we deal with there in another special way, so this is not applicable.

WARNING: Some of the code here is partially duplicated in AttrImpl, be careful to keep these two classes in sync!


Constructor & Destructor Documentation

ParentNode::ParentNode ( DocumentImpl * ownerDocument )
 

ParentNode::ParentNode ( const ParentNode & other )
 


Member Function Documentation

void ParentNode::cloneChildren ( const NodeImpl & other ) [protected]
 

virtual NodeListImpl* ParentNode::getChildNodes ( ) [virtual]
 

virtual DocumentImpl* ParentNode::getDocument ( ) [virtual]
 

virtual NodeImpl* ParentNode::getFirstChild ( ) [virtual]
 

virtual NodeImpl* ParentNode::getLastChild ( ) [virtual]
 

virtual unsigned int ParentNode::getLength ( ) [virtual]
 

virtual DocumentImpl* ParentNode::getOwnerDocument ( ) [virtual]
 

virtual bool ParentNode::hasChildNodes ( ) [virtual]
 

virtual NodeImpl* ParentNode::insertBefore ( NodeImpl * newChild,
NodeImpl * refChild ) [virtual]
 

virtual NodeImpl* ParentNode::item ( unsigned int index ) [virtual]
 

void ParentNode::lastChild ( ChildNode * ) [protected]
 

ChildNode* ParentNode::lastChild ( ) [protected]
 

virtual void ParentNode::normalize ( ) [virtual]
 

virtual NodeImpl* ParentNode::removeChild ( NodeImpl * oldChild ) [virtual]
 

virtual NodeImpl* ParentNode::replaceChild ( NodeImpl * newChild,
NodeImpl * oldChild ) [virtual]
 

virtual void ParentNode::setOwnerDocument ( DocumentImpl * doc ) [virtual]
 

virtual void ParentNode::setReadOnly ( bool isReadOnly,
bool deep ) [virtual]
 


Member Data Documentation

ChildNode * ParentNode::fCachedChild [protected]
 

Last requested child.

int ParentNode::fCachedChildIndex [protected]
 

Last requested child index.

int ParentNode::fCachedLength [protected]
 

Cached node list length.

ChildNode * ParentNode::firstChild
 

DocumentImpl * ParentNode::ownerDocument
 


The documentation for this class was generated from the following file:


Copyright © 2000 The Apache Software Foundation. All Rights Reserved.