1
|
|
/*
|
2
|
|
* JBind
|
3
|
|
*
|
4
|
|
* Copyright (c) by Stefan Wachter. All rights reserved.
|
5
|
|
*
|
6
|
|
* Usage, modification, and redistribution is subject to license terms that are
|
7
|
|
* available at 'http://www.jbind.org'. The JBind license is like the
|
8
|
|
* 'Apache Software License V 1.1'.
|
9
|
|
*/
|
10
|
|
package org.jbind.xml.dom3.core;
|
11
|
|
|
12
|
|
import java.util.Collections;
|
13
|
|
import java.util.Iterator;
|
14
|
|
import java.util.ListIterator;
|
15
|
|
|
16
|
|
import org.jbind.xml.core.bridge.IDataImplVisitor;
|
17
|
|
import org.jbind.xml.core.bridge.IElementImpl;
|
18
|
|
import org.jbind.xml.core.data.IAnyTypeData;
|
19
|
|
import org.jbind.xml.dom3.types.IDomAttr;
|
20
|
|
import org.jbind.xml.dom3.types.IDomAttrsMap;
|
21
|
|
import org.jbind.xml.dom3.types.IDomDocument;
|
22
|
|
import org.jbind.xml.dom3.types.IDomNodeList;
|
23
|
|
import org.jbind.xml.dom3.types.IDomVisitor;
|
24
|
|
import org.jbind.xml.msg.XmlException;
|
25
|
|
import org.w3c.dom.Element;
|
26
|
|
import org.w3c.dom.NamedNodeMap;
|
27
|
|
import org.w3c.dom.Node;
|
28
|
|
|
29
|
|
public class DomAttr extends DomAttrOrElm implements IDomAttr {
|
30
|
|
|
31
|
|
private IDomAttrsMap myOwnerMap = null;
|
32
|
|
|
33
|
|
private boolean mySpecified = false;
|
34
|
|
|
35
|
0
|
public DomAttr(IDomDocument aDomDocument, String aNamespaceUri, String aQName) {
|
36
|
0
|
super(aDomDocument, aNamespaceUri, aQName);
|
37
|
|
}
|
38
|
|
|
39
|
0
|
public DomAttr(IDomDocument aDomDocument, String aName) {
|
40
|
0
|
super(aDomDocument, aName);
|
41
|
|
}
|
42
|
|
|
43
|
0
|
protected DomAttr(IDomAttr aDomAttr, boolean aDeep) {
|
44
|
0
|
super(aDomAttr, aDeep);
|
45
|
0
|
setValue(aDomAttr.getValue());
|
46
|
|
}
|
47
|
|
|
48
|
0
|
public short getNodeType() {
|
49
|
0
|
return ATTRIBUTE_NODE;
|
50
|
|
}
|
51
|
|
|
52
|
0
|
public NamedNodeMap getAttributes() {
|
53
|
0
|
return null;
|
54
|
|
}
|
55
|
|
|
56
|
0
|
public boolean hasAttributes() {
|
57
|
0
|
return false;
|
58
|
|
}
|
59
|
|
|
60
|
0
|
public Iterator iterAttributes(String aNamespace, String aName) {
|
61
|
0
|
return Collections.EMPTY_LIST.iterator();
|
62
|
|
}
|
63
|
|
|
64
|
0
|
public String getName() {
|
65
|
0
|
return getNodeName();
|
66
|
|
}
|
67
|
|
|
68
|
0
|
public Node cloneNode(boolean aDeep) {
|
69
|
0
|
return new DomAttr(this, true);// specification: attributes always are cloned deeply.
|
70
|
|
}
|
71
|
|
|
72
|
0
|
public IDomNodeList doCloneChildNodes(IDomNodeList aDomNodeList, boolean aDeep) {
|
73
|
0
|
return new DomNodeList(aDomNodeList, aDeep);
|
74
|
|
}
|
75
|
|
|
76
|
0
|
public Element getOwnerElement() {
|
77
|
0
|
Element res = null;
|
78
|
0
|
if (myOwnerMap != null) {
|
79
|
0
|
res = myOwnerMap.getOwnerElement();
|
80
|
|
}
|
81
|
0
|
return res;
|
82
|
|
}
|
83
|
|
|
84
|
0
|
public IElementImpl getOwnerElementImpl() {
|
85
|
0
|
return (IElementImpl)getOwnerElement();
|
86
|
|
}
|
87
|
|
|
88
|
0
|
public boolean getSpecified() {
|
89
|
0
|
return mySpecified;
|
90
|
|
}
|
91
|
|
|
92
|
0
|
public String getValue() {
|
93
|
0
|
return getTextContent();
|
94
|
|
}
|
95
|
|
|
96
|
0
|
public void setValue(String aString) {
|
97
|
0
|
setTextContent(aString);
|
98
|
0
|
mySpecified = true;
|
99
|
|
}
|
100
|
|
|
101
|
0
|
public String getNodeValue() {
|
102
|
0
|
return getValue();
|
103
|
|
}
|
104
|
|
|
105
|
0
|
public void setNodeValue(String aString) {
|
106
|
0
|
setValue(aString);
|
107
|
|
}
|
108
|
|
|
109
|
0
|
public IDomAttrsMap getOwnerMap() {
|
110
|
0
|
return myOwnerMap;
|
111
|
|
}
|
112
|
|
|
113
|
0
|
public void setOwnerMap(IDomAttrsMap anOwnerMap) {
|
114
|
0
|
myOwnerMap = anOwnerMap;
|
115
|
|
}
|
116
|
|
|
117
|
|
|
118
|
0
|
public boolean isNil() {
|
119
|
0
|
return false;
|
120
|
|
}
|
121
|
|
|
122
|
0
|
protected void doBeforeAccept(IDomVisitor aDomVisitor) {
|
123
|
0
|
aDomVisitor.visitAttrStart(this);
|
124
|
|
}
|
125
|
0
|
protected void doAfterAccept(IDomVisitor aDomVisitor) {
|
126
|
0
|
aDomVisitor.visitAttrEnd(this);
|
127
|
|
}
|
128
|
|
|
129
|
0
|
protected Node getAncestor() {
|
130
|
0
|
return getOwnerElement();
|
131
|
|
}
|
132
|
|
|
133
|
0
|
public IAnyTypeData getAttributeData(String aNamespace, String aLocalName) {
|
134
|
0
|
return null;
|
135
|
|
}
|
136
|
|
|
137
|
0
|
public ListIterator iterElementData(String aNamespace, String aLocalName) {
|
138
|
0
|
return Collections.EMPTY_LIST.listIterator();
|
139
|
|
}
|
140
|
|
|
141
|
0
|
public boolean hasTextContent() {
|
142
|
0
|
return true;
|
143
|
|
}
|
144
|
|
|
145
|
0
|
public void accept(IDataImplVisitor aVisitor) throws XmlException {
|
146
|
|
// attribute are not visited
|
147
|
|
}
|
148
|
|
|
149
|
|
}
|
150
|
|
|