自内向外在作用域栈中查找变量，获取变量所在的 Map，主要用于 IncDec
778945
public Map getMapOfValue(Object key) {
		for (Scope cur=this; cur!=null; cur=cur.parent) {
			if (cur.data != null && cur.data.containsKey(key)) {
				return cur.data;
			}
		}
		return null;
	}
1116807
function _parseDuibaUrlQuery(urlQuery, appSecret){
    var urlObj = querystring.parse(_.trimEnd(urlQuery, '&'));
    var md5Sign = genSign(querystring.stringify(_.omit(urlObj,['sign'])), appSecret);

    // 将返回结果中的字符串 true/false，转换为 boolean 类型
    var TransDic = {
        'true': true,
        'false': false
    };
    for(var key in urlObj){
        var value = urlObj[key];
        urlObj[key] = typeof TransDic[value] === 'boolean' ? TransDic[value] : value;
    }

    if(md5Sign !== urlObj.sign){
        return {
            sign_pass: false,
            params: urlObj
        };
    }else{
        return {
            sign_pass: true,
            params: urlObj
        };
    }
}
824958
private void initMappingConfig(String key, MappingConfig baseConfigMap, MirrorDbConfig mirrorDbConfig, Dml dml) {
        MappingConfig mappingConfig = mirrorDbConfig.getTableConfig().get(key);
        if (mappingConfig == null) {
            // 构造表配置
            mappingConfig = new MappingConfig();
            mappingConfig.setDataSourceKey(baseConfigMap.getDataSourceKey());
            mappingConfig.setDestination(baseConfigMap.getDestination());
            mappingConfig.setGroupId(baseConfigMap.getGroupId());
            mappingConfig.setOuterAdapterKey(baseConfigMap.getOuterAdapterKey());
            mappingConfig.setConcurrent(baseConfigMap.getConcurrent());
            MappingConfig.DbMapping dbMapping = new MappingConfig.DbMapping();
            mappingConfig.setDbMapping(dbMapping);
            dbMapping.setDatabase(dml.getDatabase());
            dbMapping.setTable(dml.getTable());
            dbMapping.setTargetDb(dml.getDatabase());
            dbMapping.setTargetTable(dml.getTable());
            dbMapping.setMapAll(true);
            List<String> pkNames = dml.getPkNames();
            Map<String, String> pkMapping = new LinkedHashMap<>();
            pkNames.forEach(pkName -> pkMapping.put(pkName, pkName));
            dbMapping.setTargetPk(pkMapping);

            mirrorDbConfig.getTableConfig().put(key, mappingConfig);
        }
    }
703347
public Map<String, String> toMap() {
		Element root = doc.getDocumentElement();
		Map<String, String> params = new HashMap<String, String>();

		// 将节点封装成map形式
		NodeList list = root.getChildNodes();
		for (int i = 0; i < list.getLength(); i++) {
			Node node = list.item(i);
			params.put(node.getNodeName(), node.getTextContent());
		}
		// 含有空白符会生成一个#text参数
		params.remove("#text");
		return params;
	}
1295485
public static void fillPayMap(Map<String, Object> map, String key) {
        // 首先确保有随机数
        map.put("nonce_str", "" + R.random(10000000, 100000000));

        // 填充签名
        String sign = genPaySignMD5(map, key);
        map.put("sign", sign);
    }
1185610
private Map<String, Integer> createMapOfColumnIndex(String[] columns)
    {
        int i = 0;
        Map<String, Integer> map = new HashMap<String, Integer>();
        for (String column : columns)
        {
            map.put(column, i++);
        }
        return map;
    }
623349
public static String pkConditionSql(ESMapping mapping, Map<String, Object> data) {
        Set<ColumnItem> idColumns = new LinkedHashSet<>();
        SchemaItem schemaItem = mapping.getSchemaItem();

        TableItem mainTable = schemaItem.getMainTable();

        for (ColumnItem idColumnItem : schemaItem.getIdFieldItem(mapping).getColumnItems()) {
            if ((mainTable.getAlias() == null && idColumnItem.getOwner() == null)
                || (mainTable.getAlias() != null && mainTable.getAlias().equals(idColumnItem.getOwner()))) {
                idColumns.add(idColumnItem);
            }
        }

        if (idColumns.isEmpty()) {
            throw new RuntimeException("Not found primary key field in main table");
        }

        // 拼接condition
        StringBuilder condition = new StringBuilder(" ");
        for (ColumnItem idColumn : idColumns) {
            Object idVal = data.get(idColumn.getColumnName());
            if (mainTable.getAlias() != null) condition.append(mainTable.getAlias()).append(".");
            condition.append(idColumn.getColumnName()).append("=");
            if (idVal instanceof String) {
                condition.append("'").append(idVal).append("' AND ");
            } else {
                condition.append(idVal).append(" AND ");
            }
        }

        if (condition.toString().endsWith("AND ")) {
            int len2 = condition.length();
            condition.delete(len2 - 4, len2);
        }
        return condition.toString();
    }
