public String scan(String tablesToFind,Hashtable<String,String> templateOptions,Writer writer) throws ReplicatorException, InterruptedException, SQLException, IOException {
  int tablesRendered=0;
  ArrayList<Table> tables=null;
  if (tablesToFind == null) {
    tables=db.getTables(dbName,true,true);
  }
 else {
    tables=new ArrayList<Table>();
    String[] tableNames=tablesToFind.split(",");
    for (    String tableName : tableNames) {
      Table table=db.findTable(dbName,tableName,true);
      if (table != null)       tables.add(table);
    }
  }
  VelocityContext context=new VelocityContext();
  for (  String option : templateOptions.keySet()) {
    context.put(option,templateOptions.get(option));
  }
  context.put("dbName",dbName);
  context.put("user",user);
  context.put("url",url);
  context.put("db",db);
  context.put("renameDefinitions",renameDefinitions);
  context.put("enum",EnumToStringFilter.class);
  context.put("date",new java.util.Date());
  context.put("reservedWordsOracle",reservedWordsOracle);
  context.put("reservedWordsMySQL",reservedWordsMySQL);
  context.put("velocity",velocity);
  int size=tables.size();
  for (int i=0; i < size; i++) {
    Table table=tables.get(i);
    if (i == 0)     context.put("first",true);
 else     context.put("first",false);
    if (i >= size - 1)     context.put("last",true);
 else     context.put("last",false);
    rename(table);
    merge(context,table,writer);
    tablesRendered++;
  }
  if (tablesRendered == 0) {
    merge(context,null,writer);
  }
  return writer.toString();
}

public String scan ( String tablesToFind , Hashtable < String , String > templateOptions , Writer writer ) throws ReplicatorException , InterruptedException , SQLException , IOException { int tablesRendered = 0 ; ArrayList < Table > tables = null ; if ( tablesToFind == null ) { tables = db . getTables ( dbName , true , true ) ; } else { tables = new ArrayList < Table > ( ) ; String [ ] tableNames = tablesToFind . split ( "," ) ; for ( String tableName : tableNames ) { Table table = db . findTable ( dbName , tableName , true ) ; if ( table != null ) tables . add ( table ) ; } } VelocityContext context = new VelocityContext ( ) ; for ( String option : templateOptions . keySet ( ) ) { context . put ( option , templateOptions . get ( option ) ) ; } context . put ( "dbName" , dbName ) ; context . put ( "user" , user ) ; context . put ( "url" , url ) ; context . put ( "db" , db ) ; context . put ( "renameDefinitions" , renameDefinitions ) ; context . put ( "enum" , EnumToStringFilter . class ) ; context . put ( "date" , new java . util . Date ( ) ) ; context . put ( "reservedWordsOracle" , reservedWordsOracle ) ; context . put ( "reservedWordsMySQL" , reservedWordsMySQL ) ; context . put ( "velocity" , velocity ) ; int size = tables . size ( ) ; for ( int i = 0 ; i < size ; i ++ ) { Table table = tables . get ( i ) ; if ( i == 0 ) context . put ( "first" , true ) ; else context . put ( "first" , false ) ; if ( i >= size - 1 ) context . put ( "last" , true ) ; else context . put ( "last" , false ) ; rename ( table ) ; merge ( context , table , writer ) ; tablesRendered ++ ; } if ( tablesRendered == 0 ) { merge ( context , null , writer ) ; } return writer . toString ( ) ; }
scans and extracts metadata from the database of requested tables . calls merge ( . . . ) against each found table .
