/* Generated By:JJTree: Do not edit this line. ScalarSubquery.java Version 4.3 */ /* JavaCCOptions:MULTI=true,NODE_USES_PARSER=true,VISITOR=true,TRACK_TOKENS=false,NODE_PREFIX=,NODE_EXTENDS=,NODE_FACTORY=,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */ package org.teiid.query.sql.symbol; import org.teiid.designer.annotation.Since; import org.teiid.designer.query.sql.symbol.IScalarSubquery; import org.teiid.designer.runtime.version.spi.ITeiidServerVersion; import org.teiid.designer.runtime.version.spi.TeiidServerVersion.Version; import org.teiid.query.parser.LanguageVisitor; import org.teiid.query.sql.lang.QueryCommand; import org.teiid.query.sql.lang.SimpleNode; import org.teiid.query.sql.lang.SubqueryContainer; import org.teiid.query.sql.lang.SubqueryHint; /** * */ public class ScalarSubquery extends SimpleNode implements Expression, SubqueryContainer<QueryCommand>, IScalarSubquery<LanguageVisitor, QueryCommand> { private QueryCommand command; private Class<?> type; @Since(Version.TEIID_8_10) private SubqueryHint subqueryHint = new SubqueryHint(); private boolean shouldEvaluate; /** * @param p * @param id */ public ScalarSubquery(ITeiidServerVersion p, int id) { super(p, id); } /** * @return the command */ @Override public QueryCommand getCommand() { return command; } /** * @param command the command to set */ @Override public void setCommand(QueryCommand command) { this.command = command; } @Override public Class<?> getType() { if (this.type == null){ Expression symbol = this.command.getProjectedSymbols().iterator().next(); this.type = symbol.getType(); } //may still be null if this.command wasn't resolved return this.type; } /** * Set type of ScalarSubquery * @param type New type */ public void setType(Class<?> type) { this.type = type; } /** * @return sub query hint */ @Since(Version.TEIID_8_10) public SubqueryHint getSubqueryHint() { return subqueryHint; } /** * @param subqueryHint */ @Since(Version.TEIID_8_10) public void setSubqueryHint(SubqueryHint subqueryHint) { this.subqueryHint = subqueryHint; } /** * @return whether to evaluate */ public boolean shouldEvaluate() { return shouldEvaluate; } /** * @param shouldEvaluate */ public void setShouldEvaluate(boolean shouldEvaluate) { this.shouldEvaluate = shouldEvaluate; } @Override public int hashCode() { final int prime = 31; int result = super.hashCode(); result = prime * result + ((this.command == null) ? 0 : this.command.hashCode()); result = prime * result + ((this.type == null) ? 0 : this.type.hashCode()); return result; } @Override public boolean equals(Object obj) { if (this == obj) return true; if (!super.equals(obj)) return false; if (getClass() != obj.getClass()) return false; ScalarSubquery other = (ScalarSubquery)obj; if (this.command == null) { if (other.command != null) return false; } else if (!this.command.equals(other.command)) return false; if (this.type == null) { if (other.type != null) return false; } else if (!this.type.equals(other.type)) return false; if(getTeiidVersion().isGreaterThanOrEqualTo(Version.TEIID_8_10)) { if (this.subqueryHint == null) { if (other.subqueryHint != null) return false; } else if (!this.subqueryHint.equals(other.subqueryHint)) return false; } return true; } /** Accept the visitor. **/ @Override public void acceptVisitor(LanguageVisitor visitor) { visitor.visit(this); } @Override public ScalarSubquery clone() { ScalarSubquery clone = new ScalarSubquery(getTeiidVersion(), this.id); if(getType() != null) clone.setType(getType()); if(getCommand() != null) clone.setCommand(getCommand().clone()); if (getSubqueryHint() != null) { clone.setSubqueryHint(getSubqueryHint().clone()); } return clone; } } /* JavaCC - OriginalChecksum=bfe243691ae4c256b98aff43709faeed (do not edit this line) */