IDCDATASectionImpl.cpp
上传用户:huihehuasu
上传日期:2007-01-10
资源大小:6948k
文件大小:10k
源码类别:

xml/soap/webservice

开发平台:

C/C++

  1. /*
  2.  * The Apache Software License, Version 1.1
  3.  *
  4.  * Copyright (c) 2001 The Apache Software Foundation.  All rights
  5.  * reserved.
  6.  *
  7.  * Redistribution and use in source and binary forms, with or without
  8.  * modification, are permitted provided that the following conditions
  9.  * are met:
  10.  *
  11.  * 1. Redistributions of source code must retain the above copyright
  12.  *    notice, this list of conditions and the following disclaimer.
  13.  *
  14.  * 2. Redistributions in binary form must reproduce the above copyright
  15.  *    notice, this list of conditions and the following disclaimer in
  16.  *    the documentation and/or other materials provided with the
  17.  *    distribution.
  18.  *
  19.  * 3. The end-user documentation included with the redistribution,
  20.  *    if any, must include the following acknowledgment:
  21.  *       "This product includes software developed by the
  22.  *        Apache Software Foundation (http://www.apache.org/)."
  23.  *    Alternately, this acknowledgment may appear in the software itself,
  24.  *    if and wherever such third-party acknowledgments normally appear.
  25.  *
  26.  * 4. The names "Xerces" and "Apache Software Foundation" must
  27.  *    not be used to endorse or promote products derived from this
  28.  *    software without prior written permission. For written
  29.  *    permission, please contact apache@apache.org.
  30.  *
  31.  * 5. Products derived from this software may not be called "Apache",
  32.  *    nor may "Apache" appear in their name, without prior written
  33.  *    permission of the Apache Software Foundation.
  34.  *
  35.  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  36.  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  37.  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  38.  * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
  39.  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  40.  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  41.  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  42.  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  43.  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  44.  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  45.  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  46.  * SUCH DAMAGE.
  47.  * ====================================================================
  48.  *
  49.  * This software consists of voluntary contributions made by many
  50.  * individuals on behalf of the Apache Software Foundation, and was
  51.  * originally based on software copyright (c) 2001, International
  52.  * Business Machines, Inc., http://www.ibm.com .  For more information
  53.  * on the Apache Software Foundation, please see
  54.  * <http://www.apache.org/>.
  55.  */
  56. /*
  57.  * $Id: IDCDATASectionImpl.cpp,v 1.3 2001/06/04 14:55:31 tng Exp $
  58.  */
  59. #include "IDCDATASectionImpl.hpp"
  60. #include "IDNodeImpl.hpp"
  61. #include "IDDocumentImpl.hpp"
  62. #include "IDRangeImpl.hpp"
  63. #include "IDCasts.hpp"
  64. #include "IDOM_DOMException.hpp"
  65. #include <util/XMLUniDefs.hpp>
  66. IDCDATASectionImpl::IDCDATASectionImpl(IDOM_Document *ownerDoc,
  67.                                    const XMLCh *dat)
  68.     : fNode(ownerDoc), fParent(ownerDoc), fCharacterData(ownerDoc, dat)
  69. {
  70. };
  71. IDCDATASectionImpl::IDCDATASectionImpl(const IDCDATASectionImpl &other, bool deep)
  72.     : fNode(*castToNodeImpl(&other)),
  73.     fParent(*castToParentImpl(&other)),
  74.     fChild(*castToChildImpl(&other)),
  75.     fCharacterData(other.fCharacterData)
  76. {
  77.     // idom_revisit.  SOmething nees to make "deep" work.
  78. };
  79. IDCDATASectionImpl::~IDCDATASectionImpl()
  80. {
  81. };
  82. IDOM_Node  *IDCDATASectionImpl::cloneNode(bool deep) const
  83. {
  84.     return new (this->getOwnerDocument()) IDCDATASectionImpl(*this, deep);
  85. };
  86. const XMLCh * IDCDATASectionImpl::getNodeName() const {
  87.     static const XMLCh gcdata_section[] = {chPound, chLatin_c, chLatin_d, chLatin_a, chLatin_t, chLatin_a,
  88.         chDash, chLatin_s, chLatin_e, chLatin_c, chLatin_t, chLatin_i, chLatin_o, chLatin_n, 0};
  89.     return gcdata_section;
  90. };
  91. short IDCDATASectionImpl::getNodeType() const {
  92.     return IDOM_Node::CDATA_SECTION_NODE;
  93. };
  94. bool IDCDATASectionImpl::isIgnorableWhitespace() const
  95. {
  96.     return fNode.ignorableWhitespace();
  97. }
  98. //
  99. //  splitText.   idom_revist - factor into a common function for use
  100. //                             here and in IDTextImpl
  101. //
  102. IDOM_Text *IDCDATASectionImpl::splitText(unsigned int offset)
  103. {
  104.     if (fNode.isReadOnly())
  105.     {
  106.         throw IDOM_DOMException(
  107.             IDOM_DOMException::NO_MODIFICATION_ALLOWED_ERR, 0);
  108.     }
  109.     unsigned int len = XMLString::stringLen(fCharacterData.fData);
  110.     if (offset > len)
  111.         throw IDOM_DOMException(IDOM_DOMException::INDEX_SIZE_ERR, 0);
  112.     IDOM_Text *newText =
  113.                 getOwnerDocument()->createCDATASection(
  114.                         this->substringData(offset, len - offset));
  115.     IDOM_Node *parent = getParentNode();
  116.     if (parent != 0)
  117.         parent->insertBefore(newText, getNextSibling());
  118.     XMLCh *wData = (XMLCh *)(fCharacterData.fData);  // Cast off const.
  119.     wData[offset] = 0;                               //  idom_revisit - could change a string that
  120.                                                      //     application code has.  Do we want to do this?
  121.     if (this->getOwnerDocument() != 0) {
  122.         Ranges* ranges = ((IDDocumentImpl *)this->getOwnerDocument())->getRanges();
  123.         if (ranges != 0) {
  124.             unsigned int sz = ranges->size();
  125.             if (sz != 0) {
  126.                 for (unsigned int i =0; i<sz; i++) {
  127.                     ranges->elementAt(i)->updateSplitInfo( this, newText, offset);
  128.                 }
  129.             }
  130.         }
  131.     }
  132.     return newText;
  133. };
  134. //
  135. //  Delegation stubs for other DOM_Node inherited functions.
  136. //
  137.            IDOM_Node          *IDCDATASectionImpl::appendChild(IDOM_Node *newChild)        {return fParent.appendChild (newChild); };
  138.            IDOM_NamedNodeMap  *IDCDATASectionImpl::getAttributes() const          {return fNode.getAttributes (); };
  139.            IDOM_NodeList      *IDCDATASectionImpl::getChildNodes() const          {return fParent.getChildNodes (); };
  140.            IDOM_Node          *IDCDATASectionImpl::getFirstChild() const          {return fParent.getFirstChild (); };
  141.            IDOM_Node          *IDCDATASectionImpl::getLastChild() const              {return fParent.getLastChild (); };
  142.      const XMLCh              *IDCDATASectionImpl::getLocalName() const                    {return fNode.getLocalName (); };
  143.      const XMLCh              *IDCDATASectionImpl::getNamespaceURI() const                 {return fNode.getNamespaceURI (); };
  144.            IDOM_Node          *IDCDATASectionImpl::getNextSibling() const                  {return fChild.getNextSibling (); };
  145.      const XMLCh              *IDCDATASectionImpl::getNodeValue() const                    {return fCharacterData.getNodeValue (); };
  146.            IDOM_Document      *IDCDATASectionImpl::getOwnerDocument() const                {return fNode.getOwnerDocument (); };
  147.      const XMLCh              *IDCDATASectionImpl::getPrefix() const                       {return fNode.getPrefix (); };
  148.            IDOM_Node          *IDCDATASectionImpl::getParentNode() const                   {return fChild.getParentNode (this); };
  149.            IDOM_Node          *IDCDATASectionImpl::getPreviousSibling() const              {return fChild.getPreviousSibling (this); };
  150.            bool                IDCDATASectionImpl::hasChildNodes() const                   {return fParent.hasChildNodes (); };
  151.            IDOM_Node          *IDCDATASectionImpl::insertBefore(IDOM_Node *newChild, IDOM_Node *refChild)
  152.                                                                             {return fParent.insertBefore (newChild, refChild); };
  153.            void                IDCDATASectionImpl::normalize()                             {fNode.normalize (); };
  154.            IDOM_Node          *IDCDATASectionImpl::removeChild(IDOM_Node *oldChild)        {return fParent.removeChild (oldChild); };
  155.            IDOM_Node          *IDCDATASectionImpl::replaceChild(IDOM_Node *newChild, IDOM_Node *oldChild)
  156.                                                                             {return fParent.replaceChild (newChild, oldChild); };
  157.            bool                IDCDATASectionImpl::supports(const XMLCh *feature, const XMLCh *version) const
  158.                                                                             {return fNode.supports (feature, version); };
  159.            void                IDCDATASectionImpl::setPrefix(const XMLCh  *prefix)         {fNode.setPrefix(prefix); };
  160. //
  161. //   Delegation of CharacerData functions.
  162. //
  163.      const XMLCh * IDCDATASectionImpl::getData() const                  {return fCharacterData.getData();};
  164.      unsigned int  IDCDATASectionImpl::getLength() const                {return fCharacterData.getLength();};
  165.      const XMLCh * IDCDATASectionImpl::substringData(unsigned int offset, unsigned int count) const
  166.                                                                 {return fCharacterData.substringData(this, offset, count);};
  167.      void          IDCDATASectionImpl::appendData(const XMLCh *arg)     {fCharacterData.appendData(this, arg);};
  168.      void          IDCDATASectionImpl::insertData(unsigned int offset, const  XMLCh *arg)
  169.                                                                 {fCharacterData.insertData(this, offset, arg);};
  170.      void          IDCDATASectionImpl::deleteData(unsigned int offset, unsigned int count)
  171.                                                                 {fCharacterData.deleteData(this, offset, count);};
  172.      void          IDCDATASectionImpl::replaceData(unsigned int offset, unsigned int count, const XMLCh *arg)
  173.                                                                 {fCharacterData.replaceData(this, offset, count, arg);};
  174.      void          IDCDATASectionImpl::setData(const XMLCh *data)       {fCharacterData.setData(this, data);};
  175.      void          IDCDATASectionImpl::setNodeValue(const XMLCh  *nodeValue)   {fCharacterData.setNodeValue (this, nodeValue); };