[Htmlparser-cvs] htmlparser/src/org/htmlparser EscapeCharacterRemovingNode.java,NONE,1.1 Node.java,1
Brought to you by:
derrickoswald
Update of /cvsroot/htmlparser/htmlparser/src/org/htmlparser
In directory sc8-pr-cvs1:/tmp/cvs-serv26404/src/org/htmlparser
Modified Files:
Node.java Parser.java StringNode.java DecodingNode.java
Added Files:
EscapeCharacterRemovingNode.java
Log Message:
added EscapeRemovingNode decorator, remove lots of private methods and field that were never used in numerous classes
--- NEW FILE: EscapeCharacterRemovingNode.java ---
package org.htmlparser;
import org.htmlparser.tags.CompositeTag;
import org.htmlparser.util.NodeList;
import org.htmlparser.util.ParserUtils;
import org.htmlparser.visitors.NodeVisitor;
public class EscapeCharacterRemovingNode implements Node {
private Node delegate;
public EscapeCharacterRemovingNode(Node newDelegate) {
this.delegate = newDelegate;
}
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 boolean equals(Object arg0) {
return delegate.equals(arg0);
}
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 toPlainTextString() {
return ParserUtils.removeEscapeCharacters(delegate.toPlainTextString());
}
public String toString() {
return delegate.toString();
}
}
Index: Node.java
===================================================================
RCS file: /cvsroot/htmlparser/htmlparser/src/org/htmlparser/Node.java,v
retrieving revision 1.28
retrieving revision 1.29
diff -C2 -d -r1.28 -r1.29
*** Node.java 24 Jun 2003 23:59:54 -0000 1.28
--- Node.java 25 Jun 2003 03:46:37 -0000 1.29
***************
*** 129,136 ****
public abstract int elementEnd();
public abstract void accept(NodeVisitor visitor);
! /**
! * @deprecated - use toHtml() instead
! */
! public abstract String toHTML();
/**
* Get the parent of this tag
--- 129,134 ----
public abstract int elementEnd();
public abstract void accept(NodeVisitor visitor);
!
!
/**
* Get the parent of this tag
Index: Parser.java
===================================================================
RCS file: /cvsroot/htmlparser/htmlparser/src/org/htmlparser/Parser.java,v
retrieving revision 1.46
retrieving revision 1.47
diff -C2 -d -r1.46 -r1.47
*** Parser.java 22 Jun 2003 21:37:44 -0000 1.46
--- Parser.java 25 Jun 2003 03:46:37 -0000 1.47
***************
*** 183,187 ****
/**
! * Flag to tell the parser to decode nodes while parsing.
* Decoding occurs via the method, org.htmlparser.util.Translate.decode()
*/
--- 183,187 ----
/**
! * Flag to tell the parser to decode strings returned by StringNode's toPlainTextString.
* Decoding occurs via the method, org.htmlparser.util.Translate.decode()
*/
***************
*** 190,193 ****
--- 190,199 ----
/**
+ * Flag to tell the parser to remove escape characters, like \n and \t, returned by StringNode's toPlainTextString.
+ * Escape character removal occurs via the method, org.htmlparser.util.ParserUtils.removeEscapeCharacters()
+ */
+ private boolean shouldRemoveEscapeCharacters = false;
+
+ /**
* Feedback object.
*/
***************
*** 244,249 ****
public static ParserFeedback stdout = new DefaultParserFeedback ();
- private ParserHelper parserHelper = new ParserHelper();
-
//
// Static methods
--- 250,253 ----
***************
*** 1226,1229 ****
--- 1230,1241 ----
public boolean shouldDecodeNodes() {
return shouldDecodeNodes;
+ }
+
+ public void setEscapeCharacterRemoval(boolean shouldRemoveEscapeCharacters) {
+ this.shouldRemoveEscapeCharacters = shouldRemoveEscapeCharacters;
+ }
+
+ public boolean shouldRemoveEscapeCharacters() {
+ return shouldRemoveEscapeCharacters;
}
}
Index: StringNode.java
===================================================================
RCS file: /cvsroot/htmlparser/htmlparser/src/org/htmlparser/StringNode.java,v
retrieving revision 1.23
retrieving revision 1.24
diff -C2 -d -r1.23 -r1.24
*** StringNode.java 22 Jun 2003 21:37:44 -0000 1.23
--- StringNode.java 25 Jun 2003 03:46:37 -0000 1.24
***************
*** 59,66 ****
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);
}
--- 59,70 ----
public static Node createStringNode(
! StringBuffer textBuffer, int textBegin, int textEnd,
! boolean shouldDecode, boolean shouldRemoveEscapeCharacters) {
! Node newNode = new StringNode(textBuffer, textBegin, textEnd);
if (shouldDecode)
! newNode = new DecodingNode(newNode);
! if (shouldRemoveEscapeCharacters)
! newNode = new EscapeCharacterRemovingNode(newNode);
! return newNode;
}
Index: DecodingNode.java
===================================================================
RCS file: /cvsroot/htmlparser/htmlparser/src/org/htmlparser/DecodingNode.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** DecodingNode.java 24 Jun 2003 23:59:54 -0000 1.3
--- DecodingNode.java 25 Jun 2003 03:46:37 -0000 1.4
***************
*** 87,94 ****
return delegate.toHtml();
}
-
- public String toHTML() {
- return delegate.toHTML();
- }
-
}
--- 87,89 ----
|