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: /*
019: * WARNING: because java doesn't support multi-inheritance some code is
020: * duplicated. If you're changing this file you probably want to change
021: * DeferredAttrImpl.java at the same time.
022: */
023:
024: package org.apache.xerces.dom;
025:
026: /**
027: * DeferredAttrNSImpl is to AttrNSImpl, what DeferredAttrImpl is to
028: * AttrImpl.
029: *
030: * @xerces.internal
031: *
032: * @author Andy Clark, IBM
033: * @author Arnaud Le Hors, IBM
034: * @version $Id: DeferredAttrNSImpl.java 447266 2006-09-18 05:57:49Z mrglavas $
035: * @see DeferredAttrImpl
036: */
037: public final class DeferredAttrNSImpl extends AttrNSImpl implements
038: DeferredNode {
039:
040: //
041: // Constants
042: //
043:
044: /** Serialization version. */
045: static final long serialVersionUID = 6074924934945957154L;
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: DeferredAttrNSImpl(DeferredDocumentImpl ownerDocument, int nodeIndex) {
063: super (ownerDocument, null);
064:
065: fNodeIndex = nodeIndex;
066: needsSyncData(true);
067: needsSyncChildren(true);
068:
069: } // <init>(DeferredDocumentImpl,int)
070:
071: //
072: // DeferredNode methods
073: //
074:
075: /** Returns the node index. */
076: public int getNodeIndex() {
077: return fNodeIndex;
078: }
079:
080: //
081: // Protected methods
082: //
083:
084: /** Synchronizes the data (name and value) for fast nodes. */
085: protected void synchronizeData() {
086:
087: // no need to sync in the future
088: needsSyncData(false);
089:
090: // fluff data
091: DeferredDocumentImpl ownerDocument = (DeferredDocumentImpl) ownerDocument();
092: name = ownerDocument.getNodeName(fNodeIndex);
093:
094: // extract prefix and local part from QName
095: int index = name.indexOf(':');
096: if (index < 0) {
097: localName = name;
098: } else {
099: localName = name.substring(index + 1);
100: }
101:
102: int extra = ownerDocument.getNodeExtra(fNodeIndex);
103: isSpecified((extra & SPECIFIED) != 0);
104: isIdAttribute((extra & ID) != 0);
105:
106: namespaceURI = ownerDocument.getNodeURI(fNodeIndex);
107:
108: int extraNode = ownerDocument.getLastChild(fNodeIndex);
109: type = ownerDocument.getTypeInfo(extraNode);
110: } // synchronizeData()
111:
112: /**
113: * Synchronizes the node's children with the internal structure.
114: * Fluffing the children at once solves a lot of work to keep
115: * the two structures in sync. The problem gets worse when
116: * editing the tree -- this makes it a lot easier.
117: */
118: protected void synchronizeChildren() {
119: DeferredDocumentImpl ownerDocument = (DeferredDocumentImpl) ownerDocument();
120: ownerDocument.synchronizeChildren(this , fNodeIndex);
121: } // synchronizeChildren()
122:
123: } // class DeferredAttrImpl
|