1 16 package org.apache.html.dom; 17 18 import org.w3c.dom.Node ; 19 import org.w3c.dom.Text ; 20 import org.w3c.dom.html.HTMLTitleElement; 21 22 29 public class HTMLTitleElementImpl 30 extends HTMLElementImpl 31 implements HTMLTitleElement 32 { 33 34 private static final long serialVersionUID = 4050769294810034992L; 35 36 public String getText() 37 { 38 Node child; 39 StringBuffer text = new StringBuffer (); 40 41 child = getFirstChild(); 44 while ( child != null ) 45 { 46 if ( child instanceof Text ) { 47 text.append(( (Text ) child ).getData()); 48 } 49 child = child.getNextSibling(); 50 } 51 return text.toString(); 52 } 53 54 55 public void setText( String text ) 56 { 57 Node child; 58 Node next; 59 60 child = getFirstChild(); 63 while ( child != null ) 64 { 65 next = child.getNextSibling(); 66 removeChild( child ); 67 child = next; 68 } 69 insertBefore( getOwnerDocument().createTextNode( text ), getFirstChild() ); 70 } 71 72 73 78 public HTMLTitleElementImpl( HTMLDocumentImpl owner, String name ) 79 { 80 super( owner, name ); 81 } 82 83 84 } 85 86 | Popular Tags |