Top Description Fields Constructors Methods
com.mysql.cj.jdbc

pack-priv Class EscapeProcessor

extends Object
Class Inheritance
Imports
java.sql.SQLException, .Timestamp, java.text.SimpleDateFormat, java.util.Collections, .HashMap, .Locale, .Map, .StringTokenizer, .TimeZone, com.mysql.cj.Messages, com.mysql.cj.exceptions.ExceptionInterceptor, .MysqlErrorNumbers, com.mysql.cj.jdbc.exceptions.SQLError, com.mysql.cj.util.EscapeTokenizer, .StringUtils, .TimeUtil

EscapeProcessor performs all escape code processing as outlined in the JDBC spec by JavaSoft.

Field Summary

Modifier and TypeField and Description
private static Map<String, String>

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public static final Object

Returns:

the SQL after it has been escape processed.
escapeSQL
(String
the SQL to escape process.
sql
,
TimeZone
server time zone
connectionTimeZone
,
boolean
flag indicating if server supports fractional seconds
serverSupportsFractionalSecond
,
boolean
flag indicating if server truncates fractional seconds (sql_mode contains TIME_TRUNCATE_FRACTIONAL)
serverTruncatesFractionalSecond
,
ExceptionInterceptor
exception interceptor
exceptionInterceptor
)

Escape process one string

private static String

Returns:

result of rewriting
processConvertToken
(String
token
functionToken
,
ExceptionInterceptor
exception interceptor
exceptionInterceptor
)

Re-writes {fn convert (expr, type)} as cast(expr AS type)

private static void
processTimestampToken(TimeZone tz, StringBuilder newSql, String token, boolean serverSupportsFractionalSecond, boolean serverTruncatesFractionalSecond, ExceptionInterceptor exceptionInterceptor)

private static void
processTimeToken(StringBuilder newSql, String token, boolean serverSupportsFractionalSecond, ExceptionInterceptor exceptionInterceptor)

private static String

Returns:

a string with _no_ whitespace.
removeWhitespace
(String
the string to remove the whitespace from
toCollapse
)

Removes all whitespace from the given String.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

JDBC_CONVERT_TO_MYSQL_TYPE_MAPback to summary
private static Map<String, String> JDBC_CONVERT_TO_MYSQL_TYPE_MAP

Constructor Detail

EscapeProcessorback to summary
pack-priv EscapeProcessor()

Method Detail

escapeSQLback to summary
public static final Object escapeSQL(String sql, TimeZone connectionTimeZone, boolean serverSupportsFractionalSecond, boolean serverTruncatesFractionalSecond, ExceptionInterceptor exceptionInterceptor) throws SQLException

Escape process one string

Parameters
sql:String

the SQL to escape process.

connectionTimeZone:TimeZone

server time zone

serverSupportsFractionalSecond:boolean

flag indicating if server supports fractional seconds

serverTruncatesFractionalSecond:boolean

flag indicating if server truncates fractional seconds (sql_mode contains TIME_TRUNCATE_FRACTIONAL)

exceptionInterceptor:ExceptionInterceptor

exception interceptor

Returns:Object

the SQL after it has been escape processed.

Exceptions
SQLException:
if error occurs
processConvertTokenback to summary
private static String processConvertToken(String functionToken, ExceptionInterceptor exceptionInterceptor) throws SQLException

Re-writes {fn convert (expr, type)} as cast(expr AS type)

Parameters
functionToken:String

token

exceptionInterceptor:ExceptionInterceptor

exception interceptor

Returns:String

result of rewriting

Exceptions
SQLException:
if error occurs
processTimestampTokenback to summary
private static void processTimestampToken(TimeZone tz, StringBuilder newSql, String token, boolean serverSupportsFractionalSecond, boolean serverTruncatesFractionalSecond, ExceptionInterceptor exceptionInterceptor) throws SQLException
processTimeTokenback to summary
private static void processTimeToken(StringBuilder newSql, String token, boolean serverSupportsFractionalSecond, ExceptionInterceptor exceptionInterceptor) throws SQLException
removeWhitespaceback to summary
private static String removeWhitespace(String toCollapse)

Removes all whitespace from the given String. We use this to make escape token comparison white-space ignorant.

Parameters
toCollapse:String

the string to remove the whitespace from

Returns:String

a string with _no_ whitespace.