Examples of CommonTree


Examples of org.antlr.runtime.tree.CommonTree

    private final ISqlJetTypeDef type;
    private final List<ISqlJetColumnConstraint> constraints;

    public SqlJetColumnDef(CommonTree ast) throws SqlJetException {
        name = ast.getText();
        CommonTree constraintsNode = (CommonTree) ast.getChild(0);
        assert "constraints".equalsIgnoreCase(constraintsNode.getText());
        List<ISqlJetColumnConstraint> constraints = new ArrayList<ISqlJetColumnConstraint>();
        for (int i = 0; i < constraintsNode.getChildCount(); i++) {
            CommonTree constraintRootNode = (CommonTree) constraintsNode.getChild(i);
            assert "column_constraint".equalsIgnoreCase(constraintRootNode.getText());
            CommonTree constraintNode = (CommonTree) constraintRootNode.getChild(0);
            String constraintType = constraintNode.getText();
            String constraintName = constraintRootNode.getChildCount() > 1 ? constraintRootNode.getChild(1).getText()
                    : null;
            if ("primary".equalsIgnoreCase(constraintType)) {
                constraints.add(new SqlJetColumnPrimaryKey(this, constraintName, constraintNode));
            } else if ("not_null".equalsIgnoreCase(constraintType)) {
                constraints.add(new SqlJetColumnNotNull(this, constraintName, constraintNode));
            } else if ("unique".equalsIgnoreCase(constraintType)) {
                constraints.add(new SqlJetColumnUnique(this, constraintName, constraintNode));
            } else if ("check".equalsIgnoreCase(constraintType)) {
                constraints.add(new SqlJetColumnCheck(this, constraintName, constraintNode));
            } else if ("default".equalsIgnoreCase(constraintType)) {
                constraints.add(new SqlJetColumnDefault(this, constraintName, constraintNode));
            } else if ("collate".equalsIgnoreCase(constraintType)) {
                constraints.add(new SqlJetColumnCollate(this, constraintName, constraintNode));
            } else if ("references".equalsIgnoreCase(constraintType)) {
                constraints.add(new SqlJetColumnForeignKey(constraintName, constraintNode));
            } else if ("is_null".equalsIgnoreCase(constraintType)) {
                constraints.add(new SqlJetColumnNull(this, constraintName, constraintNode));
            } else {
                assert false;
            }
        }
        this.constraints = Collections.unmodifiableList(constraints);
        if (ast.getChildCount() > 1) {
            CommonTree typeNode = (CommonTree) ast.getChild(1);
            assert "type".equalsIgnoreCase(typeNode.getText());
            type = new SqlJetTypeDef(typeNode);
        } else {
            type = null;
        }
    }
View Full Code Here

Examples of org.antlr.runtime.tree.CommonTree

    private final String columnName, tableName, databaseName;

    public SqlJetColumnExpression(CommonTree ast) {
        assert "column_expression".equalsIgnoreCase(ast.getText());
        CommonTree columnNode = (CommonTree) ast.getChild(0);
        columnName = columnNode.getText();
        if (columnNode.getChildCount() > 0) {
            CommonTree tableNode = (CommonTree) columnNode.getChild(0);
            tableName = tableNode.getText();
            databaseName = (tableNode.getChildCount() > 0) ? tableNode.getChild(0).getText() : null;
        } else {
            tableName = null;
            databaseName = null;
        }
    }
View Full Code Here

