package com.alibaba.druid.sql.dialect.mongo.parser;

import java.util.ArrayList;
import java.util.List;

public class Method {
   private String name;
   private List<String> args = new ArrayList();
   private List<Integer> argsType = new ArrayList();
   private Method next;
   public static final String PLACE_HOLDER_1 = "\"";
   public static final String PLACE_HOLDER_2 = "'";

   public String getName() {
      return this.name;
   }

   public void setName(String name) {
      this.name = name;
   }

   public List<String> getArgs() {
      return this.args;
   }

   public void setArgs(List<String> args) {
      this.args = args;
   }

   public Method getNext() {
      return this.next;
   }

   public void setNext(Method next) {
      this.next = next;
   }

   public String getArgs(int i) {
      return this.unWrap((String)this.args.get(i));
   }

   public String unWrap(String arg) {
      String temp = arg;
      if (arg != null && arg.startsWith("\"") && arg.endsWith("\"")) {
         temp = arg.replaceAll("\"", "");
      }

      if (temp != null && temp.startsWith("\"") && temp.endsWith("\"")) {
         temp = temp.replaceAll("\"", "");
      }

      return temp;
   }

   public List<Integer> getArgsType() {
      return this.argsType;
   }

   public void setArgsType(List<Integer> argsType) {
      this.argsType = argsType;
   }

   public void addArg(String arg, int type) {
      this.getArgs().add(arg);
      this.getArgsType().add(type);
   }
}
