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 { // Assume we start with open parenthesis '(', then we can count on walking through ALL tokens until we find the close // parenthesis ')'. If there are intermediate parenthesis, we can count on them being pairs. tokens . consume ( L_PAREN ) ; // EXPECTED 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 ( ) ; }
Method which extracts the table element string from a CREATE TABLE statement .