package util.sqlparse.visitor.common.memo;

import com.alibaba.druid.sql.ast.SQLExpr;
import com.alibaba.druid.sql.ast.SQLObject;
import com.alibaba.druid.sql.ast.expr.SQLValuableExpr;
import util.sqlparse.visitor.mongo.MongoNode;

public class ValueMemo {
   private static final String QUESTION_MARK = "?";
   public FieldMemo field;
   public Object value;
   public SQLObject ref;
   public SQLObject expr;
   public MongoNode refMongo;
   public MongoNode nodeMongo;
   public int sequence;
   public String operator;
   public boolean isPreDefined;

   public ValueMemo() {
      this.value = "?";
   }

   public ValueMemo(SQLExpr x) {
      if (x instanceof SQLValuableExpr) {
         this.value = ((SQLValuableExpr)x).getValue();
      } else {
         this.value = x.toString();
      }

      this.isPreDefined = x.toString().equals("?");
   }

   public FieldMemo getField() {
      return this.field;
   }

   public void setField(FieldMemo field) {
      this.field = field;
   }

   public Object getValue() {
      return this.value;
   }

   public void setValue(Object value) {
      this.value = value;
   }

   public SQLObject getRef() {
      return this.ref;
   }

   public void setRef(SQLObject ref) {
      this.ref = ref;
   }

   public SQLObject getExpr() {
      return this.expr;
   }

   public void setExpr(SQLObject expr) {
      this.expr = expr;
   }

   public MongoNode getRefMongo() {
      return this.refMongo;
   }

   public void setRefMongo(MongoNode refMongo) {
      this.refMongo = refMongo;
   }

   public MongoNode getNodeMongo() {
      return this.nodeMongo;
   }

   public void setNodeMongo(MongoNode nodeMongo) {
      this.nodeMongo = nodeMongo;
   }

   public int getSequence() {
      return this.sequence;
   }

   public void setSequence(int sequence) {
      this.sequence = sequence;
   }

   public String getOperator() {
      return this.operator;
   }

   public void setOperator(String operator) {
      this.operator = operator;
   }

   public boolean isPreDefined() {
      return this.isPreDefined;
   }

   public void setPreDefined(boolean preDefined) {
      this.isPreDefined = preDefined;
   }
}
