1 56 57 package org.jdom; 58 59 import java.io.*; 60 61 77 public abstract class Content implements Cloneable , Serializable { 78 79 protected Parent parent = null; 80 81 protected Content() {} 82 83 89 public Content detach() { 90 if (parent != null) { 91 parent.removeContent(this); 92 } 93 return this; 94 } 95 96 103 public Parent getParent() { 104 return parent; 105 } 106 107 116 public Element getParentElement() { 117 Parent parent = getParent(); 118 return (Element) ((parent instanceof Element) ? parent : null); 119 } 120 121 128 protected Content setParent(Parent parent) { 129 this.parent = parent; 130 return this; 131 } 132 133 139 public Document getDocument() { 140 if (parent == null) return null; 141 return parent.getDocument(); 142 } 143 144 145 150 public abstract String getValue(); 151 152 158 public Object clone() { 159 try { 160 Content c = (Content)super.clone(); 161 c.parent = null; 162 return c; 163 } catch (CloneNotSupportedException e) { 164 return null; 167 } 168 } 169 170 180 public final boolean equals(Object ob) { 181 return (ob == this); 182 } 183 184 189 public final int hashCode() { 190 return super.hashCode(); 191 } 192 } 193 | Popular Tags |