@Test public void shouldParseBIT() { printTest("shouldParseBIT()"); String typeString = getDataTypeString(DataTypes.DTYPE_BIT); String content = typeString; DdlTokenStream tokens = getTokens(content); DataType dType = parser.parse(tokens); Assert.assertNotNull("DataType was NOT found for Type = " + typeString, dType); Assert.assertEquals("Wrong DataType found", typeString, dType.getName()); }
public DataType parse( DdlTokenStream tokens ) throws ParsingException { DataType result = null; if (isDatatype(tokens, DataTypes.DTYPE_CODE_CHAR_STRING)) { result = parseCharStringType(tokens); } else if (isDatatype(tokens, DataTypes.DTYPE_CODE_NCHAR_STRING)) { result = parseNationalCharStringType(tokens); } else if (isDatatype(tokens, DataTypes.DTYPE_CODE_BIT_STRING)) { result = parseBitStringType(tokens); } else if (isDatatype(tokens, DataTypes.DTYPE_CODE_EXACT_NUMERIC)) { result = parseExactNumericType(tokens); } else if (isDatatype(tokens, DataTypes.DTYPE_CODE_APROX_NUMERIC)) { result = parseApproxNumericType(tokens); } else if (isDatatype(tokens, DataTypes.DTYPE_CODE_DATE_TIME)) { result = parseDateTimeType(tokens); } else if (isDatatype(tokens, DataTypes.DTYPE_CODE_MISC)) { result = parseMiscellaneousType(tokens); } else { result = parseCustomType(tokens); } if (tokens.canConsume('[')) { if (!tokens.canConsume(']')) { tokens.consume(); tokens.consume(']'); } if (tokens.canConsume('[')) { if (!tokens.canConsume(']')) { tokens.consume(); tokens.consume(']'); } } } return result; }
DataTypeParser implements DdlConstants { public DataType parse( DdlTokenStream tokens ) throws ParsingException { DataType result = null; if (isDatatype(tokens, DataTypes.DTYPE_CODE_CHAR_STRING)) { result = parseCharStringType(tokens); } else if (isDatatype(tokens, DataTypes.DTYPE_CODE_NCHAR_STRING)) { result = parseNationalCharStringType(tokens); } else if (isDatatype(tokens, DataTypes.DTYPE_CODE_BIT_STRING)) { result = parseBitStringType(tokens); } else if (isDatatype(tokens, DataTypes.DTYPE_CODE_EXACT_NUMERIC)) { result = parseExactNumericType(tokens); } else if (isDatatype(tokens, DataTypes.DTYPE_CODE_APROX_NUMERIC)) { result = parseApproxNumericType(tokens); } else if (isDatatype(tokens, DataTypes.DTYPE_CODE_DATE_TIME)) { result = parseDateTimeType(tokens); } else if (isDatatype(tokens, DataTypes.DTYPE_CODE_MISC)) { result = parseMiscellaneousType(tokens); } else { result = parseCustomType(tokens); } if (tokens.canConsume('[')) { if (!tokens.canConsume(']')) { tokens.consume(); tokens.consume(']'); } if (tokens.canConsume('[')) { if (!tokens.canConsume(']')) { tokens.consume(); tokens.consume(']'); } } } return result; } }
DataTypeParser implements DdlConstants { public DataType parse( DdlTokenStream tokens ) throws ParsingException { DataType result = null; if (isDatatype(tokens, DataTypes.DTYPE_CODE_CHAR_STRING)) { result = parseCharStringType(tokens); } else if (isDatatype(tokens, DataTypes.DTYPE_CODE_NCHAR_STRING)) { result = parseNationalCharStringType(tokens); } else if (isDatatype(tokens, DataTypes.DTYPE_CODE_BIT_STRING)) { result = parseBitStringType(tokens); } else if (isDatatype(tokens, DataTypes.DTYPE_CODE_EXACT_NUMERIC)) { result = parseExactNumericType(tokens); } else if (isDatatype(tokens, DataTypes.DTYPE_CODE_APROX_NUMERIC)) { result = parseApproxNumericType(tokens); } else if (isDatatype(tokens, DataTypes.DTYPE_CODE_DATE_TIME)) { result = parseDateTimeType(tokens); } else if (isDatatype(tokens, DataTypes.DTYPE_CODE_MISC)) { result = parseMiscellaneousType(tokens); } else { result = parseCustomType(tokens); } if (tokens.canConsume('[')) { if (!tokens.canConsume(']')) { tokens.consume(); tokens.consume(']'); } if (tokens.canConsume('[')) { if (!tokens.canConsume(']')) { tokens.consume(); tokens.consume(']'); } } } return result; } DataTypeParser(); }
DataTypeParser implements DdlConstants { public DataType parse( DdlTokenStream tokens ) throws ParsingException { DataType result = null; if (isDatatype(tokens, DataTypes.DTYPE_CODE_CHAR_STRING)) { result = parseCharStringType(tokens); } else if (isDatatype(tokens, DataTypes.DTYPE_CODE_NCHAR_STRING)) { result = parseNationalCharStringType(tokens); } else if (isDatatype(tokens, DataTypes.DTYPE_CODE_BIT_STRING)) { result = parseBitStringType(tokens); } else if (isDatatype(tokens, DataTypes.DTYPE_CODE_EXACT_NUMERIC)) { result = parseExactNumericType(tokens); } else if (isDatatype(tokens, DataTypes.DTYPE_CODE_APROX_NUMERIC)) { result = parseApproxNumericType(tokens); } else if (isDatatype(tokens, DataTypes.DTYPE_CODE_DATE_TIME)) { result = parseDateTimeType(tokens); } else if (isDatatype(tokens, DataTypes.DTYPE_CODE_MISC)) { result = parseMiscellaneousType(tokens); } else { result = parseCustomType(tokens); } if (tokens.canConsume('[')) { if (!tokens.canConsume(']')) { tokens.consume(); tokens.consume(']'); } if (tokens.canConsume('[')) { if (!tokens.canConsume(']')) { tokens.consume(); tokens.consume(']'); } } } return result; } DataTypeParser(); final boolean isDatatype( DdlTokenStream tokens ); DataType parse( DdlTokenStream tokens ); int getDefaultLength(); void setDefaultLength( int defaultLength ); int getDefaultPrecision(); void setDefaultPrecision( int defaultPrecision ); int getDefaultScale(); void setDefaultScale( int defaultScale ); String getStatementTypeName( String[] stmtPhrase ); void setPropertiesOnNode( AstNode columnNode,
                                     DataType datatype ); }
