1 19 20 package org.netbeans.tax.dom; 21 22 import org.w3c.dom.*; 23 import org.netbeans.tax.*; 24 25 29 public class Wrapper { 30 31 32 public static Attr wrap(TreeAttribute attr) { 33 return new AttrImpl(attr); 34 } 35 36 public static Element wrap(TreeElement element) { 37 return new ElementImpl(element); 38 } 39 40 public static Text wrap(TreeText text) { 41 return new TextImpl(text); 42 } 43 44 public static Document wrap(TreeDocumentRoot document) { 45 return new DocumentImpl(document); 46 } 47 48 public static DocumentType wrap(TreeDocumentType documentType) { 49 return new DocumentTypeImpl(documentType); 50 } 51 52 public static Comment wrap(TreeComment comment) { 53 return new CommentImpl(comment); 54 } 55 56 static NodeList wrap(TreeObjectList list) { 57 return new NodeListImpl(list); 58 } 59 60 static NamedNodeMap wrap(TreeNamedObjectMap map) { 61 return new NamedNodeMapImpl(map); 62 } 63 64 public static Node wrap(TreeObject object) { 65 if (object == null) return null; 66 if (object instanceof TreeAttribute) { 67 return wrap((TreeAttribute) object); 68 } else if (object instanceof TreeElement) { 69 return wrap((TreeElement) object); 70 } else if (object instanceof TreeText) { 71 return wrap((TreeText) object); 72 } else if (object instanceof TreeDocumentRoot) { 73 return wrap((TreeDocumentRoot) object); 74 } else if (object instanceof TreeDocumentType) { 75 return wrap((TreeDocumentType) object); 76 } else if (object instanceof TreeComment) { 77 return wrap((TreeComment) object); 78 } else { 79 throw new RuntimeException ("Cannot wrap: " + object.getClass()); 80 } 81 } 82 } 83 | Popular Tags |