[Htmlparser-cvs] htmlparser/src/org/htmlparser DecodingNode.java,NONE,1.1 Node.java,1.25,1.26 String
Brought to you by:
derrickoswald
From: <jke...@us...> - 2003-06-19 17:24:32
|
Update of /cvsroot/htmlparser/htmlparser/src/org/htmlparser In directory sc8-pr-cvs1:/tmp/cvs-serv16674/src/org/htmlparser Modified Files: Node.java StringNode.java AbstractNode.java Added Files: DecodingNode.java Log Message: added support for StringNode Decoration --- NEW FILE: DecodingNode.java --- package org.htmlparser; import org.htmlparser.tags.CompositeTag; import org.htmlparser.util.NodeList; import org.htmlparser.util.Translate; import org.htmlparser.visitors.NodeVisitor; public class DecodingNode implements Node { private Node delegate; protected DecodingNode(Node node) { delegate = node; } public String toPlainTextString() { return Translate.decode(delegate.toPlainTextString()); } public void accept(NodeVisitor visitor) { delegate.accept(visitor); } public void collectInto(NodeList collectionList, Class nodeType) { delegate.collectInto(collectionList, nodeType); } public void collectInto(NodeList collectionList, String filter) { delegate.collectInto(collectionList, filter); } public int elementBegin() { return delegate.elementBegin(); } public int elementEnd() { return delegate.elementEnd(); } public CompositeTag getParent() { return delegate.getParent(); } public String getText() { return delegate.getText(); } public void setParent(CompositeTag tag) { delegate.setParent(tag); } public void setText(String text) { delegate.setText(text); } public String toHtml() { return delegate.toHtml(); } public String toHTML() { return delegate.toHTML(); } } Index: Node.java =================================================================== RCS file: /cvsroot/htmlparser/htmlparser/src/org/htmlparser/Node.java,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -d -r1.25 -r1.26 *** Node.java 17 Jun 2003 03:26:19 -0000 1.25 --- Node.java 19 Jun 2003 17:24:30 -0000 1.26 *************** *** 113,116 **** */ public abstract void setParent(CompositeTag tag); ! ! } \ No newline at end of file --- 113,126 ---- */ public abstract void setParent(CompositeTag tag); ! ! /** ! * Returns the text of the string line ! */ ! public String getText(); ! ! /** ! * Sets the string contents of the node. ! * @param The new text for the node. ! */ ! public void setText(String text); ! } Index: StringNode.java =================================================================== RCS file: /cvsroot/htmlparser/htmlparser/src/org/htmlparser/StringNode.java,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** StringNode.java 17 Jun 2003 03:26:19 -0000 1.21 --- StringNode.java 19 Jun 2003 17:24:30 -0000 1.22 *************** *** 31,35 **** import org.htmlparser.util.NodeList; - import org.htmlparser.util.Translate; import org.htmlparser.visitors.NodeVisitor; --- 31,34 ---- *************** *** 39,47 **** public class StringNode extends AbstractNode { - /** - * boolean to tell whether decoding of this node should happen or not. - */ - private boolean shouldDecode = false;; - public static final String STRING_FILTER="-string"; --- 38,41 ---- *************** *** 63,78 **** } ! ! public StringNode(StringBuffer textBuffer, int textBegin, int textEnd, ! boolean shouldDecode) { ! this(textBuffer, textBegin, textEnd); ! this.shouldDecode = shouldDecode; } /** * Returns the text of the string line */ ! public String getText() ! { return textBuffer.toString(); } --- 57,73 ---- } ! ! public static Node createStringNode( ! StringBuffer textBuffer, int textBegin, int textEnd, boolean shouldDecode) { ! if (shouldDecode) ! return new DecodingNode(new StringNode(textBuffer, textBegin, textEnd)); ! return new StringNode(textBuffer, textBegin, textEnd); } + /** * Returns the text of the string line */ ! public String getText() { return textBuffer.toString(); } *************** *** 87,102 **** public String toPlainTextString() { ! return nodeContents(); } public String toHtml() { ! return nodeContents(); ! } ! ! private String nodeContents() { ! String result = textBuffer.toString(); ! if (shouldDecode) ! result = Translate.decode(result); ! return result; } --- 82,90 ---- public String toPlainTextString() { ! return textBuffer.toString(); } public String toHtml() { ! return textBuffer.toString(); } *************** *** 104,107 **** --- 92,96 ---- return "Text = "+getText()+"; begins at : "+elementBegin()+"; ends at : "+elementEnd(); } + public void collectInto(NodeList collectionList, String filter) { if (filter==STRING_FILTER) collectionList.add(this); *************** *** 111,114 **** visitor.visitStringNode(this); } - } --- 100,102 ---- Index: AbstractNode.java =================================================================== RCS file: /cvsroot/htmlparser/htmlparser/src/org/htmlparser/AbstractNode.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** AbstractNode.java 13 Jun 2003 20:27:04 -0000 1.1 --- AbstractNode.java 19 Jun 2003 17:24:30 -0000 1.2 *************** *** 190,193 **** --- 190,208 ---- parent = tag; } + + /** + * Returns the text of the string line + */ + public String getText() { + return null; + } + + /** + * Sets the string contents of the node. + * @param The new text for the node. + */ + public void setText(String text) { + + } } |