KickJava   Java API By Example, From Geeks To Geeks.

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


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 /*
18  * WARNING: because java doesn't support multi-inheritance some code is
19  * duplicated. If you're changing this file you probably want to change
20  * DeferredAttrImpl.java at the same time.
21  */

22
23
24 package org.apache.xerces.dom;
25
26 /**
27  * DeferredAttrNSImpl is to AttrNSImpl, what DeferredAttrImpl is to
28  * AttrImpl.
29  *
30  * @xerces.internal
31  *
32  * @author Andy Clark, IBM
33  * @author Arnaud Le Hors, IBM
34  * @version $Id: DeferredAttrNSImpl.java,v 1.25 2004/10/05 17:12:50 mrglavas Exp $
35  * @see DeferredAttrImpl
36  */

37 public final class DeferredAttrNSImpl
38     extends AttrNSImpl
39     implements DeferredNode {
40
41     //
42
// Constants
43
//
44

45     /** Serialization version. */
46     static final long serialVersionUID = 6074924934945957154L;
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     DeferredAttrNSImpl(DeferredDocumentImpl ownerDocument, int nodeIndex) {
64         super(ownerDocument, null);
65
66         fNodeIndex = nodeIndex;
67         needsSyncData(true);
68         needsSyncChildren(true);
69
70     } // <init>(DeferredDocumentImpl,int)
71

72     //
73
// DeferredNode methods
74
//
75

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

85     /** Synchronizes the data (name and value) for fast nodes. */
86     protected void synchronizeData() {
87
88         // no need to sync in the future
89
needsSyncData(false);
90
91         // fluff data
92
DeferredDocumentImpl ownerDocument =
93         (DeferredDocumentImpl) ownerDocument();
94         name = ownerDocument.getNodeName(fNodeIndex);
95
96         // extract prefix and local part from QName
97
int index = name.indexOf(':');
98         if (index < 0) {
99             localName = name;
100         }
101         else {
102             localName = name.substring(index + 1);
103         }
104
105         int extra = ownerDocument.getNodeExtra(fNodeIndex);
106         isSpecified((extra & SPECIFIED) != 0);
107         isIdAttribute((extra & ID) != 0);
108
109         namespaceURI = ownerDocument.getNodeURI(fNodeIndex);
110         
111         int extraNode = ownerDocument.getLastChild(fNodeIndex);
112         type = ownerDocument.getTypeInfo(extraNode);
113     } // synchronizeData()
114

115     /**
116      * Synchronizes the node's children with the internal structure.
117      * Fluffing the children at once solves a lot of work to keep
118      * the two structures in sync. The problem gets worse when
119      * editing the tree -- this makes it a lot easier.
120      */

121     protected void synchronizeChildren() {
122         DeferredDocumentImpl ownerDocument =
123             (DeferredDocumentImpl) ownerDocument();
124         ownerDocument.synchronizeChildren(this, fNodeIndex);
125     } // synchronizeChildren()
126

127 } // class DeferredAttrImpl
128
Popular Tags