1 23 24 package org.enhydra.xml.xmlc.metadata; 25 26 29 public class DOMType extends EnumeratedType { 30 33 public static final DOMType LAZYDOM 34 = new DOMType("lazydom", 35 org.enhydra.xml.xmlc.dom.lazydom.LazyDomFactory.class, 36 org.enhydra.xml.xmlc.dom.lazydom.LazyHTMLDomFactory.class); 37 38 41 public static final DOMType XERCES 42 = new DOMType("xerces", 43 org.enhydra.xml.xmlc.dom.xerces.XercesDomFactory.class, 44 org.enhydra.xml.xmlc.dom.xerces.XercesHTMLDomFactory.class); 45 46 47 50 public static final DOMType GENERIC 52 = new DOMType("generic", 53 org.enhydra.xml.xmlc.dom.xerces.XercesDomFactory.class, 54 org.enhydra.xml.xmlc.dom.xerces.XercesHTMLDomFactory.class); 55 56 59 public static DOMType XHTML; 60 61 64 public static DOMType WML; 65 66 69 public static DOMType VOICEXML; 70 71 74 public static DOMType CHTML; 75 76 static { 78 try { 79 XHTML = new DOMType("xhtml", 80 Class.forName("org.enhydra.xml.xhtml.XHTMLDomFactory"), 81 Class.forName("org.enhydra.xml.xhtml.HTMLDomFactory")); 82 } catch (ClassNotFoundException e) { XHTML = null; } 83 84 try { 85 WML = new DOMType("wml", 86 Class.forName("org.enhydra.wireless.wml.WMLDomFactory"), 87 null); 88 } catch (ClassNotFoundException e) { WML = null; } 89 90 try { 91 VOICEXML = new DOMType("voicexml", 92 Class.forName("org.enhydra.wireless.voicexml.VoiceXMLDomFactory"), 93 null); 94 95 } catch (ClassNotFoundException e) { VOICEXML = null; } 96 97 try { 98 CHTML = new DOMType("chtml", 99 null, 100 Class.forName("org.enhydra.wireless.chtml.CHTMLDomFactory")); 101 } catch (ClassNotFoundException e) { CHTML = null; } 102 } 103 104 107 private final Class fXMLDomFactoryClass; 108 109 112 private final Class fHTMLDomFactoryClass; 113 114 117 private DOMType(String name, 118 Class xmlDomFactoryClass, 119 Class htmlDomFactoryClass) { 120 super(name); 121 fXMLDomFactoryClass = xmlDomFactoryClass; 122 fHTMLDomFactoryClass = htmlDomFactoryClass; 123 } 124 125 128 public Class getXMLDomFactoryClass() { 129 return fXMLDomFactoryClass; 130 } 131 132 135 public Class getHTMLDomFactoryClass() { 136 return fHTMLDomFactoryClass; 137 } 138 139 143 public static DOMType getType(String desiredType) { 144 if (desiredType == null) { 145 return null; 146 } else if (LAZYDOM.fName.equals(desiredType)) { 147 return LAZYDOM; 148 } else if (XERCES.fName.equals(desiredType)) { 149 return XERCES; 150 } else if (XHTML != null && XHTML.fName.equals(desiredType)) { 151 return XHTML; 152 } else if (CHTML != null && CHTML.fName.equals(desiredType)) { 153 return CHTML; 154 } else if (VOICEXML != null && VOICEXML.fName.equals(desiredType)) { 155 return VOICEXML; 156 } else if (WML != null && WML.fName.equals(desiredType)) { 157 return WML; 158 } else { 159 throw new IllegalArgumentException ( 160 "Invalid DOMType: \"" 161 + desiredType 162 + "\", expected one of \"" 163 + (XHTML!=null?XHTML.fName + "\", \"":"") 164 + (WML!=null?WML.fName + "\", \"":"") 165 + (VOICEXML!=null?VOICEXML.fName + "\", \"":"") 166 + (CHTML!=null?CHTML.fName + "\", \"":"") 167 + LAZYDOM.fName + "\" or \"" 168 + XERCES.fName); 169 } 170 } 171 } 172 | Popular Tags |