Package org.modeshape.sequencer.ddl.datatype

Examples of org.modeshape.sequencer.ddl.datatype.DataType


            if (tokens.matches("DEFAULT")) {
                parseDefaultClause(tokens, columnNode);
            } else if (tokens.canConsume("SET")) {
                if (tokens.canConsume("DATA", "TYPE")) {
                    DataType datatype = getDatatypeParser().parse(tokens);

                    columnNode.setProperty(StandardDdlLexicon.DATATYPE_NAME, datatype.getName());
                    if (datatype.getLength() >= 0) {
                        columnNode.setProperty(StandardDdlLexicon.DATATYPE_LENGTH, datatype.getLength());
                    }
                    if (datatype.getPrecision() >= 0) {
                        columnNode.setProperty(StandardDdlLexicon.DATATYPE_PRECISION, datatype.getPrecision());
                    }
                    if (datatype.getScale() >= 0) {
                        columnNode.setProperty(StandardDdlLexicon.DATATYPE_SCALE, datatype.getScale());
                    }

                } else if (tokens.canConsume("INCREMENT")) {
                    tokens.consume("BY", TokenStream.ANY_VALUE);
                }
View Full Code Here


        // (i INT GENERATED BY DEFAULT AS IDENTITY (START WITH 2, INCREMENT BY 1),
        // ch CHAR(50));

        tokens.canConsume("COLUMN"); // FOR ALTER TABLE ADD [COLUMN] case
        String columnName = parseName(tokens);
        DataType datatype = getDatatypeParser().parse(tokens);

        AstNode columnNode = nodeFactory().node(columnName, tableNode, TYPE_COLUMN_DEFINITION);

        columnNode.setProperty(StandardDdlLexicon.DATATYPE_NAME, datatype.getName());
        if (datatype.getLength() >= 0) {
            columnNode.setProperty(StandardDdlLexicon.DATATYPE_LENGTH, datatype.getLength());
        }
        if (datatype.getPrecision() >= 0) {
            columnNode.setProperty(StandardDdlLexicon.DATATYPE_PRECISION, datatype.getPrecision());
        }
        if (datatype.getScale() >= 0) {
            columnNode.setProperty(StandardDdlLexicon.DATATYPE_SCALE, datatype.getScale());
        }

        // Now clauses and constraints can be defined in any order, so we need to keep parsing until we get to a comma
        // Now clauses and constraints can be defined in any order, so we need to keep parsing until we get to a comma
        StringBuilder unusedTokensSB = new StringBuilder();
View Full Code Here

            return super.isCustomDataType(tokens);
        }

        @Override
        protected DataType parseApproxNumericType( DdlTokenStream tokens ) throws ParsingException {
            DataType dType = super.parseApproxNumericType(tokens);
            tokens.canConsume("UNSIGNED");
            tokens.canConsume("ZEROFILL");
            tokens.canConsume("UNSIGNED");
            return dType;
        }
View Full Code Here

            return super.parseBitStringType(tokens);
        }

        @Override
        protected DataType parseCharStringType( DdlTokenStream tokens ) throws ParsingException {
            DataType result = super.parseCharStringType(tokens);

            tokens.canConsume("FOR", "BIT", "DATA");

            return result;
        }
