|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.objectweb.cjdbc.common.sql.filters.MacrosHandler
This class defines a MacrosHandler
Field Summary | |
private long |
clockResolution
|
private int |
currentDate
|
private int |
currentTime
|
private int |
currentTimestamp
|
static int |
DATE_DATE
Value if date macro should be replaced by an java.sql.Date value |
static int |
DATE_OFF
Value if a date macro should not be replaced |
static int |
DATE_TIME
Value if date macro should be replaced by an java.sql.Time value |
static int |
DATE_TIMESTAMP
Value if date macro should be replaced by an java.sql.Timestamp value |
private static java.lang.String |
MACRO_CURRENT_DATE
String for current_date macro |
private static java.lang.String |
MACRO_CURRENT_TIME
String for current_times macro |
private static java.lang.String |
MACRO_CURRENT_TIMESTAMP
String for current_timestamp macro |
private static java.lang.String |
MACRO_NOW
String for now() macro |
private static java.lang.String |
MACRO_RAND
String for rand() macro |
private static java.lang.String |
MACRO_TIMEODFAY
String for timeofday() macro |
private boolean |
needsDateProcessing
|
private boolean |
needsProcessing
|
private int |
now
|
static int |
RAND_DOUBLE
Value if rand() macro should be replaced by an double value |
static int |
RAND_FLOAT
Value if rand() macro should be replaced by an float value (default) |
static int |
RAND_INT
Value if rand() macro should be replaced by an integer value |
static int |
RAND_LONG
Value if rand() macro should be replaced by an long value |
static int |
RAND_OFF
Value if rand() macro should not be replaced |
private java.util.Random |
randGenerator
|
private int |
replaceRand
|
private int |
timeOfDay
|
static int |
UNKNOWN_INT_VALUE
Used when level is unknown |
static java.lang.String |
UNKNOWN_STRING_VALUE
Used when level is unknown |
Fields inherited from interface org.objectweb.cjdbc.common.xml.XmlComponent |
DOCTYPE_CONTROLLER, DOCTYPE_DB, XML_VERSION |
Constructor Summary | |
MacrosHandler(int replaceRand,
long clockResolution,
int now,
int currentDate,
int currentTime,
int timeOfDay,
int currentTimestamp)
Creates a new MacrosHandler object |
Method Summary | |
static int |
getIntDateLevel(java.lang.String dateLevel)
Convert the date level from string (xml value) to integer |
static int |
getIntRandLevel(java.lang.String randLevel)
Convert the rand level from string (xml value) to integer |
private java.lang.Integer[] |
getQuoteIndexes(java.lang.String sql)
Retrieve all the indexes of quotes in the string |
static java.lang.String |
getStringDateLevel(int dateLevel)
Convert the date level from int (java code) to string (xml value) |
static java.lang.String |
getStringRandLevel(int randLevel)
Convert the rand level from int (java code) to string (xml value) |
java.lang.String |
getXml()
Return this MacrosHandler to the corresponding xml form |
java.lang.String |
macroDate(java.lang.String originalSql,
java.lang.String macroPattern,
int replacementPolicy,
long currentClock,
java.lang.Integer[] idxs)
Processes a date related macro using the given timestamp. |
java.lang.String |
macroRand(java.lang.String originalSql,
java.lang.Integer[] idxs)
Replaces rand() with a randomized value. |
java.lang.String |
processMacros(java.lang.String sql)
Processes all macros in the given request and returns a new String with the processed macros. |
private boolean |
shouldReplaceMacro(int idx,
java.lang.Integer[] list)
Should we replace a macro situated at index idx, knowing that the quotes are at indexes list |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final int UNKNOWN_INT_VALUE
public static final java.lang.String UNKNOWN_STRING_VALUE
private static final java.lang.String MACRO_RAND
public static final int RAND_OFF
public static final int RAND_INT
public static final int RAND_LONG
public static final int RAND_FLOAT
public static final int RAND_DOUBLE
private final java.util.Random randGenerator
private int replaceRand
private static final java.lang.String MACRO_NOW
private static final java.lang.String MACRO_CURRENT_DATE
private static final java.lang.String MACRO_CURRENT_TIME
private static final java.lang.String MACRO_TIMEODFAY
private static final java.lang.String MACRO_CURRENT_TIMESTAMP
public static final int DATE_OFF
public static final int DATE_DATE
public static final int DATE_TIME
public static final int DATE_TIMESTAMP
private long clockResolution
private int now
private int currentDate
private int currentTime
private int timeOfDay
private int currentTimestamp
private boolean needsProcessing
private boolean needsDateProcessing
Constructor Detail |
public MacrosHandler(int replaceRand, long clockResolution, int now, int currentDate, int currentTime, int timeOfDay, int currentTimestamp)
MacrosHandler
object
replaceRand
- replacement of rand() macroclockResolution
- clock resolution for date macrosnow
- replacement of now()currentDate
- replacement of current_datecurrentTime
- replacement of current_timetimeOfDay
- replacement of timeofday()currentTimestamp
- replacement of current_timestampMethod Detail |
public static final int getIntRandLevel(java.lang.String randLevel)
randLevel
- the rand level
public java.lang.String getXml()
MacrosHandler
to the corresponding xml form
getXml
in interface XmlComponent
public static final java.lang.String getStringRandLevel(int randLevel)
randLevel
- the rand level
public static final int getIntDateLevel(java.lang.String dateLevel)
dateLevel
- the date level
public static final java.lang.String getStringDateLevel(int dateLevel)
dateLevel
- the date level
public java.lang.String macroDate(java.lang.String originalSql, java.lang.String macroPattern, int replacementPolicy, long currentClock, java.lang.Integer[] idxs)
originalSql
- original SQL requestmacroPattern
- macro text to look forreplacementPolicy
- DATE_DATE, DATE_TIME or DATE_TIMESTAMPcurrentClock
- current time in msidxs
- quote indexes
public java.lang.String macroRand(java.lang.String originalSql, java.lang.Integer[] idxs)
originalSql
- original SQL requestidxs
- quote indexes
public final java.lang.String processMacros(java.lang.String sql)
sql
- SQL statement to process
private java.lang.Integer[] getQuoteIndexes(java.lang.String sql)
sql
- the original query
private boolean shouldReplaceMacro(int idx, java.lang.Integer[] list)
idx
- the index of the macrolist
- the indexes of quotes
true
if we should change the macro,
false
if the macro is within a string
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |