当前位置: 首页>>代码示例>>Java>>正文


Java ColumnDefinition类代码示例

本文整理汇总了Java中net.sf.jsqlparser.statement.create.table.ColumnDefinition的典型用法代码示例。如果您正苦于以下问题:Java ColumnDefinition类的具体用法?Java ColumnDefinition怎么用?Java ColumnDefinition使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ColumnDefinition类属于net.sf.jsqlparser.statement.create.table包,在下文中一共展示了ColumnDefinition类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: isAutoIncrement

import net.sf.jsqlparser.statement.create.table.ColumnDefinition; //导入依赖的package包/类
private boolean isAutoIncrement(ColumnDefinition definition) {
    List<String> specList = definition.getColumnSpecStrings();

    if (specList != null) {
        String tmpStr;
        int conditionSize = specList.size();
        for (int i = 0; i < conditionSize; i++) {
            tmpStr = specList.get(i).toUpperCase();

            if (tmpStr.equals(Constant.AUTOINCREMENT_VALUE)) {
                return true;
            }
        }
    }

    return false;
}
 
开发者ID:WeiMei-Tian,项目名称:editor-sql,代码行数:18,代码来源:SQLHelper.java

示例2: configurationData

import net.sf.jsqlparser.statement.create.table.ColumnDefinition; //导入依赖的package包/类
/**
 * configurationData函数,辅助填充Database的hashmap函数
 * @param statement 对应的文件中的一条创建数据库请求
 * @throws JSQLParserException
 */
public void configurationData(String statement) throws JSQLParserException {
    CreateTable createTable = (CreateTable) parserManager.parse(new StringReader(statement));
    MTable mtable = new MTable();
    ArrayList<MField> mFields = new ArrayList<MField>(); // field信息用ArrayList进行构造

    for(int i = 0;i < createTable.getColumnDefinitions().size();i++){ // 填充该mtable的field信息
        MField mField = new MField();
        mField.setField(((ColumnDefinition) createTable.getColumnDefinitions().get(i)).getColumnName().split("`")[1], ((ColumnDefinition) createTable.getColumnDefinitions().get(i)).getColumnSpecStrings().get(1),((ColumnDefinition)createTable.getColumnDefinitions().get(i)).getColDataType().toString().split(" ")[0]);
        mFields.add(mField);
    }
    // 填充mtable
    mtable.set_mTable(createTable.getTable().getName().split("`")[1],"JData", createTable.getColumnDefinitions().size(),mFields);
    // 填充hashmap
    this.DataBase.put(createTable.getTable().getName().split("`")[1], mtable);

}
 
开发者ID:bigdataFlySQL,项目名称:SQLonStorm,代码行数:22,代码来源:Global.java

示例3: visit

import net.sf.jsqlparser.statement.create.table.ColumnDefinition; //导入依赖的package包/类
@Override
public void visit(CreateTable s) {
    visit(s.getTable());
    for (ColumnDefinition def : s.getColumnDefinitions()) {
        def.setColumnName(CompatibilityUtils.fixMySqlName(def.getColumnName()));
    }
    if (s.getIndexes() != null) {
        for (Index index : s.getIndexes()) {
            visit(index);
        }
    }
}
 
开发者ID:diennea,项目名称:herddb,代码行数:13,代码来源:JdbcQueryRewriter.java

示例4: extractColumns

import net.sf.jsqlparser.statement.create.table.ColumnDefinition; //导入依赖的package包/类
private LinkedList<Column> extractColumns(CreateTable createStatement) {
    LinkedList<Column> columns = Lists.newLinkedList();
    List<ColumnDefinition> columnDefinitions = createStatement.getColumnDefinitions();
    for (ColumnDefinition c:columnDefinitions){
        Column.ColumnBuilder cBuilder = new Column.ColumnBuilder();
        cBuilder.withName(c.getColumnName().toUpperCase());
        cBuilder.withType(c.getColDataType().getDataType());
        columns.add(cBuilder.build());
    }
    return columns;
}
 
开发者ID:jadetang,项目名称:maliang,代码行数:12,代码来源:JavaDataBaseRelationBuilder.java

示例5: extractFields

