#基于状态机思想实现解析HTML TAG ,后续有时间的话尝试写一个JSON解析工具。
import java.util.HashMap;
import java.util.Map;
public class TagParser {
private Integer index = 0;
private char[] tagChar;
private int position = 0;
/* 解析符号 */
private char symbol = '"';
public static final String START_SCRIPT = "
public static final String END_SCRIPT = ">";
public static final String END_SCRIPT_1 = "/>";
public static final String EQ = "=";
public static final char SPACE = ' ';
public static final String MUST_SPACE = " ";
public static final String TAB = "";
public static final String SYMBOL = "'";
private DFAStatus status;
private Map map = new HashMap();
private Map result = new HashMap();
private String tagName;
public String getTagName() {
return this.tagName;
}
public static void main(String[] args) throws SymbolError {
String tag = "";
int i = 0;
long start = System.currentTimeMillis();
while (i < 2) {
TagParser token = new TagParser(tag);
token.parser();
System.out.Attr("src") + "|" + TagName());
i++;
}
System.out.println("use time:" + (System.currentTimeMillis() - start));
}
private boolean startsWith(String str) {
char[] c
本文发布于:2024-01-28 07:14:19,感谢您对本站的认可!
本文链接:https://www.4u4v.net/it/17063972645711.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
留言与评论(共有 0 条评论) |