com.clickntap.tool.html.TextParserCallBack Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of Stripecube Show documentation
Show all versions of Stripecube Show documentation
Stripecube is an open source Java framework for Web Applications
package com.clickntap.tool.html;
import com.clickntap.utils.ConstUtils;
import javax.swing.text.MutableAttributeSet;
import javax.swing.text.html.HTML.Tag;
import javax.swing.text.html.HTMLEditorKit.ParserCallback;
import java.io.Writer;
public class TextParserCallBack extends ParserCallback {
private Writer writer;
public TextParserCallBack(Writer writer) {
this.writer = writer;
}
public void handleStartTag(Tag tag, MutableAttributeSet attributeSet, int index) {
try {
if (tag.breaksFlow())
writer.write(ConstUtils.SPACE);
} catch (Exception e) {
}
}
public void handleEndTag(Tag tag, int index) {
try {
if (tag.breaksFlow())
writer.write(ConstUtils.SPACE);
} catch (Exception e) {
}
}
public void handleText(char[] text, int index) {
try {
writer.write(text);
} catch (Exception e) {
}
}
public void handleSimpleTag(Tag tag, MutableAttributeSet attributeSet, int index) {
try {
if (tag.breaksFlow())
writer.write(ConstUtils.SPACE);
} catch (Exception e) {
}
}
}