Package net.sf.jsqlparser.statement.create.table

Examples of net.sf.jsqlparser.statement.create.table.ColumnDefinition


        Token tk = null;
        Token tk2 = null;
        Token tk3 = null;
        ColDataType colDataType = null;
        String stringList = null;
        ColumnDefinition coldef = null;
        List indexes = new ArrayList();
        List colNames = null;
        Index index = null;
        String parameter = null;
    jj_consume_token(K_CREATE);
    label_27:
    while (true) {
      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
      case K_KEY:
      case K_NOT:
      case K_NULL:
      case K_PRIMARY:
      case S_DOUBLE:
      case S_INTEGER:
      case S_IDENTIFIER:
      case S_CHAR_LITERAL:
      case 77:
      case 79:
        ;
        break;
      default:
        jj_la1[136] = jj_gen;
        break label_27;
      }
      CreateParameter();
    }
    jj_consume_token(K_TABLE);
    table = Table();
    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
    case 79:
      jj_consume_token(79);
      columnName = jj_consume_token(S_IDENTIFIER);
      colDataType = ColDataType();
                        columnSpecs = new ArrayList();
      label_28:
      while (true) {
        switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
        case K_KEY:
        case K_NOT:
        case K_NULL:
        case K_PRIMARY:
        case S_DOUBLE:
        case S_INTEGER:
        case S_IDENTIFIER:
        case S_CHAR_LITERAL:
        case 77:
        case 79:
          ;
          break;
        default:
          jj_la1[137] = jj_gen;
          break label_28;
        }
        parameter = CreateParameter();
                                                columnSpecs.add(parameter);
      }
                        coldef = new ColumnDefinition();
                        coldef.setColumnName(columnName.image);
                        coldef.setColDataType(colDataType);
                        if (columnSpecs.size() > 0)
                                coldef.setColumnSpecStrings(columnSpecs);
                        columnDefinitions.add(coldef);
      label_29:
      while (true) {
        switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
        case 78:
          ;
          break;
        default:
          jj_la1[138] = jj_gen;
          break label_29;
        }
        jj_consume_token(78);
        switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
        case K_INDEX:
          tk = jj_consume_token(K_INDEX);
          tk3 = jj_consume_token(S_IDENTIFIER);
          colNames = ColumnsNamesList();
                                                        index = new Index();
                                                        index.setType(tk.image);
                                                        index.setName(tk3.image);
                                                        index.setColumnsNames(colNames);
                                                        indexes.add(index);
          break;
        case K_PRIMARY:
          tk = jj_consume_token(K_PRIMARY);
          tk2 = jj_consume_token(K_KEY);
          colNames = ColumnsNamesList();
                                                        index = new Index();
                                                        index.setType(tk.image + " "+ tk2.image);
                                                        index.setColumnsNames(colNames);
                                                        indexes.add(index);
          break;
        case K_KEY:
          tk = jj_consume_token(K_KEY);
          tk3 = jj_consume_token(S_IDENTIFIER);
          colNames = ColumnsNamesList();
                                                        index = new Index();
                                                        index.setType(tk.image);
                                                        index.setName(tk3.image);
                                                        index.setColumnsNames(colNames);
                                                        indexes.add(index);
          break;
        case S_IDENTIFIER:
          columnName = jj_consume_token(S_IDENTIFIER);
          colDataType = ColDataType();
                                                columnSpecs = new ArrayList();
          label_30:
          while (true) {
            switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
            case K_KEY:
            case K_NOT:
            case K_NULL:
            case K_PRIMARY:
            case S_DOUBLE:
            case S_INTEGER:
            case S_IDENTIFIER:
            case S_CHAR_LITERAL:
            case 77:
            case 79:
              ;
              break;
            default:
              jj_la1[139] = jj_gen;
              break label_30;
            }
            parameter = CreateParameter();
                                                                              columnSpecs.add(parameter);
          }
                                                coldef = new ColumnDefinition();
                                                coldef.setColumnName(columnName.image);
                                                coldef.setColDataType(colDataType);
                                                if (columnSpecs.size() > 0)
                                                        coldef.setColumnSpecStrings(columnSpecs);
                                                columnDefinitions.add(coldef);
          break;
        default:
          jj_la1[140] = jj_gen;
          jj_consume_token(-1);
