1 16 package org.apache.wml.dom; 17 18 import java.lang.reflect.Constructor ; 19 import java.util.Hashtable ; 20 21 import org.apache.wml.WMLDocument; 22 import org.apache.xerces.dom.DocumentImpl; 23 import org.w3c.dom.DOMException ; 24 import org.w3c.dom.DocumentType ; 25 import org.w3c.dom.Element ; 26 27 32 public class WMLDocumentImpl extends DocumentImpl implements WMLDocument { 33 34 private static final long serialVersionUID = 3257844364091929145L; 35 36 private static Hashtable _elementTypesWML; 37 private static final Class [] _elemClassSigWML = 38 new Class [] { WMLDocumentImpl.class, String .class }; 39 40 public Element createElement( String tagName ) throws DOMException 41 { 42 Class elemClass; 43 Constructor cnst; 44 45 elemClass = (Class ) _elementTypesWML.get( tagName ); 46 if ( elemClass != null ) { 47 try { 48 cnst = elemClass.getConstructor( _elemClassSigWML ); 49 return (Element ) cnst.newInstance( new Object [] { this, tagName } ); 50 } catch ( Exception except ) { 51 Throwable thrw; 52 53 if ( except instanceof java.lang.reflect.InvocationTargetException ) 54 thrw = ( (java.lang.reflect.InvocationTargetException ) except ).getTargetException(); 55 else 56 thrw = except; 57 58 System.out.println( "Exception " + thrw.getClass().getName() ); 59 System.out.println( thrw.getMessage() ); 60 61 throw new IllegalStateException ( "Tag '" + tagName + "' associated with an Element class that failed to construct." ); 62 } 63 } 64 return new WMLElementImpl( this, tagName ); 65 } 66 67 static { 68 _elementTypesWML = new Hashtable (); 69 _elementTypesWML.put("b", WMLBElementImpl.class); 70 _elementTypesWML.put("noop", WMLNoopElementImpl.class); 71 _elementTypesWML.put("a", WMLAElementImpl.class); 72 _elementTypesWML.put("setvar", WMLSetvarElementImpl.class); 73 _elementTypesWML.put("access", WMLAccessElementImpl.class); 74 _elementTypesWML.put("strong", WMLStrongElementImpl.class); 75 _elementTypesWML.put("postfield", WMLPostfieldElementImpl.class); 76 _elementTypesWML.put("do", WMLDoElementImpl.class); 77 _elementTypesWML.put("wml", WMLWmlElementImpl.class); 78 _elementTypesWML.put("tr", WMLTrElementImpl.class); 79 _elementTypesWML.put("go", WMLGoElementImpl.class); 80 _elementTypesWML.put("big", WMLBigElementImpl.class); 81 _elementTypesWML.put("anchor", WMLAnchorElementImpl.class); 82 _elementTypesWML.put("timer", WMLTimerElementImpl.class); 83 _elementTypesWML.put("small", WMLSmallElementImpl.class); 84 _elementTypesWML.put("optgroup", WMLOptgroupElementImpl.class); 85 _elementTypesWML.put("head", WMLHeadElementImpl.class); 86 _elementTypesWML.put("td", WMLTdElementImpl.class); 87 _elementTypesWML.put("fieldset", WMLFieldsetElementImpl.class); 88 _elementTypesWML.put("img", WMLImgElementImpl.class); 89 _elementTypesWML.put("refresh", WMLRefreshElementImpl.class); 90 _elementTypesWML.put("onevent", WMLOneventElementImpl.class); 91 _elementTypesWML.put("input", WMLInputElementImpl.class); 92 _elementTypesWML.put("prev", WMLPrevElementImpl.class); 93 _elementTypesWML.put("table", WMLTableElementImpl.class); 94 _elementTypesWML.put("meta", WMLMetaElementImpl.class); 95 _elementTypesWML.put("template", WMLTemplateElementImpl.class); 96 _elementTypesWML.put("br", WMLBrElementImpl.class); 97 _elementTypesWML.put("option", WMLOptionElementImpl.class); 98 _elementTypesWML.put("u", WMLUElementImpl.class); 99 _elementTypesWML.put("p", WMLPElementImpl.class); 100 _elementTypesWML.put("select", WMLSelectElementImpl.class); 101 _elementTypesWML.put("em", WMLEmElementImpl.class); 102 _elementTypesWML.put("i", WMLIElementImpl.class); 103 _elementTypesWML.put("card", WMLCardElementImpl.class); 104 } 105 106 107 public WMLDocumentImpl(DocumentType doctype) { 108 super(doctype, false); 109 } 110 } 111 | Popular Tags |