@Test public void shouldGetTableElementString() { printTest("shouldGetTableElementString()"); String content = "(PARTID VARCHAR (255) NOT NULL DEFAULT (100), -- COLUMN 1 COMMENT with comma \nPARTCOLOR INTEGER NOT NULL)"; DdlTokenStream tokens = getTokens(content); String result = parser.getTableElementsString(tokens, false); printResult(" STRING = " + result); }
protected String getTableElementsString( DdlTokenStream tokens, boolean useTerminator ) throws ParsingException { assert tokens != null; StringBuilder sb = new StringBuilder(100); if (useTerminator) { while (!isTerminator(tokens)) { sb.append(SPACE).append(tokens.consume()); } } else { tokens.consume(L_PAREN); int iParen = 0; while (tokens.hasNext()) { if (tokens.matches(L_PAREN)) { iParen++; } else if (tokens.matches(R_PAREN)) { if (iParen == 0) { tokens.consume(R_PAREN); break; } iParen--; } if (isComment(tokens)) { tokens.consume(); } else { sb.append(SPACE).append(tokens.consume()); } } } return sb.toString(); }
StandardDdlParser implements DdlParser, DdlConstants, DdlConstants.StatementStartPhrases { protected String getTableElementsString( DdlTokenStream tokens, boolean useTerminator ) throws ParsingException { assert tokens != null; StringBuilder sb = new StringBuilder(100); if (useTerminator) { while (!isTerminator(tokens)) { sb.append(SPACE).append(tokens.consume()); } } else { tokens.consume(L_PAREN); int iParen = 0; while (tokens.hasNext()) { if (tokens.matches(L_PAREN)) { iParen++; } else if (tokens.matches(R_PAREN)) { if (iParen == 0) { tokens.consume(R_PAREN); break; } iParen--; } if (isComment(tokens)) { tokens.consume(); } else { sb.append(SPACE).append(tokens.consume()); } } } return sb.toString(); } }
StandardDdlParser implements DdlParser, DdlConstants, DdlConstants.StatementStartPhrases { protected String getTableElementsString( DdlTokenStream tokens, boolean useTerminator ) throws ParsingException { assert tokens != null; StringBuilder sb = new StringBuilder(100); if (useTerminator) { while (!isTerminator(tokens)) { sb.append(SPACE).append(tokens.consume()); } } else { tokens.consume(L_PAREN); int iParen = 0; while (tokens.hasNext()) { if (tokens.matches(L_PAREN)) { iParen++; } else if (tokens.matches(R_PAREN)) { if (iParen == 0) { tokens.consume(R_PAREN); break; } iParen--; } if (isComment(tokens)) { tokens.consume(); } else { sb.append(SPACE).append(tokens.consume()); } } } return sb.toString(); } StandardDdlParser(); }
StandardDdlParser implements DdlParser, DdlConstants, DdlConstants.StatementStartPhrases { protected String getTableElementsString( DdlTokenStream tokens, boolean useTerminator ) throws ParsingException { assert tokens != null; StringBuilder sb = new StringBuilder(100); if (useTerminator) { while (!isTerminator(tokens)) { sb.append(SPACE).append(tokens.consume()); } } else { tokens.consume(L_PAREN); int iParen = 0; while (tokens.hasNext()) { if (tokens.matches(L_PAREN)) { iParen++; } else if (tokens.matches(R_PAREN)) { if (iParen == 0) { tokens.consume(R_PAREN); break; } iParen--; } if (isComment(tokens)) { tokens.consume(); } else { sb.append(SPACE).append(tokens.consume()); } } } 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 getTableElementsString( DdlTokenStream tokens, boolean useTerminator ) throws ParsingException { assert tokens != null; StringBuilder sb = new StringBuilder(100); if (useTerminator) { while (!isTerminator(tokens)) { sb.append(SPACE).append(tokens.consume()); } } else { tokens.consume(L_PAREN); int iParen = 0; while (tokens.hasNext()) { if (tokens.matches(L_PAREN)) { iParen++; } else if (tokens.matches(R_PAREN)) { if (iParen == 0) { tokens.consume(R_PAREN); break; } iParen--; } if (isComment(tokens)) { tokens.consume(); } else { sb.append(SPACE).append(tokens.consume()); } } } 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; }