Examples of org.antlr.runtime.tree.CommonTree

    private final ISqlJetForeignKeyDeferrable deferrable;

    public SqlJetForeignKey(CommonTree ast) {
        assert "references".equalsIgnoreCase(ast.getText());
        foreignTableName = ast.getChild(0).getText();
        CommonTree columnsNode = (CommonTree) ast.getChild(1);
        assert "columns".equalsIgnoreCase(columnsNode.getText());
        List<String> columnNames = new ArrayList<String>();
        for (int i = 0; i < columnsNode.getChildCount(); i++) {
            columnNames.add(columnsNode.getChild(i).getText());
        }
        this.columnNames = Collections.unmodifiableList(columnNames);
        List<ISqlJetForeignKeyAction> actions = new ArrayList<ISqlJetForeignKeyAction>();
        ISqlJetForeignKeyDeferrable deferrable = null;
        for (int i = 2; i < ast.getChildCount(); i++) {
            CommonTree child = (CommonTree) ast.getChild(i);
            if ("deferrable".equalsIgnoreCase(child.getText())) {
                assert deferrable == null;
                deferrable = new SqlJetForeignKeyDeferrable(child);
            } else if ("on".equalsIgnoreCase(child.getText())) {
                actions.add(new SqlJetForeignKeyUpdateAction(child));
            } else if ("match".equalsIgnoreCase(child.getText())) {
                actions.add(new SqlJetForeignKeyMatchAction(child));
            } else {
                assert false;
            }
        }
View Full Code Here

Examples of org.antlr.runtime.tree.CommonTree

    public SqlJetColumnUnique(SqlJetColumnDef column, String name, CommonTree ast) {
        super(column, name);
        assert "unique".equalsIgnoreCase(ast.getText());
        for (int i = 0; i < ast.getChildCount(); i++) {
            CommonTree child = (CommonTree) ast.getChild(i);
            if ("conflict".equalsIgnoreCase(child.getText())) {
                assert child.getChildCount() == 1;
                child = (CommonTree) child.getChild(0);
                conflictAction = SqlJetConflictAction.decode(child.getText());
            } else {
                assert false;
            }
        }
    }
View Full Code Here

Examples of org.antlr.runtime.tree.CommonTree

    public SqlJetColumnNotNull(SqlJetColumnDef column, String name, CommonTree ast) {
        super(column, name);
        assert "not_null".equalsIgnoreCase(ast.getText());
        for (int i = 0; i < ast.getChildCount(); i++) {
            CommonTree child = (CommonTree) ast.getChild(i);
            if ("conflict".equalsIgnoreCase(child.getText())) {
                assert child.getChildCount() == 1;
                child = (CommonTree) child.getChild(0);
                conflictAction = SqlJetConflictAction.decode(child.getText());
            } else {
                assert false;
            }
        }
    }
View Full Code Here

Examples of org.antlr.runtime.tree.CommonTree

    private String sqlStatement;

    private long rowId;

    public SqlJetViewDef(String sql, CommonTree ast) {
        CommonTree optionsNode = (CommonTree) ast.getChild(0);

        sqlStatement = sql;
        temporary = SqlJetTableDef.hasOption(optionsNode, "temporary");
        ifNotExists = SqlJetTableDef.hasOption(optionsNode, "exists");

        CommonTree nameNode = (CommonTree) ast.getChild(1);
        name = nameNode.getText();
        databaseName = nameNode.getChildCount() > 0 ? nameNode.getChild(0).getText() : null;
    }
View Full Code Here

Examples of org.antlr.runtime.tree.CommonTree

    private final List<String> names;
    private final Double size1;
    private final Double size2;

    public SqlJetTypeDef(CommonTree typeNode) {
        CommonTree paramsNode = (CommonTree) typeNode.getChild(0);
        if (paramsNode.getChildCount() > 0) {
            String text = paramsNode.getChild(0).getText();
            size1 = Double.valueOf(text);
        } else {
            size1 = null;
        }
        if (paramsNode.getChildCount() > 1) {
            String text = paramsNode.getChild(1).getText();
            size2 = Double.valueOf(text);
        } else {
            size2 = null;
        }
        List<String> typeNames = new ArrayList<String>();
View Full Code Here

Examples of org.antlr.runtime.tree.CommonTree

    private final String tableName, databaseName;

    public SqlJetInTableExpression(CommonTree ast) throws SqlJetException {
        assert "in_table".equalsIgnoreCase(ast.getText());
        int idx = 0;
        CommonTree child = (CommonTree) ast.getChild(idx++);
        if ("not".equalsIgnoreCase(child.getText())) {
            not = true;
            child = (CommonTree) ast.getChild(idx++);
        } else {
            not = false;
        }
        assert "in".equalsIgnoreCase(child.getText());
        CommonTree tableNode = (CommonTree) child.getChild(0);
        tableName = tableNode.getText();
        if (tableNode.getChildCount() > 0) {
            databaseName = tableNode.getChild(0).getText();
        } else {
            databaseName = null;
        }
        expression = create((CommonTree) ast.getChild(idx));
    }
View Full Code Here

Examples of org.antlr.runtime.tree.CommonTree

    private SqlJetConflictAction conflictAction;
    private String indexName;

    public SqlJetTableIndexConstraint(String name, CommonTree ast) {
        super(name);
        CommonTree columnsNode = (CommonTree) ast.getChild(0);
        assert "columns".equalsIgnoreCase(columnsNode.getText());
        List<String> columns = new ArrayList<String>();
        for (int i = 0; i < columnsNode.getChildCount(); i++) {
            CommonTree child = (CommonTree) columnsNode.getChild(i);
            columns.add(child.getText());
        }
        this.columns = Collections.unmodifiableList(columns);
        if (ast.getChildCount() > 1) {
            CommonTree child = (CommonTree) ast.getChild(1);
            assert "conflict".equalsIgnoreCase(child.getText());
            assert child.getChildCount() == 1;
            child = (CommonTree) child.getChild(0);
            conflictAction = SqlJetConflictAction.decode(child.getText());
        }
    }
View Full Code Here

Examples of org.antlr.runtime.tree.CommonTree

    public SqlJetIndexedColumn(CommonTree ast) {
        name = ast.getText();
        String collation = null;
        SqlJetSortingOrder sortingOrder = null;
        for (int i = 0; i < ast.getChildCount(); i++) {
            CommonTree child = (CommonTree) ast.getChild(i);
            if ("collate".equalsIgnoreCase(child.getText())) {
                collation = child.getChild(0).getText();
            } else if ("asc".equalsIgnoreCase(child.getText())) {
                sortingOrder = SqlJetSortingOrder.ASC;
            } else if ("desc".equalsIgnoreCase(child.getText())) {
                sortingOrder = SqlJetSortingOrder.DESC;
            } else {
                assert false;
            }
        }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.