import net.sf.jsqlparser.statement.create.table.ColumnDefinition; //导入依赖的package包/类
private LinkedList<JavaField> extractFields(CreateTable createStatement) {
    LinkedList<JavaField> javaFields = Lists.newLinkedList();
    List<ColumnDefinition> columnDefinitions = createStatement.getColumnDefinitions();
    for (ColumnDefinition c:columnDefinitions){
        javaFields.add(convertColumnToField(c));
    }
    return javaFields;
}
 
开发者ID:jadetang,项目名称:maliang,代码行数:9,代码来源:JavaDataBaseRelationBuilder.java

示例6: convertColumnToField

import net.sf.jsqlparser.statement.create.table.ColumnDefinition; //导入依赖的package包/类
private JavaField convertColumnToField(ColumnDefinition columnDefinition){
    JavaFieldBuilder jfBuilder = new JavaFieldBuilder();
    String columnName = columnDefinition.getColumnName();
    String javaFieldName = transformName(columnName,columnPrefix,separator);
    jfBuilder.withName(javaFieldName);
    String javaType = mConfig.getJavaType(columnDefinition.getColDataType().getDataType());
    jfBuilder.withType(javaType);
    return jfBuilder.build();
}
 
开发者ID:jadetang,项目名称:maliang,代码行数:10,代码来源:JavaDataBaseRelationBuilder.java

示例7: testCreateTable

import net.sf.jsqlparser.statement.create.table.ColumnDefinition; //导入依赖的package包/类
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());
	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);
}
 
开发者ID:UBOdin,项目名称:jsqlparser,代码行数:13,代码来源:CreateTableTest.java

示例8: testCreateTable

import net.sf.jsqlparser.statement.create.table.ColumnDefinition; //导入依赖的package包/类
@Test
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());
    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);
}
 
开发者ID:marat-gainullin,项目名称:platypus-js,代码行数:14,代码来源:CreateTableTest.java

示例9: addColumn

import net.sf.jsqlparser.statement.create.table.ColumnDefinition; //导入依赖的package包/类
public int addColumn(String tableName, NewColumnField columnField) throws Exception {
    String tmpTableName = "@[email protected]";
    dropTable(tmpTableName);

    try {
        _db.beginTransaction();

        List<String> list = getColumnFieldNameList(tableName);
        String oldColumns = "";
        for (String str : list) {
            if (TextUtils.isEmpty(oldColumns)) {
                oldColumns = "'" + str + "'";
            } else {
                oldColumns = oldColumns + "," + "'" + str + "'";
            }
        }

        //1:获取原始表的sql
        String sql = "SELECT sql FROM sqlite_master WHERE type='table' AND name='" + tableName + "'";

        Cursor cursor = _db.rawQuery(sql, null);
        if (cursor == null) return Constant.FAIL;

        if (!cursor.moveToFirst()) {
            cursor.close();
            return Constant.FAIL;
        }

        String sqlStr = cursor.getString(0);
        cursor.close();

        if (TextUtils.isEmpty(sqlStr)) return Constant.FAIL;

        CreateTable select = (CreateTable) CCJSqlParserUtil.parse(sqlStr);
        List<ColumnDefinition> columnsNames = select.getColumnDefinitions();

        ColumnDefinition newDefinition = new ColumnDefinition();
        newDefinition.setColumnName(columnField.getFieldName());
        newDefinition.setColumnSpecStrings(SQLTools.getConditionList(columnField));

        ColDataType type = new ColDataType();
        type.setDataType(columnField.getFieldType());
        newDefinition.setColDataType(type);
        columnsNames.add(newDefinition);

        Table table = select.getTable();
        table.setName("'" + tmpTableName + "'");
        select.setTable(table);
        Logger.d(select);

        sql = select.toString();
        _db.execSQL(sql);

        sql = "INSERT INTO '" + tmpTableName + "' (" + oldColumns + ") SELECT * FROM '" + tableName + "'";
        _db.execSQL(sql);

        sql = "DROP TABLE IF EXISTS '" + tableName + "'";
        _db.execSQL(sql);

        sql = "ALTER TABLE '" + tmpTableName + "' RENAME TO '" + tableName + "'";
        _db.execSQL(sql);

        _db.setTransactionSuccessful();

    } catch (Exception e) {
        e.printStackTrace();
        return Constant.FAIL;

    } finally {
        SQLManager.getSQLHelper()._db.endTransaction();
    }


    return Constant.SUCCESS;
}
 
开发者ID:WeiMei-Tian,项目名称:editor-sql,代码行数:76,代码来源:SQLHelper.java

