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: * Text nodes hold the non-markup, non-Entity content of
022: * an Element or Attribute.
023: * <P>
024: * When a document is first made available to the DOM, there is only
025: * one Text object for each block of adjacent plain-text. Users (ie,
026: * applications) may create multiple adjacent Texts during editing --
027: * see {@link org.w3c.dom.Element#normalize} for discussion.
028: * <P>
029: * Note that CDATASection is a subclass of Text. This is conceptually
030: * valid, since they're really just two different ways of quoting
031: * characters when they're written out as part of an XML stream.
032: *
033: * @xerces.internal
034: *
035: * @version $Id: DeferredTextImpl.java 447266 2006-09-18 05:57:49Z mrglavas $
036: * @since PR-DOM-Level-1-19980818.
037: */
038: public class DeferredTextImpl extends TextImpl implements DeferredNode {
039:
040: //
041: // Constants
042: //
043:
044: /** Serialization version. */
045: static final long serialVersionUID = 2310613872100393425L;
046:
047: //
048: // Data
049: //
050:
051: /** Node index. */
052: protected transient int fNodeIndex;
053:
054: //
055: // Constructors
056: //
057:
058: /**
059: * This is the deferred constructor. Only the fNodeIndex is given here.
060: * All other data, can be requested from the ownerDocument via the index.
061: */
062: DeferredTextImpl(DeferredDocumentImpl ownerDocument, int nodeIndex) {
063: super (ownerDocument, null);
064:
065: fNodeIndex = nodeIndex;
066: needsSyncData(true);
067:
068: } // <init>(DeferredDocumentImpl,int)
069:
070: //
071: // DeferredNode methods
072: //
073:
074: /** Returns the node index. */
075: public int getNodeIndex() {
076: return fNodeIndex;
077: }
078:
079: //
080: // Protected methods
081: //
082:
083: /** Synchronizes the underlying data. */
084: protected void synchronizeData() {
085:
086: // no need for future synchronizations
087: needsSyncData(false);
088:
089: // get initial text value
090: DeferredDocumentImpl ownerDocument = (DeferredDocumentImpl) this
091: .ownerDocument();
092: data = ownerDocument.getNodeValueString(fNodeIndex);
093:
094: // NOTE: We used to normalize adjacent text node values here.
095: // This code has moved to the DeferredDocumentImpl
096: // getNodeValueString() method. -Ac
097:
098: // ignorable whitespace
099: isIgnorableWhitespace(ownerDocument.getNodeExtra(fNodeIndex) == 1);
100:
101: } // synchronizeData()
102:
103: } // class DeferredTextImpl
|