1 5 6 package org.w3c.tidy; 7 8 import java.util.Hashtable ; 9 import java.util.Enumeration ; 10 11 36 37 public class AttributeTable { 38 39 public AttributeTable() 40 { 41 } 42 43 public Attribute lookup( String name ) 44 { 45 return (Attribute)attributeHashtable.get( name ); 46 } 47 48 public Attribute install( Attribute attr ) 49 { 50 return (Attribute)attributeHashtable.put( attr.name, attr ); 51 } 52 53 54 public Attribute findAttribute( AttVal attval ) 55 { 56 Attribute np; 57 58 if ( attval.attribute != null ) { 59 np = lookup( attval.attribute ); 60 return np; 61 } 62 63 return null; 64 } 65 66 public boolean isUrl( String attrname ) 67 { 68 Attribute np; 69 70 np = lookup( attrname ); 71 return ( np != null && np.attrchk == AttrCheckImpl.getCheckUrl() ); 72 } 73 74 public boolean isScript( String attrname ) 75 { 76 Attribute np; 77 78 np = lookup( attrname ); 79 return ( np != null && np.attrchk == AttrCheckImpl.getCheckScript() ); 80 } 81 82 public boolean isLiteralAttribute( String attrname ) 83 { 84 Attribute np; 85 86 np = lookup( attrname ); 87 return ( np != null && np.literal ); 88 } 89 90 96 public void declareLiteralAttrib(String name) 97 { 98 Attribute attrib = lookup(name); 99 100 if (attrib == null) 101 attrib = install(new Attribute(name, Dict.VERS_PROPRIETARY, null)); 102 103 attrib.literal = true; 104 } 105 106 private Hashtable attributeHashtable = new Hashtable (); 107 108 private static AttributeTable defaultAttributeTable = null; 109 110 private static Attribute[] attrs = { 111 112 new Attribute( "abbr", Dict.VERS_HTML40, null ), 113 new Attribute( "accept-charset", Dict.VERS_HTML40, null ), 114 new Attribute( "accept", Dict.VERS_ALL, null ), 115 new Attribute( "accesskey", Dict.VERS_HTML40, null ), 116 new Attribute( "action", Dict.VERS_ALL, AttrCheckImpl.getCheckUrl() ), 117 new Attribute( "add_date", Dict.VERS_NETSCAPE, null ), 118 new Attribute( "align", Dict.VERS_ALL, AttrCheckImpl.getCheckAlign() ), 119 new Attribute( "alink", Dict.VERS_LOOSE, null ), 120 new Attribute( "alt", Dict.VERS_ALL, null ), 121 new Attribute( "archive", Dict.VERS_HTML40, null ), 122 new Attribute( "axis", Dict.VERS_HTML40, null ), 123 new Attribute( "background", Dict.VERS_LOOSE, AttrCheckImpl.getCheckUrl() ), 124 new Attribute( "bgcolor", Dict.VERS_LOOSE, null ), 125 new Attribute( "bgproperties", Dict.VERS_PROPRIETARY, null ), 126 new Attribute( "border", Dict.VERS_ALL, AttrCheckImpl.getCheckBool() ), 127 new Attribute( "bordercolor", Dict.VERS_MICROSOFT, null ), 128 new Attribute( "bottommargin", Dict.VERS_MICROSOFT, null ), 129 new Attribute( "cellpadding", Dict.VERS_FROM32, null ), 130 new Attribute( "cellspacing", Dict.VERS_FROM32, null ), 131 new Attribute( "char", Dict.VERS_HTML40, null ), 132 new Attribute( "charoff", Dict.VERS_HTML40, null ), 133 new Attribute( "charset", Dict.VERS_HTML40, null ), 134 new Attribute( "checked", Dict.VERS_ALL, AttrCheckImpl.getCheckBool() ), 135 new Attribute( "cite", Dict.VERS_HTML40, AttrCheckImpl.getCheckUrl() ), 136 new Attribute( "class", Dict.VERS_HTML40, null ), 137 new Attribute( "classid", Dict.VERS_HTML40, AttrCheckImpl.getCheckUrl() ), 138 new Attribute( "clear", Dict.VERS_LOOSE, null ), 139 new Attribute( "code", Dict.VERS_LOOSE, null ), 140 new Attribute( "codebase", Dict.VERS_HTML40, AttrCheckImpl.getCheckUrl() ), 141 new Attribute( "codetype", Dict.VERS_HTML40, null ), 142 new Attribute( "color", Dict.VERS_LOOSE, null ), 143 new Attribute( "cols", Dict.VERS_IFRAMES, null ), 144 new Attribute( "colspan", Dict.VERS_FROM32, null ), 145 new Attribute( "compact", Dict.VERS_ALL, AttrCheckImpl.getCheckBool() ), 146 new Attribute( "content", Dict.VERS_ALL, null ), 147 new Attribute( "coords", Dict.VERS_FROM32, null ), 148 new Attribute( "data", Dict.VERS_HTML40, AttrCheckImpl.getCheckUrl() ), 149 new Attribute( "datafld", Dict.VERS_MICROSOFT, null ), 150 new Attribute( "dataformatas", Dict.VERS_MICROSOFT, null ), 151 new Attribute( "datapagesize", Dict.VERS_MICROSOFT, null ), 152 new Attribute( "datasrc", Dict.VERS_MICROSOFT, AttrCheckImpl.getCheckUrl() ), 153 new Attribute( "datetime", Dict.VERS_HTML40, null ), 154 new Attribute( "declare", Dict.VERS_HTML40, AttrCheckImpl.getCheckBool() ), 155 new Attribute( "defer", Dict.VERS_HTML40, AttrCheckImpl.getCheckBool() ), 156 new Attribute( "dir", Dict.VERS_HTML40, null ), 157 new Attribute( "disabled", Dict.VERS_HTML40, AttrCheckImpl.getCheckBool() ), 158 new Attribute( "enctype", Dict.VERS_ALL, null ), 159 new Attribute( "face", Dict.VERS_LOOSE, null ), 160 new Attribute( "for", Dict.VERS_HTML40, null ), 161 new Attribute( "frame", Dict.VERS_HTML40, null ), 162 new Attribute( "frameborder", Dict.VERS_FRAMES, null ), 163 new Attribute( "framespacing", Dict.VERS_PROPRIETARY, null ), 164 new Attribute( "gridx", Dict.VERS_PROPRIETARY, null ), 165 new Attribute( "gridy", Dict.VERS_PROPRIETARY, null ), 166 new Attribute( "headers", Dict.VERS_HTML40, null ), 167 new Attribute( "height", Dict.VERS_ALL, null ), 168 new Attribute( "href", Dict.VERS_ALL, AttrCheckImpl.getCheckUrl() ), 169 new Attribute( "hreflang", Dict.VERS_HTML40, null ), 170 new Attribute( "hspace", Dict.VERS_ALL, null ), 171 new Attribute( "http-equiv", Dict.VERS_ALL, null ), 172 new Attribute( "id", Dict.VERS_HTML40, AttrCheckImpl.getCheckId() ), 173 new Attribute( "ismap", Dict.VERS_ALL, AttrCheckImpl.getCheckBool() ), 174 new Attribute( "label", Dict.VERS_HTML40, null ), 175 new Attribute( "lang", Dict.VERS_HTML40, null ), 176 new Attribute( "language", Dict.VERS_LOOSE, null ), 177 new Attribute( "last_modified", Dict.VERS_NETSCAPE, null ), 178 new Attribute( "last_visit", Dict.VERS_NETSCAPE, null ), 179 new Attribute( "leftmargin", Dict.VERS_MICROSOFT, null ), 180 new Attribute( "link", Dict.VERS_LOOSE, null ), 181 new Attribute( "longdesc", Dict.VERS_HTML40, AttrCheckImpl.getCheckUrl() ), 182 new Attribute( "lowsrc", Dict.VERS_PROPRIETARY, AttrCheckImpl.getCheckUrl() ), 183 new Attribute( "marginheight", Dict.VERS_IFRAMES, null ), 184 new Attribute( "marginwidth", Dict.VERS_IFRAMES, null ), 185 new Attribute( "maxlength", Dict.VERS_ALL, null ), 186 new Attribute( "media", Dict.VERS_HTML40, null ), 187 new Attribute( "method", Dict.VERS_ALL, null ), 188 new Attribute( "multiple", Dict.VERS_ALL, AttrCheckImpl.getCheckBool() ), 189 new Attribute( "name", Dict.VERS_ALL, AttrCheckImpl.getCheckName() ), 190 new Attribute( "nohref", Dict.VERS_FROM32, AttrCheckImpl.getCheckBool() ), 191 new Attribute( "noresize", Dict.VERS_FRAMES, AttrCheckImpl.getCheckBool() ), 192 new Attribute( "noshade", Dict.VERS_LOOSE, AttrCheckImpl.getCheckBool() ), 193 new Attribute( "nowrap", Dict.VERS_LOOSE, AttrCheckImpl.getCheckBool() ), 194 new Attribute( "object", Dict.VERS_HTML40_LOOSE, null ), 195 new Attribute( "onblur", Dict.VERS_HTML40, AttrCheckImpl.getCheckScript() ), 196 new Attribute( "onchange", Dict.VERS_HTML40, AttrCheckImpl.getCheckScript() ), 197 new Attribute( "onclick", Dict.VERS_HTML40, AttrCheckImpl.getCheckScript() ), 198 new Attribute( "ondblclick", Dict.VERS_HTML40, AttrCheckImpl.getCheckScript() ), 199 new Attribute( "onkeydown", Dict.VERS_HTML40, AttrCheckImpl.getCheckScript() ), 200 new Attribute( "onkeypress", Dict.VERS_HTML40, AttrCheckImpl.getCheckScript() ), 201 new Attribute( "onkeyup", Dict.VERS_HTML40, AttrCheckImpl.getCheckScript() ), 202 new Attribute( "onload", Dict.VERS_HTML40, AttrCheckImpl.getCheckScript() ), 203 new Attribute( "onmousedown", Dict.VERS_HTML40, AttrCheckImpl.getCheckScript() ), 204 new Attribute( "onmousemove", Dict.VERS_HTML40, AttrCheckImpl.getCheckScript() ), 205 new Attribute( "onmouseout", Dict.VERS_HTML40, AttrCheckImpl.getCheckScript() ), 206 new Attribute( "onmouseover", Dict.VERS_HTML40, AttrCheckImpl.getCheckScript() ), 207 new Attribute( "onmouseup", Dict.VERS_HTML40, AttrCheckImpl.getCheckScript() ), 208 new Attribute( "onsubmit", Dict.VERS_HTML40, AttrCheckImpl.getCheckScript() ), 209 new Attribute( "onreset", Dict.VERS_HTML40, AttrCheckImpl.getCheckScript() ), 210 new Attribute( "onselect", Dict.VERS_HTML40, AttrCheckImpl.getCheckScript() ), 211 new Attribute( "onunload", Dict.VERS_HTML40, AttrCheckImpl.getCheckScript() ), 212 new Attribute( "onafterupdate", Dict.VERS_MICROSOFT, AttrCheckImpl.getCheckScript() ), 213 new Attribute( "onbeforeupdate", Dict.VERS_MICROSOFT, AttrCheckImpl.getCheckScript() ), 214 new Attribute( "onerrorupdate", Dict.VERS_MICROSOFT, AttrCheckImpl.getCheckScript() ), 215 new Attribute( "onrowenter", Dict.VERS_MICROSOFT, AttrCheckImpl.getCheckScript() ), 216 new Attribute( "onrowexit", Dict.VERS_MICROSOFT, AttrCheckImpl.getCheckScript() ), 217 new Attribute( "onbeforeunload", Dict.VERS_MICROSOFT, AttrCheckImpl.getCheckScript() ), 218 new Attribute( "ondatasetchanged", Dict.VERS_MICROSOFT, AttrCheckImpl.getCheckScript() ), 219 new Attribute( "ondataavailable", Dict.VERS_MICROSOFT, AttrCheckImpl.getCheckScript() ), 220 new Attribute( "ondatasetcomplete",Dict.VERS_MICROSOFT, AttrCheckImpl.getCheckScript() ), 221 new Attribute( "profile", Dict.VERS_HTML40, AttrCheckImpl.getCheckUrl() ), 222 new Attribute( "prompt", Dict.VERS_LOOSE, null ), 223 new Attribute( "readonly", Dict.VERS_HTML40, AttrCheckImpl.getCheckBool() ), 224 new Attribute( "rel", Dict.VERS_ALL, null ), 225 new Attribute( "rev", Dict.VERS_ALL, null ), 226 new Attribute( "rightmargin", Dict.VERS_MICROSOFT, null ), 227 new Attribute( "rows", Dict.VERS_ALL, null ), 228 new Attribute( "rowspan", Dict.VERS_ALL, null ), 229 new Attribute( "rules", Dict.VERS_HTML40, null ), 230 new Attribute( "scheme", Dict.VERS_HTML40, null ), 231 new Attribute( "scope", Dict.VERS_HTML40, null ), 232 new Attribute( "scrolling", Dict.VERS_IFRAMES, null ), 233 new Attribute( "selected", Dict.VERS_ALL, AttrCheckImpl.getCheckBool() ), 234 new Attribute( "shape", Dict.VERS_FROM32, null ), 235 new Attribute( "showgrid", Dict.VERS_PROPRIETARY, AttrCheckImpl.getCheckBool() ), 236 new Attribute( "showgridx", Dict.VERS_PROPRIETARY, AttrCheckImpl.getCheckBool() ), 237 new Attribute( "showgridy", Dict.VERS_PROPRIETARY, AttrCheckImpl.getCheckBool() ), 238 new Attribute( "size", Dict.VERS_LOOSE, null ), 239 new Attribute( "span", Dict.VERS_HTML40, null ), 240 new Attribute( "src", (short)(Dict.VERS_ALL | Dict.VERS_FRAMES), AttrCheckImpl.getCheckUrl() ), 241 new Attribute( "standby", Dict.VERS_HTML40, null ), 242 new Attribute( "start", Dict.VERS_ALL, null ), 243 new Attribute( "style", Dict.VERS_HTML40, null ), 244 new Attribute( "summary", Dict.VERS_HTML40, null ), 245 new Attribute( "tabindex", Dict.VERS_HTML40, null ), 246 new Attribute( "target", Dict.VERS_HTML40, null ), 247 new Attribute( "text", Dict.VERS_LOOSE, null ), 248 new Attribute( "title", Dict.VERS_HTML40, null ), 249 new Attribute( "topmargin", Dict.VERS_MICROSOFT, null ), 250 new Attribute( "type", Dict.VERS_FROM32, null ), 251 new Attribute( "usemap", Dict.VERS_ALL, AttrCheckImpl.getCheckBool() ), 252 new Attribute( "valign", Dict.VERS_FROM32, AttrCheckImpl.getCheckValign() ), 253 new Attribute( "value", Dict.VERS_ALL, null ), 254 new Attribute( "valuetype", Dict.VERS_HTML40, null ), 255 new Attribute( "version", Dict.VERS_ALL, null ), 256 new Attribute( "vlink", Dict.VERS_LOOSE, null ), 257 new Attribute( "vspace", Dict.VERS_LOOSE, null ), 258 new Attribute( "width", Dict.VERS_ALL, null ), 259 new Attribute( "wrap", Dict.VERS_NETSCAPE, null ), 260 new Attribute( "xml:lang", Dict.VERS_XML, null ), 261 new Attribute( "xmlns", Dict.VERS_ALL, null ), 262 263 }; 264 265 public static Attribute attrHref = null; 266 public static Attribute attrSrc = null; 267 public static Attribute attrId = null; 268 public static Attribute attrName = null; 269 public static Attribute attrSummary = null; 270 public static Attribute attrAlt = null; 271 public static Attribute attrLongdesc = null; 272 public static Attribute attrUsemap = null; 273 public static Attribute attrIsmap = null; 274 public static Attribute attrLanguage = null; 275 public static Attribute attrType = null; 276 public static Attribute attrTitle = null; 277 public static Attribute attrXmlns = null; 278 public static Attribute attrValue = null; 279 public static Attribute attrContent = null; 280 public static Attribute attrDatafld = null; 281 public static Attribute attrWidth = null; 282 public static Attribute attrHeight = null; 283 284 public static AttributeTable getDefaultAttributeTable() 285 { 286 if ( defaultAttributeTable == null ) { 287 defaultAttributeTable = new AttributeTable(); 288 for ( int i = 0; i < attrs.length; i++ ) { 289 defaultAttributeTable.install( attrs[i] ); 290 } 291 attrHref = defaultAttributeTable.lookup("href"); 292 attrSrc = defaultAttributeTable.lookup("src"); 293 attrId = defaultAttributeTable.lookup("id"); 294 attrName = defaultAttributeTable.lookup("name"); 295 attrSummary = defaultAttributeTable.lookup("summary"); 296 attrAlt = defaultAttributeTable.lookup("alt"); 297 attrLongdesc = defaultAttributeTable.lookup("longdesc"); 298 attrUsemap = defaultAttributeTable.lookup("usemap"); 299 attrIsmap = defaultAttributeTable.lookup("ismap"); 300 attrLanguage = defaultAttributeTable.lookup("language"); 301 attrType = defaultAttributeTable.lookup("type"); 302 attrTitle = defaultAttributeTable.lookup("title"); 303 attrXmlns = defaultAttributeTable.lookup("xmlns"); 304 attrValue = defaultAttributeTable.lookup("value"); 305 attrContent = defaultAttributeTable.lookup("content"); 306 attrDatafld = defaultAttributeTable.lookup("datafld");; 307 attrWidth = defaultAttributeTable.lookup("width");; 308 attrHeight = defaultAttributeTable.lookup("height");; 309 310 attrAlt.nowrap = true; 311 attrValue.nowrap = true; 312 attrContent.nowrap = true; 313 } 314 return defaultAttributeTable; 315 } 316 317 } 318 | Popular Tags |