package org.drizzle.jdbc.internal.common;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * Created by IntelliJ IDEA. User: marcuse Date: Jul 13, 2009 Time: 6:50:13 PM To change this template use File |
 * Settings | File Templates.
 */
public class RewriteParameterizedBatchHandlerFactory implements ParameterizedBatchHandlerFactory {

    public ParameterizedBatchHandler get(final String query, final Protocol protocol) {
        System.out.println(query);
        final Pattern p = Pattern.compile(
                "(?i)^\\s*+(INSERT (INTO)?\\s*(\\w+\\.)?\\w+\\s*(\\([^\\)]*\\))?\\s*VALUES?)\\s*(\\([^\\)]*\\))\\s*(ON DUPLICATE KEY UPDATE.+)?");
        final Matcher m = p.matcher(query);
        if (m.matches()) {
            return new RewriteParameterizedBatchHandler(protocol, m.group(1), m.group(5), m.group(6));
        } else {
            return new DefaultParameterizedBatchHandler(protocol);
        }
    }
}

@@ -445,43 +445,8 @@
 ) %7B%0A
-        System.out.println(query);%0A
     

remove system.out stuff