001/* 002 * JKNIV, SQLegance keeping queries maintainable. 003 * 004 * Copyright (C) 2017, the original author or authors. 005 * 006 * This library is free software; you can redistribute it and/or 007 * modify it under the terms of the GNU Lesser General Public 008 * License as published by the Free Software Foundation; either 009 * version 2.1 of the License. 010 * 011 * This library is distributed in the hope that it will be useful, 012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 014 * Lesser General Public License for more details. 015 * 016 * You should have received a copy of the GNU Lesser General Public 017 * License along with this library; if not, write to the Free Software Foundation, Inc., 018 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 019 */ 020package net.sf.jkniv.sqlegance.params; 021 022/** 023 * Strategy to parser the parameters from query extracting yours names or replacing 024 * the names for question mark <code>'?'</code>, used at JDBC prepared statements. 025 * 026 * <b>Instances of this class must be IMMUTABLE and safe for use by multiple concurrent threads</b> 027 * 028 * @author Alisson Gomes 029 * @since 0.6.0 030 */ 031public interface ParamParser 032{ 033 034 /** 035 * extract the parameters names from query. 036 * @param query the SQL sentence 037 * @return array parameters from query 038 */ 039 String[] find(final String query); 040 041 /** 042 * Replace the parameters names for question marks 043 * @param query the SQL sentence 044 * @param params parameters used at query, its necessary when the query use IN clause 045 * @return the new SQL sentence with question marks. 046 */ 047 String replaceForPlaceholder(final String query, final Object params); 048 049 /** 050 * Replace the parameters names for question marks 051 * @param query the SQL sentence 052 * @return the new SQL sentence with question marks. 053 */ 054 String replaceForPlaceholder(final String query); 055 056 String replaceForPlaceholderWithNumber(final String query, Object params); 057 058 ParamMarkType getType(); 059 060 /** 061 * Specifies a character that will be replaced to in SQL query. Default is {@code ?} 062 * @return the place holder from parser 063 */ 064 String getPlaceholder(); 065}