001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */
017:
018: package org.apache.xerces.dom;
019:
020: /**
021: * XML provides the CDATA markup to allow a region of text in which
022: * most of the XML delimiter recognition does not take place. This is
023: * intended to ease the task of quoting XML fragments and other
024: * programmatic information in a document's text without needing to
025: * escape these special characters. It's primarily a convenience feature
026: * for those who are hand-editing XML.
027: * <P>
028: * CDATASection is an Extended DOM feature, and is not used in HTML
029: * contexts.
030: * <P>
031: * Within the DOM, CDATASections are treated essentially as Text
032: * blocks. Their distinct type is retained in order to allow us to
033: * properly recreate the XML syntax when we write them out.
034: * <P>
035: * Reminder: CDATA IS NOT A COMPLETELY GENERAL SOLUTION; it can't
036: * quote its own end-of-block marking. If you need to write out a
037: * CDATA that contains the ]]> sequence, it's your responsibility to
038: * split that string over two successive CDATAs at that time.
039: * <P>
040: * CDATA does not participate in Element.normalize() processing.
041: *
042: * @xerces.internal
043: *
044: * @version $Id: DeferredCDATASectionImpl.java 447266 2006-09-18 05:57:49Z mrglavas $
045: * @since PR-DOM-Level-1-19980818.
046: */
047: public class DeferredCDATASectionImpl extends CDATASectionImpl
048: implements DeferredNode {
049:
050: //
051: // Constants
052: //
053:
054: /** Serialization version. */
055: static final long serialVersionUID = 1983580632355645726L;
056:
057: //
058: // Data
059: //
060:
061: /** Node index. */
062: protected transient int fNodeIndex;
063:
064: //
065: // Constructors
066: //
067:
068: /**
069: * This is the deferred constructor. Only the fNodeIndex is given here. All other data,
070: * can be requested from the ownerDocument via the index.
071: */
072: DeferredCDATASectionImpl(DeferredDocumentImpl ownerDocument,
073: int nodeIndex) {
074: super (ownerDocument, null);
075:
076: fNodeIndex = nodeIndex;
077: needsSyncData(true);
078:
079: } // <init>(DeferredDocumentImpl,int)
080:
081: //
082: // DeferredNode methods
083: //
084:
085: /** Returns the node index. */
086: public int getNodeIndex() {
087: return fNodeIndex;
088: }
089:
090: //
091: // Protected methods
092: //
093:
094: /** Synchronizes the data (name and value) for fast nodes. */
095: protected void synchronizeData() {
096:
097: // no need to sync in the future
098: needsSyncData(false);
099:
100: // fluff data
101: DeferredDocumentImpl ownerDocument = (DeferredDocumentImpl) this
102: .ownerDocument();
103: data = ownerDocument.getNodeValueString(fNodeIndex);
104:
105: } // synchronizeData()
106:
107: } // class DeferredCDATASectionImpl
|