/* Generated By:JJTree: Do not edit this line. AssignmentStatement.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.proc; import org.teiid.designer.query.sql.proc.IAssignmentStatement; import org.teiid.query.parser.LanguageVisitor; import org.teiid.query.parser.TeiidNodeFactory.ASTNodes; import org.teiid.designer.runtime.version.spi.ITeiidServerVersion; import org.teiid.query.sql.lang.Command; import org.teiid.query.sql.lang.Query; import org.teiid.query.sql.lang.QueryCommand; import org.teiid.query.sql.symbol.ElementSymbol; import org.teiid.query.sql.symbol.Expression; import org.teiid.query.sql.symbol.ScalarSubquery; /** * */ public class AssignmentStatement extends Statement implements ExpressionStatement, IAssignmentStatement<Expression, LanguageVisitor> { // the variable to which a value is assigned private ElementSymbol variable; private Expression value; private Command command; /** * @param p * @param id */ public AssignmentStatement(ITeiidServerVersion p, int id) { super(p, id); } /** * Return the type for this statement, this is one of the types * defined on the statement object. * @return The type of this statement */ @Override public StatementType getType() { return StatementType.TYPE_ASSIGNMENT; } /** * @return command */ @Deprecated public Command getCommand() { if (command != null) { return command; } if (value instanceof ScalarSubquery && ((ScalarSubquery)value).getCommand() instanceof Query) { Query query = (Query)((ScalarSubquery)value).getCommand(); if (query.getInto() != null) { return query; } } return null; } /** * @param command */ public void setCommand(Command command) { if (command instanceof QueryCommand) { ScalarSubquery ssq = createASTNode(ASTNodes.SCALAR_SUBQUERY); ssq.setCommand((QueryCommand) command); this.value = ssq; } else this.command = command; } /** * @see #getExpression() */ @Override @Deprecated public Expression getValue() { return value; } /** * @see #setExpression(Expression) */ @Override @Deprecated public void setValue(Expression value) { this.value = value; } @Override public Expression getExpression() { return this.value; } /** * @param expression */ public void setExpression(Expression expression) { this.value = expression; } /** * Get the expression giving the value that is assigned to the variable. * @return An <code>Expression</code> with the value */ @Override public ElementSymbol getVariable() { return this.variable; } /** * Set the variable that is assigned to the value * * @param variable <code>ElementSymbol</code> that is being assigned */ public void setVariable(ElementSymbol variable) { this.variable = variable; } @Override public Class<?> getExpectedType() { if (this.variable == null) { return null; } return this.variable.getType(); } @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.value == null) ? 0 : this.value.hashCode()); result = prime * result + ((this.variable == null) ? 0 : this.variable.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; AssignmentStatement other = (AssignmentStatement)obj; if (this.command == null) { if (other.command != null) return false; } else if (!this.command.equals(other.command)) return false; if (this.value == null) { if (other.value != null) return false; } else if (!this.value.equals(other.value)) return false; if (this.variable == null) { if (other.variable != null) return false; } else if (!this.variable.equals(other.variable)) return false; return true; } /** Accept the visitor. **/ @Override public void acceptVisitor(LanguageVisitor visitor) { visitor.visit(this); } @Override public AssignmentStatement clone() { AssignmentStatement clone = new AssignmentStatement(getTeiidVersion(), this.id); if(getExpression() != null) clone.setExpression(getExpression().clone()); if(getCommand() != null) clone.setCommand(getCommand().clone()); if(getVariable() != null) clone.setVariable(getVariable().clone()); if(getValue() != null) clone.setValue(getValue().clone()); return clone; } } /* JavaCC - OriginalChecksum=9d8e32dbc35c1c90feaec305fa14473f (do not edit this line) */