|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.javasimon.jdbc.SqlNormalizer
public final class SqlNormalizer
SqlNormalizer takes SQL statement and replaces parameters with question marks. It is important to realize, that normalizer IS NOT SQL analyzer. It makes as simple replacement as possible (with my coding skill ;-)) to still truly represent the original statement. Normalized statement is merely used to recognize the original one and also to merge the same statements with various arguments. Its primary purpose is to limit count of distinct per-statement Simons. It doesn't suppose to be perfect or proof to all dialects.
Usage is simple, you create normalizer with SQL statement and than you can ask the object for normalizedSql and type via respective getters.
| Field Summary | |
|---|---|
private static Replacer[] |
FIRST_REPLACERS
|
private static Replacer |
FUNCTION_REPLACER
|
private String |
normalizedSql
|
private static Replacer[] |
SECOND_REPLACERS
|
private String |
sql
|
private String |
type
|
private static Replacer |
TYPE_SELECTOR
|
| Constructor Summary | |
|---|---|
SqlNormalizer(List<String> batch)
Constructor for batch normalization. |
|
SqlNormalizer(String sql)
Creates SQL normalizer and performs the normalization. |
|
| Method Summary | |
|---|---|
private void |
applyReplacers(Replacer[] replacers)
|
String |
getNormalizedSql()
Returns the normalized SQL. |
String |
getSql()
Returns the original SQL. |
String |
getType()
Returns SQL type which is typicaly first word of the SQL (insert, select, etc). |
private void |
normalize(String sql)
|
String |
toString()
Returns human readable string describing this SQL normalizer. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
private static final Replacer[] FIRST_REPLACERS
private static final Replacer[] SECOND_REPLACERS
private static final Replacer FUNCTION_REPLACER
private static final Replacer TYPE_SELECTOR
private final String sql
private String normalizedSql
private String type
| Constructor Detail |
|---|
public SqlNormalizer(String sql)
sql - SQL to normalizepublic SqlNormalizer(List<String> batch)
batch - list of statements| Method Detail |
|---|
private void normalize(String sql)
private void applyReplacers(Replacer[] replacers)
public String getSql()
public String getNormalizedSql()
public String getType()
public String toString()
toString in class Object
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||