Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* Copyright 2020 io.xream.sqli
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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.
*/
package io.xream.sqli.builder;
import io.xream.sqli.filter.BaseTypeFilter;
import io.xream.sqli.filter.UnsafeSyntaxFilter;
import io.xream.sqli.mapping.Mappable;
import io.xream.sqli.mapping.Mapper;
import io.xream.sqli.mapping.Script;
import io.xream.sqli.mapping.SqlNormalizer;
import io.xream.sqli.parser.BeanElement;
import io.xream.sqli.parser.Parsed;
import io.xream.sqli.parser.Parser;
import io.xream.sqli.support.TimeSupport;
import io.xream.sqli.util.EnumUtil;
import io.xream.sqli.util.SqliStringUtil;
import java.util.Iterator;
import java.util.List;
/**
* @Author Sim
*/
public interface ConditionToSql extends Mapper, SqlNormalizer, UnsafeSyntaxFilter {
default void buildConditionSql(StringBuilder sb, List bbList, Mappable mappable) {
if (bbList == null || bbList.isEmpty())
return;
for (Bb bb : bbList) {
Op p = bb.getP();
if (p == Op.LIMIT || p == Op.OFFSET) {
continue;
}
if (p == Op.SUB) {
if (bb.getSubList().isEmpty())
continue;
bb.getSubList().get(0).setC(Op.NONE);
sb.append(bb.getC().sql());
sb.append(SqlScript.SPACE).append(SqlScript.LEFT_PARENTTHESIS).append(SqlScript.SPACE);
buildConditionSql(sb, bb.getSubList(), mappable);
sb.append(SqlScript.SPACE).append(SqlScript.RIGHT_PARENTTHESIS);
continue;
}
String mapper = null;
if (p == Op.X){
final String str = normalizeSql(bb.getKey());
StringBuilder sbx = new StringBuilder();
mapping((reg)->str.split(reg), mappable,sbx);
mapper = sbx.toString();
sb.append(bb.getC().sql()).append(mapper);
}else {
mapper = mapping(bb.getKey(), mappable);
sb.append(bb.getC().sql()).append(mapper).append(Script.SPACE).append(p.sql()).append(Script.SPACE);
}
if (bb.getValue() != null) {
if (p == Op.IN || p == Op.NOT_IN) {
List