1 18 19 package org.enhydra.wireless.chtml.dom.xerces; 20 21 import java.lang.reflect.Constructor ; 22 import java.util.HashMap ; 23 24 import org.enhydra.apache.html.dom.HTMLAnchorElementImpl; 25 import org.enhydra.apache.html.dom.HTMLBRElementImpl; 26 import org.enhydra.apache.html.dom.HTMLBaseElementImpl; 27 import org.enhydra.apache.html.dom.HTMLBodyElementImpl; 28 import org.enhydra.apache.html.dom.HTMLDListElementImpl; 29 import org.enhydra.apache.html.dom.HTMLDOMImplementationImpl; 30 import org.enhydra.apache.html.dom.HTMLDirectoryElementImpl; 31 import org.enhydra.apache.html.dom.HTMLDivElementImpl; 32 import org.enhydra.apache.html.dom.HTMLDocumentImpl; 33 import org.enhydra.apache.html.dom.HTMLElementImpl; 34 import org.enhydra.apache.html.dom.HTMLFontElementImpl; 35 import org.enhydra.apache.html.dom.HTMLFormElementImpl; 36 import org.enhydra.apache.html.dom.HTMLHRElementImpl; 37 import org.enhydra.apache.html.dom.HTMLHeadElementImpl; 38 import org.enhydra.apache.html.dom.HTMLHeadingElementImpl; 39 import org.enhydra.apache.html.dom.HTMLHtmlElementImpl; 40 import org.enhydra.apache.html.dom.HTMLImageElementImpl; 41 import org.enhydra.apache.html.dom.HTMLInputElementImpl; 42 import org.enhydra.apache.html.dom.HTMLLIElementImpl; 43 import org.enhydra.apache.html.dom.HTMLMenuElementImpl; 44 import org.enhydra.apache.html.dom.HTMLMetaElementImpl; 45 import org.enhydra.apache.html.dom.HTMLOListElementImpl; 46 import org.enhydra.apache.html.dom.HTMLOptionElementImpl; 47 import org.enhydra.apache.html.dom.HTMLParagraphElementImpl; 48 import org.enhydra.apache.html.dom.HTMLPreElementImpl; 49 import org.enhydra.apache.html.dom.HTMLQuoteElementImpl; 50 import org.enhydra.apache.html.dom.HTMLSelectElementImpl; 51 import org.enhydra.apache.html.dom.HTMLTextAreaElementImpl; 52 import org.enhydra.apache.html.dom.HTMLTitleElementImpl; 53 import org.enhydra.apache.html.dom.HTMLUListElementImpl; 54 import org.enhydra.wireless.chtml.dom.CHTMLDocument; 55 import org.enhydra.xml.xmlc.XMLObject; 56 import org.enhydra.xml.xmlc.XMLObjectLink; 57 import org.w3c.dom.DOMException ; 58 import org.w3c.dom.DOMImplementation ; 59 import org.w3c.dom.Element ; 60 61 69 public class CHTMLDocumentImpl extends HTMLDocumentImpl 70 implements CHTMLDocument, XMLObjectLink { 71 72 75 private static HashMap fElementTypes; 76 77 80 private static final Class [] fElemClassSig = new Class [] { 81 HTMLDocumentImpl.class, String .class 82 }; 83 84 85 89 public DOMImplementation getImplementation() { 90 return HTMLDOMImplementationImpl.getDOMImplementation(); 91 } 92 93 96 public Element createElementNS(String namespaceURI, 97 String qualifiedName) throws DOMException { 98 if ((namespaceURI == null) || (namespaceURI.length() == 0)) { 99 return createElement(qualifiedName); 100 } else { 101 return super.createElementNS(namespaceURI, qualifiedName); 102 } 103 } 104 105 108 public Element createElement(String tagName) throws DOMException { 109 Class elemClass; 110 Constructor cnst; 111 112 elemClass = (Class )fElementTypes.get(tagName.toUpperCase()); 113 if (elemClass != null) { 114 try { 115 cnst = elemClass.getConstructor(fElemClassSig); 116 117 return (Element )cnst.newInstance(new Object [] { 118 this, tagName 119 }); 120 } catch (Exception except) { 121 Throwable thrw; 122 123 if (except instanceof java.lang.reflect.InvocationTargetException ) { 124 thrw = 125 ((java.lang.reflect.InvocationTargetException ) except).getTargetException(); 126 } else { 127 thrw = except; 128 } 129 130 throw new IllegalStateException ("HTM15 Tag '" + tagName 131 + "' associated with an Element class that failed to construct.\n" 132 + thrw.getClass().getName() + " " + thrw.getMessage()); 133 } 134 } 135 136 return new HTMLElementImpl(this, tagName); 137 } 138 139 142 static { 143 fElementTypes = new HashMap (); 144 145 fElementTypes.put("A", HTMLAnchorElementImpl.class); 146 fElementTypes.put("BASE", HTMLBaseElementImpl.class); 147 fElementTypes.put("BLOCKQUOTE", HTMLQuoteElementImpl.class); 148 fElementTypes.put("BODY", HTMLBodyElementImpl.class); 149 fElementTypes.put("BR", HTMLBRElementImpl.class); 150 fElementTypes.put("DIR", HTMLDirectoryElementImpl.class); 151 fElementTypes.put("DIV", HTMLDivElementImpl.class); 152 fElementTypes.put("DL", HTMLDListElementImpl.class); 153 fElementTypes.put("FONT", HTMLFontElementImpl.class); 154 fElementTypes.put("FORM", HTMLFormElementImpl.class); 155 fElementTypes.put("H1", HTMLHeadingElementImpl.class); 156 fElementTypes.put("H2", HTMLHeadingElementImpl.class); 157 fElementTypes.put("H3", HTMLHeadingElementImpl.class); 158 fElementTypes.put("H4", HTMLHeadingElementImpl.class); 159 fElementTypes.put("H5", HTMLHeadingElementImpl.class); 160 fElementTypes.put("H6", HTMLHeadingElementImpl.class); 161 fElementTypes.put("HEAD", HTMLHeadElementImpl.class); 162 fElementTypes.put("HEADING", HTMLHeadingElementImpl.class); 163 fElementTypes.put("HR", HTMLHRElementImpl.class); 164 fElementTypes.put("HTML", HTMLHtmlElementImpl.class); 165 fElementTypes.put("IMG", HTMLImageElementImpl.class); 166 fElementTypes.put("INPUT", HTMLInputElementImpl.class); 167 fElementTypes.put("LI", HTMLLIElementImpl.class); 168 fElementTypes.put("MENU", HTMLMenuElementImpl.class); 169 fElementTypes.put("META", HTMLMetaElementImpl.class); 170 fElementTypes.put("OL", HTMLOListElementImpl.class); 171 fElementTypes.put("OPTION", HTMLOptionElementImpl.class); 172 fElementTypes.put("P", HTMLParagraphElementImpl.class); 173 fElementTypes.put("PLAINTEXT", HTMLPreElementImpl.class); 174 fElementTypes.put("PRE", HTMLPreElementImpl.class); 175 fElementTypes.put("SELECT", HTMLSelectElementImpl.class); 176 fElementTypes.put("TEXTAREA", HTMLTextAreaElementImpl.class); 177 fElementTypes.put("TITLE", HTMLTitleElementImpl.class); 178 fElementTypes.put("UL", HTMLUListElementImpl.class); 179 } 180 181 185 188 private XMLObject fXmlObjectLink; 189 190 193 public void setXMLObject(XMLObject xmlObject) { 194 fXmlObjectLink = xmlObject; 195 } 196 197 200 public XMLObject getXMLObject() { 201 return fXmlObjectLink; 202 } 203 204 } 205 | Popular Tags |