2
* Licensed to the Apache Software Foundation (ASF) under one or more
3
* contributor license agreements. See the NOTICE file distributed with
4
* this work for additional information regarding copyright ownership.
5
* The ASF licenses this file to You under the Apache License, Version 2.0
6
* (the "License"); you may not use this file except in compliance with
7
* the License. You may obtain a copy of the License at
9
* http://www.apache.org/licenses/LICENSE-2.0
11
* Unless required by applicable law or agreed to in writing, software
12
* distributed under the License is distributed on an "AS IS" BASIS,
13
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
* See the License for the specific language governing permissions and
15
* limitations under the License.
19
* WARNING: because java doesn't support multi-inheritance some code is
20
* duplicated. If you're changing this file you probably want to change
21
* DeferredAttrNSImpl.java at the same time.
24
package org.apache.xerces.dom;
27
* Attribute represents an XML-style attribute of an
28
* Element. Typically, the allowable values are controlled by its
29
* declaration in the Document Type Definition (DTD) governing this
32
* If the attribute has not been explicitly assigned a value, but has
33
* been declared in the DTD, it will exist and have that default. Only
34
* if neither the document nor the DTD specifies a value will the
35
* Attribute really be considered absent and have no value; in that
36
* case, querying the attribute will return null.
38
* Attributes may have multiple children that contain their data. (XML
39
* allows attributes to contain entity references, and tokenized
40
* attribute types such as NMTOKENS may have a child for each token.)
41
* For convenience, the Attribute object's getValue() method returns
42
* the string version of the attribute's value.
44
* Attributes are not children of the Elements they belong to, in the
45
* usual sense, and have no valid Parent reference. However, the spec
46
* says they _do_ belong to a specific Element, and an INUSE exception
47
* is to be thrown if the user attempts to explicitly share them
50
* Note that Elements do not permit attributes to appear to be shared
51
* (see the INUSE exception), so this object's mutability is
52
* officially not an issue.
54
* DeferredAttrImpl inherits from AttrImpl which does not support
55
* Namespaces. DeferredAttrNSImpl, which inherits from AttrNSImpl, does.
56
* @see DeferredAttrNSImpl
60
* @author Andy Clark, IBM
61
* @author Arnaud Le Hors, IBM
62
* @version $Id: DeferredAttrImpl.java,v 1.2 2009/12/10 03:18:32 matthewoliver Exp $
63
* @since PR-DOM-Level-1-19980818.
65
public final class DeferredAttrImpl
67
implements DeferredNode {
73
/** Serialization version. */
74
static final long serialVersionUID = 6903232312469148636L;
81
protected transient int fNodeIndex;
88
* This is the deferred constructor. Only the fNodeIndex is given here.
89
* All other data, can be requested from the ownerDocument via the index.
91
DeferredAttrImpl(DeferredDocumentImpl ownerDocument, int nodeIndex) {
92
super(ownerDocument, null);
94
fNodeIndex = nodeIndex;
96
needsSyncChildren(true);
98
} // <init>(DeferredDocumentImpl,int)
101
// DeferredNode methods
104
/** Returns the node index. */
105
public int getNodeIndex() {
113
/** Synchronizes the data (name and value) for fast nodes. */
114
protected void synchronizeData() {
116
// no need to sync in the future
117
needsSyncData(false);
120
DeferredDocumentImpl ownerDocument =
121
(DeferredDocumentImpl) ownerDocument();
122
name = ownerDocument.getNodeName(fNodeIndex);
123
int extra = ownerDocument.getNodeExtra(fNodeIndex);
124
isSpecified((extra & SPECIFIED) != 0);
125
isIdAttribute((extra & ID) != 0);
127
int extraNode = ownerDocument.getLastChild(fNodeIndex);
128
type = ownerDocument.getTypeInfo(extraNode);
129
} // synchronizeData()
132
* Synchronizes the node's children with the internal structure.
133
* Fluffing the children at once solves a lot of work to keep
134
* the two structures in sync. The problem gets worse when
135
* editing the tree -- this makes it a lot easier.
137
protected void synchronizeChildren() {
138
DeferredDocumentImpl ownerDocument =
139
(DeferredDocumentImpl) ownerDocument();
140
ownerDocument.synchronizeChildren(this, fNodeIndex);
141
} // synchronizeChildren()
143
} // class DeferredAttrImpl