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

项目:SplitCharater    文件:HTMLDocumentImpl.java   
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 "";
}
项目:SplitCharater    文件:HTMLDocumentImpl.java   
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 );
    }
}