示例10: getAutoincrementColumn

import net.sf.jsqlparser.statement.create.table.ColumnDefinition; //导入依赖的package包/类
public List<ColumnField> getAutoincrementColumn(String tableName) {
    List<ColumnField> columnFieldList = new LinkedList<>();

    if (!isDBOk()) {
        return columnFieldList;
    }

    String sql = "SELECT sql FROM sqlite_master WHERE type='table' AND name='" + tableName + "'";
    Cursor cursor = _db.rawQuery(sql, null);
    if (cursor == null) return columnFieldList;

    if (!cursor.moveToFirst()) {
        cursor.close();
        return columnFieldList;
    }

    String sqlStr = cursor.getString(0);
    cursor.close();

    if (TextUtils.isEmpty(sqlStr)) return columnFieldList;

    try {
        CreateTable createTable = (CreateTable) CCJSqlParserUtil.parse(sqlStr);
        List<ColumnDefinition> columnList = createTable.getColumnDefinitions();

        ColumnField field;
        List<String> specList;
        for (ColumnDefinition definition : columnList) {

            field = new ColumnField();
            field.setFieldName(SQLTools.removeColumnMark(definition.getColumnName()));
            field.setFieldType(SQLTools.removeColumnMark(definition.getColDataType().getDataType()));

            specList = definition.getColumnSpecStrings();
            if (specList != null) {
                String tmpStr;
                int next;
                int conditionSize = specList.size();
                for (int i = 0; i < conditionSize; i++) {
                    next = i + 1;
                    tmpStr = specList.get(i).toUpperCase();

                    if (tmpStr.equals(Constant.PRIMARY_VALUE)) {
                        field.setPk(1);
                    }

                    if (tmpStr.equals(Constant.AUTOINCREMENT_VALUE)) {
                        field.setIsAutoIncr(true);
                    }

                    if (tmpStr.equals(Constant.NOT_VALUE) &&
                            specList.get(next).toUpperCase().equals(Constant.NULL_VALUE)) {
                        field.setNotNull(1);
                    }

                    if (tmpStr.equals(Constant.DEFAULT_VALUE)) {
                        if (next < conditionSize && !TextUtils.isEmpty(specList.get(next))) {
                            field.setDef(SQLTools.removeColumnMark(specList.get(next)));
                        }
                    }
                }
            }

            columnFieldList.add(field);
            Logger.d("--------" + field.toString());
        }

    } catch (JSQLParserException e) {
        e.printStackTrace();
    }

    return columnFieldList;
}
 
开发者ID:WeiMei-Tian,项目名称:editor-sql,代码行数:74,代码来源:SQLHelper.java

示例11: deParse

import net.sf.jsqlparser.statement.create.table.ColumnDefinition; //导入依赖的package包/类
public void deParse(CreateTable createTable) {
    buffer.append("CREATE ");
    if (createTable.isUnlogged()) {
        buffer.append("UNLOGGED ");
    }
    String params = PlainSelect.getStringList(createTable.getCreateOptionsStrings(), false, false);
    if (!"".equals(params)) {
        buffer.append(params).append(' ');
    }

    buffer.append("TABLE ");
    if (createTable.isIfNotExists()) {
        buffer.append("IF NOT EXISTS ");
    }
    buffer.append(createTable.getTable().getFullyQualifiedName());
    if (createTable.getSelect() != null) {
        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);
                    }
                }

                if (iter.hasNext()) {
                    buffer.append(", ");
                }
            }

            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(")");
        }
    }

    params = PlainSelect.getStringList(createTable.getTableOptionsStrings(), false, false);
    if (!"".equals(params)) {
        buffer.append(' ').append(params);
    }
}
 
开发者ID:WeiMei-Tian,项目名称:editor-sql,代码行数:55,代码来源:CreateTableDeParser.java

示例12: deParse

