Top Description Inners Fields Constructors Methods
com.mysql.cj.xdevapi

public Class ExprParser

extends Object
Class Inheritance
Imports
java.util.ArrayList, .Arrays, .Collections, .HashMap, .LinkedList, .List, .Map, java.util.function.Supplier, com.mysql.cj.exceptions.WrongArgumentException, com.mysql.cj.x.protobuf.MysqlxCrud.Column, .MysqlxCrud.Order, .MysqlxCrud.Projection, .MysqlxExpr.Array, .MysqlxExpr.ColumnIdentifier, .MysqlxExpr.DocumentPathItem, .MysqlxExpr.Expr, .MysqlxExpr.FunctionCall, .MysqlxExpr.Identifier, .MysqlxExpr.Object, .MysqlxExpr.Object.ObjectField, .MysqlxExpr.Operator

Expression parser for X protocol.

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv static interface
ExprParser.ParseExpr

An expression parser.

pack-priv static class
private static enum
ExprParser.TokenType

Token types used by the lexer.

Field Summary

Modifier and TypeField and Description
private boolean
allowRelationalColumns

Are relational columns identifiers allowed?

private static HashMap<Character, Character>
pack-priv Map<String, Integer>
placeholderNameToPosition

Mapping of names to positions for named placeholders.

pack-priv int
positionalPlaceholderCount

Number of positional placeholders.

pack-priv static Map<String, ExprParser.TokenType>
reservedWords

Mapping of reserved words to token types.

pack-priv String
string

String being parsed.

pack-priv int
tokenPos

Parser's position in token stream.

pack-priv List<ExprParser.Token>
tokens

Token stream produced by lexer.

Constructor Summary

AccessConstructor and Description
public
ExprParser(String
expression string to parse
s
)

Constructor.

public
ExprParser(String
expression string to parse
s
,
boolean
are relational columns identifiers allowed?
allowRelationalColumns
)

Constructor.

Method Summary

Modifier and TypeMethod and Description
pack-priv MysqlxExpr.Expr
pack-priv MysqlxExpr.Expr
pack-priv MysqlxExpr.Expr
pack-priv void
assertTokenAt(int
The current position in the string
pos
,
ExprParser.TokenType type)

Assert that the token at pos is of type type.

pack-priv MysqlxExpr.Expr

Returns:

Expr
atomicExpr
()

Parse an atomic expression.

pack-priv MysqlxExpr.Expr
pack-priv MysqlxExpr.Expr

Returns:

Expr
buildUnaryOp
(String
operator name
name
,
MysqlxExpr.Expr
operator parameter
param
)

Build a unary operator expression.

pack-priv MysqlxExpr.Expr

Returns:

Expr
columnIdentifier
()

Parse a column identifier (which may optionally include a JSON document path).

pack-priv MysqlxExpr.Expr
pack-priv String

Returns:

the string value of the consumed token
consumeToken
(ExprParser.TokenType t)

Consume token.

pack-priv boolean

Returns:

true if equals
currentTokenTypeEquals
(ExprParser.TokenType t)

Does the current token have type `t'?

pack-priv MysqlxExpr.DocumentPathItem
docPathArrayLoc()

Parse a document path array index.

pack-priv MysqlxExpr.DocumentPathItem
docPathMember()

Parse a document path member.

public MysqlxExpr.Expr

Returns:

Expr
documentField
()

Parse a document field.

public List<MysqlxExpr.DocumentPathItem>

Returns:

list of DocumentPathItem objects
documentPath
()

Parse a JSON-style document path, like WL#7909, but prefix by @.

pack-priv MysqlxExpr.Expr
expr()

pack-priv MysqlxExpr.Expr

Returns:

an Expr representing the function call.
functionCall
()

Parse a function call of the form: IDENTIFIER PAREN_EXPR_LIST.

public Map<String, Integer>

Returns:

a mapping of parameter names to positions.
getPlaceholderNameToPositionMap
()

Get a mapping of parameter names to positions.

public int

Returns:

the number of positional placeholders in the expression
getPositionalPlaceholderCount
()

Return the number of positional placeholders in the expression.

pack-priv MysqlxExpr.Identifier

Returns:

Identifier
identifier
()

Parse an identifier for a function call: [schema.]name

pack-priv MysqlxExpr.Expr
pack-priv void
lex()

Lexer for X DevAPI expression language.

private int

Returns:

the next position in the string after the number.
lexNumber
(int
The current position in the string
i
)

Helper function to match integer or floating point numbers.

pack-priv MysqlxExpr.Expr
pack-priv boolean

Returns:

true if equals
nextCharEquals
(int
The current position in the string
i
,
char
character to compare with
c
)

Does the next character equal the given character?

pack-priv boolean

Returns:

true if equals
nextTokenTypeEquals
(ExprParser.TokenType t)

Does the next token have type `t'?

pack-priv MysqlxExpr.Expr
pack-priv List<MysqlxExpr.Expr>

Returns:

a List of expressions
parenExprList
()

Parse a paren-enclosed expression list.

public MysqlxExpr.Expr

Returns:

an X protocol expression tree
parse
()

Parse the entire string as an expression.

private <
the type of element to be parsed
T
>
List<T>

Returns:

a list of elements parsed
parseCommaSeparatedList
(Supplier<T>
the single element parser
elementParser
)

Utility method to wrap a parser of a list of elements separated by comma.

public List<MysqlxCrud.Projection>

Returns:

list of Projection objects
parseDocumentProjection
()

Parse a document projection which is similar to SELECT but with document paths as the target alias.

public List<MysqlxExpr.Expr>

Returns:

list of Expr objects
parseExprList
()

Parse a list of expressions used for GROUP BY.

pack-priv MysqlxExpr.Expr

Returns:

an expression tree of the binary operator or a single operand
parseLeftAssocBinaryOpExpr
(ExprParser.TokenType[]
The token types that denote this operator.
types
,
ExprParser.ParseExpr
The inner parser that should be called to parse operands.
innerParser
)

Parse a left-associated binary operator.

public List<MysqlxCrud.Order>

Returns:

list of Order objects
parseOrderSpec
()

Parse an ORDER BY specification which is a comma-separated list of expressions, each may be optionally suffixed by ASC/DESC.

public MysqlxCrud.Column

Returns:

Column
parseTableInsertField
()

Parse an INSERT field name.

public List<MysqlxCrud.Projection>

Returns:

list of Projection objects
parseTableSelectProjection
()

Parse a SELECT projection which is a comma-separated list of expressions, each optionally suffixed with a target alias.

public MysqlxExpr.ColumnIdentifier
parseTableUpdateField()

Parse an UPDATE field which can include can document paths.

pack-priv boolean

Returns:

true if equals
posTokenTypeEquals
(int
The current position in the string
pos
,
ExprParser.TokenType t)

Does the token at position `pos' have type `t'?

pack-priv MysqlxExpr.Expr
pack-priv MysqlxExpr.Expr
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait