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