OracleSelectParser.java 3.8 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
/*
 * Copyright 1999-2015 dangdang.com.
 * <p>
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * </p>
 */

T
terrymanu 已提交
18
package com.dangdang.ddframe.rdb.sharding.parsing.parser.dialect.oracle;
19

20
import com.dangdang.ddframe.rdb.sharding.api.rule.ShardingRule;
T
terrymanu 已提交
21
import com.dangdang.ddframe.rdb.sharding.parsing.lexer.LexerEngine;
22
import com.dangdang.ddframe.rdb.sharding.parsing.parser.sql.AbstractOrderBySQLParser;
T
terrymanu 已提交
23
import com.dangdang.ddframe.rdb.sharding.parsing.parser.sql.DistinctSQLParser;
24
import com.dangdang.ddframe.rdb.sharding.parsing.parser.sql.GroupBySQLParser;
T
terrymanu 已提交
25
import com.dangdang.ddframe.rdb.sharding.parsing.parser.sql.HavingSQLParser;
26
import com.dangdang.ddframe.rdb.sharding.parsing.parser.sql.SelectListSQLParser;
T
terrymanu 已提交
27
import com.dangdang.ddframe.rdb.sharding.parsing.parser.sql.SelectRestSQLParser;
T
terrymanu 已提交
28
import com.dangdang.ddframe.rdb.sharding.parsing.parser.sql.WhereSQLParser;
T
terrymanu 已提交
29
import com.dangdang.ddframe.rdb.sharding.parsing.parser.statement.dql.select.AbstractSelectParser;
30
import com.dangdang.ddframe.rdb.sharding.parsing.parser.statement.dql.select.SelectStatement;
31

T
terrymanu 已提交
32 33 34 35 36 37
/**
 * Oracle Select语句解析器.
 *
 * @author zhangliang
 */
public final class OracleSelectParser extends AbstractSelectParser {
38
    
T
terrymanu 已提交
39 40
    private final DistinctSQLParser distinctSQLParser;
    
41 42
    private final SelectListSQLParser selectListSQLParser;
    
T
terrymanu 已提交
43 44
    private final WhereSQLParser whereSQLParser;
    
45 46
    private final OracleHierarchicalQueryClauseParser hierarchicalQueryClauseParser;
    
47 48
    private final GroupBySQLParser groupBySQLParser;
    
T
terrymanu 已提交
49 50
    private final HavingSQLParser havingSQLParser;
    
T
terrymanu 已提交
51 52
    private final OracleModelClauseParser modelClauseParser;
    
53 54
    private final AbstractOrderBySQLParser orderBySQLParser;
    
T
terrymanu 已提交
55 56
    private final OracleForParser forParser;
    
T
terrymanu 已提交
57 58
    private final SelectRestSQLParser selectRestSQLParser;
    
59
    public OracleSelectParser(final ShardingRule shardingRule, final LexerEngine lexerEngine) {
T
terrymanu 已提交
60
        super(shardingRule, lexerEngine, new OracleTableSQLParser(shardingRule, lexerEngine));
T
terrymanu 已提交
61
        distinctSQLParser = new OracleDistinctSQLParser(lexerEngine);
62
        selectListSQLParser = new OracleSelectListSQLParser(shardingRule, lexerEngine);
T
terrymanu 已提交
63
        whereSQLParser = new OracleWhereSQLParser(lexerEngine);
64
        hierarchicalQueryClauseParser = new OracleHierarchicalQueryClauseParser(shardingRule, lexerEngine);
65
        groupBySQLParser = new OracleGroupBySQLParser(lexerEngine);
T
terrymanu 已提交
66
        havingSQLParser = new HavingSQLParser(lexerEngine);
T
terrymanu 已提交
67
        modelClauseParser = new OracleModelClauseParser(lexerEngine);
68
        orderBySQLParser = new OracleOrderBySQLParser(lexerEngine);
T
terrymanu 已提交
69
        forParser = new OracleForParser(lexerEngine);
T
terrymanu 已提交
70
        selectRestSQLParser = new SelectRestSQLParser(lexerEngine);
71 72
    }
    
T
terrymanu 已提交
73
    @Override
74
    protected void parseInternal(final SelectStatement selectStatement) {
T
terrymanu 已提交
75
        distinctSQLParser.parse();
76
        selectListSQLParser.parse(selectStatement, getItems());
77
        parseFrom(selectStatement);
T
terrymanu 已提交
78
        whereSQLParser.parse(getShardingRule(), selectStatement, getItems());
79
        hierarchicalQueryClauseParser.parse(selectStatement);
80
        groupBySQLParser.parse(selectStatement);
T
terrymanu 已提交
81
        havingSQLParser.parse();
T
terrymanu 已提交
82
        modelClauseParser.parse(selectStatement);
83
        orderBySQLParser.parse(selectStatement);
T
terrymanu 已提交
84
        forParser.parse(selectStatement);
T
terrymanu 已提交
85
        selectRestSQLParser.parse();
T
terrymanu 已提交
86
    }
87
}