512620
private static ScanDynamicModel analysis4DisconfUpdate(ScanStaticModel scanModel, Registry registry) {

        // 配置项或文件
        Map<DisconfKey, List<IDisconfUpdate>> inverseMap = new HashMap<DisconfKey, List<IDisconfUpdate>>();

        Set<Class<?>> disconfUpdateServiceSet = scanModel.getDisconfUpdateService();
        for (Class<?> disconfUpdateServiceClass : disconfUpdateServiceSet) {

            // 回调对应的参数
            DisconfUpdateService disconfUpdateService =
                    disconfUpdateServiceClass.getAnnotation(DisconfUpdateService.class);

            //
            // 校验是否有继承正确,是否继承IDisconfUpdate
            if (!ScanVerify.hasIDisconfUpdate(disconfUpdateServiceClass)) {
                continue;
            }

            //
            // 获取回调接口实例
            IDisconfUpdate iDisconfUpdate = getIDisconfUpdateInstance(disconfUpdateServiceClass, registry);
            if (iDisconfUpdate == null) {
                continue;
            }

            //
            // 配置项
            processItems(inverseMap, disconfUpdateService, iDisconfUpdate);

            //
            // 配置文件
            processFiles(inverseMap, disconfUpdateService, iDisconfUpdate);

        }

        // set data
        ScanDynamicModel scanDynamicModel = new ScanDynamicModel();
        scanDynamicModel.setDisconfUpdateServiceInverseIndexMap(inverseMap);

        //
        // set update pipeline
        //
        if (scanModel.getiDisconfUpdatePipeline() != null) {
            IDisconfUpdatePipeline iDisconfUpdatePipeline = getIDisconfUpdatePipelineInstance(scanModel
                    .getiDisconfUpdatePipeline(), registry);
            if (iDisconfUpdatePipeline != null) {
                scanDynamicModel.setDisconfUpdatePipeline(iDisconfUpdatePipeline);
            }
        }

        return scanDynamicModel;
    }
1066624
function _buildIriMap($iri_map, $key, $idx) {
    $entries = $iri_map[$key];
    $next = $iri_map[$key] = new ArrayObject();

    foreach($entries as $entry) {
      $iri = $entry->iri;
      if($idx >= strlen($iri)) {
        $letter = '';
      } else {
        $letter = $iri[$idx];
      }
      if(!isset($next[$letter])) {
        $next[$letter] = new ArrayObject();
      }
      $next[$letter][] = $entry;
    }

    foreach($next as $key => $value) {
      if($key === '') {
        continue;
      }
      $this->_buildIriMap($next, $key, $idx + 1);
    }
  }
557063
public static void decodeTo(String content, MultiMap map, String charset)
    {
        if (charset==null)
            charset=StringUtil.__ISO_8859_1;

        synchronized(map)
        {
            String key = null;
            String value = null;
            int mark=-1;
            boolean encoded=false;
            for (int i=0;i<content.length();i++)
            {
                char c = content.charAt(i);
                switch (c)
                {
                  case '&':
                      value = encoded
                          ?decodeString(content,mark+1,i-mark-1,charset)
                          :content.substring(mark+1,i);
                      
                      mark=i;
                      encoded=false;
                      if (key != null)
                      {
                          map.add(key,value);
                          key = null;
                      }
                      break;
                  case '=':
                      if (key!=null)
                          break;
                      key = encoded
                          ?decodeString(content,mark+1,i-mark-1,charset)
                          :content.substring(mark+1,i);
                      mark=i;
                      encoded=false;
                      break;
                  case '+':
                      encoded=true;
                      break;
                  case '%':
                      encoded=true;
                      break;
                }                
            }
            
            if (key != null)
            {
                value =  encoded
                    ?decodeString(content,mark+1,content.length()-mark-1,charset)
                    :content.substring(mark+1);
                map.add(key,value);
            }
            else if (mark<content.length())
            {
                key = encoded
                    ?decodeString(content,mark+1,content.length()-mark-1,charset)
                    :content.substring(mark+1);
                map.add(key,"");
            }
        }
    }
