MCPcopy
hub / github.com/alibaba/druid / TDDLHint

Method TDDLHint

core/src/main/java/com/alibaba/druid/sql/ast/TDDLHint.java:24–271  ·  view source on GitHub ↗
(String text)

Source from the content-addressed store, hash-verified

22 }
23
24 public TDDLHint(String text) {
25 super(text);
26
27 MySqlExprParser hintParser = new MySqlExprParser(text, SQLParserFeature.TDDLHint);
28 Lexer lexer = hintParser.getLexer();
29 if (lexer.token() == Token.PLUS || lexer.token() == Token.BANG) {
30 lexer.nextToken();
31 }
32
33 if (!lexer.identifierEquals(FnvHash.Constants.TDDL)) {
34 // error tddl hint
35 return;
36 }
37
38 lexer.nextToken();
39
40 switch (lexer.token()) {
41 case COLON:
42 lexer.nextToken();
43 break;
44 case LPAREN:
45 int rp = text.lastIndexOf(')');
46 if (rp != -1) {
47 json = text.substring(lexer.pos(), rp);
48 type = Type.JSON;
49 }
50 return;
51 default:
52 return;
53 }
54
55 for (; ; ) {
56 if (lexer.token() == Token.AND) {
57 lexer.nextToken();
58 }
59
60 String name = lexer.stringVal();
61 long hash = lexer.hashLCase();
62
63 if (lexer.identifierEquals(FnvHash.Constants.NODE)) {
64 lexer.nextToken();
65 if (lexer.token() == Token.IN) {
66 lexer.nextToken();
67 name = "NODE_IN";
68 } else if (lexer.token() == Token.EQ) {
69 lexer.nextToken();
70 name = "NODE_IN";
71 SQLExpr value = hintParser.primary();
72 Function function = new Function(name);
73 Argument argument = new Argument(null, value);
74 function.getArguments().add(argument);
75 functions.add(function);
76
77 if (lexer.token() == Token.EOF) {
78 break;
79 }
80
81 continue;

Callers

nothing calls this directly

Calls 15

tokenMethod · 0.95
nextTokenMethod · 0.95
identifierEqualsMethod · 0.95
posMethod · 0.95
stringValMethod · 0.95
hashLCaseMethod · 0.95
primaryMethod · 0.95
getArgumentsMethod · 0.95
markMethod · 0.95
resetMethod · 0.95
getLexerMethod · 0.80
substringMethod · 0.80

Tested by

no test coverage detected