Package org.mariadb.jdbc.util
Class ClientParser
- java.lang.Object
-
- org.mariadb.jdbc.util.ClientParser
-
- All Implemented Interfaces:
PrepareResult
public final class ClientParser extends java.lang.Object implements PrepareResult
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static classClientParser.LexState
-
Field Summary
Fields Modifier and Type Field Description private booleanisInsertprivate booleanisInsertDuplicateprivate booleanisMultiQueryprivate intparamCountprivate java.util.List<java.lang.Integer>paramPositionsprivate byte[]queryprivate java.lang.Stringsqlprivate java.util.List<java.lang.Integer>valuesBracketPositions
-
Constructor Summary
Constructors Modifier Constructor Description privateClientParser(java.lang.String sql, byte[] query, java.util.List<java.lang.Integer> paramPositions, java.util.List<java.lang.Integer> valuesBracketPositions, boolean isInsert, boolean isInsertDuplicate, boolean isMultiQuery)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private static booleanequalsIgnoreCase(byte b, byte lower)Fast case-insensitive byte comparison for ASCII letters.intgetParamCount()java.util.List<java.lang.Integer>getParamPositions()byte[]getQuery()java.lang.StringgetSql()java.util.List<java.lang.Integer>getValuesBracketPositions()private static booleanisDelimiter(byte b)Fast check if byte is a delimiter character: ();><=-+, Avoids String.indexOf() overheadbooleanisInsert()booleanisInsertDuplicate()booleanisMultiQuery()private static booleanisWhitespace(byte b)Fast check if byte is whitespace: space, \n, \r, \tstatic ClientParserparameterParts(java.lang.String queryString, boolean noBackslashEscapes)For a givenqueryString, get query - a byte array containing the UTF8 representation of that string paramPositions - the byte positions of any '?' positional parameters inqueryand set the following flags: isInsert - queryString contains 'INSERT' outside of quotes, without one of the characters '();><=-+,' immediately preceding or following isInsertDuplicate - isInsert && queryString contains 'DUPLICATE' outside of quotes, without one of the characters '();><=-+,' immediately preceding or following isMulti - queryString contains text after the last ';' outside of quotesstatic ClientParserrewritableParts(java.lang.String queryString, boolean noBackslashEscapes)For a givenqueryString, get the fields and flags fromparameterParts(String, boolean), and valuesBracketPositions - a two-element list containing the positions of the opening and closing parenthesis of the VALUES block
-
-
-
Field Detail
-
sql
private final java.lang.String sql
-
query
private final byte[] query
-
paramPositions
private final java.util.List<java.lang.Integer> paramPositions
-
valuesBracketPositions
private final java.util.List<java.lang.Integer> valuesBracketPositions
-
paramCount
private final int paramCount
-
isInsert
private final boolean isInsert
-
isInsertDuplicate
private final boolean isInsertDuplicate
-
isMultiQuery
private final boolean isMultiQuery
-
-
Method Detail
-
parameterParts
public static ClientParser parameterParts(java.lang.String queryString, boolean noBackslashEscapes)
For a givenqueryString, get- query - a byte array containing the UTF8 representation of that string
- paramPositions - the byte positions of any '?' positional parameters in
query
- isInsert - queryString contains 'INSERT' outside of quotes, without one of the characters '();><=-+,' immediately preceding or following
- isInsertDuplicate - isInsert && queryString contains 'DUPLICATE' outside of quotes, without one of the characters '();><=-+,' immediately preceding or following
- isMulti - queryString contains text after the last ';' outside of quotes
- Parameters:
queryString- querynoBackslashEscapes- escape mode- Returns:
- ClientParser
-
rewritableParts
public static ClientParser rewritableParts(java.lang.String queryString, boolean noBackslashEscapes)
For a givenqueryString, get the fields and flags fromparameterParts(String, boolean), and- valuesBracketPositions - a two-element list containing the positions of the opening and closing parenthesis of the VALUES block
- Parameters:
queryString- querynoBackslashEscapes- escape mode- Returns:
- ClientParser
-
getSql
public java.lang.String getSql()
- Specified by:
getSqlin interfacePrepareResult
-
getQuery
public byte[] getQuery()
-
getParamPositions
public java.util.List<java.lang.Integer> getParamPositions()
-
getValuesBracketPositions
public java.util.List<java.lang.Integer> getValuesBracketPositions()
-
getParamCount
public int getParamCount()
- Specified by:
getParamCountin interfacePrepareResult
-
isInsert
public boolean isInsert()
-
isInsertDuplicate
public boolean isInsertDuplicate()
-
isMultiQuery
public boolean isMultiQuery()
-
isDelimiter
private static boolean isDelimiter(byte b)
Fast check if byte is a delimiter character: ();><=-+, Avoids String.indexOf() overhead
-
isWhitespace
private static boolean isWhitespace(byte b)
Fast check if byte is whitespace: space, \n, \r, \t
-
equalsIgnoreCase
private static boolean equalsIgnoreCase(byte b, byte lower)Fast case-insensitive byte comparison for ASCII letters. Uses bitwise OR to convert to lowercase before comparison.
-
-