1 19 20 33 34 package org.htmlparser; 35 36 import org.htmlparser.util.NodeList; 37 import org.htmlparser.visitors.NodeVisitor; 38 39 42 public class StringNode extends Node 43 { 44 public static final String STRING_FILTER = "-string"; 45 48 protected StringBuffer textBuffer; 49 50 56 public StringNode(StringBuffer textBuffer, int textBegin, int textEnd) 57 { 58 super(textBegin, textEnd); 59 this.textBuffer = textBuffer; 60 61 } 62 63 66 public String getText() 67 { 68 return textBuffer.toString(); 69 } 70 74 public void setText(String text) 75 { 76 textBuffer = new StringBuffer (text); 77 } 78 public String toPlainTextString() 79 { 80 return textBuffer.toString(); 81 } 82 public String toHtml() 83 { 84 return textBuffer.toString(); 85 } 86 public String toString() 87 { 88 return "Text = " 89 + getText() 90 + "; begins at : " 91 + elementBegin() 92 + "; ends at : " 93 + elementEnd(); 94 } 95 public void collectInto(NodeList collectionList, String filter) 96 { 97 if (filter.equals(STRING_FILTER)) 98 collectionList.add(this); 99 } 100 101 public void accept(NodeVisitor visitor) 102 { 103 visitor.visitStringNode(this); 104 } 105 106 } 107 | Popular Tags |