1 18 package org.apache.batik.dom; 19 20 import org.w3c.dom.Attr ; 21 import org.w3c.dom.CDATASection ; 22 import org.w3c.dom.Comment ; 23 import org.w3c.dom.DOMException ; 24 import org.w3c.dom.DOMImplementation ; 25 import org.w3c.dom.DocumentFragment ; 26 import org.w3c.dom.DocumentType ; 27 import org.w3c.dom.Element ; 28 import org.w3c.dom.EntityReference ; 29 import org.w3c.dom.Node ; 30 import org.w3c.dom.ProcessingInstruction ; 31 import org.w3c.dom.Text ; 32 33 40 public class GenericDocument 41 extends AbstractDocument { 42 43 44 protected final static String ATTR_ID = "id"; 45 46 49 protected boolean readonly; 50 51 54 protected GenericDocument() { 55 } 56 57 60 public GenericDocument(DocumentType dt, DOMImplementation impl) { 61 super(dt, impl); 62 } 63 64 67 public boolean isReadonly() { 68 return readonly; 69 } 70 71 74 public void setReadonly(boolean v) { 75 readonly = v; 76 } 77 78 82 public boolean isId(Attr node) { 83 if (node.getNamespaceURI() != null) return false; 84 return ATTR_ID.equals(node.getNodeName()); 85 } 86 87 91 public Element createElement(String tagName) throws DOMException { 92 return new GenericElement(tagName.intern(), this); 93 } 94 95 99 public DocumentFragment createDocumentFragment() { 100 return new GenericDocumentFragment(this); 101 } 102 103 107 public Text createTextNode(String data) { 108 return new GenericText(data, this); 109 } 110 111 115 public Comment createComment(String data) { 116 return new GenericComment(data, this); 117 } 118 119 123 public CDATASection createCDATASection(String data) throws DOMException { 124 return new GenericCDATASection(data, this); 125 } 126 127 133 public ProcessingInstruction createProcessingInstruction(String target, 134 String data) 135 throws DOMException { 136 return new GenericProcessingInstruction(target, data, this); 137 } 138 139 143 public Attr createAttribute(String name) throws DOMException { 144 return new GenericAttr(name.intern(), this); 145 } 146 147 151 public EntityReference createEntityReference(String name) 152 throws DOMException { 153 return new GenericEntityReference(name, this); 154 } 155 156 160 public Element createElementNS(String namespaceURI, String qualifiedName) 161 throws DOMException { 162 if (namespaceURI == null) { 163 return new GenericElement(qualifiedName.intern(), this); 164 } else { 165 return new GenericElementNS(namespaceURI.intern(), 166 qualifiedName.intern(), 167 this); 168 } 169 } 170 171 175 public Attr createAttributeNS(String namespaceURI, String qualifiedName) 176 throws DOMException { 177 if (namespaceURI == null) { 178 return new GenericAttr(qualifiedName.intern(), this); 179 } else { 180 return new GenericAttrNS(namespaceURI.intern(), 181 qualifiedName.intern(), 182 this); 183 } 184 } 185 186 189 protected Node newNode() { 190 return new GenericDocument(); 191 } 192 } 193 | Popular Tags |