GME  13
DOMDocumentFragmentImpl.cpp
Go to the documentation of this file.
00001 /*
00002  * Licensed to the Apache Software Foundation (ASF) under one or more
00003  * contributor license agreements.  See the NOTICE file distributed with
00004  * this work for additional information regarding copyright ownership.
00005  * The ASF licenses this file to You under the Apache License, Version 2.0
00006  * (the "License"); you may not use this file except in compliance with
00007  * the License.  You may obtain a copy of the License at
00008  *
00009  *      http://www.apache.org/licenses/LICENSE-2.0
00010  *
00011  * Unless required by applicable law or agreed to in writing, software
00012  * distributed under the License is distributed on an "AS IS" BASIS,
00013  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00014  * See the License for the specific language governing permissions and
00015  * limitations under the License.
00016  */
00017 
00018 /*
00019  * $Id: DOMDocumentFragmentImpl.cpp 671894 2008-06-26 13:29:21Z borisk $
00020  */
00021 
00022 #include "DOMDocumentFragmentImpl.hpp"
00023 #include "DOMDocumentImpl.hpp"
00024 #include "DOMCasts.hpp"
00025 #include <xercesc/dom/DOMNode.hpp>
00026 #include <xercesc/dom/DOMException.hpp>
00027 #include <xercesc/util/XMLUniDefs.hpp>
00028 
00029 XERCES_CPP_NAMESPACE_BEGIN
00030 
00031 DOMDocumentFragmentImpl::DOMDocumentFragmentImpl(DOMDocument *masterDoc)
00032     : fNode(masterDoc), fParent(masterDoc)
00033 {
00034 }
00035 
00036 
00037 DOMDocumentFragmentImpl::DOMDocumentFragmentImpl(const DOMDocumentFragmentImpl &other,
00038                                            bool deep)
00039     : fNode(other.fNode), fParent(other.fParent)
00040 {
00041     if (deep)
00042         castToParentImpl(this)->cloneChildren(&other);
00043 }
00044 
00045 
00046 DOMDocumentFragmentImpl::~DOMDocumentFragmentImpl()
00047 {
00048 }
00049 
00050 
00051 
00052 DOMNode *DOMDocumentFragmentImpl::cloneNode(bool deep) const
00053 {
00054     DOMNode* newNode = new (castToNodeImpl(this)->getOwnerDocument(), DOMMemoryManager::DOCUMENT_FRAGMENT_OBJECT) DOMDocumentFragmentImpl(*this, deep);
00055     fNode.callUserDataHandlers(DOMUserDataHandler::NODE_CLONED, this, newNode);
00056     return newNode;
00057 }
00058 
00059 
00060 const XMLCh * DOMDocumentFragmentImpl::getNodeName() const {
00061     static const XMLCh name[] = {chPound, chLatin_d, chLatin_o, chLatin_c, chLatin_u, chLatin_m,
00062         chLatin_e, chLatin_n, chLatin_t, chDash,
00063         chLatin_f, chLatin_r, chLatin_a, chLatin_g, chLatin_m, chLatin_e, chLatin_n, chLatin_t, 0};
00064     return name;
00065 }
00066 
00067 
00068 DOMNode::NodeType DOMDocumentFragmentImpl::getNodeType() const {
00069     return DOMNode::DOCUMENT_FRAGMENT_NODE;
00070 }
00071 
00072 
00073 void DOMDocumentFragmentImpl::setNodeValue(const XMLCh *x)
00074 {
00075     fNode.setNodeValue(x);
00076 }
00077 
00078 
00079 void DOMDocumentFragmentImpl::release()
00080 {
00081     if (fNode.isOwned() && !fNode.isToBeReleased())
00082         throw DOMException(DOMException::INVALID_ACCESS_ERR,0, GetDOMNodeMemoryManager);
00083 
00084     DOMDocumentImpl* doc = (DOMDocumentImpl*) getOwnerDocument();
00085     if (doc) {
00086         fNode.callUserDataHandlers(DOMUserDataHandler::NODE_DELETED, 0, 0);
00087         fParent.release();
00088         doc->release(this, DOMMemoryManager::DOCUMENT_FRAGMENT_OBJECT);
00089     }
00090     else {
00091         // shouldn't reach here
00092         throw DOMException(DOMException::INVALID_ACCESS_ERR,0, GetDOMNodeMemoryManager);
00093     }
00094 }
00095 
00096 //
00097 //  Delegation stubs for inherited functions.
00098 //
00099            DOMNode*         DOMDocumentFragmentImpl::appendChild(DOMNode *newChild)          {return fParent.appendChild (newChild); }
00100            DOMNamedNodeMap* DOMDocumentFragmentImpl::getAttributes() const                   {return fNode.getAttributes (); }
00101            DOMNodeList*     DOMDocumentFragmentImpl::getChildNodes() const                   {return fParent.getChildNodes (); }
00102            DOMNode*         DOMDocumentFragmentImpl::getFirstChild() const                   {return fParent.getFirstChild (); }
00103            DOMNode*         DOMDocumentFragmentImpl::getLastChild() const                    {return fParent.getLastChild (); }
00104      const XMLCh*           DOMDocumentFragmentImpl::getLocalName() const                    {return fNode.getLocalName (); }
00105      const XMLCh*           DOMDocumentFragmentImpl::getNamespaceURI() const                 {return fNode.getNamespaceURI (); }
00106            DOMNode*         DOMDocumentFragmentImpl::getNextSibling() const                  {return fNode.getNextSibling (); }
00107      const XMLCh*           DOMDocumentFragmentImpl::getNodeValue() const                    {return fNode.getNodeValue (); }
00108            DOMDocument*     DOMDocumentFragmentImpl::getOwnerDocument() const                {return fParent.fOwnerDocument; }
00109      const XMLCh*           DOMDocumentFragmentImpl::getPrefix() const                       {return fNode.getPrefix (); }
00110            DOMNode*         DOMDocumentFragmentImpl::getParentNode() const                   {return fNode.getParentNode (); }
00111            DOMNode*         DOMDocumentFragmentImpl::getPreviousSibling() const              {return fNode.getPreviousSibling (); }
00112            bool             DOMDocumentFragmentImpl::hasChildNodes() const                   {return fParent.hasChildNodes (); }
00113            DOMNode*         DOMDocumentFragmentImpl::insertBefore(DOMNode *newChild, DOMNode *refChild)
00114                                                                                              {return fParent.insertBefore (newChild, refChild); }
00115            void             DOMDocumentFragmentImpl::normalize()                             {fParent.normalize (); }
00116            DOMNode*         DOMDocumentFragmentImpl::removeChild(DOMNode *oldChild)          {return fParent.removeChild (oldChild); }
00117            DOMNode*         DOMDocumentFragmentImpl::replaceChild(DOMNode *newChild, DOMNode *oldChild)
00118                                                                                              {return fParent.replaceChild (newChild, oldChild); }
00119            bool             DOMDocumentFragmentImpl::isSupported(const XMLCh *feature, const XMLCh *version) const
00120                                                                                              {return fNode.isSupported (feature, version); }
00121            void             DOMDocumentFragmentImpl::setPrefix(const XMLCh  *prefix)         {fNode.setPrefix(prefix); }
00122            bool             DOMDocumentFragmentImpl::hasAttributes() const                   {return fNode.hasAttributes(); }
00123            bool             DOMDocumentFragmentImpl::isSameNode(const DOMNode* other) const  {return fNode.isSameNode(other); }
00124            bool             DOMDocumentFragmentImpl::isEqualNode(const DOMNode* arg) const   {return fParent.isEqualNode(arg); }
00125            void*            DOMDocumentFragmentImpl::setUserData(const XMLCh* key, void* data, DOMUserDataHandler* handler)
00126                                                                                              {return fNode.setUserData(key, data, handler); }
00127            void*            DOMDocumentFragmentImpl::getUserData(const XMLCh* key) const     {return fNode.getUserData(key); }
00128            const XMLCh*     DOMDocumentFragmentImpl::getBaseURI() const                      {return fNode.getBaseURI(); }
00129            short            DOMDocumentFragmentImpl::compareDocumentPosition(const DOMNode* other) const {return fNode.compareDocumentPosition(other); }
00130            const XMLCh*     DOMDocumentFragmentImpl::getTextContent() const                  {return fNode.getTextContent(); }
00131            void             DOMDocumentFragmentImpl::setTextContent(const XMLCh* textContent){fNode.setTextContent(textContent); }
00132            const XMLCh*     DOMDocumentFragmentImpl::lookupPrefix(const XMLCh* namespaceURI) const  {return fNode.lookupPrefix(namespaceURI); }
00133            bool             DOMDocumentFragmentImpl::isDefaultNamespace(const XMLCh* namespaceURI) const {return fNode.isDefaultNamespace(namespaceURI); }
00134            const XMLCh*     DOMDocumentFragmentImpl::lookupNamespaceURI(const XMLCh* prefix) const  {return fNode.lookupNamespaceURI(prefix); }
00135            void*            DOMDocumentFragmentImpl::getFeature(const XMLCh* feature, const XMLCh* version) const {return fNode.getFeature(feature, version); }
00136 
00137 XERCES_CPP_NAMESPACE_END