View Full Code Here


    String tableName=createTable.getTable().getName();
    buffer.append("\r\n");

    for(int i=0;i<createTable.getColumnDefinitions().size();i++)
    {
      ColumnDefinition col=(ColumnDefinition)createTable.getColumnDefinitions().get(i);
      String colname=col.getColumnName();
      String[] coltype=col.getColDataType().getDataType().split("_mdrill_");
      String type=coltype[0];
      String fieldstore=store;
      if(coltype.length>1)
      {
        fieldstore=coltype[1];
View Full Code Here

  public void deParse(CreateTable createTable) {
    buffer.append("CREATE TABLE " + createTable.getTable().getWholeTableName());
    if (createTable.getColumnDefinitions() != null) {
      buffer.append(" { ");
      for (Iterator iter = createTable.getColumnDefinitions().iterator(); iter.hasNext();) {
        ColumnDefinition columnDefinition = (ColumnDefinition) iter.next();
        buffer.append(columnDefinition.getColumnName());
        buffer.append(" ");
        buffer.append(columnDefinition.getColDataType().getDataType());
        if (columnDefinition.getColDataType().getArgumentsStringList() != null) {
          for (Iterator iterator = columnDefinition.getColDataType().getArgumentsStringList().iterator(); iterator.hasNext();) {
            buffer.append(" ");
            buffer.append((String) iterator.next());
          }
        }
        if (columnDefinition.getColumnSpecStrings() != null) {
          for (Iterator iterator = columnDefinition.getColumnSpecStrings().iterator(); iterator.hasNext();) {
            buffer.append(" ");
            buffer.append((String) iterator.next());
          }
        }
View Full Code Here

          }
          List colsFound = new ArrayList();
          if (createTable.getColumnDefinitions() != null) {
            for (Iterator iter = createTable.getColumnDefinitions().iterator(); iter.hasNext();) {
              ColumnDefinition columnDefinition = (ColumnDefinition) iter.next();
              String colName = columnDefinition.getColumnName();
              boolean unique = false;
              if (createTable.getIndexes() != null) {
                for (Iterator iterator = createTable.getIndexes().iterator(); iterator.hasNext();) {
                  Index index = (Index) iterator.next();
                  if (index.getType().equals("PRIMARY KEY") && index.getColumnsNames().size() == 1
                      && index.getColumnsNames().get(0).equals(colName)) {
                    unique = true;
                  }

                }
              }

              if (!unique) {
                if (columnDefinition.getColumnSpecStrings() != null) {
                  for (Iterator iterator = columnDefinition.getColumnSpecStrings().iterator(); iterator
                      .hasNext();) {
                    String par = (String) iterator.next();
                    if (par.equals("UNIQUE")) {
                      unique = true;
                    } else if (par.equals("PRIMARY") && iterator.hasNext()
View Full Code Here

            buffer.append(" AS ").append(createTable.getSelect().toString());
        } else {
            if (createTable.getColumnDefinitions() != null) {
                buffer.append(" (");
                for (Iterator<ColumnDefinition> iter = createTable.getColumnDefinitions().iterator(); iter.hasNext();) {
                    ColumnDefinition columnDefinition = iter.next();
                    buffer.append(columnDefinition.getColumnName());
                    buffer.append(" ");
                    buffer.append(columnDefinition.getColDataType().toString());
                    if (columnDefinition.getColumnSpecStrings() != null) {
                        for (String s : columnDefinition.getColumnSpecStrings()) {
                            buffer.append(" ");
                            buffer.append(s);
                        }
                    }
View Full Code Here

TOP

Related Classes of net.sf.jsqlparser.statement.create.table.ColumnDefinition

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.