1 20 21 package org.ozoneDB.xml.dom.html; 22 23 import org.ozoneDB.xml.dom.CollectionImpl; 24 import org.w3c.dom.Element ; 25 import org.w3c.dom.html.*; 26 27 28 54 final class HTMLCollectionImpl extends CollectionImpl implements HTMLCollection { 55 56 57 65 protected boolean recurse() { 66 return _lookingFor > 0; 67 } 68 69 70 81 protected boolean collectionMatch( Element elem, String name ) { 82 boolean match; 83 84 synchronized (elem) { 85 match = false; 90 switch (_lookingFor) { 91 case ANCHOR: 92 match = elem instanceof HTMLAnchorElement && elem.getAttribute( "name" ) != null; 95 break; 96 case FORM: 97 match = elem instanceof HTMLFormElement; 99 break; 100 case IMAGE: 101 match = elem instanceof HTMLImageElement; 103 break; 104 case APPLET: 105 match = elem instanceof HTMLAppletElement || elem instanceof HTMLObjectElement 109 && ("application/java".equals( elem.getAttribute( "codetype" ) ) || elem.getAttribute( 110 "classid" ) != null && elem.getAttribute( "classid" ).startsWith( "java:" )); 111 break; 112 case ELEMENT: 113 match = elem instanceof HTMLFormControl; 115 break; 116 case LINK: 117 match = (elem instanceof HTMLAnchorElement || elem instanceof HTMLAreaElement) && elem.getAttribute( 119 "href" ) != null; 120 break; 121 case AREA: 122 match = elem instanceof HTMLAreaElement; 124 break; 125 case OPTION: 126 match = elem instanceof HTMLOptionElement; 128 break; 129 case ROW: 130 match = elem instanceof HTMLTableRowElement; 132 break; 133 case TBODY: 134 match = elem instanceof HTMLTableSectionElement && elem.getTagName().equals( "tbody" ); 136 break; 137 case CELL: 138 match = elem instanceof HTMLTableCellElement; 140 break; 141 } 142 143 if (match && name != null) { 147 if (elem instanceof HTMLAnchorElement && name.equals( elem.getAttribute( "name" ) )) { 150 return true; 151 } 152 match = name.equals( elem.getAttribute( "id" ) ); 153 } 154 } 155 return match; 156 } 157 158 159 167 HTMLCollectionImpl( HTMLElement topLevel, short lookingFor ) { 168 super( topLevel ); 169 _lookingFor = lookingFor; 170 } 171 172 173 177 final static short ANCHOR = 1; 178 179 180 183 final static short FORM = 2; 184 185 186 189 final static short IMAGE = 3; 190 191 192 196 final static short APPLET = 4; 197 198 199 203 final static short LINK = 5; 204 205 206 210 final static short OPTION = 6; 211 212 213 217 final static short ROW = 7; 218 219 220 225 final static short ELEMENT = 8; 226 227 228 232 final static short AREA = -1; 233 234 235 239 final static short TBODY = -2; 240 241 242 246 final static short CELL = -3; 247 248 249 254 private short _lookingFor; 255 256 257 } 258 | Popular Tags |