1 20 package org.enhydra.barracuda.core.view; 21 22 import java.util.*; 23 import org.w3c.dom.*; 24 import org.w3c.dom.html.*; 25 26 101 public abstract class ClientType { 102 103 public static final ClientType HTML_BROWSER = new HtmlBrowserImpl(); 105 public static final ClientType HTML_3_2_BROWSER = new Html32BrowserImpl(); 106 public static final ClientType IE_3x = new IE3xImpl(); 107 public static final ClientType IE_4x = new IE4xImpl(); 108 public static final ClientType NN_3x = new NN3xImpl(); 109 public static final ClientType NN_4x = new NN4xImpl(); 110 public static final ClientType OPERA_4x = new Opera4xImpl(); 111 public static final ClientType HTML_4_0_BROWSER = new Html40BrowserImpl(); 112 public static final ClientType IE_5x = new IE5xImpl(); 113 public static final ClientType IE_6x = new IE6xImpl(); 114 public static final ClientType NN_6x = new NN6xImpl(); 115 public static final ClientType OPERA_5x = new Opera5xImpl(); 116 public static final ClientType CHTML_BROWSER = new ChtmlBrowserImpl(); 117 public static final ClientType XML_BROWSER = new XmlBrowserImpl(); 118 public static final ClientType VXML_BROWSER = new VxmlBrowserImpl(); 119 public static final ClientType WML_BROWSER = new WmlBrowserImpl(); 120 public static final ClientType XHTML_BROWSER = new XhtmlBrowserImpl(); 121 public static final ClientType UNKNOWN_BROWSER = new UnknownBrowserImpl(); 122 123 public interface GenericBrowser {}; 125 public interface HtmlBrowser extends GenericBrowser {}; 126 public interface HtmlStandardBrowser extends HtmlBrowser {}; 127 public interface Html32Browser extends HtmlStandardBrowser {}; 128 public interface IE3x extends Html32Browser {}; 129 public interface IE4x extends IE3x {}; 130 public interface NN3x extends Html32Browser {}; 131 public interface NN4x extends NN3x {}; 132 public interface Opera4x extends Html32Browser {}; 133 public interface Html40Browser extends Html32Browser {}; 134 public interface IE5x extends Html40Browser, IE4x {}; 135 public interface IE6x extends Html40Browser, IE5x {}; 136 public interface NN6x extends Html40Browser, NN4x {}; 137 public interface Opera5x extends Html40Browser, Opera4x {}; 138 public interface ChtmlBrowser extends HtmlBrowser {}; 139 public interface XmlBrowser extends GenericBrowser {}; 140 public interface VxmlBrowser extends XmlBrowser {}; 141 public interface WmlBrowser extends XmlBrowser {}; 142 public interface XhtmlBrowser extends XmlBrowser {}; 143 public interface UnknownBrowser extends GenericBrowser {}; 144 145 147 151 protected static class GenericBrowserImpl extends ClientType implements GenericBrowser { 153 public String toString() { 154 String s = this.getClass().getName(); 155 int spos = s.indexOf("$"); 156 int epos = s.indexOf("Impl"); 157 return s.substring(spos+1, epos); 158 } 159 }; 160 protected static class HtmlBrowserImpl extends GenericBrowserImpl implements HtmlBrowser {}; 161 protected static class HtmlStandardBrowserImpl extends HtmlBrowserImpl implements HtmlStandardBrowser {}; 162 protected static class Html32BrowserImpl extends HtmlStandardBrowserImpl implements Html32Browser {}; 163 protected static class IE3xImpl extends Html32BrowserImpl implements IE3x {}; 164 protected static class IE4xImpl extends IE3xImpl implements IE4x {}; 165 protected static class NN3xImpl extends Html32BrowserImpl implements NN3x {}; 166 protected static class NN4xImpl extends NN3xImpl implements NN4x {}; 167 protected static class Opera4xImpl extends Html32BrowserImpl implements Opera4x {}; 168 protected static class Html40BrowserImpl extends Html32BrowserImpl implements Html40Browser {}; 169 protected static class IE5xImpl extends Html40BrowserImpl implements IE5x {}; 170 protected static class IE6xImpl extends Html40BrowserImpl implements IE6x {}; 171 protected static class NN6xImpl extends Html40BrowserImpl implements NN6x {}; 172 protected static class Opera5xImpl extends Html40BrowserImpl implements Opera5x {}; 173 protected static class ChtmlBrowserImpl extends HtmlBrowserImpl implements ChtmlBrowser {}; 174 protected static class XmlBrowserImpl extends GenericBrowserImpl implements XmlBrowser {}; 175 protected static class VxmlBrowserImpl extends XmlBrowserImpl implements VxmlBrowser {}; 176 protected static class WmlBrowserImpl extends XmlBrowserImpl implements WmlBrowser {}; 177 protected static class XhtmlBrowserImpl extends XmlBrowserImpl implements XhtmlBrowser {}; 178 protected static class UnknownBrowserImpl extends GenericBrowserImpl implements UnknownBrowser {}; 179 180 187 public static ClientType getInstance(String strName) { 188 if (strName.indexOf("HTML_BROWSER")!=-1) return ClientType.HTML_BROWSER; 189 else if (strName.indexOf("HTML_3_2_BROWSER")!=-1) return ClientType.HTML_3_2_BROWSER; 190 else if (strName.indexOf("IE_3x")!=-1) return ClientType.IE_3x; 191 else if (strName.indexOf("IE_4x")!=-1) return ClientType.IE_4x; 192 else if (strName.indexOf("NN_3x")!=-1) return ClientType.NN_3x; 193 else if (strName.indexOf("NN_4x")!=-1) return ClientType.NN_4x; 194 else if (strName.indexOf("OPERA_4x")!=-1) return ClientType.OPERA_4x; 195 else if (strName.indexOf("HTML_4_0_BROWSER")!=-1) return ClientType.HTML_4_0_BROWSER; 196 else if (strName.indexOf("IE_5x")!=-1) return ClientType.IE_5x; 197 else if (strName.indexOf("IE_6x")!=-1) return ClientType.IE_6x; 198 else if (strName.indexOf("NN_6x")!=-1) return ClientType.NN_6x; 199 else if (strName.indexOf("OPERA_5x")!=-1) return ClientType.OPERA_5x; 200 else if (strName.indexOf("CHTML_BROWSER")!=-1) return ClientType.CHTML_BROWSER; 201 else if (strName.indexOf("XML_BROWSER")!=-1) return ClientType.XML_BROWSER; 202 else if (strName.indexOf("VXML_BROWSER")!=-1) return ClientType.VXML_BROWSER; 203 else if (strName.indexOf("WML_BROWSER")!=-1) return ClientType.WML_BROWSER; 204 else if (strName.indexOf("XHTML_BROWSER")!=-1) return ClientType.XHTML_BROWSER; 205 else if (strName.indexOf("UNKNOWN_BROWSER")!=-1) return ClientType.UNKNOWN_BROWSER; 206 else return null; 207 } 208 209 212 protected ClientType() {} 213 214 public static void main(String args[]) { 215 System.out.println ("Testing..."); 216 System.out.println ("IE_5x instanceof ClientType.Html32Browser:"+(ClientType.IE_5x instanceof ClientType.Html32Browser)); 217 } 218 } 219 | Popular Tags |