001 /* 002 * Created on Sep 15, 2003 by Ravi Mohan 003 * 004 */ 005 package aima.logic.propositional.parsing.ast; 006 007 import aima.logic.propositional.parsing.PLVisitor; 008 009 /** 010 * @author Ravi Mohan 011 * 012 */ 013 014 public class Symbol extends AtomicSentence { 015 private String value; 016 017 public Symbol(String value) { 018 this.value = value; 019 } 020 021 @Override 022 public boolean equals(Object o) { 023 024 if (this == o) { 025 return true; 026 } 027 if ((o == null) || (this.getClass() != o.getClass())) { 028 return false; 029 } 030 Symbol sym = (Symbol) o; 031 return (sym.getValue().equals(getValue())); 032 033 } 034 035 @Override 036 public int hashCode() { 037 int result = 17; 038 result = 37 * result + value.hashCode(); 039 return result; 040 } 041 042 public String getValue() { 043 return value; 044 } 045 046 @Override 047 public String toString() { 048 return getValue(); 049 } 050 051 @Override 052 public Object accept(PLVisitor plv, Object arg) { 053 return plv.visitSymbol(this, arg); 054 } 055 056 }