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