Java 类org.w3c.dom.html.HTMLOptionElement 实例源码

项目:SplitCharater    文件:HTMLSelectElementImpl.java   
public int getSelectedIndex()
{
    NodeList    options;
    int            i;

    // Use getElementsByTagName() which creates a snapshot of all the
    // OPTION elements under this SELECT. Access to the returned NodeList
    // is very fast and the snapshot solves many synchronization problems.
    // Locate the first selected OPTION and return its index. Note that
    // the OPTION might be under an OPTGROUP.
    options = getElementsByTagName( "OPTION" );
    for ( i = 0 ; i < options.getLength() ; ++i )
        if ( ( (HTMLOptionElement) options.item( i ) ).getSelected() )
            return i;
    return -1;
}
项目:lams    文件:HTMLSelectElementImpl.java   
public int getSelectedIndex() {
    HTMLCollection options = getOptions();
    for (int i = 0; i < options.getLength(); i++) {
        if (((HTMLOptionElement)options.item(i)).getSelected()) return i;
    }
    return isMultiSelect() ? -1 : 0;
}
项目:lams    文件:HTMLSelectElementImpl.java   
public String getValue() {
    HTMLCollection options = getOptions();
    for (int i = 0; i < options.getLength(); i++) {
        HTMLOptionElement optionElement = ((HTMLOptionElement)options.item(i));
        if (optionElement.getSelected()) return optionElement.getValue();
    }
    return (isMultiSelect() || options.getLength() == 0) ? null : ((HTMLOptionElement)options.item(0)).getValue();
}
项目:ui4j    文件:WebKitElement.java   
@Override
public Optional<String> getValue() {
    String value = null;
    if (element instanceof HTMLInputElement) {
        value = ((HTMLInputElement) element).getValue();
    } else if (element instanceof HTMLOptionElement) {
        value = ((HTMLOptionElement) element).getValue();
    }
    return value == null || value.isEmpty() ? Optional.empty() : Optional.of(value);
}
项目:ui4j    文件:WebKitElement.java   
@Override
public Element setValue(String value) {
    if (element instanceof HTMLInputElement) {
        ((HTMLInputElement) element).setValue(value);
    } else if (element instanceof HTMLOptionElement) {
        ((HTMLOptionElement) element).setValue(value);
    }
    return this;
}
项目:ui4j    文件:WebKitElement.java   
@Override
public Optional<Option> getOption() {
    if (element instanceof HTMLOptionElement) {
        return Optional.of(new Option(this));
    } else {
        return Optional.empty();
    }
}