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


Java ColumnDefinition.getColumnSpecStrings方法代码示例

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


在下文中一共展示了ColumnDefinition.getColumnSpecStrings方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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

示例3: 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

示例4: 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


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