expression.java
来自「这个文件里面包含了java设计模式的一些例子讲解」· Java 代码 · 共 43 行
JAVA
43 行
package com.javapatterns.interpreter;
/**
* Abstraction of a class representing terminal and non-terminal
* classes of the following little grammar:<br>
* <pre>
* BooleanExp ::=
* BooleanExp AND BooleanExp
* | BooleanExp OR BooleanExp
* | NOT BooleanExp
* | Variable
* | Constant
* Variable ::= ... // a string of printable, non-white space characters
* Contant ::= "true" | "false"
* </pre>
*/
public abstract class Expression {
/**
* Given a BooleanExp object denoting a term,
* this method interprets this term relative to a Context
* object.
*/
public abstract boolean interpret(Context ctx);
/**
* Given a BooleanExp object denoting a term,
* this method test whether the given argument
* denoting another term is structurally the same.
*/
public abstract boolean equals(Object o);
/**
* Returns a hash code of this term.
*/
public abstract int hashCode();
/**
* Converts a term into a string. Can be used as the
* basis for calculating the hashCode.
*/
public abstract String toString();
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?