KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > xerces > dom > DeferredCDATASectionImpl


1 /*
2  * Copyright 1999-2002,2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16
17 package org.apache.xerces.dom;
18
19 /**
20  * XML provides the CDATA markup to allow a region of text in which
21  * most of the XML delimiter recognition does not take place. This is
22  * intended to ease the task of quoting XML fragments and other
23  * programmatic information in a document's text without needing to
24  * escape these special characters. It's primarily a convenience feature
25  * for those who are hand-editing XML.
26  * <P>
27  * CDATASection is an Extended DOM feature, and is not used in HTML
28  * contexts.
29  * <P>
30  * Within the DOM, CDATASections are treated essentially as Text
31  * blocks. Their distinct type is retained in order to allow us to
32  * properly recreate the XML syntax when we write them out.
33  * <P>
34  * Reminder: CDATA IS NOT A COMPLETELY GENERAL SOLUTION; it can't
35  * quote its own end-of-block marking. If you need to write out a
36  * CDATA that contains the ]]> sequence, it's your responsibility to
37  * split that string over two successive CDATAs at that time.
38  * <P>
39  * CDATA does not participate in Element.normalize() processing.
40  *
41  * @xerces.internal
42  *
43  * @version $Id: DeferredCDATASectionImpl.java,v 1.12 2004/10/05 17:12:51 mrglavas Exp $
44  * @since PR-DOM-Level-1-19980818.
45  */

46 public class DeferredCDATASectionImpl
47     extends CDATASectionImpl
48     implements DeferredNode {
49
50     //
51
// Constants
52
//
53

54     /** Serialization version. */
55     static final long serialVersionUID = 1983580632355645726L;
56
57     //
58
// Data
59
//
60

61     /** Node index. */
62     protected transient int fNodeIndex;
63
64     //
65
// Constructors
66
//
67

68     /**
69      * This is the deferred constructor. Only the fNodeIndex is given here. All other data,
70      * can be requested from the ownerDocument via the index.
71      */

72     DeferredCDATASectionImpl(DeferredDocumentImpl ownerDocument, int nodeIndex) {
73         super(ownerDocument, null);
74
75         fNodeIndex = nodeIndex;
76         needsSyncData(true);
77
78     } // <init>(DeferredDocumentImpl,int)
79

80     //
81
// DeferredNode methods
82
//
83

84     /** Returns the node index. */
85     public int getNodeIndex() {
86         return fNodeIndex;
87     }
88
89     //
90
// Protected methods
91
//
92

93     /** Synchronizes the data (name and value) for fast nodes. */
94     protected void synchronizeData() {
95
96         // no need to sync in the future
97
needsSyncData(false);
98
99         // fluff data
100
DeferredDocumentImpl ownerDocument =
101             (DeferredDocumentImpl) this.ownerDocument();
102         data = ownerDocument.getNodeValueString(fNodeIndex);
103
104     } // synchronizeData()
105

106 } // class DeferredCDATASectionImpl
107
Popular Tags