464822
@Override
    public Map<String, Object> toMap() {
        Map<String, Object> map = new HashMap<>();
        map.put("kontoinhaber", getKontoinhaber());
        map.put("iban", getIban());
        getBic().ifPresent(b -> map.put("bic", b));
        return map;
    }
211994
private static String getNoSign(Map<String, Object> params, boolean includeEmptyParam) {
        //对参数按照key做升序排序，对map的所有value进行处理，转化成string类型
        //拼接成key=value&key=value&....格式的字符串
        StringBuilder content = new StringBuilder();

        // 按照key做排序
        List<String> keys = new ArrayList<String>(params.keySet());
        Collections.sort(keys);

        String value = null;
        Object object = null;
        boolean isFirstParm = true;
        for (int i = 0; i < keys.size(); i++) {
            String key = (String) keys.get(i);
            object = params.get(key);

            if (object == null) {
                value = "";
            }else if (object instanceof String) {
                value = (String) object;
            } else {
                value = String.valueOf(object);
            }

            if (includeEmptyParam || !TextUtils.isEmpty(value)) {
                content.append((isFirstParm ? "" : "&") + key + "=" + value);
                isFirstParm = false;
            } else {
                continue;
            }
        }

        //待签名的字符串
        return content.toString();
    }
689388
function getIdMapping(idColumnNames, columns) {
  var idColumns = getIdColumns(idColumnNames, columns);
  if (idColumns.length === 0) {
    return {};
  }
  return idColumns[0].values.reduce(function(result, value, rowNumber) {
    var idString = getIdStringForRowNumber(idColumns, rowNumber);
    if (!defined(result[idString])) {
      result[idString] = [];
    }
    result[idString].push(rowNumber);
    return result;
  }, {});
}
313849
function contents(map, tight) {
    var minDepth = Infinity;
    var index = -1;
    var length = map.length;
    var table;

    /*
     * Find minimum depth.
     */

    while (++index < length) {
        if (map[index].depth < minDepth) {
            minDepth = map[index].depth;
        }
    }

    /*
     * Normalize depth.
     */

    index = -1;

    while (++index < length) {
        map[index].depth -= minDepth - 1;
    }

    /*
     * Construct the main list.
     */

    table = list();

    /*
     * Add TOC to list.
     */

    index = -1;

    while (++index < length) {
        insert(map[index], table, tight);
    }

    return table;
}
109656
private boolean hasRegisterMapper(Class<?> mapperInterface){
        //如果一个都没匹配上，很可能是还没有注册 mappers，此时通过 @RegisterMapper 注解进行判断
        Class<?>[] interfaces = mapperInterface.getInterfaces();
        boolean hasRegisterMapper = false;
        if (interfaces != null && interfaces.length > 0) {
            for (Class<?> anInterface : interfaces) {
                //自动注册标记了 @RegisterMapper 的接口
                if(anInterface.isAnnotationPresent(RegisterMapper.class)){
                    hasRegisterMapper = true;
                    //如果已经注册过，就避免在反复调用下面会迭代的方法
                    if (!registerMapper.containsKey(anInterface)) {
                        registerMapper(anInterface);
                    }
                }
                //如果父接口的父接口存在注解，也可以注册
                else if(hasRegisterMapper(anInterface)){
                    hasRegisterMapper = true;
                }
            }
        }
        return hasRegisterMapper;
    }
1149416
private String getMapResultString(Map result) {
        StringBuilder sb = new StringBuilder();
        Iterator<Entry> i = result.entrySet().iterator();
        if (!i.hasNext()) {
            return "{}";
        }
        sb.append('{');
        for (;;) {
            Entry e = i.next();
            Object key = e.getKey();
            Object value = e.getValue();
            // 注意: 修改为getResultString(e)进行递归处理
            sb.append(key == this ? "(this Map)" : getResultString(key));
            sb.append('=');
            // 注意: 修改为getResultString(e)进行递归处理
            sb.append(value == this ? "(this Map)" : getResultString(value));
            if (!i.hasNext()) {
                return sb.append('}').toString();
            }
            sb.append(", ");
        }
    }
