当前位置: 首页>>代码示例>>Java>>正文


Java NodeList.getLength方法代码示例

本文整理汇总了Java中mf.org.w3c.dom.NodeList.getLength方法的典型用法代码示例。如果您正苦于以下问题:Java NodeList.getLength方法的具体用法?Java NodeList.getLength怎么用?Java NodeList.getLength使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在mf.org.w3c.dom.NodeList的用法示例。


在下文中一共展示了NodeList.getLength方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getTitle

import mf.org.w3c.dom.NodeList; //导入方法依赖的package包/类
public synchronized String getTitle()
{
    HTMLElement head;
    NodeList    list;
    Node        title;

    // Get the HEAD element and look for the TITLE element within.
    // When found, make sure the TITLE is a direct child of HEAD,
    // and return the title's text (the Text node contained within).
    head = getHead();
    list = head.getElementsByTagName( "TITLE" );
    if ( list.getLength() > 0 ) {
        title = list.item( 0 );
        return ( (HTMLTitleElement) title ).getText();
    }
    // No TITLE found, return an empty string.
    return "";
}
 
开发者ID:MaTriXy,项目名称:xerces-for-android,代码行数:19,代码来源:HTMLDocumentImpl.java

示例2: setTitle

import mf.org.w3c.dom.NodeList; //导入方法依赖的package包/类
public synchronized void setTitle( String newTitle )
{
    HTMLElement head;
    NodeList    list;
    Node        title;

    // Get the HEAD element and look for the TITLE element within.
    // When found, make sure the TITLE is a direct child of HEAD,
    // and set the title's text (the Text node contained within).
    head = getHead();
    list = head.getElementsByTagName( "TITLE" );
    if ( list.getLength() > 0 ) {
        title = list.item( 0 );
        if ( title.getParentNode() != head )
            head.appendChild( title );
        ( (HTMLTitleElement) title ).setText( newTitle );
    }
    else
    {
        // No TITLE found, create a new element and place it at the end
        // of the HEAD element.
        title = new HTMLTitleElementImpl( this, "TITLE" );
        ( (HTMLTitleElement) title ).setText( newTitle );
        head.appendChild( title );
    }
}
 
开发者ID:MaTriXy,项目名称:xerces-for-android,代码行数:27,代码来源:HTMLDocumentImpl.java

示例3: getIndex

import mf.org.w3c.dom.NodeList; //导入方法依赖的package包/类
public int getIndex()
{
    Node        parent;
    NodeList    options;
    int            i;
    
    // Locate the parent SELECT. Note that this OPTION might be inside a
    // OPTGROUP inside the SELECT. Or it might not have a parent SELECT.
    // Everything is possible. If no parent is found, return -1.
    parent = getParentNode();
    while ( parent != null && ! ( parent instanceof HTMLSelectElement ) )
        parent = parent.getParentNode();
    if ( parent != null )
    {
        // Use getElementsByTagName() which creates a snapshot of all the
        // OPTION elements under the SELECT. Access to the returned NodeList
        // is very fast and the snapshot solves many synchronization problems.
        options = ( (HTMLElement) parent ).getElementsByTagName( "OPTION" );
        for ( i = 0 ; i < options.getLength() ; ++i )
            if ( options.item( i ) == this )
                return i;
    }
    return -1;
}
 
开发者ID:MaTriXy,项目名称:xerces-for-android,代码行数:25,代码来源:HTMLOptionElementImpl.java

示例4: getSelectedIndex

import mf.org.w3c.dom.NodeList; //导入方法依赖的package包/类
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;
}
 
开发者ID:MaTriXy,项目名称:xerces-for-android,代码行数:17,代码来源:HTMLSelectElementImpl.java

示例5: getRowIndex

import mf.org.w3c.dom.NodeList; //导入方法依赖的package包/类
int getRowIndex( Node parent )
{
    NodeList    rows;
    int            i;
    
    // Use getElementsByTagName() which creates a snapshot of all the
    // TR elements under the TABLE/section. Access to the returned NodeList
    // is very fast and the snapshot solves many synchronization problems.
    rows = ( (HTMLElement) parent ).getElementsByTagName( "TR" );
    for ( i = 0 ; i < rows.getLength() ; ++i ) {
        if ( rows.item( i ) == this ) {
            return i;
        }
    }
    return -1;
}
 
