|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.springframework.jdbc.core.namedparam.NamedParameterUtils
public abstract class NamedParameterUtils
Helper methods for named parameter parsing. Only intended for internal use within Spring's JDBC framework.
Nested Class Summary | |
---|---|
private static class |
NamedParameterUtils.ParameterHolder
|
Field Summary | |
---|---|
private static char[] |
PARAMETER_SEPARATORS
Set of characters that qualify as parameter separators, indicating that a parameter name in a SQL String has ended. |
private static java.lang.String[] |
START_SKIP
Set of characters that qualify as comment or quotes starting characters. |
private static java.lang.String[] |
STOP_SKIP
Set of characters that at are the corresponding comment or quotes ending characters. |
Constructor Summary | |
---|---|
NamedParameterUtils()
|
Method Summary | |
---|---|
private static int |
addNamedParameter(java.util.List<NamedParameterUtils.ParameterHolder> parameterList,
int totalParameterCount,
int escapes,
int i,
int j,
java.lang.String parameter)
|
private static int |
addNewNamedParameter(java.util.Set<java.lang.String> namedParameters,
int namedParameterCount,
java.lang.String parameter)
|
static java.util.List<SqlParameter> |
buildSqlParameterList(ParsedSql parsedSql,
SqlParameterSource paramSource)
Convert parameter declarations from an SqlParameterSource to a corresponding List of SqlParameters. |
static int[] |
buildSqlTypeArray(ParsedSql parsedSql,
SqlParameterSource paramSource)
Convert parameter types from an SqlParameterSource into a corresponding int array. |
static java.lang.Object[] |
buildValueArray(ParsedSql parsedSql,
SqlParameterSource paramSource,
java.util.List<SqlParameter> declaredParams)
Convert a Map of named parameter values to a corresponding array. |
static java.lang.Object[] |
buildValueArray(java.lang.String sql,
java.util.Map<java.lang.String,?> paramMap)
Convert a Map of named parameter values to a corresponding array. |
private static SqlParameter |
findParameter(java.util.List<SqlParameter> declaredParams,
java.lang.String paramName,
int paramIndex)
Find a matching parameter in the given list of declared parameters. |
private static boolean |
isParameterSeparator(char c)
Determine whether a parameter name ends at the current position, that is, whether the given character qualifies as a separator. |
static ParsedSql |
parseSqlStatement(java.lang.String sql)
Parse the SQL statement and locate any placeholders or named parameters. |
static java.lang.String |
parseSqlStatementIntoString(java.lang.String sql)
Parse the SQL statement and locate any placeholders or named parameters. |
private static int |
skipCommentsAndQuotes(char[] statement,
int position)
Skip over comments and quoted names present in an SQL statement |
static java.lang.String |
substituteNamedParameters(ParsedSql parsedSql,
SqlParameterSource paramSource)
Parse the SQL statement and locate any placeholders or named parameters. |
static java.lang.String |
substituteNamedParameters(java.lang.String sql,
SqlParameterSource paramSource)
Parse the SQL statement and locate any placeholders or named parameters. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private static final char[] PARAMETER_SEPARATORS
private static final java.lang.String[] START_SKIP
private static final java.lang.String[] STOP_SKIP
Constructor Detail |
---|
public NamedParameterUtils()
Method Detail |
---|
public static ParsedSql parseSqlStatement(java.lang.String sql)
sql
- the SQL statement
private static int addNamedParameter(java.util.List<NamedParameterUtils.ParameterHolder> parameterList, int totalParameterCount, int escapes, int i, int j, java.lang.String parameter)
private static int addNewNamedParameter(java.util.Set<java.lang.String> namedParameters, int namedParameterCount, java.lang.String parameter)
private static int skipCommentsAndQuotes(char[] statement, int position)
statement
- character array containing SQL statementposition
- current position of statement
public static java.lang.String substituteNamedParameters(ParsedSql parsedSql, SqlParameterSource paramSource)
The parameter values passed in are used to determine the number of placeholder to be used for a select list. Select lists should be limited to 100 or fewer elements. A larger number of elements is not guaramteed to be supported by the database and is strictly vendor-dependent.
parsedSql
- the parsed represenation of the SQL statementparamSource
- the source for named parameters
parseSqlStatement(java.lang.String)
public static java.lang.Object[] buildValueArray(ParsedSql parsedSql, SqlParameterSource paramSource, java.util.List<SqlParameter> declaredParams)
parsedSql
- the parsed SQL statementparamSource
- the source for named parametersdeclaredParams
- the List of declared SqlParameter objects
(may be null
). If specified, the parameter metadata will
be built into the value array in the form of SqlParameterValue objects.
private static SqlParameter findParameter(java.util.List<SqlParameter> declaredParams, java.lang.String paramName, int paramIndex)
declaredParams
- the declared SqlParameter objectsparamName
- the name of the desired parameterparamIndex
- the index of the desired parameter
null
if none foundprivate static boolean isParameterSeparator(char c)
public static int[] buildSqlTypeArray(ParsedSql parsedSql, SqlParameterSource paramSource)
parsedSql
- the parsed SQL statementparamSource
- the source for named parameterspublic static java.util.List<SqlParameter> buildSqlParameterList(ParsedSql parsedSql, SqlParameterSource paramSource)
parsedSql
- the parsed SQL statementparamSource
- the source for named parameterspublic static java.lang.String parseSqlStatementIntoString(java.lang.String sql)
This is a shortcut version of
parseSqlStatement(String)
in combination with
substituteNamedParameters(ParsedSql, SqlParameterSource)
.
sql
- the SQL statement
public static java.lang.String substituteNamedParameters(java.lang.String sql, SqlParameterSource paramSource)
This is a shortcut version of
substituteNamedParameters(ParsedSql, SqlParameterSource)
.
sql
- the SQL statementparamSource
- the source for named parameters
public static java.lang.Object[] buildValueArray(java.lang.String sql, java.util.Map<java.lang.String,?> paramMap)
This is a shortcut version of
buildValueArray(ParsedSql, SqlParameterSource, java.util.List)
.
sql
- the SQL statementparamMap
- the Map of parameters
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |