1 24 25 package org.enhydra.xml.xhtml.dom.xerces; 26 27 import org.w3c.dom.Node ; 28 import org.w3c.dom.NodeList ; 29 import org.w3c.dom.Text ; 30 import org.w3c.dom.html.HTMLElement; 31 import org.w3c.dom.html.HTMLSelectElement; 32 33 public class XHTMLOptionElementImpl 34 extends XHTMLElementImpl 35 implements org.enhydra.xml.xhtml.dom.XHTMLOptionElement 36 { 37 38 public XHTMLOptionElementImpl (XHTMLDocumentBase owner, String namespaceURI, String tagName) { 39 super( owner, namespaceURI, tagName); 40 } 41 42 public void setId (String newValue) { 43 setAttribute("id", newValue); 44 } 45 46 public String getId () { 47 return getAttribute ("id"); 48 } 49 public void setLang (String newValue) { 50 setAttribute("lang", newValue); 51 } 52 53 public String getLang () { 54 return getAttribute ("lang"); 55 } 56 public void setDir (String newValue) { 57 setAttribute("dir", newValue); 58 } 59 60 public String getDir () { 61 return getAttribute ("dir"); 62 } 63 public void setClassName (String newValue) { 64 setAttribute("class", newValue); 65 } 66 67 public String getClassName () { 68 return getAttribute ("class"); 69 } 70 public void setTitle (String newValue) { 71 setAttribute("title", newValue); 72 } 73 74 public String getTitle () { 75 return getAttribute ("title"); 76 } 77 public void setValue (String newValue) { 78 setAttribute("value", newValue); 79 } 80 81 public String getValue () { 82 return getAttribute ("value"); 83 } 84 public void setDisabled (boolean newValue) { 85 setAttribute("disabled", newValue); 86 } 87 88 public boolean getDisabled () { 89 return getBooleanAttribute("disabled"); 90 } 91 public void setLabel (String newValue) { 92 setAttribute("label", newValue); 93 } 94 95 public String getLabel () { 96 return getAttribute ("label"); 97 } 98 public void setDefaultSelected (boolean newValue) { 99 setAttribute("defaultselected", newValue); 100 } 101 102 public boolean getDefaultSelected () { 103 return getBooleanAttribute("defaultselected"); 104 } 105 public void setSelected (boolean newValue) { 106 setAttribute("selected", newValue); 107 } 108 109 public boolean getSelected () { 110 return getBooleanAttribute("selected"); 111 } 112 public void setOnKeyUp (String newValue) { 113 setAttribute("onkeyup", newValue); 114 } 115 116 public String getOnKeyUp () { 117 return getAttribute ("onkeyup"); 118 } 119 public void setStyle (String newValue) { 120 setAttribute("style", newValue); 121 } 122 123 public String getStyle () { 124 return getAttribute ("style"); 125 } 126 public void setOnMouseDown (String newValue) { 127 setAttribute("onmousedown", newValue); 128 } 129 130 public String getOnMouseDown () { 131 return getAttribute ("onmousedown"); 132 } 133 public void setOnKeyPress (String newValue) { 134 setAttribute("onkeypress", newValue); 135 } 136 137 public String getOnKeyPress () { 138 return getAttribute ("onkeypress"); 139 } 140 public void setOnDblClick (String newValue) { 141 setAttribute("ondblclick", newValue); 142 } 143 144 public String getOnDblClick () { 145 return getAttribute ("ondblclick"); 146 } 147 public void setOnKeyDown (String newValue) { 148 setAttribute("onkeydown", newValue); 149 } 150 151 public String getOnKeyDown () { 152 return getAttribute ("onkeydown"); 153 } 154 public void setOnMouseMove (String newValue) { 155 setAttribute("onmousemove", newValue); 156 } 157 158 public String getOnMouseMove () { 159 return getAttribute ("onmousemove"); 160 } 161 public void setOnMouseUp (String newValue) { 162 setAttribute("onmouseup", newValue); 163 } 164 165 public String getOnMouseUp () { 166 return getAttribute ("onmouseup"); 167 } 168 public void setXmlLang (String newValue) { 169 setAttribute("xml:lang", newValue); 170 } 171 172 public String getXmlLang () { 173 return getAttribute ("xml:lang"); 174 } 175 public void setOnMouseOut (String newValue) { 176 setAttribute("onmouseout", newValue); 177 } 178 179 public String getOnMouseOut () { 180 return getAttribute ("onmouseout"); 181 } 182 public void setOnClick (String newValue) { 183 setAttribute("onclick", newValue); 184 } 185 186 public String getOnClick () { 187 return getAttribute ("onclick"); 188 } 189 public void setOnMouseOver (String newValue) { 190 setAttribute("onmouseover", newValue); 191 } 192 193 public String getOnMouseOver () { 194 return getAttribute ("onmouseover"); 195 } 196 ; 197 198 199 public String getText() { 200 Node child; 201 String text; 202 203 child = getFirstChild(); 206 text = ""; 207 while ( child != null ) 208 { 209 if ( child instanceof Text ) 210 text = text + ( (Text ) child ).getData(); 211 child = child.getNextSibling(); 212 } 213 return text; 214 } 215 216 217 public void setText( String text ) { 218 Node child; 219 Node next; 220 221 child = getFirstChild(); 224 while ( child != null ) 225 { 226 next = child.getNextSibling(); 227 removeChild( child ); 228 child = next; 229 } 230 insertBefore( getOwnerDocument().createTextNode( text ), getFirstChild() ); 231 } 232 233 234 public int getIndex() { 235 Node parent; 236 NodeList options; 237 int i; 238 239 parent = getParentNode(); 243 while ( parent != null && ! ( parent instanceof HTMLSelectElement ) ) 244 parent = parent.getParentNode(); 245 if ( parent != null ) 246 { 247 options = ( (HTMLElement) parent ).getElementsByTagName( "option" ); 251 for ( i = 0 ; i < options.getLength() ; ++i ) 252 if ( options.item( i ) == this ) 253 return i; 254 } 255 return -1; 256 } 257 258 259 public void setIndex( int index ) { 260 Node parent; 261 NodeList options; 262 Node item; 263 264 parent = getParentNode(); 268 while ( parent != null && ! ( parent instanceof HTMLSelectElement ) ) 269 parent = parent.getParentNode(); 270 if ( parent != null ) { 271 options = ( (HTMLElement) parent ).getElementsByTagName( "option" ); 276 if ( options.item( index ) != this ) { 277 getParentNode().removeChild( this ); 281 item = options.item( index ); 282 item.getParentNode().insertBefore( this, item ); 283 } 284 } 285 } 286 287 288 ; 289 } 290 291 292 | Popular Tags |