1 21 22 package nu.xom; 23 24 63 public class NodeFactory { 64 65 71 public NodeFactory() {} 72 73 97 public Element makeRootElement(String name, String namespace) { 98 return startMakingElement(name, namespace); 99 } 100 101 102 126 public Element startMakingElement(String name, String namespace) { 127 return new Element(name, namespace); 128 } 129 130 131 175 public Nodes finishMakingElement(Element element) { 176 return new Nodes(element); 177 } 178 179 180 206 public Document startMakingDocument() { 207 return new Document( 208 Element.build("root", "http://www.xom.nu/fakeRoot") 209 ); 210 } 211 212 213 223 public void finishMakingDocument(Document document) {} 224 225 226 251 public Nodes makeAttribute(String name, String URI, 252 String value, Attribute.Type type) { 253 return new Nodes(new Attribute(name, URI, value, type)); 254 } 255 256 257 281 public Nodes makeComment(String data) { 282 return new Nodes(new Comment(data)); 283 } 284 285 286 315 public Nodes makeDocType(String rootElementName, 316 String publicID, String systemID) { 317 return new Nodes(new DocType(rootElementName, publicID, systemID)); 318 } 319 320 321 343 public Nodes makeText(String data) { 344 return new Nodes(new Text(data)); 345 } 346 347 348 358 Nodes makeCDATASection(String data) { 359 return makeText(data); 360 } 361 362 363 393 public Nodes makeProcessingInstruction( 394 String target, String data) { 395 return new Nodes(new ProcessingInstruction(target, data)); 396 } 397 398 399 void addAttribute(Element element, Attribute attribute) { 400 element.addAttribute(attribute); 401 } 402 403 404 void insertChild(Element element, Node child, int position) { 405 element.insertChild(child, position); 406 } 407 408 409 } 410 | Popular Tags |