DataTypeParser implements DdlConstants { public DataType parse( DdlTokenStream tokens ) throws ParsingException { DataType result = null; if (isDatatype(tokens, DataTypes.DTYPE_CODE_CHAR_STRING)) { result = parseCharStringType(tokens); } else if (isDatatype(tokens, DataTypes.DTYPE_CODE_NCHAR_STRING)) { result = parseNationalCharStringType(tokens); } else if (isDatatype(tokens, DataTypes.DTYPE_CODE_BIT_STRING)) { result = parseBitStringType(tokens); } else if (isDatatype(tokens, DataTypes.DTYPE_CODE_EXACT_NUMERIC)) { result = parseExactNumericType(tokens); } else if (isDatatype(tokens, DataTypes.DTYPE_CODE_APROX_NUMERIC)) { result = parseApproxNumericType(tokens); } else if (isDatatype(tokens, DataTypes.DTYPE_CODE_DATE_TIME)) { result = parseDateTimeType(tokens); } else if (isDatatype(tokens, DataTypes.DTYPE_CODE_MISC)) { result = parseMiscellaneousType(tokens); } else { result = parseCustomType(tokens); } if (tokens.canConsume('[')) { if (!tokens.canConsume(']')) { tokens.consume(); tokens.consume(']'); } if (tokens.canConsume('[')) { if (!tokens.canConsume(']')) { tokens.consume(); tokens.consume(']'); } } } return result; } DataTypeParser(); final boolean isDatatype( DdlTokenStream tokens ); DataType parse( DdlTokenStream tokens ); int getDefaultLength(); void setDefaultLength( int defaultLength ); int getDefaultPrecision(); void setDefaultPrecision( int defaultPrecision ); int getDefaultScale(); void setDefaultScale( int defaultScale ); String getStatementTypeName( String[] stmtPhrase ); void setPropertiesOnNode( AstNode columnNode,
                                     DataType datatype );  }