⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 element.java

📁 利用广度优先遍历搜索一定范围内的所有网页,可用于建立搜索引擎和查找网络错误.
💻 JAVA
字号:
/**
 * Represents an HTML element.
 *
 * @author  SeungJin Lim
 * @version 1.0, 2006/10/20
 * @since   JDK1.5
 */
package html;

import java.util.Enumeration;

public class Element {
	
	public Element( String arg ) {
		if( !arg.startsWith("<") || !arg.endsWith(">") );
		int whitespace = arg.indexOf(" "); 
		if( whitespace<0 ) throw new RuntimeException("[Element] invalid anchor tag: "+arg );
		name = arg.substring( 1, whitespace ).toUpperCase();
		attrList = new AttributeList( arg );
	}
	/**
	 * Returns attribute names contained in this element.
	 * @return
	 */
	public Enumeration attributes() {
		return attrList.getAttributes();
	}
	/**
	 * Returns the value of attribute <code>key</code>.
	 * @param key
	 * @return
	 */
	public String attributeValueOf( String key ) {
		return attrList.getAttributeValueOf(key.toUpperCase());
	}
	public String name() {
		return name;
	}
	/**
	 * Sets attribute <code>attr</code> with <code>value</code>.
	 * @param attr
	 * @param value
	 */
	public void setAttribute( String attr, String value ) {
		attrList.putAttributeValueOf( attr, value );
	}
	public String toString() {
		return "<"+name+" "+attrList+">";
	}

	/**
	 * The name of this element:
	 */
	private String name;
	/**
	 * The attribute list in this element:
	 */
	private AttributeList attrList;

}

⌨️ 快捷键说明

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