亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? parser.java

?? JAVA的一些源碼 JAVA2 STANDARD EDITION DEVELOPMENT KIT 5.0
?? JAVA
?? 第 1 頁 / 共 4 頁
字號:
/* * @(#)Parser.java	1.43 05/05/27 * * Copyright 2005 Sun Microsystems, Inc. All rights reserved. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. */package javax.swing.text.html.parser;import javax.swing.text.SimpleAttributeSet;import javax.swing.text.html.HTML;import javax.swing.text.ChangedCharSetException;import java.io.*;import java.util.Hashtable;import java.util.Properties;import java.util.Vector;import java.util.Enumeration;import java.net.URL;import sun.misc.MessageUtils;/** * A simple DTD-driven HTML parser. The parser reads an * HTML file from an InputStream and calls various methods * (which should be overridden in a subclass) when tags and * data are encountered. * <p> * Unfortunately there are many badly implemented HTML parsers * out there, and as a result there are many badly formatted * HTML files. This parser attempts to parse most HTML files. * This means that the implementation sometimes deviates from * the SGML specification in favor of HTML. * <p> * The parser treats \r and \r\n as \n. Newlines after starttags * and before end tags are ignored just as specified in the SGML/HTML * specification. * <p> * The html spec does not specify how spaces are to be coalesced very well. * Specifically, the following scenarios are not discussed (note that a * space should be used here, but I am using &amp;nbsp to force the space to * be displayed): * <p> * '&lt;b>blah&nbsp;&lt;i>&nbsp;&lt;strike>&nbsp;foo' which can be treated as: * '&lt;b>blah&nbsp;&lt;i>&lt;strike>foo'  * <p>as well as: * '&lt;p>&lt;a href="xx">&nbsp;&lt;em>Using&lt;/em>&lt;/a>&lt;/p>' * which appears to be treated as: * '&lt;p>&lt;a href="xx">&lt;em>Using&lt;/em>&lt;/a>&lt;/p>' * <p> * If <code>strict</code> is false, when a tag that breaks flow, * (<code>TagElement.breaksFlows</code>) or trailing whitespace is * encountered, all whitespace will be ignored until a non whitespace * character is encountered. This appears to give behavior closer to * the popular browsers. * * @see DTD * @see TagElement * @see SimpleAttributeSet * @version 1.43, 05/27/05 * @author Arthur van Hoff * @author Sunita Mani */publicclass Parser implements DTDConstants {    private char text[] = new char[1024];    private int textpos = 0;    private TagElement last;    private boolean space;    private char str[] = new char[128];    private int strpos = 0;    protected DTD dtd = null;    private int ch;    private int ln;    private Reader in;    private Element recent;    private TagStack stack;    private boolean skipTag = false;    private TagElement lastFormSent = null;    private SimpleAttributeSet attributes = new SimpleAttributeSet();    // State for <html>, <head> and <body>.  Since people like to slap    // together HTML documents without thinking, occasionally they    // have multiple instances of these tags.  These booleans track    // the first sightings of these tags so they can be safely ignored    // by the parser if repeated.    private boolean seenHtml = false;    private boolean seenHead = false;    private boolean seenBody = false;    /**     * The html spec does not specify how spaces are coalesced very well.     * If strict == false, ignoreSpace is used to try and mimic the behavior     * of the popular browsers.     * <p>     * The problematic scenarios are:     * '&lt;b>blah &lt;i> &lt;strike> foo' which can be treated as:     * '&lt;b>blah &lt;i>&lt;strike>foo'     * as well as:     * '&lt;p>&lt;a href="xx"> &lt;em>Using&lt;/em>&lt;/a>&lt;/p>'     * which appears to be treated as:     * '&lt;p>&lt;a href="xx">&lt;em>Using&lt;/em>&lt;/a>&lt;/p>'     * <p>     * When a tag that breaks flow, or trailing whitespace is encountered     * ignoreSpace is set to true. From then on, all whitespace will be     * ignored.     * ignoreSpace will be set back to false the first time a     * non whitespace character is encountered. This appears to give     * behavior closer to the popular browsers.     */    private boolean ignoreSpace;    /**     * This flag determines whether or not the Parser will be strict     * in enforcing SGML compatibility.  If false, it will be lenient     * with certain common classes of erroneous HTML constructs.     * Strict or not, in either case an error will be recorded.     *     */    protected boolean strict = false;    /** Number of \r\n's encountered. */    private int crlfCount;    /** Number of \r's encountered. A \r\n will not increment this. */    private int crCount;    /** Number of \n's encountered. A \r\n will not increment this. */    private int lfCount;    //    // To correctly identify the start of a tag/comment/text we need two    // ivars. Two are needed as handleText isn't invoked until the tag    // after the text has been parsed, that is the parser parses the text,    // then a tag, then invokes handleText followed by handleStart.    //    /** The start position of the current block. Block is overloaded here,     * it really means the current start position for the current comment,     * tag, text. Use getBlockStartPosition to access this. */    private int currentBlockStartPos;    /** Start position of the last block. */    private int lastBlockStartPos;    /**     * array for mapping numeric references in range     * 130-159 to displayable Unicode characters.     */    private static final char[] cp1252Map = {        8218,  // &#130;        402,   // &#131;        8222,  // &#132;        8230,  // &#133;        8224,  // &#134;        8225,  // &#135;        710,   // &#136;        8240,  // &#137;        352,   // &#138;        8249,  // &#139;        338,   // &#140;        141,   // &#141;        142,   // &#142;        143,   // &#143;        144,   // &#144;        8216,  // &#145;        8217,  // &#146;        8220,  // &#147;        8221,  // &#148;        8226,  // &#149;        8211,  // &#150;        8212,  // &#151;        732,   // &#152;        8482,  // &#153;        353,   // &#154;        8250,  // &#155;        339,   // &#156;        157,   // &#157;        158,   // &#158;        376    // &#159;    };    public Parser(DTD dtd) {	this.dtd = dtd;    }    /**     * @return the line number of the line currently being parsed     */    protected int getCurrentLine() {	return ln;    }    /**     * Returns the start position of the current block. Block is     * overloaded here, it really means the current start position for     * the current comment tag, text, block.... This is provided for     * subclassers that wish to know the start of the current block when     * called with one of the handleXXX methods.     */    int getBlockStartPosition() {	return Math.max(0, lastBlockStartPos - 1);    }    /**     * Makes a TagElement.     */    protected TagElement makeTag(Element elem, boolean fictional) {	return new TagElement(elem, fictional);    }    protected TagElement makeTag(Element elem) {	return makeTag(elem, false);    }    protected SimpleAttributeSet getAttributes() {	return attributes;    }    protected void flushAttributes() {	attributes.removeAttributes(attributes);    }    /**     * Called when PCDATA is encountered.     */    protected void handleText(char text[]) {    }    /**     * Called when an HTML title tag is encountered.     */    protected void handleTitle(char text[]) {	// default behavior is to call handleText. Subclasses	// can override if necessary.	handleText(text);    }    /**     * Called when an HTML comment is encountered.     */    protected void handleComment(char text[]) {    }    protected void handleEOFInComment() {	// We've reached EOF.  Our recovery strategy is to	// see if we have more than one line in the comment;	// if so, we pretend that the comment was an unterminated	// single line comment, and reparse the lines after the	// first line as normal HTML content.	int commentEndPos = strIndexOf('\n');	if (commentEndPos >= 0) {	    handleComment(getChars(0, commentEndPos));	    try {		in.close();		in = new CharArrayReader(getChars(commentEndPos + 1));		ch = '>';	    } catch (IOException e) {		error("ioexception");	    }	    resetStrBuffer();	} else {	    // no newline, so signal an error	    error("eof.comment");	}    }    /**     * Called when an empty tag is encountered.     */    protected void handleEmptyTag(TagElement tag) throws ChangedCharSetException {    }    /**     * Called when a start tag is encountered.     */    protected void handleStartTag(TagElement tag) {    }    /**     * Called when an end tag is encountered.     */    protected void handleEndTag(TagElement tag) {    }    /**     * An error has occurred.     */    protected void handleError(int ln, String msg) {	/*	Thread.dumpStack();	System.out.println("**** " + stack);	System.out.println("line " + ln + ": error: " + msg);	System.out.println();	*/    }    /**     * Output text.     */    void handleText(TagElement tag) {	if (tag.breaksFlow()) {	    space = false;            if (!strict) {                ignoreSpace = true;            }	}	if (textpos == 0) {	    if ((!space) || (stack == null) || last.breaksFlow() ||		!stack.advance(dtd.pcdata)) {		last = tag;		space = false;		lastBlockStartPos = currentBlockStartPos;		return;	    }	}	if (space) {            if (!ignoreSpace) {                // enlarge buffer if needed                if (textpos + 1 > text.length) {                    char newtext[] = new char[text.length + 200];                    System.arraycopy(text, 0, newtext, 0, text.length);                    text = newtext;                }                // output pending space                text[textpos++] = ' ';                if (!strict && !tag.getElement().isEmpty()) {                    ignoreSpace = true;                }            }            space = false;	}	char newtext[] = new char[textpos];	System.arraycopy(text, 0, newtext, 0, textpos);	// Handles cases of bad html where the title tag	// was getting lost when we did error recovery.	if (tag.getElement().getName().equals("title")) {	    handleTitle(newtext);        } else {	    handleText(newtext);	}	lastBlockStartPos = currentBlockStartPos;	textpos = 0;	last = tag;	space = false;    }    /**     * Invoke the error handler.     */    protected void error(String err, String arg1, String arg2,	String arg3) {	// big hack, but this should never get used...	handleError (ln, err + arg1 + arg2 + arg3);    }    protected void error(String err, String arg1, String arg2) {	error(err, arg1, arg2, "?");    }    protected void error(String err, String arg1) {	error(err, arg1, "?", "?");    }    protected void error(String err) {	error(err, "?", "?", "?");    }    /**     * Handle a start tag. The new tag is pushed     * onto the tag stack. The attribute list is     * checked for required attributes.     */    protected void startTag(TagElement tag) throws ChangedCharSetException {	Element elem = tag.getElement();	// If the tag is an empty tag and texpos != 0	// this implies that there is text before the	// start tag that needs to be processed before	// handling the tag.	//	if (!elem.isEmpty() || textpos != 0) {	    handleText(tag);	} else {	    // this variable gets updated in handleText().	    // Since in this case we do not call handleText()	    // we need to update it here.	    //	    last = tag;	    // Note that we should really check last.breakFlows before	    // assuming this should be false.	    space = false;	}	lastBlockStartPos = currentBlockStartPos;	// check required attributes	for (AttributeList a = elem.atts ; a != null ; a = a.next) {	    if ((a.modifier == REQUIRED) && ((attributes.isEmpty()) || (!attributes.isDefined(a.name)))) {		error("req.att ", a.getName(), elem.getName());	    }	}	if (elem.isEmpty()) {	    handleEmptyTag(tag);            /*	} else if (elem.getName().equals("form")) {	    handleStartTag(tag);            */	} else {	    recent = elem;	    stack = new TagStack(tag, stack);	    handleStartTag(tag);	}    }    /**     * Handle an end tag. The end tag is popped     * from the tag stack.     */    protected void endTag(boolean omitted) {	handleText(stack.tag);	if (omitted && !stack.elem.omitEnd()) {	    error("end.missing", stack.elem.getName());	} else if (!stack.terminate()) {	    error("end.unexpected", stack.elem.getName());	}	// handle the tag	handleEndTag(stack.tag);	stack = stack.next;	recent = (stack != null) ? stack.elem : null;    }    boolean ignoreElement(Element elem) {        String stackElement = stack.elem.getName();	String elemName = elem.getName();	/* We ignore all elements that are not valid in the context of	   a table except <td>, <th> (these we handle in	   legalElementContext()) and #pcdata.  We also ignore the	   <font> tag in the context of <ul> and <ol> We additonally	   ignore the <meta> and the <style> tag if the body tag has	   been seen. **/	if ((elemName.equals("html") && seenHtml) ||	    (elemName.equals("head") && seenHead) ||	    (elemName.equals("body") && seenBody)) {	    return true;	}	if (elemName.equals("dt") || elemName.equals("dd")) {	    TagStack s = stack;	    while (s != null && !s.elem.getName().equals("dl")) {		s = s.next;	    }	    if (s == null) {		return true;	    }	}	if (((stackElement.equals("table")) &&	     (!elemName.equals("#pcdata")) && (!elemName.equals("input"))) ||	    ((elemName.equals("font")) &&	     (stackElement.equals("ul") || stackElement.equals("ol"))) ||	    (elemName.equals("meta") && stack != null) ||	    (elemName.equals("style") && seenBody) ||	    (stackElement.equals("table") && elemName.equals("a"))) {	    return true;	}	return false;    }    /**     * Marks the first time a tag has been seen in a document     */    protected void markFirstTime(Element elem) {	String elemName = elem.getName();	if (elemName.equals("html")) {	    seenHtml = true;	} else if (elemName.equals("head")) {	    seenHead = true;	} else if (elemName.equals("body")) {            if (buf.length == 1) {                // Refer to note in definition of buf for details on this.                char[] newBuf = new char[256];                newBuf[0] = buf[0];                buf = newBuf;            }	    seenBody = true;	}    }    /**     * Create a legal content for an element.     */    boolean legalElementContext(Element elem) throws ChangedCharSetException {	// System.out.println("-- legalContext -- " + elem);	// Deal with the empty stack	if (stack == null) {	    // System.out.println("-- stack is empty");	    if (elem != dtd.html) {		// System.out.println("-- pushing html");		startTag(makeTag(dtd.html, true));		return legalElementContext(elem);	    }	    return true;	}	// Is it allowed in the current context	if (stack.advance(elem)) {	    // System.out.println("-- legal context");	    markFirstTime(elem);	    return true;	}	boolean insertTag = false;	// The use of all error recovery strategies are contingent	// on the value of the strict property.	//	// These are commonly occuring errors.  if insertTag is true,	// then we want to adopt an error recovery strategy that	// involves attempting to insert an additional tag to	// legalize the context.  The two errors addressed here	// are:	// 1) when a <td> or <th> is seen soon after a <table> tag.	//    In this case we insert a <tr>.	// 2) when any other tag apart from a <tr> is seen	//    in the context of a <tr>.  In this case we would	//    like to add a <td>.  If a <tr> is seen within a	//    <tr> context, then we will close out the current	//    <tr>.	//	// This insertion strategy is handled later in the method.	// The reason for checking this now, is that in other cases	// we would like to apply other error recovery strategies for example	// ignoring tags.	//	// In certain cases it is better to ignore a tag than try to	// fix the situation.  So the first test is to see if this	// is what we need to do.	//	String stackElemName = stack.elem.getName();	String elemName = elem.getName();

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
在线免费一区三区| 一区二区三区在线播| **欧美大码日韩| 日本视频在线一区| 97成人超碰视| 久久久久久免费毛片精品| 亚洲电影激情视频网站| 99精品视频一区二区三区| 精品国产乱码久久久久久久久| 亚洲狼人国产精品| 欧美一级精品在线| 亚洲影视资源网| 97久久精品人人做人人爽| 久久亚洲综合色一区二区三区| 亚洲一区二区黄色| 一本色道久久综合亚洲91| 久久嫩草精品久久久精品| 日av在线不卡| 欧美欧美午夜aⅴ在线观看| 一区二区三区国产精品| av激情亚洲男人天堂| 国产精品无圣光一区二区| 成+人+亚洲+综合天堂| 国产亚洲精品久| 国精产品一区一区三区mba视频| 欧美日本在线一区| 偷拍自拍另类欧美| 欧美日韩在线直播| 亚洲成人中文在线| 欧美日韩三级视频| 日韩精品欧美精品| 日韩三级.com| 国产一区不卡视频| 视频一区欧美日韩| 91精品国产福利在线观看| 午夜精品一区二区三区电影天堂| 欧美性色黄大片手机版| 亚洲va天堂va国产va久| 56国语精品自产拍在线观看| 日日夜夜一区二区| 精品久久人人做人人爽| 国内外精品视频| 中文幕一区二区三区久久蜜桃| 国产大陆亚洲精品国产| 日本最新不卡在线| 欧美成人一区二区三区| 国产精品综合在线视频| 国产精品国产三级国产三级人妇 | 国产在线精品免费| 精品国产乱码久久久久久老虎| 国产精品77777竹菊影视小说| 国产日本欧美一区二区| 91视视频在线观看入口直接观看www| 免费三级欧美电影| www日韩大片| 91在线精品一区二区三区| 亚洲综合色区另类av| 欧美一区午夜视频在线观看| 久久 天天综合| 国产精品伦理在线| 欧美男生操女生| 国产很黄免费观看久久| 亚洲精品综合在线| 精品久久久久一区二区国产| 99在线精品一区二区三区| 国产在线一区观看| 最新高清无码专区| 日韩一区二区视频| 91在线高清观看| 极品瑜伽女神91| 一区二区三区在线观看国产| 欧美精品久久天天躁| 成人久久久精品乱码一区二区三区| 一区二区三区久久久| 国产人成一区二区三区影院| 欧美色图12p| 成熟亚洲日本毛茸茸凸凹| 首页国产欧美久久| 中文字幕一区二区5566日韩| 日韩欧美一级二级三级久久久| 97se亚洲国产综合自在线 | 欧美亚一区二区| 国产在线精品一区二区不卡了 | 色呦呦网站一区| 精品一区二区三区在线观看| 亚洲精品高清视频在线观看| 久久久久久久久免费| 91精品欧美综合在线观看最新 | 精品无人码麻豆乱码1区2区 | 中文字幕一区av| 欧美精品一区二区在线播放| 欧洲一区在线观看| 成人午夜电影小说| 国产精品正在播放| 韩国午夜理伦三级不卡影院| 日韩福利电影在线| 偷拍一区二区三区| 午夜视频在线观看一区| 亚洲欧美日韩国产成人精品影院| 国产亚洲欧美日韩在线一区| 精品少妇一区二区三区在线播放 | 中文字幕一区日韩精品欧美| 日韩精品一区二区三区视频在线观看 | 中文字幕av一区 二区| 日韩欧美一级二级三级久久久 | 91黄色免费版| 99re视频精品| 成人妖精视频yjsp地址| 国产精品一区二区你懂的| 久久99精品国产麻豆不卡| 丝袜诱惑制服诱惑色一区在线观看 | 经典一区二区三区| 欧美影院一区二区三区| 欧美三级电影网| 欧美日韩一区二区在线观看| 欧美色国产精品| 3atv一区二区三区| 日韩免费电影一区| 久久久久久**毛片大全| 国产视频在线观看一区二区三区| 久久久亚洲精品一区二区三区| 国产无遮挡一区二区三区毛片日本| 久久久精品免费免费| 国产精品理论在线观看| 亚洲欧美日韩成人高清在线一区| 亚洲精品成人天堂一二三| 国产91精品露脸国语对白| 成人免费毛片app| 色婷婷国产精品| 在线电影欧美成精品| 精品福利av导航| 亚洲国产成人午夜在线一区 | 亚洲成人动漫一区| 久久爱www久久做| 盗摄精品av一区二区三区| 99精品欧美一区二区蜜桃免费| 欧美日韩一区二区三区在线看| 日韩一级二级三级精品视频| 一区二区欧美精品| 免费观看在线色综合| 久久99精品久久久久久久久久久久| 国产伦精品一区二区三区免费| a亚洲天堂av| 91精品国产综合久久精品app| 欧美成人伊人久久综合网| 亚洲欧洲国产日韩| 三级在线观看一区二区| 国产精品伊人色| 欧美亚洲自拍偷拍| 久久久久久日产精品| 亚洲欧美日韩国产另类专区| 免费视频一区二区| 日韩欧美不卡在线观看视频| 久久久久99精品国产片| 亚洲国产日韩一级| 国产成人久久精品77777最新版本| 91一区二区在线| 精品sm在线观看| 一区二区欧美视频| 成人免费视频视频| 91精品国产综合久久小美女| 国产欧美日韩三级| 久久se精品一区二区| 在线视频中文字幕一区二区| 久久久久一区二区三区四区| 无吗不卡中文字幕| 99久久99精品久久久久久| 亚洲精品中文字幕在线观看| 精品亚洲国产成人av制服丝袜| 91精彩视频在线| 国产精品免费久久久久| 乱一区二区av| 欧美日韩一区三区| 亚洲人亚洲人成电影网站色| 国内精品第一页| 日韩欧美中文字幕一区| 亚洲成人免费在线| 在线免费不卡视频| 亚洲婷婷综合久久一本伊一区 | 国产三级精品三级在线专区| 日韩电影在线免费看| 精品久久久久久久久久久久久久久久久 | 国产精品一区二区久激情瑜伽| 欧美日韩午夜在线视频| 亚洲精品免费看| 91一区二区在线观看| 国产精品久久久久久户外露出| 欧美日精品一区视频| 亚洲情趣在线观看| 91首页免费视频| 亚洲精品亚洲人成人网| 色综合久久99| 综合自拍亚洲综合图不卡区| 国产高清在线观看免费不卡| 精品福利一二区| 韩国视频一区二区| 国产日韩欧美不卡在线| 懂色av一区二区三区免费观看| 国产日产精品1区| 成人永久aaa|