@@ -0,0 +1,3086 @@
+/*%0A * Licensed to the Apache Software Foundation (ASF) under one or more%0A * contributor license agreements.  See the NOTICE file distributed with%0A * this work for additional information regarding copyright ownership.%0A * The ASF licenses this file to You under the Apache License, Version 2.0%0A * (the %22License%22); you may not use this file except in compliance with%0A * the License.  You may obtain a copy of the License at%0A *%0A *     http://www.apache.org/licenses/LICENSE-2.0%0A *%0A * Unless required by applicable law or agreed to in writing, software%0A * distributed under the License is distributed on an %22AS IS%22 BASIS,%0A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A * See the License for the specific language governing permissions and%0A * limitations under the License.%0A */%0A%0Apackage org.apache.shardingsphere.core.parsing;%0A%0Aimport com.google.common.base.Optional;%0Aimport org.apache.shardingsphere.core.constant.DatabaseType;%0Aimport org.apache.shardingsphere.core.metadata.table.ShardingTableMetaData;%0Aimport org.apache.shardingsphere.core.parsing.cache.ParsingResultCache;%0Aimport org.apache.shardingsphere.core.parsing.parser.sql.AbstractSQLStatement;%0Aimport org.apache.shardingsphere.core.parsing.parser.sql.SQLParserFactory;%0Aimport org.apache.shardingsphere.core.parsing.parser.sql.SQLStatement;%0Aimport org.apache.shardingsphere.core.rule.EncryptRule;%0A%0A/**%0A * Encrypt sql parsing engine.%0A *%0A * @author panjuan%0A */%0Apublic final class EncryptSQLParsingEngine %7B%0A    %0A    private final DatabaseType dbType;%0A    %0A    private final String sql;%0A    %0A    private final EncryptRule encryptRule;%0A    %0A    private final ShardingTableMetaData shardingTableMetaData;%0A    %0A    private final ParsingResultCache parsingResultCache;%0A    %0A    public EncryptSQLParsingEngine(final DatabaseType dbType, final String sql, final EncryptRule encryptRule, final ShardingTableMetaData shardingTableMetaData) %7B%0A        this.dbType = dbType;%0A        this.sql = sql;%0A        this.encryptRule = encryptRule;%0A        this.shardingTableMetaData = shardingTableMetaData;%0A        parsingResultCache = encryptRule.getParsingResultCache();%0A    %7D%0A    %0A    /**%0A     * Parse SQL.%0A     *%0A     * @param useCache use cache or not%0A     * @return parsed SQL statement%0A     */%0A    public SQLStatement parse(final boolean useCache) %7B%0A        Optional%3CSQLStatement%3E cachedSQLStatement = getSQLStatementFromCache(useCache);%0A        if (cachedSQLStatement.isPresent()) %7B%0A            return cachedSQLStatement.get();%0A        %7D%0A        SQLStatement result = SQLParserFactory.newInstance(dbType, encryptRule, shardingTableMetaData, sql).parse();%0A        if (result instanceof AbstractSQLStatement) %7B%0A            ((AbstractSQLStatement) result).setLogicSQL(sql);%0A        %7D%0A        if (useCache) %7B%0A            parsingResultCache.put(sql, result);%0A        %7D%0A        return result;%0A    %7D%0A    %0A    private Optional%3CSQLStatement%3E getSQLStatementFromCache(final boolean useCache) %7B%0A        return useCache ? Optional.fromNullable(parsingResultCache.getSQLStatement(sql)) : Optional.%3CSQLStatement%3Eabsent();%0A    %7D%0A%7D%0A

add EncryptSQLParsingEngine.java