开发者ID:MaTriXy,项目名称:xerces-for-android,代码行数:17,代码来源:HTMLTableRowElementImpl.java

示例6: setSelectedIndex

import mf.org.w3c.dom.NodeList; //导入方法依赖的package包/类
public void setSelectedIndex( 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 );
}
 
开发者ID:MaTriXy,项目名称:xerces-for-android,代码行数:15,代码来源:HTMLSelectElementImpl.java

示例7: isAttrValueWF

import mf.org.w3c.dom.NodeList; //导入方法依赖的package包/类
/** NON-DOM: check if attribute value is well-formed
 * @param attributes
 * @param a
 * @param value
 */
public static final void isAttrValueWF(DOMErrorHandler errorHandler, DOMErrorImpl error, 
        DOMLocatorImpl locator, NamedNodeMap attributes, Attr a, String value, boolean xml11Version) {
    if (a instanceof AttrImpl && ((AttrImpl)a).hasStringValue()) {
        isXMLCharWF(errorHandler, error, locator, value, xml11Version);
    } else {
    	NodeList children = a.getChildNodes(); 
        //check each child node of the attribute's value
        for (int j = 0; j < children.getLength(); j++) {
            Node child = children.item(j);
            //If the attribute's child is an entity refernce
            if (child.getNodeType() == Node.ENTITY_REFERENCE_NODE) {
                Document owner = a.getOwnerDocument();
                Entity ent = null;
                //search for the entity in the docType
                //of the attribute's ownerDocument
                if (owner != null) {
                    DocumentType docType = owner.getDoctype();
                    if (docType != null) {
                        NamedNodeMap entities = docType.getEntities();
                        ent = (Entity) entities.getNamedItemNS(
                                "*",
                                child.getNodeName());
                    }
                }
                //If the entity was not found issue a fatal error
                if (ent == null) {
                    String msg = DOMMessageFormatter.formatMessage(
                        DOMMessageFormatter.DOM_DOMAIN, "UndeclaredEntRefInAttrValue", 
                        new Object[]{a.getNodeName()});
                    reportDOMError(errorHandler, error, locator, msg, DOMError.SEVERITY_ERROR, 
                        "UndeclaredEntRefInAttrValue");
                }
            }
            else {
                // Text node
                isXMLCharWF(errorHandler, error, locator, child.getNodeValue(), xml11Version);
            }
        }
    }
}
 
开发者ID:MaTriXy,项目名称:xerces-for-android,代码行数:46,代码来源:DOMNormalizer.java

示例8: setBody

import mf.org.w3c.dom.NodeList; //导入方法依赖的package包/类
public synchronized void setBody( HTMLElement newBody )
{
    Node    html;
    Node    body;
    Node    head;
    Node    child;
    NodeList list;

    synchronized ( newBody )
    {
        // Call getDocumentElement() to get the HTML element that is also the
        // top-level element in the document. Get the first element in the
        // document that is called BODY. Work with that.
        html = getDocumentElement();
        head = getHead();
        synchronized ( html )
        {
            list = this.getElementsByTagName( "BODY" );
            if ( list.getLength() > 0 ) {
                // BODY exists but might not follow HEAD in HTML. If not,
                // make it so and replce it. Start with the HEAD and make
                // sure the BODY is the first element after the HEAD.
                body = list.item( 0 );
                synchronized ( body )
                {
                    child = head;
                    while ( child != null )
                    {
                        if ( child instanceof Element )
                        {
                            if ( child != body )
                                html.insertBefore( newBody, child );
                            else
                                html.replaceChild( newBody, body );
                            return;
                        }
                        child = child.getNextSibling();
                    }
                    html.appendChild( newBody );
                }
                return;
            }
            // BODY does not exist, place it in the HTML element
            // right after the HEAD.
            html.appendChild( newBody );
        }
    }
}
 
开发者ID:MaTriXy,项目名称:xerces-for-android,代码行数:49,代码来源:HTMLDocumentImpl.java


注:本文中的mf.org.w3c.dom.NodeList.getLength方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。