simplehtmltoken.java

来自「网络实验参考资料,希望对大家有点用,也是希望资源共享啊」· Java 代码 · 共 89 行

JAVA
89
字号
package bplatt.spider;

/**
 * SimpleHTMLToken - an HTML Token
 * Copyright 2002, Robert L. Platt, All rights reserved
 * @author Robert L. Platt 
 * 
 */

import java.io.*;

public class SimpleHTMLToken {
	public static final int TAG = 0;
	public static final int ENDTAG = 1;
	public static final int CONTENT = 2;
	private static final int UNDEFINED = -1;

	private int type;
	private String content;
	
	/**
	 * Constructor for SimpleHTMLToken.
	 */
	public SimpleHTMLToken() { 
		type = UNDEFINED;
		content = null;
	}
	
	/**
	 * Constructor for SimpleHTMLToken.
	 */
	public SimpleHTMLToken(int type, String content) {
		this.type = type;
		this.content = content;
	}	
	
	/**
	 * Returns the content.
	 * @return String
	 */
	public String getContent() {
		return content;
	}

	/**
	 * Returns the type.
	 * @return int
	 */
	public int getType() {
		return type;
	}

	/**
	 * Sets the content.
	 * @param content The content to set
	 */
	public void setContent(String content) {
		this.content = content;
	}

	/**
	 * Sets the type.
	 * @param type The type to set
	 */
	public void setType(int type) {
		this.type = type;
	}
	
	/**
	 * dump - used for debugging
	 */
	public void dump(PrintStream out)
	{
		switch(type) {
			case UNDEFINED:	out.println("Error!");		
								break;
			case TAG:			out.println("<" + content + ">");
								break;
			case ENDTAG:		out.println("</"+ content + ">");
								break;
			case CONTENT:		out.println("\"" + content + "\"");
								break;
			default:			out.println("Error!");
								break;
		}
	
	}
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?