import net.sf.jsqlparser.statement.create.table.ColumnDefinition; //导入依赖的package包/类
public void deParse(CreateTable aCreateTable) {
    buffer.append(aCreateTable.getComment() != null ? aCreateTable.getComment() + " " + ExpressionDeParser.LINE_SEPARATOR : "").append("Create");
    for (int i = 0; i < aCreateTable.getCreateOptions().size(); i++) {
        buffer.append(!"".equals(aCreateTable.getCommentCreateOptions().get(i)) ? " " + aCreateTable.getCommentCreateOptions().get(i) + " " + ExpressionDeParser.LINE_SEPARATOR : "");
        buffer.append(aCreateTable.getCreateOptions().get(i));
    }
    buffer.append(aCreateTable.getCommentTable() != null ? " " + aCreateTable.getCommentTable() + ExpressionDeParser.LINE_SEPARATOR : "").append(" table ").append(aCreateTable.getComment() != null ? aCreateTable.getComment() + " " + ExpressionDeParser.LINE_SEPARATOR : "").append(aCreateTable.getTable().getWholeTableName());
    if (aCreateTable.getColumnDefinitions() != null) {
        buffer.append(aCreateTable.getCommentBeginBracket() != null ? " " + aCreateTable.getCommentBeginBracket() + ExpressionDeParser.LINE_SEPARATOR : "").append(" ( ");

        for (int i = 0; i < aCreateTable.getColumnDefinitions().size(); i++) {
            ColumnDefinition columnDefinition = (ColumnDefinition) aCreateTable.getColumnDefinitions().get(i);
            buffer.append(columnDefinition.getCommentName() != null ? columnDefinition.getCommentName() + " " + ExpressionDeParser.LINE_SEPARATOR : "");
            buffer.append(columnDefinition.getColumnName());
            buffer.append(" ");
            buffer.append(columnDefinition.getColDataType().toString());

            if (columnDefinition.getColumnSpecStrings() != null) {
                for (int j = 0; j < columnDefinition.getColumnSpecStrings().size(); j++) {
                    buffer.append(" ");
                    buffer.append(!"".equals(columnDefinition.getCommentsSpec().get(i)) ? columnDefinition.getCommentsSpec().get(i) + " " + ExpressionDeParser.LINE_SEPARATOR : "");
                    buffer.append((String) columnDefinition.getColumnSpecStrings().get(i));
                }
            }

            if (i < aCreateTable.getColumnDefinitions().size() - 1) {
                buffer.append(!"".equals(aCreateTable.getCommentCommaIndexes().get(i)) ? " " + aCreateTable.getCommentCommaIndexes().get(i) + ExpressionDeParser.LINE_SEPARATOR : "").append(", ");
            }
        }
        int shift = aCreateTable.getColumnDefinitions().size() - 1;
        for (int i = 0; i < aCreateTable.getIndexes().size(); i++) {
            buffer.append(!"".equals(aCreateTable.getCommentCommaIndexes().get(i + shift)) ? aCreateTable.getCommentCommaIndexes().get(i + shift) + " " + ExpressionDeParser.LINE_SEPARATOR : "");
            buffer.append(",").append(ExpressionDeParser.LINE_SEPARATOR);
            Index index = (Index) aCreateTable.getIndexes().get(i);
            buffer.append(index.toString());
        }
        buffer.append(" ").append(aCreateTable.getCommentEndBracket() != null ? aCreateTable.getCommentEndBracket() + " " : "").append(ExpressionDeParser.LINE_SEPARATOR).append(") ");
    }

    for (int i = 0; i < aCreateTable.getTableOptionsStrings().size(); i++) {
        buffer.append(!"".equals(aCreateTable.getCommentTableOptions().get(i)) ? aCreateTable.getCommentTableOptions().get(i) + " " + ExpressionDeParser.LINE_SEPARATOR : "");
        buffer.append(aCreateTable.getTableOptionsStrings().get(i));
        buffer.append(" ");
    }
    buffer.append(!"".equals(aCreateTable.getEndComment()) ? " " + aCreateTable.getEndComment() : "");
}
 
开发者ID:marat-gainullin,项目名称:platypus-js,代码行数:47,代码来源:CreateTableDeParser.java

示例13: convertColumnDef

import net.sf.jsqlparser.statement.create.table.ColumnDefinition; //导入依赖的package包/类
private CreateTableQuery.ColumnDefinition convertColumnDef(ColumnDefinition columnDefinition) {
    String columnName = columnDefinition.getColumnName();
    Type type = convertDataType(columnDefinition.getColDataType());
    return new CreateTableQuery.ColumnDefinition(columnName, type);
}
 
开发者ID:SerCeMan,项目名称:cjdb,代码行数:6,代码来源:QueryParserImpl.java


注:本文中的net.sf.jsqlparser.statement.create.table.ColumnDefinition类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。