Package org.reldb.wrapd.sqldb
Class SQLParameterConverter
java.lang.Object
org.reldb.wrapd.sqldb.SQLParameterConverter
public class SQLParameterConverter
extends java.lang.Object
Convert SQL text with optional parameters specified as ? or {name} to
SQL text with only ? parameters, and obtain a list of parameter names,
where a generated parameter name will correspond to each ?, and the specified
name will be for each {name}.
-
Constructor Summary
Constructors Constructor Description SQLParameterConverter(java.lang.String sqlText)
Create a SQL parameter converter. -
Method Summary
Modifier and Type Method Description java.util.List<java.lang.String>
getParameterNames()
Get the parameter names obtained by process().java.lang.String
getSQLText()
Get SQL text.void
process()
Generate the revised SQL and parameter name list.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Constructor Details
-
SQLParameterConverter
public SQLParameterConverter(java.lang.String sqlText)Create a SQL parameter converter.- Parameters:
sqlText
- SQL query text. Parameters may be specified as ? or {name}. If {name} is used, it will appear as a corresponding Java method name. If ? is used, it will be named pn, where n is a unique number in the given definition. Use getSQLText() after generate() to obtain final SQL text with all {name} converted to ? for subsequent evaluation.
-
-
Method Details
-
process
public void process()Generate the revised SQL and parameter name list.- Throws:
java.lang.IllegalArgumentException
- is thrown if the parameter specification is invalid.
-
getSQLText
public java.lang.String getSQLText()Get SQL text. May be modified by process().- Returns:
- SQL text.
-
getParameterNames
public java.util.List<java.lang.String> getParameterNames()Get the parameter names obtained by process().- Returns:
- List of parameter names, in the order of appearance.
-