8340
function CheckParams(data, query)
{
    for (let key in data) {
        let par = data[key];
        if(par.constructor!=Object)continue;//非
        let errkey = par.lbl?par.lbl:(par.rem?par.rem:key);//发生错误时的key的称呼方式
        if(par.constructor != Object){return `${errkey}接口文档定义错误。`}
        if (null==par.rem && null==par.lbl) {//这里则认为是两层及以上对象嵌套,递归
            if(par.need && null==query[key]){query[key]={};delete par.need;delete par.rem;delete par.lbl;}//如果需要的传外层的话,且为空时,默认给空对象
            let msg =CheckParams(data[key],query[key]);
            if(msg){return msg;}
        }else {
            //参数是否缺少
            if(!query){return 0;}
            let val = query[key];
            //检验必要的请求参数,非必要参数则不验证
            if (par.need&&null==val) {return`缺少${par.lbl?par.lbl:(par.rem?par.rem:key)}参数。`;}
            //若未传,且有默认值,则设置默认值,然后继续向下检验默认值
            if(null!=par.default&&null==val){query[key]=par.default;val = par.default;CTX.usedefault = true;}
            if(null!=par.def&&null==val){query[key]=par.def;val = par.def;CTX.usedefault = true;}
            if(null==val){continue;}//未传的非必须参数不需要校验
            //参数类型
            if(par.type) {
                let isObj=true;
                try{
                    switch(par.type.toLowerCase()){
                        case 'number':
                        case 'int':
                            if((par.type == 'number'||par.type =='int')&& parseInt(val)!=val)throw Error('类型错误');
                            query[key] = parseInt(val);
                            val = query[key];
                            break;
                        case 'float':
                            if(par.type == 'float' && parseFloat(val)!=val)throw Error('类型错误');
                            query[key] = parseFloat(val);
                            val = query[key];
                            break;
                        case 'string':if(val.constructor.name != 'String')throw Error('类型错误');break;
                        case 'boolean':
                            if(par.type == 'boolean'&&val.constructor!=Boolean&&(val.trim()!="false"&&val.trim()!="true"))throw Error('类型错误');
                            if(val.constructor!=Boolean)query[key]=(val.trim()==="false"?false:true);
                            val = query[key];
                            break;
                        case 'object':
                            if(val.constructor != Object){
                                try{
                                    val=JSON.parse(val);
                                }catch(err){isObj=false;}
                            }
                            if(!isObj)throw Error('类型错误');break;
                        case 'array':
                            if(val.constructor != Array){
                                try{
                                    val=JSON.parse(val);
                                }catch(err){isObj=false}
                            }
                            if(!isObj)throw Error('类型错误');break;
                        case 'array':if(val.constructor.name != 'Array')throw Error('类型错误');break;
                        case 'file':if(val.path && !isExist(val.path)) throw Error('类型错误');break;
                        case 'json':
                            try{
                                let t=JSON.parse(val);
                                query[key]=t;
                                val=t;
                            }catch(err){
                                throw Error('json格式错误');
                            }
                            break;
                        default :
                            if(val.constructor.name != 'String')throw Error('类型错误');
                    }
                }catch(err){return `${errkey}参数类型错误。`;}
            }
            let msg;
            //参数长度控制
            if(par.len){
                //接口文档在定义的时候定义为一个对象
                var ol = 0;
                let name = "长度";
                switch (par.type.toLowerCase()){
                    case 'array':
                        ol =  val.length;
                        name = "数组长度";
                        break;
                    case 'object'://数组或者对象
                        ol =  Object.keys(val).length;
                        name = "对象长度";
                        break;
                    case 'string':
                        ol = val.length;
                        name = "字符串长度";
                        break;
                    case 'file':
                        ol = val.size;//文件大小
                        name = "文件大小";
                        break;
                    default:
                        ol = val.length;
                        name = "字符串长度";
                        break;
                }
                if((msg=getRange(ol,par.len))){
                    return `${errkey}${name}${msg}${'file'==par.type?'字节':''}`;
                }
            }
            //范围控制
            if(par.range && (msg=getRange(val,par.range))){return `${errkey}${'string'==par.type?"字符内容":""}${msg}`;}
            //枚举型判断参数是否在设置范围内
            if (par.enum && par.enum.indexOf(val)<0) {return `${errkey}参数只能是${par.enum}。`;}
            //正则验证参数是否合法
            if(par.reg && !eval(par.reg).test((par.type == 'file' ? val.name:par.type=='json'?JSON.stringify(val):val))){return `${errkey}格式错误`;}
            // RES.usedefault = null;
        }
    }
    return 0;
}