package com.alibaba.druid.sql.dialect.oracle.visitor;

import com.alibaba.druid.sql.ast.expr.SQLBinaryOpExpr;
import com.alibaba.druid.sql.dialect.oracle.ast.expr.OracleMethodInvokeAccessExpr;
import com.alibaba.druid.sql.dialect.oracle.ast.expr.OracleXmlContentExpr;
import com.alibaba.druid.sql.visitor.ParameterizedVisitor;
import com.alibaba.druid.sql.visitor.VisitorFeature;

public class OracleParameterizedOutputVisitor extends OracleOutputVisitor implements ParameterizedVisitor {
   public OracleParameterizedOutputVisitor() {
      this(new StringBuilder());
      this.config(VisitorFeature.OutputParameterized, true);
   }

   public OracleParameterizedOutputVisitor(Appendable appender) {
      super(appender);
      this.config(VisitorFeature.OutputParameterized, true);
   }

   public OracleParameterizedOutputVisitor(Appendable appender, boolean printPostSemi) {
      super(appender, printPostSemi);
      this.config(VisitorFeature.OutputParameterized, true);
   }

   public boolean visit(SQLBinaryOpExpr x) {
      x = SQLBinaryOpExpr.merge(this, x);
      return super.visit((SQLBinaryOpExpr)x);
   }

   public boolean visit(OracleXmlContentExpr x) {
      this.print0(x.getPlaceholder().toString());
      x.getValue().accept(this);
      if (x.isWellformed()) {
         this.print0(" WELLFORMED ");
      }

      return false;
   }

   public boolean visit(OracleMethodInvokeAccessExpr x) {
      x.getMethod().accept(this);
      this.print0(".");
      x.getCall().accept(this);
      return false;
   }
}
