org.kuali.common.jdbc.convert
Class AbstractInsertMergeSqlConverter

java.lang.Object
  extended by org.kuali.common.jdbc.convert.AbstractInsertMergeSqlConverter
All Implemented Interfaces:
SqlConverter

public abstract class AbstractInsertMergeSqlConverter
extends Object
implements SqlConverter

This class provides a common framework for SqlConverter classes which merge insert statements into batch inserts

Author:
andrewlubbers

Constructor Summary
AbstractInsertMergeSqlConverter()
           
 
Method Summary
protected abstract  String combineInserts(ConversionContext conversionContext, SqlInsertContext sqlInsertContext)
          Performs the real work of combining insert statements into batch inserts.
protected  boolean continueBatch(String sql, int count, int length, ConversionContext context)
          A common test to determine if the current insert batch should continue adding data
 ConversionResult convert(ConversionContext context)
           
protected  ConversionResult convert(ConversionContext context, SqlReader reader, BufferedReader in, OutputStream out)
           
abstract  String getInsertPrefix()
          Returns the platform-specific prefix for an INSERT statement
 String getLineFeed()
           
protected  SqlMetaData getMetaData(File file, SqlReader reader, String encoding)
           
protected  String getOutputSql(ConversionContext context, BufferedReader in, String sql, SqlReader reader)
           
protected  boolean isInsert(String sql)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractInsertMergeSqlConverter

public AbstractInsertMergeSqlConverter()
Method Detail

convert

public ConversionResult convert(ConversionContext context)
Specified by:
convert in interface SqlConverter

convert

protected ConversionResult convert(ConversionContext context,
                                   SqlReader reader,
                                   BufferedReader in,
                                   OutputStream out)
                            throws IOException
Throws:
IOException

getOutputSql

protected String getOutputSql(ConversionContext context,
                              BufferedReader in,
                              String sql,
                              SqlReader reader)
                       throws IOException
Throws:
IOException

combineInserts

protected abstract String combineInserts(ConversionContext conversionContext,
                                         SqlInsertContext sqlInsertContext)
                                  throws IOException
Performs the real work of combining insert statements into batch inserts.

Parameters:
conversionContext - reference to meta data for this conversion process
sqlInsertContext - contains the sql to convert and IO objects to write conversion results
Returns:
converted sql
Throws:
IOException

isInsert

protected boolean isInsert(String sql)

getInsertPrefix

public abstract String getInsertPrefix()
Returns the platform-specific prefix for an INSERT statement

Returns:
the prefix

getMetaData

protected SqlMetaData getMetaData(File file,
                                  SqlReader reader,
                                  String encoding)

getLineFeed

public String getLineFeed()

continueBatch

protected boolean continueBatch(String sql,
                                int count,
                                int length,
                                ConversionContext context)
A common test to determine if the current insert batch should continue adding data

Parameters:
sql - the remaining sql to process
count - the number of inserts already processed
length - the character length of the inserts already processed
context - the metadata for this conversion
Returns:
True if the current batch should be appended to, false otherwise


Copyright © 2010-2013 The Kuali Foundation. All Rights Reserved.