@Test public void shouldParseName() { printTest("shouldParseName()"); String content = "simpleName"; String targetName = "simpleName"; DdlTokenStream tokens = getTokens(content); String result = parser.parseName(tokens); assertEquals(targetName, result); content = "schema_name.table_name"; targetName = "schema_name.table_name"; tokens = getTokens(content); result = parser.parseName(tokens); assertEquals(targetName, result); content = "[schema_name].[table_name]"; targetName = "schema_name.table_name"; tokens = getTokens(content); result = parser.parseName(tokens); assertEquals(targetName, result); content = "[schema_name].[\"COLUMN\"]"; targetName = "schema_name.COLUMN"; tokens = getTokens(content); result = parser.parseName(tokens); assertEquals(targetName, result); content = "\"_RETURN\""; targetName = "_RETURN"; tokens = getTokens(content); result = parser.parseName(tokens); assertEquals(targetName, result); }
protected String parseName( DdlTokenStream tokens ) { StringBuilder sb = new StringBuilder(); if (tokens.matches('[')) { while (true) { tokens.consume('['); sb.append(consumeIdentifier(tokens)); tokens.consume(']'); if (tokens.matches('.')) { sb.append(tokens.consume()); } else { break; } } } else { while (true) { sb.append(consumeIdentifier(tokens)); if (tokens.matches('.')) { sb.append(tokens.consume()); } else { break; } } } return sb.toString(); }
StandardDdlParser implements DdlParser, DdlConstants, DdlConstants.StatementStartPhrases { protected String parseName( DdlTokenStream tokens ) { StringBuilder sb = new StringBuilder(); if (tokens.matches('[')) { while (true) { tokens.consume('['); sb.append(consumeIdentifier(tokens)); tokens.consume(']'); if (tokens.matches('.')) { sb.append(tokens.consume()); } else { break; } } } else { while (true) { sb.append(consumeIdentifier(tokens)); if (tokens.matches('.')) { sb.append(tokens.consume()); } else { break; } } } return sb.toString(); } }
StandardDdlParser implements DdlParser, DdlConstants, DdlConstants.StatementStartPhrases { protected String parseName( DdlTokenStream tokens ) { StringBuilder sb = new StringBuilder(); if (tokens.matches('[')) { while (true) { tokens.consume('['); sb.append(consumeIdentifier(tokens)); tokens.consume(']'); if (tokens.matches('.')) { sb.append(tokens.consume()); } else { break; } } } else { while (true) { sb.append(consumeIdentifier(tokens)); if (tokens.matches('.')) { sb.append(tokens.consume()); } else { break; } } } return sb.toString(); } StandardDdlParser(); }
StandardDdlParser implements DdlParser, DdlConstants, DdlConstants.StatementStartPhrases { protected String parseName( DdlTokenStream tokens ) { StringBuilder sb = new StringBuilder(); if (tokens.matches('[')) { while (true) { tokens.consume('['); sb.append(consumeIdentifier(tokens)); tokens.consume(']'); if (tokens.matches('.')) { sb.append(tokens.consume()); } else { break; } } } else { while (true) { sb.append(consumeIdentifier(tokens)); if (tokens.matches('.')) { sb.append(tokens.consume()); } else { break; } } } return sb.toString(); } StandardDdlParser(); DataTypeParser getDatatypeParser(); void setDatatypeParser( DataTypeParser datatypeParser ); AstNodeFactory nodeFactory(); AstNode getRootNode(); void setRootNode( AstNode rootNode ); @Override Object score( String ddl,
                         String fileName,
                         DdlParserScorer scorer ); String[] getIdentifyingKeywords(); @Override void parse( String ddl,
                       AstNode rootNode,
                       Object scoreReturnObject ); final void addProblem( DdlParserProblem problem,
                                  AstNode node ); final void addProblem( DdlParserProblem problem ); final List<DdlParserProblem> getProblems(); final void attachNewProblem( DdlParserProblem problem,
                                        AstNode parentNode ); void mergeNodes( DdlTokenStream tokens,
                            AstNode firstNode,
                            AstNode secondNode ); AstNode handleUnknownToken( DdlTokenStream tokens,
                                       String tokenValue ); final AstNode unknownTerminatedNode( AstNode parentNode ); final AstNode missingTerminatorNode( AstNode parentNode ); final boolean isMissingTerminatorNode( AstNode node ); final boolean isValidSchemaChild( AstNode node ); final boolean setAsSchemaChildNode( AstNode statementNode,
                                               boolean stmtIsMissingTerminator ); boolean doUseTerminator(); void setDoUseTerminator( boolean useTerminator ); String getStatementTypeName( String[] stmtPhrase ); final Position getCurrentMarkedPosition(); final void markStartOfStatement( DdlTokenStream tokens ); final void markEndOfStatement( DdlTokenStream tokens,
                                          AstNode statementNode ); @Override void postProcess( AstNode rootNode ); boolean isTestMode(); void setTestMode( boolean testMode ); @Override String getId(); @Override int hashCode(); @Override boolean equals( Object obj ); }
StandardDdlParser implements DdlParser, DdlConstants, DdlConstants.StatementStartPhrases { protected String parseName( DdlTokenStream tokens ) { StringBuilder sb = new StringBuilder(); if (tokens.matches('[')) { while (true) { tokens.consume('['); sb.append(consumeIdentifier(tokens)); tokens.consume(']'); if (tokens.matches('.')) { sb.append(tokens.consume()); } else { break; } } } else { while (true) { sb.append(consumeIdentifier(tokens)); if (tokens.matches('.')) { sb.append(tokens.consume()); } else { break; } } } return sb.toString(); } StandardDdlParser(); DataTypeParser getDatatypeParser(); void setDatatypeParser( DataTypeParser datatypeParser ); AstNodeFactory nodeFactory(); AstNode getRootNode(); void setRootNode( AstNode rootNode ); @Override Object score( String ddl,
                         String fileName,
                         DdlParserScorer scorer ); String[] getIdentifyingKeywords(); @Override void parse( String ddl,
                       AstNode rootNode,
                       Object scoreReturnObject ); final void addProblem( DdlParserProblem problem,
                                  AstNode node ); final void addProblem( DdlParserProblem problem ); final List<DdlParserProblem> getProblems(); final void attachNewProblem( DdlParserProblem problem,
                                        AstNode parentNode ); void mergeNodes( DdlTokenStream tokens,
                            AstNode firstNode,
                            AstNode secondNode ); AstNode handleUnknownToken( DdlTokenStream tokens,
                                       String tokenValue ); final AstNode unknownTerminatedNode( AstNode parentNode ); final AstNode missingTerminatorNode( AstNode parentNode ); final boolean isMissingTerminatorNode( AstNode node ); final boolean isValidSchemaChild( AstNode node ); final boolean setAsSchemaChildNode( AstNode statementNode,
                                               boolean stmtIsMissingTerminator ); boolean doUseTerminator(); void setDoUseTerminator( boolean useTerminator ); String getStatementTypeName( String[] stmtPhrase ); final Position getCurrentMarkedPosition(); final void markStartOfStatement( DdlTokenStream tokens ); final void markEndOfStatement( DdlTokenStream tokens,
                                          AstNode statementNode ); @Override void postProcess( AstNode rootNode ); boolean isTestMode(); void setTestMode( boolean testMode ); @Override String getId(); @Override int hashCode(); @Override boolean equals( Object obj ); static final String ID; }