|
1 |
| |
|
2 |
| |
|
3 |
| |
|
4 |
| |
|
5 |
| |
|
6 |
| |
|
7 |
| |
|
8 |
| |
|
9 |
| |
|
10 |
| package org.dom4j.tree; |
|
11 |
| |
|
12 |
| import java.util.List; |
|
13 |
| |
|
14 |
| import org.dom4j.Branch; |
|
15 |
| import org.dom4j.Document; |
|
16 |
| import org.dom4j.Element; |
|
17 |
| import org.dom4j.Namespace; |
|
18 |
| import org.dom4j.QName; |
|
19 |
| |
|
20 |
| |
|
21 |
| |
|
22 |
| |
|
23 |
| |
|
24 |
| |
|
25 |
| |
|
26 |
| public class BaseElement extends AbstractElement { |
|
27 |
| |
|
28 |
| |
|
29 |
| private QName qname; |
|
30 |
| |
|
31 |
| |
|
32 |
| |
|
33 |
| |
|
34 |
| |
|
35 |
| |
|
36 |
| private Branch parentBranch; |
|
37 |
| |
|
38 |
| |
|
39 |
| protected List content; |
|
40 |
| |
|
41 |
| |
|
42 |
| protected List attributes; |
|
43 |
| |
|
44 |
| |
|
45 |
| |
|
46 |
2
| public BaseElement(String name) {
|
|
47 |
2
| this.qname = getDocumentFactory().createQName(name);
|
|
48 |
| } |
|
49 |
| |
|
50 |
0
| public BaseElement(QName qname) {
|
|
51 |
0
| this.qname = qname;
|
|
52 |
| } |
|
53 |
| |
|
54 |
0
| public BaseElement(String name,Namespace namespace) {
|
|
55 |
0
| this.qname = getDocumentFactory().createQName(name, namespace);
|
|
56 |
| } |
|
57 |
| |
|
58 |
0
| public Element getParent() {
|
|
59 |
0
| return ( parentBranch instanceof Element )
|
|
60 |
| ? (Element) parentBranch : null; |
|
61 |
| } |
|
62 |
| |
|
63 |
0
| public void setParent(Element parent) {
|
|
64 |
0
| if ( parentBranch instanceof Element || parent != null ) {
|
|
65 |
0
| parentBranch = parent;
|
|
66 |
| } |
|
67 |
| } |
|
68 |
| |
|
69 |
0
| public Document getDocument() {
|
|
70 |
0
| if ( parentBranch instanceof Document ) {
|
|
71 |
0
| return (Document) parentBranch;
|
|
72 |
| } |
|
73 |
0
| else if ( parentBranch instanceof Element ) {
|
|
74 |
0
| Element parent = (Element) parentBranch;
|
|
75 |
0
| return parent.getDocument();
|
|
76 |
| } |
|
77 |
0
| return null;
|
|
78 |
| } |
|
79 |
| |
|
80 |
0
| public void setDocument(Document document) {
|
|
81 |
0
| if ( parentBranch instanceof Document || document != null ) {
|
|
82 |
0
| parentBranch = document;
|
|
83 |
| } |
|
84 |
| } |
|
85 |
| |
|
86 |
0
| public boolean supportsParent() {
|
|
87 |
0
| return true;
|
|
88 |
| } |
|
89 |
| |
|
90 |
6
| public QName getQName() {
|
|
91 |
6
| return qname;
|
|
92 |
| } |
|
93 |
| |
|
94 |
0
| public void setQName(QName qname) {
|
|
95 |
0
| this.qname = qname;
|
|
96 |
| } |
|
97 |
| |
|
98 |
0
| public void clearContent() {
|
|
99 |
0
| contentList().clear();
|
|
100 |
| } |
|
101 |
| |
|
102 |
0
| public void setContent(List content) {
|
|
103 |
0
| this.content = content;
|
|
104 |
0
| if ( content instanceof ContentListFacade ) {
|
|
105 |
0
| this.content = ((ContentListFacade) content).getBackingList();
|
|
106 |
| } |
|
107 |
| } |
|
108 |
| |
|
109 |
0
| public void setAttributes(List attributes) {
|
|
110 |
0
| this.attributes = attributes;
|
|
111 |
0
| if ( attributes instanceof ContentListFacade ) {
|
|
112 |
0
| this.attributes = ((ContentListFacade) attributes).getBackingList();
|
|
113 |
| } |
|
114 |
| } |
|
115 |
| |
|
116 |
| |
|
117 |
| |
|
118 |
| |
|
119 |
| |
|
120 |
2
| protected List contentList() {
|
|
121 |
2
| if ( content == null ) {
|
|
122 |
2
| content = createContentList();
|
|
123 |
| } |
|
124 |
2
| return content;
|
|
125 |
| } |
|
126 |
| |
|
127 |
2
| protected List attributeList() {
|
|
128 |
2
| if ( attributes == null ) {
|
|
129 |
2
| attributes = createAttributeList();
|
|
130 |
| } |
|
131 |
2
| return attributes;
|
|
132 |
| } |
|
133 |
| |
|
134 |
0
| protected List attributeList(int size) {
|
|
135 |
0
| if ( attributes == null ) {
|
|
136 |
0
| attributes = createAttributeList(size);
|
|
137 |
| } |
|
138 |
0
| return attributes;
|
|
139 |
| } |
|
140 |
| |
|
141 |
0
| protected void setAttributeList(List attributes) {
|
|
142 |
0
| this.attributes = attributes;
|
|
143 |
| } |
|
144 |
| |
|
145 |
| } |
|
146 |
| |
|
147 |
| |
|
148 |
| |
|
149 |
| |
|
150 |
| |
|
151 |
| |
|
152 |
| |
|
153 |
| |
|
154 |
| |
|
155 |
| |
|
156 |
| |
|
157 |
| |
|
158 |
| |
|
159 |
| |
|
160 |
| |
|
161 |
| |
|
162 |
| |
|
163 |
| |
|
164 |
| |
|
165 |
| |
|
166 |
| |
|
167 |
| |
|
168 |
| |
|
169 |
| |
|
170 |
| |
|
171 |
| |
|
172 |
| |
|
173 |
| |
|
174 |
| |
|
175 |
| |
|
176 |
| |
|
177 |
| |
|
178 |
| |
|
179 |
| |
|
180 |
| |
|
181 |
| |
|
182 |
| |
|
183 |
| |
|
184 |
| |
|
185 |
| |
|
186 |
| |
|
187 |
| |
|
188 |
| |
|
189 |
| |
|
190 |
| |
|
191 |
| |
|
192 |
| |
|
193 |
| |