xmlstartofelement.java

来自「JAVA在编译原理上的应用。」· Java 代码 · 共 59 行

JAVA
59
字号
package lolo.scans;/** A recognizer to scan for <tt>&lt;aElementName</tt>.  * * @author <a href="http://www.inf.uos.de/bernd" target="_blank">Bernd K&uuml;hl</a>           (<a href="mailto:bernd@informatik.uni-osnabrueck.de">bernd@informatik.uni-osnabrueck.de</a>) */public class XMLStartOfElement extends Word {    /** To mark the start of a scan. */    protected boolean start = true;        /** Constructs a <tt>XMLStartOfElement</tt> to the start of the element <tt>elementName</tt>.     *     * @param elementName the element name.     * @throws IllegalArgumentException if <tt>elementName</tt> is <tt>null</tt> or contains no character.     */	public XMLStartOfElement(String elementName) throws IllegalArgumentException {        super(elementName);	}        	public void reset() {        super.reset();        start = true;	}        	public State nextChar(char ch) {        if (start) {            start = false;            return stateObject.set(                ch == '<',  // need more?                false       // found            );        }        return super.nextChar(ch);	}    	public String toString() {        return getClass().getName()+"[<"+word+"]";	}           private static final int ltHashCode = new Character('<').hashCode();    /** Returns a hash code for the object.     *     * @return a hash code for the object.     */    public int hashCode() {        return ltHashCode/2+super.hashCode()/2;    }    /** Indicates whether some other object is "equal to" this one.     *     * @return <tt>true</tt> if the receiver and <tt>obj</tt> are from the same class     * and if the element names are the same, <tt>false</tt> otherwise.     */    public boolean equals(Object obj) {        if (obj == null || !(obj instanceof XMLStartOfElement)) return false;        return super.equals(obj);    }}

⌨️ 快捷键说明

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