FileDocCategorySizeDatePackage
HTMLSelectElementImpl.javaAPI DocJava SE 5 API7827Fri Aug 26 14:55:28 BST 2005com.sun.org.apache.html.internal.dom

HTMLSelectElementImpl

public class HTMLSelectElementImpl extends HTMLElementImpl implements HTMLFormControl, HTMLSelectElement
version
$Revision: 1.7 $ $Date: 2003/05/08 20:13:09 $
author
Assaf Arkin
see
org.w3c.dom.html.HTMLSelectElement
see
com.sun.org.apache.xerces.internal.dom.ElementImpl

Fields Summary
private HTMLCollection
_options
Constructors Summary
public HTMLSelectElementImpl(HTMLDocumentImpl owner, String name)
Constructor requires owner document.

param
owner The owner HTML document

        super( owner, name );
    
Methods Summary
public voidadd(org.w3c.dom.html.HTMLElement element, org.w3c.dom.html.HTMLElement before)

        insertBefore( element, before );
    
public voidblur()

        // No scripting in server-side DOM. This method is moot.
    
public voidfocus()

        // No scripting in server-side DOM. This method is moot.
    
public org.w3c.dom.NodeListgetChildNodes()

        return getChildNodesUnoptimized();
    
public booleangetDisabled()

        return getBinary( "disabled" );
    
public intgetLength()

        return getOptions().getLength();
    
public booleangetMultiple()

        return getBinary( "multiple" );
    
public java.lang.StringgetName()

        return getAttribute( "name" );
    
public org.w3c.dom.html.HTMLCollectiongetOptions()

        if ( _options == null )
            _options = new HTMLCollectionImpl( this, HTMLCollectionImpl.OPTION );
        return _options;
    
public intgetSelectedIndex()

        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;
    
public intgetSize()

        return getInteger( getAttribute( "size" ) );
    
public intgetTabIndex()

        return getInteger( getAttribute( "tabindex" ) );
    
public java.lang.StringgetType()

        return getAttribute( "type" );
    
public java.lang.StringgetValue()

        return getAttribute( "value" );
    
public voidremove(int index)

        NodeList    options;
        Node        removed;
        
        // 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.
        // Remove the indexed OPTION from it's parent, this might be this
        // SELECT or an OPTGROUP.
        options = getElementsByTagName( "OPTION" );
        removed = options.item( index );
        if ( removed != null )
            removed.getParentNode().removeChild ( removed );
    
public voidsetDisabled(boolean disabled)

        setAttribute( "disabled", disabled );
    
public voidsetMultiple(boolean multiple)

        setAttribute( "multiple", multiple );
    
public voidsetName(java.lang.String name)

        setAttribute( "name", name );
    
public voidsetSelectedIndex(int selectedIndex)

        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.
        // Change the select so all OPTIONs are off, except for the
        // selectIndex-th one.
        options = getElementsByTagName( "OPTION" );
        for ( i = 0 ; i < options.getLength() ; ++i )
            ( (HTMLOptionElementImpl) options.item( i ) ).setSelected( i == selectedIndex );
    
public voidsetSize(int size)

        setAttribute( "size", String.valueOf( size ) );
    
public voidsetTabIndex(int tabIndex)

        setAttribute( "tabindex", String.valueOf( tabIndex ) );
    
public voidsetValue(java.lang.String value)

        setAttribute( "value", value );