1 38 package com.gargoylesoftware.htmlunit.html; 39 40 import java.io.IOException ; 41 import java.util.Map ; 42 43 import com.gargoylesoftware.htmlunit.Assert; 44 import com.gargoylesoftware.htmlunit.ElementNotFoundException; 45 import com.gargoylesoftware.htmlunit.KeyValuePair; 46 import com.gargoylesoftware.htmlunit.Page; 47 48 58 public abstract class HtmlInput extends FocusableElement implements DisabledElement, SubmittableElement { 59 60 61 public static final String TAG_NAME = "input"; 62 63 69 public HtmlInput( final HtmlPage page, final Map attributes ) { 70 super( page, attributes ); 71 } 72 73 76 public String getTagName() { 77 return TAG_NAME; 78 } 79 80 85 public void setValueAttribute( final String newValue ) { 86 Assert.notNull( "newValue", newValue ); 87 setAttributeValue( "value", newValue ); 88 89 getPage().executeOnChangeHandlerIfAppropriate(this); 90 } 91 92 93 102 public KeyValuePair[] getSubmitKeyValuePairs() { 103 return new KeyValuePair[]{new KeyValuePair( getNameAttribute(), getValueAttribute() )}; 104 } 105 106 114 public String asText() { 115 return getValueAttribute(); 116 } 117 118 119 127 public final String getTypeAttribute() { 128 return getAttributeValue("type"); 129 } 130 131 132 140 public final String getNameAttribute() { 141 return getAttributeValue("name"); 142 } 143 144 145 153 public final String getValueAttribute() { 154 return getAttributeValue("value"); 155 } 156 157 158 166 public final String getCheckedAttribute() { 167 return getAttributeValue("checked"); 168 } 169 170 171 179 public final String getDisabledAttribute() { 180 return getAttributeValue("disabled"); 181 } 182 183 184 188 public final boolean isDisabled() { 189 return isAttributeDefined("disabled"); 190 } 191 192 193 201 public final String getReadOnlyAttribute() { 202 return getAttributeValue("readonly"); 203 } 204 205 206 214 public final String getSizeAttribute() { 215 return getAttributeValue("size"); 216 } 217 218 219 227 public final String getMaxLengthAttribute() { 228 return getAttributeValue("maxlength"); 229 } 230 231 232 240 public final String getSrcAttribute() { 241 return getAttributeValue("src"); 242 } 243 244 245 253 public final String getAltAttribute() { 254 return getAttributeValue("alt"); 255 } 256 257 258 266 public final String getUseMapAttribute() { 267 return getAttributeValue("usemap"); 268 } 269 270 271 279 public final String getTabIndexAttribute() { 280 return getAttributeValue("tabindex"); 281 } 282 283 284 292 public final String getAccessKeyAttribute() { 293 return getAttributeValue("accesskey"); 294 } 295 296 297 305 public final String getOnFocusAttribute() { 306 return getAttributeValue("onfocus"); 307 } 308 309 310 318 public final String getOnBlurAttribute() { 319 return getAttributeValue("onblur"); 320 } 321 322 323 331 public final String getOnSelectAttribute() { 332 return getAttributeValue("onselect"); 333 } 334 335 336 344 public final String getOnChangeAttribute() { 345 return getAttributeValue("onchange"); 346 } 347 348 349 357 public final String getAcceptAttribute() { 358 return getAttributeValue("accept"); 359 } 360 361 362 370 public final String getAlignAttribute() { 371 return getAttributeValue("align"); 372 } 373 374 375 378 public void reset() { 379 } 381 382 387 public void setChecked( final boolean isChecked ) { 388 } 390 391 392 397 public boolean isChecked() { 398 return isAttributeDefined("checked"); 399 } 400 401 402 413 public Page click( final int x, final int y ) 414 throws 415 IOException , 416 ElementNotFoundException { 417 418 return click(); 420 } 421 422 432 public Page submit() 433 throws 434 IOException , 435 ElementNotFoundException { 436 437 return click(); 438 } 439 440 441 } 442 | Popular Tags |