icu.easyj.core.code.analysis.CodeAnalysisUtils Maven / Gradle / Ivy
/*
* Copyright 2021 the original author or authors.
*
* 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
*
* https://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 icu.easyj.core.code.analysis;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
import icu.easyj.core.exception.AnalysisException;
import icu.easyj.core.util.PatternUtils;
import icu.easyj.core.util.StringUtils;
import org.apache.commons.lang3.ArrayUtils;
import org.springframework.lang.NonNull;
/**
* 代码解析类
*
* @author wangliang181230
*/
public abstract class CodeAnalysisUtils {
//region 解析参数列表
/**
* 解析参数列表
*
* @param parametersStr 含所有参数的串(不要包含其他代码内容)
* @param limitParameterSize 限制获取参数数量
* @return parameters 返回参数列表
*/
@NonNull
public static Object[] analysisParameters(String parametersStr, int limitParameterSize) {
if (StringUtils.isBlank(parametersStr) || limitParameterSize <= 0) {
return ArrayUtils.EMPTY_OBJECT_ARRAY;
}
Matcher mParameter = PatternUtils.P_CODE_DATA_VALUE.matcher(parametersStr);
List