View Full Code Here

            return result;
        }

        @Override
        protected DataType parseCustomType( DdlTokenStream tokens ) throws ParsingException {
            DataType dataType = null;

            if (tokens.matches(DTYPE_FIXED) || tokens.matches(DTYPE_DOUBLE)) {
                dataType = new DataType();
                String typeName = tokens.consume();
                dataType.setName(typeName);

                int precision = 0;
                int scale = 0;

                if (tokens.matches(L_PAREN)) {
                    consume(tokens, dataType, false, L_PAREN);
                    precision = (int)parseLong(tokens, dataType);
                    if (tokens.canConsume(COMMA)) {
                        scale = (int)parseLong(tokens, dataType);
                    } else {
                        scale = getDefaultScale();
                    }
                    tokens.consume(R_PAREN);
                } else {
                    precision = getDefaultPrecision();
                    scale = getDefaultScale();
                }
                dataType.setPrecision(precision);
                dataType.setScale(scale);
            } else if (tokens.matches(DTYPE_MEDIUMBLOB) || tokens.matches(DTYPE_LONGBLOB) || tokens.matches(DTYPE_BLOB)
                       || tokens.matches(DTYPE_TINYBLOB) || tokens.matches(DTYPE_YEAR) || tokens.matches(DTYPE_DATETIME)
                       || tokens.matches(DTYPE_BOOLEAN) || tokens.matches(DTYPE_BOOL)) {
                String typeName = tokens.consume();
                dataType = new DataType(typeName);
            } else if (tokens.matches(DTYPE_MEDIUMINT) || tokens.matches(DTYPE_TINYINT) || tokens.matches(DTYPE_VARBINARY)
                       || tokens.matches(DTYPE_BINARY) || tokens.matches(DTYPE_BIGINT)) {
                String typeName = tokens.consume();
                dataType = new DataType(typeName);
                long length = getDefaultLength();
                if (tokens.matches(L_PAREN)) {
                    length = parseBracketedLong(tokens, dataType);
                }
                dataType.setLength(length);
            } else if (tokens.matches(DTYPE_NATIONAL_VARCHAR)) {
                String typeName = getStatementTypeName(DTYPE_NATIONAL_VARCHAR);
                dataType = new DataType(typeName);
                tokens.consume(DTYPE_NATIONAL_VARCHAR);
                long length = getDefaultLength();
                if (tokens.matches(L_PAREN)) {
                    length = parseBracketedLong(tokens, dataType);
                }
                dataType.setLength(length);
            } else if (tokens.matches(DTYPE_MEDIUMTEXT) || tokens.matches(DTYPE_TEXT) || tokens.matches(DTYPE_LONGTEXT)
                       || tokens.matches(DTYPE_TINYTEXT)) {
                String typeName = tokens.consume();
                dataType = new DataType(typeName);
                tokens.canConsume("BINARY");
                tokens.canConsume("COLLATE", TokenStream.ANY_VALUE);
                tokens.canConsume("CHARACTER", "SET", TokenStream.ANY_VALUE);
                tokens.canConsume("COLLATE", TokenStream.ANY_VALUE);
            } else if (tokens.matches(DTYPE_SET)) {
                // SET(value1,value2,value3,...) [CHARACTER SET charset_name] [COLLATE collation_name]
                String typeName = tokens.consume();
                dataType = new DataType(typeName);

                tokens.consume(L_PAREN);
                do {
                    tokens.consume();
                } while (tokens.canConsume(COMMA));
                tokens.consume(R_PAREN);

                tokens.canConsume("COLLATE", TokenStream.ANY_VALUE);
                tokens.canConsume("CHARACTER", "SET", TokenStream.ANY_VALUE);
                tokens.canConsume("COLLATE", TokenStream.ANY_VALUE);
            } else if (tokens.matches(DTYPE_ENUM)) {
                // ENUM(value1,value2,value3,...) [CHARACTER SET charset_name] [COLLATE collation_name]
                String typeName = tokens.consume();
                dataType = new DataType(typeName);

                tokens.consume(L_PAREN);
                do {
                    tokens.consume();
                } while (tokens.canConsume(COMMA));
View Full Code Here

            return super.parseDateTimeType(tokens);
        }

        @Override
        protected DataType parseExactNumericType( DdlTokenStream tokens ) throws ParsingException {
            DataType dType = super.parseExactNumericType(tokens);
            tokens.canConsume("UNSIGNED");
            tokens.canConsume("ZEROFILL");
            tokens.canConsume("UNSIGNED");
            return dType;
        }
View Full Code Here

        final String id = parseIdentifier(tokens);
        final AstNode parameterNode = getNodeFactory().node(id, procedureNode, TeiidDdlLexicon.CreateProcedure.PARAMETER);
        parameterNode.setProperty(TeiidDdlLexicon.CreateProcedure.PARAMETER_TYPE, paramType);

        // parse data type
        final DataType dataType = getDataTypeParser().parse(tokens);
        getDataTypeParser().setPropertiesOnNode(parameterNode, dataType);

        // parse any optional clauses
        boolean foundNotNull = false;
        boolean foundResult = false;
View Full Code Here

     * @param resultSetNode the result set node owning this result column (cannot be <code>null</code>)
     */
    void parseProcedureResultColumn( final DdlTokenStream tokens,
                                     final AstNode resultSetNode ) {
        final String id = parseIdentifier(tokens);
        final DataType dataType = getDataTypeParser().parse(tokens);
        final boolean notNull = tokens.canConsume(NOT_NULL);

        final AstNode resultColumnNode = getNodeFactory().node(id, resultSetNode, TeiidDdlLexicon.CreateProcedure.RESULT_COLUMN);
        resultColumnNode.setProperty(StandardDdlLexicon.NULLABLE, (notNull ? "NOT NULL" : "NULL"));
        getDataTypeParser().setPropertiesOnNode(resultColumnNode, dataType);
View Full Code Here

    boolean parseReturnsClause( final DdlTokenStream tokens,
                                final AstNode procedureNode ) {
        if (tokens.canConsume(TeiidReservedWord.RETURNS.toDdl())) {
            // must have either one or more result columns or a data type
            if (!parseProcedureResultColumns(tokens, procedureNode)) {
                final DataType dataType = getDataTypeParser().parse(tokens);

                // create result node
                final AstNode resultNode = getNodeFactory().node(TeiidDdlLexicon.CreateProcedure.RESULT_SET,
                                                                 procedureNode,
                                                                 TeiidDdlLexicon.CreateProcedure.RESULT_DATA_TYPE);
                resultNode.setProperty(DATATYPE_NAME, dataType.getName());

                if (dataType.getLength() != DataType.DEFAULT_LENGTH) {
                    resultNode.setProperty(DATATYPE_LENGTH, dataType.getLength());
                }

                if (dataType.getPrecision() != DataType.DEFAULT_PRECISION) {
                    resultNode.setProperty(DATATYPE_PRECISION, dataType.getPrecision());
                }

                if (dataType.getScale() != DataType.DEFAULT_SCALE) {
                    resultNode.setProperty(DATATYPE_SCALE, dataType.getScale());
                }
            }

            return true;
        }
View Full Code Here

                tokens.consume(); // integer
            } else if (tokens.canConsume("DROP", "DEFAULT")) {

            } else if (tokens.canConsume("SET", "DATA")) {
                tokens.consume("TYPE");
                DataType datatype = getDatatypeParser().parse(tokens);

                getDatatypeParser().setPropertiesOnNode(columnNode, datatype);

                if (tokens.canConsume("USING")) {
                    // TODO: Not storing the following expression in properties.
                    parseUntilCommaOrTerminator(tokens);
                }
            } else if (tokens.canConsume("TYPE")) {
                DataType datatype = getDatatypeParser().parse(tokens);

                getDatatypeParser().setPropertiesOnNode(columnNode, datatype);

                if (tokens.canConsume("USING")) {
                    // TODO: Not storing the following expression in properties.
View Full Code Here

TOP

Related Classes of org.modeshape.sequencer.ddl.datatype.DataType

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.