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

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


        {if (true) return subSelect;}
    throw new Error("Missing return statement in function");
  }

  final public CreateTable CreateTable() throws ParseException {
        CreateTable createTable = new CreateTable();
        Table table = null;
        ArrayList columnDefinitions = new ArrayList();
        List columnSpecs = null;
        List tableOptions = new ArrayList();
        Token columnName;
        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);
          throw new ParseException();
        }
      }
      jj_consume_token(80);
      label_31:
      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[141] = jj_gen;
          break label_31;
        }
        parameter = CreateParameter();
                                                      tableOptions.add(parameter);
      }
      break;
    default:
      jj_la1[142] = jj_gen;
      ;
    }
                createTable.setTable(table);
                if (indexes.size() > 0)
                        createTable.setIndexes(indexes);
                if (tableOptions.size() > 0)
                        createTable.setTableOptionsStrings(tableOptions);
                if (columnDefinitions.size() > 0)
                        createTable.setColumnDefinitions(columnDefinitions);
                {if (true) return createTable;}
    throw new Error("Missing return statement in function");
  }
View Full Code Here


    FileSystem lfs=FileSystem.getLocal(conf);
    String topschema=getFileContent(lfs,new Path(stormhome,"solr/conf/schema.top.txt"));
    String downschema=getFileContent(lfs,new Path(stormhome,"solr/conf/schema.down.txt"));
    String fieldschema=getFileContent(lfs,new Path(tableConfig));
    CCJSqlParserManager parserManager = new CCJSqlParserManager();
    CreateTable createTable = (CreateTable) parserManager.parse(new StringReader(fieldschema));
    StringBuffer buffer=new StringBuffer();
    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)
View Full Code Here

  }

  public void testCreateTable() throws JSQLParserException {
    String statement = "CREATE TABLE mytab (mycol a (10, 20) c nm g, mycol2 mypar1 mypar2 (23,323,3) asdf ('23','123') dasd, "
        + "PRIMARY KEY (mycol2, mycol)) type = myisam";
    CreateTable createTable = (CreateTable) parserManager.parse(new StringReader(statement));
    assertEquals(2, createTable.getColumnDefinitions().size());
        assertFalse(createTable.isUnlogged());
    assertEquals("mycol", ((ColumnDefinition) createTable.getColumnDefinitions().get(0)).getColumnName());
    assertEquals("mycol2", ((ColumnDefinition) createTable.getColumnDefinitions().get(1)).getColumnName());
    assertEquals("PRIMARY KEY", ((Index) createTable.getIndexes().get(0)).getType());
    assertEquals("mycol", ((Index) createTable.getIndexes().get(0)).getColumnsNames().get(1));
    assertEquals(statement, "" + createTable);
  }
View Full Code Here

  }
   
    public void testCreateTableUnlogged() throws JSQLParserException {
    String statement = "CREATE UNLOGGED TABLE mytab (mycol a (10, 20) c nm g, mycol2 mypar1 mypar2 (23,323,3) asdf ('23','123') dasd, "
        + "PRIMARY KEY (mycol2, mycol)) type = myisam";
    CreateTable createTable = (CreateTable) parserManager.parse(new StringReader(statement));
    assertEquals(2, createTable.getColumnDefinitions().size());
        assertTrue(createTable.isUnlogged());
    assertEquals("mycol", ((ColumnDefinition) createTable.getColumnDefinitions().get(0)).getColumnName());
    assertEquals("mycol2", ((ColumnDefinition) createTable.getColumnDefinitions().get(1)).getColumnName());
    assertEquals("PRIMARY KEY", ((Index) createTable.getIndexes().get(0)).getType());
    assertEquals("mycol", ((Index) createTable.getIndexes().get(0)).getColumnsNames().get(1));
    assertEquals(statement, "" + createTable);
  }
View Full Code Here

        }

        String tableName = getLine(in);
        String cols = getLine(in);
        try {
          CreateTable createTable = (CreateTable) parserManager.parse(new StringReader(query));
          String[] colsList = null;
          if (cols.equals("null")) {
            colsList = new String[0];
          } else {
            StringTokenizer tokenizer = new StringTokenizer(cols, " ");

            List colsListList = new ArrayList();
            while (tokenizer.hasMoreTokens()) {
              colsListList.add(tokenizer.nextToken());
            }

            colsList = (String[]) colsListList.toArray(new String[colsListList.size()]);

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

TOP

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

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.