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

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


      }

      for (Iterator iter = createTable.getIndexes().iterator(); iter.hasNext();) {
        buffer.append(",\n");
        Index index = (Index) iter.next();
        buffer.append(index.getType() + " " + index.getName());
        buffer.append("(");
        for (Iterator iterator = index.getColumnsNames().iterator(); iterator.hasNext();) {
          buffer.append((String) iterator.next());
          if (iterator.hasNext()) {
            buffer.append(", ");
          }
        }
View Full Code Here


        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();
View Full Code Here

              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;
                  }

                }
              }
View Full Code Here

                }

                if (createTable.getIndexes() != null) {
                    for (Iterator<Index> iter = createTable.getIndexes().iterator(); iter.hasNext();) {
                        buffer.append(", ");
                        Index index = iter.next();
                        buffer.append(index.toString());
                    }
                }

                buffer.append(")");
            }
View Full Code Here

  public CreateIndexDeParser(StringBuilder buffer) {
    this.buffer = buffer;
  }

  public void deParse(CreateIndex createIndex) {
    Index index = createIndex.getIndex();

    buffer.append("CREATE ");

    if (index.getType() != null) {
      buffer.append(index.getType());
      buffer.append(" ");
    }

    buffer.append("INDEX ");
    buffer.append(index.getName());
    buffer.append(" ON ");
    buffer.append(createIndex.getTable().getFullyQualifiedName());

    if (index.getColumnsNames() != null) {
      buffer.append(" (");
      for (Iterator iter = index.getColumnsNames().iterator(); iter.hasNext();) {
        String columnName = (String)iter.next();
        buffer.append(columnName);

        if (iter.hasNext()) {
          buffer.append(", ");
View Full Code Here

TOP

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

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.