migratory-core/src/main/java/com/nesscomputing/migratory/migration/sql/SqlScript.java
List<SqlStatement> linesToStatements(List<String> lines)
    {
        final List<SqlStatement> statements = Lists.newArrayList();
        final StringBuilder statementSql = new StringBuilder();
        int count = 0;

        String delimiter = DEFAULT_STATEMENT_DELIMITER;

        for (final String line : lines)
        {
            if (StringUtils.isBlank(line)) {
                continue;
            }

            if (statementSql.length() > 0) {
                statementSql.append(" ");
            }
            statementSql.append(line);

            final String oldDelimiter = delimiter;
            delimiter = changeDelimiterIfNecessary(statementSql.toString(), line, delimiter);
            if (!StringUtils.equals(delimiter, oldDelimiter) && isDelimiterChangeExplicit()) {
                statementSql.setLength(0);
                continue; // for
            }

            if (StringUtils.endsWith(line, delimiter)) {
                // Trim off the delimiter at the end.
                statementSql.setLength(statementSql.length() - delimiter.length());
                statements.add(new SqlStatement(count++, StringUtils.trimToEmpty(statementSql.toString())));
                LOG.debug("Found statement: {}", statementSql);

                if (!isDelimiterChangeExplicit()) {
                    delimiter = DEFAULT_STATEMENT_DELIMITER;
                }
                statementSql.setLength(0);
            }
        }

        // Catch any statements not followed by delimiter.
        if (statementSql.length() > 0) {
            statements.add(new SqlStatement(count++, StringUtils.trimToEmpty(statementSql.toString())));
        }

        return statements;
    }
List<SqlStatement> linesToStatements(List<String> lines)
    {
        final List<SqlStatement> statements = Lists.newArrayList();
        final StringBuilder statementSql = new StringBuilder();
        int count = 0;

        String delimiter = DEFAULT_STATEMENT_DELIMITER;

        for (final String line : lines)
        {
            if (StringUtils.isBlank(line)) {
                continue;
            }

            if (statementSql.length() > 0) {
                statementSql.append(" ");
            }
            statementSql.append(line);

            final String oldDelimiter = delimiter;
            delimiter = changeDelimiterIfNecessary(statementSql.toString(), line, delimiter);
            if (!StringUtils.equals(delimiter, oldDelimiter) && isDelimiterChangeExplicit()) {
                statementSql.setLength(0);
                continue; // for
            }

            if (StringUtils.endsWith(line, delimiter)) {
                // Trim off the delimiter at the end.
                statementSql.setLength(statementSql.length() - delimiter.length());
                statements.add(new SqlStatement(count++, StringUtils.trimToEmpty(statementSql.toString())));
                LOG.debug("Found statement: {}", statementSql);

                if (!isDelimiterChangeExplicit()) {
                    delimiter = DEFAULT_STATEMENT_DELIMITER;
                }
                statementSql.setLength(0);
            }
        }

        // Catch any statements not followed by delimiter.
        if (statementSql.length() > 0) {
            statements.add(new SqlStatement(count++, StringUtils.trimToEmpty(statementSql.toString())));
        }

        return statements;
    }
List < SqlStatement > linesToStatements ( List < String > lines ) { final List < SqlStatement > statements = Lists . newArrayList ( ) ; final StringBuilder statementSql = new StringBuilder ( ) ; int count = 0 ; String delimiter = DEFAULT_STATEMENT_DELIMITER ; for ( final String line : lines ) { if ( StringUtils . isBlank ( line ) ) { continue ; } if ( statementSql . length ( ) > 0 ) { statementSql . append ( " " ) ; } statementSql . append ( line ) ; final String oldDelimiter = delimiter ; delimiter = changeDelimiterIfNecessary ( statementSql . toString ( ) , line , delimiter ) ; if ( ! StringUtils . equals ( delimiter , oldDelimiter ) && isDelimiterChangeExplicit ( ) ) { statementSql . setLength ( 0 ) ; continue ; // for } if ( StringUtils . endsWith ( line , delimiter ) ) { // Trim off the delimiter at the end. statementSql . setLength ( statementSql . length ( ) - delimiter . length ( ) ) ; statements . add ( new SqlStatement ( count ++ , StringUtils . trimToEmpty ( statementSql . toString ( ) ) ) ) ; LOG . debug ( "Found statement: {}" , statementSql ) ; if ( ! isDelimiterChangeExplicit ( ) ) { delimiter = DEFAULT_STATEMENT_DELIMITER ; } statementSql . setLength ( 0 ) ; } } // Catch any statements not followed by delimiter. if ( statementSql . length ( ) > 0 ) { statements . add ( new SqlStatement ( count ++ , StringUtils . trimToEmpty ( statementSql . toString ( ) ) ) ) ; } return statements ; }
Turns these lines in a series of statements.
Turns these lines in a series of statements .