KickJava   Java API By Example, From Geeks To Geeks.

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


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  * Text nodes hold the non-markup, non-Entity content of
21  * an Element or Attribute.
22  * <P>
23  * When a document is first made available to the DOM, there is only
24  * one Text object for each block of adjacent plain-text. Users (ie,
25  * applications) may create multiple adjacent Texts during editing --
26  * see {@link org.w3c.dom.Element#normalize} for discussion.
27  * <P>
28  * Note that CDATASection is a subclass of Text. This is conceptually
29  * valid, since they're really just two different ways of quoting
30  * characters when they're written out as part of an XML stream.
31  *
32  * @xerces.internal
33  *
34  * @version $Id: DeferredTextImpl.java,v 1.14 2004/10/05 17:12:50 mrglavas Exp $
35  * @since PR-DOM-Level-1-19980818.
36  */

37 public class DeferredTextImpl
38     extends TextImpl
39     implements DeferredNode {
40
41     //
42
// Constants
43
//
44

45     /** Serialization version. */
46     static final long serialVersionUID = 2310613872100393425L;
47
48     //
49
// Data
50
//
51

52     /** Node index. */
53     protected transient int fNodeIndex;
54
55     //
56
// Constructors
57
//
58

59     /**
60      * This is the deferred constructor. Only the fNodeIndex is given here.
61      * All other data, can be requested from the ownerDocument via the index.
62      */

63     DeferredTextImpl(DeferredDocumentImpl ownerDocument, int nodeIndex) {
64         super(ownerDocument, null);
65
66         fNodeIndex = nodeIndex;
67         needsSyncData(true);
68
69     } // <init>(DeferredDocumentImpl,int)
70

71     //
72
// DeferredNode methods
73
//
74

75     /** Returns the node index. */
76     public int getNodeIndex() {
77         return fNodeIndex;
78     }
79
80     //
81
// Protected methods
82
//
83

84     /** Synchronizes the underlying data. */
85     protected void synchronizeData() {
86
87         // no need for future synchronizations
88
needsSyncData(false);
89
90         // get initial text value
91
DeferredDocumentImpl ownerDocument =
92             (DeferredDocumentImpl) this.ownerDocument();
93         data = ownerDocument.getNodeValueString(fNodeIndex);
94
95         // NOTE: We used to normalize adjacent text node values here.
96
// This code has moved to the DeferredDocumentImpl
97
// getNodeValueString() method. -Ac
98

99         // ignorable whitespace
100
isIgnorableWhitespace(ownerDocument.getNodeExtra(fNodeIndex) == 1);
101
102     } // synchronizeData()
103

104 } // class DeferredTextImpl
105
Popular Tags