FileDocCategorySizeDatePackage
HTMLSelectElementImpl.javaAPI DocApache Xerces 3.0.16575Fri Sep 14 20:33:54 BST 2007org.apache.html.dom

HTMLSelectElementImpl

public class HTMLSelectElementImpl extends HTMLElementImpl implements HTMLFormControl, HTMLSelectElement
xerces.internal
version
$Revision: 447255 $ $Date: 2006-09-18 01:36:42 -0400 (Mon, 18 Sep 2006) $
author
Assaf Arkin
see
org.w3c.dom.html.HTMLSelectElement
see
org.apache.xerces.dom.ElementImpl

Fields Summary
private static final long
serialVersionUID
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 org.w3c.dom.NodecloneNode(boolean deep)
Explicit implementation of cloneNode() to ensure that cache used for getOptions() gets cleared.

        HTMLSelectElementImpl clonedNode = (HTMLSelectElementImpl)super.cloneNode( deep );
        clonedNode._options = null;
        return clonedNode;
    
public voidfocus()

        // No scripting in server-side DOM. This method is moot.
    
public org.w3c.dom.NodeListgetChildNodes()
Explicit implementation of getChildNodes() to avoid problems with overriding the getLength() method hidden in the super class.

        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 );