/*--------------------优化内容：listAll、listByIds、findById合并-------------------------------
195255
public List<Channel> listByIds(Long... identities) {

        List<Channel> channels = new ArrayList<Channel>();
        try {
            List<ChannelDO> channelDos = null;
            if (identities.length < 1) {
                channelDos = channelDao.listAll();
                if (channelDos.isEmpty()) {
                    logger.debug("DEBUG ## couldn't query any channel, maybe hasn't create any channel.");
                    return channels;
                }
            } else {
                channelDos = channelDao.listByMultiId(identities);
                if (channelDos.isEmpty()) {
                    String exceptionCause = "couldn't query any channel by channelIds:" + Arrays.toString(identities);
                    logger.error("ERROR ## " + exceptionCause);
                    throw new ManagerException(exceptionCause);
                }
            }
            channels = doToModel(channelDos);
        } catch (Exception e) {
            logger.error("ERROR ## query channels has an exception!");
            throw new ManagerException(e);
        }

        return channels;
    }
284051
function htmlParse() {
  var data = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '<div></div>';
  var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  var transData = {}; //存放转化后的数据

  var res = {}; //返回的数据

  transData = (0, _html2json.html2json)(data, 'root', options); // console.log('解析结果是', transData);

  res = transData;
  return res;
}
119460
function () {
                    var index = 0;

                    while (index < fireLength) {

                        if ([].indexOf.call(arguments, list[index]) !== -1) {

                            // 从队列中删除当前回调
                            list.splice(index, 1);

                            // 如果当前回调队列被多层嵌套执行
                            // 上几层队列也可能会受到影响
                            if (firing) {
                                if (fireQueue.length) {
                                    fireQueue.forEach(function (value, key) {
                                        // 被删除的回调位于当前索引位置前面
                                        // 当前索引位置自减1
                                        if (index <= value) {
                                            fireQueue[key]--;
                                        }
                                    });
                                }

                                // 如果被删除的函数的索引位置在fireIndex的前面
                                // fireIndex自减1

                                if (index <= fireIndex) {
                                    fireIndex--;
                                }
                            }

                            // 回调列表长度改变
                            fireLength--;
                        } else {
                            index++;
                        }
                    }

                    return this;
                }
996023
function(id) {
    if (id && (id = id.trim())) {

      // js embend 同名.html 而 同名.html 又开启了依赖同名.js，然后就出现了，自己依赖自己了。
      // 所以这里做了 id !== this.id 的判断
      if (id !== this.id && !~this.requires.indexOf(id)) {
        this.requires.push(id);
      }

      // 如果在异步依赖中，则需要把它删了。
      var idx;
      if (~(idx = this.asyncs.indexOf(id))) {
        this.asyncs.splice(idx, 1);
      }

      return id;
    }
    return false;
  }
1207123
function completePreDefine( currentId ) {
        var preDefines = wait4PreDefines.slice( 0 );

        wait4PreDefines.length = 0;
        wait4PreDefines = [];

        // 预定义模块：
        // 此时处理的模块都是匿名define的模块
        each(
            preDefines,
            function ( module ) {
                modPreDefine(
                    module.id || currentId,
                    module.deps,
                    module.factory
                );
            }
        );

        modAnalyse();
    }
87231
function(){
		var partslist = this.modifyNodes;
		var newcomponents = [];
		for(var i=0,len=partslist.length;i<len;i++){
			partslist[i].component = null;
		}
		for(var i=0,len=partslist.length;i<len;i++){
			if(partslist[i].component!==null){ continue;}	// 既にidがついていたらスルー
			var component = this.createComponent();
			this.searchSingle(partslist[i], component);
			this.setComponentInfo(component);
			newcomponents.push(component);
		}
		this.modifyNodes = [];
		return newcomponents;
	}
564042
function parseContent(options, contents, filePath, asyncMod, callback) {
    // 读取主入口路径信息
    // eg: {id: "a", path: "/Users/tankunpeng/WebSite/gulp-seajs-combo/test/src/a.js", extName: ".js"}
    var pathResult = modPathResolve(options, filePath);
    // 设置入口模块基于base的真实id
    pathResult.origId = getorigIdbyBase(options, filePath, true);
    if (asyncMod) pathResult.asyncMod = asyncMod;
    // 读取主入口依赖模块路径信息
    // [{id: "b", extName: "", path: "/Users/tankunpeng/WebSite/gulp-seajs-combo/test/src/b", origId: "./b"},...]
    var deps = parseDeps(options, contents, pathResult);
    if (deps.length) {
        readDeps(options, deps);
        callback && callback();
    } else {
        callback && callback();
    }
}
1067910
@SuppressWarnings("unchecked")
    private static Object putIfNotExist(Object data, Map<String, Object> resultMap) {
        LOG.info("[RuleController]补全信息时:data = " + data);
        if (data == null) {
            return resultMap;
        } else if (!(data instanceof Collection) && !(data instanceof Map)) {//既不是map也不是list,需要显示地配置出最后一个unit的返回结果列表
            return resultMap;
        } else if (data instanceof Map) {
            putToMap((Map) data, resultMap);
            return data;
        } else/* if (data instanceof Collection)*/ {
            Collection newCollection = new ArrayList<>();
            Collection listData = (Collection) data;
            for (Object o : listData) {
                newCollection.add(putIfNotExist(o, resultMap));
            }
            return newCollection;
        }
    }
472443
function find(datas, context) {
    if (!datas[0][0]) return [];
    var results = [],
      notNullResult = 0;

    for (var i = 0, len = datas.length; i < len; i++) {
      var data = datas[i],
        dlen = data.length,
        last = data[dlen - 1],
        result = getTargets(data, context);

      if (result && result.length) {notNullResult++;};
      if (!results) results = result;
      else results =results.concat(result);
    }
    clearNthPositionCache();//清理
    if (notNullResult > 1) uniqueSort(results);
    return results;
  }
209341
function () {
            var reg = new RegExp(domUtils.fillChar, 'g');
            //取出来的空格会有c2a0会变成乱码，处理这种情况\u00a0
            return this.body[browser.ie ? 'innerText' : 'textContent'].replace(reg, '').replace(/\u00a0/g, ' ');
        }
166626
function tokenizeByLine (element, index, array) {
    parser.line = index + 1
    parser.column = 1

    var paragraphNode = parser.createParentNode('Paragraph')

    // 空行ではない場合
    if (element !== '') {
      // 半角括弧を全角括弧に変換
      var str = new Jaco(element).toWideJapneseSymbol().toString()

      // 改行ノードをParagraphNodeに追加する
      parser.add(parser.createTextNode('Text', str), paragraphNode)
    }

    // 改行ノードをParagraphNodeに追加する
    parser.add(parser.createTextNode('WhiteSpace', '\n'), paragraphNode)

    // ParagraphNodeをRoodNodeに追加
    parser.add(paragraphNode, rootNode)
  }
795247
public List<ENTITY> find(List<Match> matches, List<Order> order, int offset, int limit) {
        // FIXME
        Query operate =
                queryGenerator.getSelectQuery(matches, (order == null) ? null : order.toArray(new Order[order.size()]));
        String sql = operate.getSql();
        List<Object> params = operate.getParams();

        if (offset != 0 || limit != 0) {
            sql = sql + " limit ?, ?";
            params.add(offset);
            params.add(limit);
        }

        // 执行操作
        return findBySQL(sql, operate.getParams());
    }
1262765
@SuppressWarnings({ "unchecked", "rawtypes" })
	public static <T> Collection<T> addAll(Collection<T> collection, Object value, Type elementType) {
		if (null == collection || null == value) {
			return collection;
		}
		if (TypeUtil.isUnknow(elementType)) {
			// 元素类型为空时，使用Object类型来接纳所有类型
			elementType = Object.class;
		} else {
			final Class<?> elementRowType = TypeUtil.getClass(elementType);
			if (null != elementRowType && (elementRowType.isInstance(value) && false == Iterable.class.isAssignableFrom(elementRowType))) {
				// 其它类型按照单一元素处理
				collection.add((T) value);
				return collection;
			}
		}

		Iterator iter;
		if (value instanceof Iterator) {
			iter = (Iterator) value;
		} else if (value instanceof Iterable) {
			iter = ((Iterable) value).iterator();
		} else if (value instanceof Enumeration) {
			iter = new EnumerationIter<>((Enumeration) value);
		} else if (ArrayUtil.isArray(value)) {
			iter = new ArrayIter<>(value);
		} else if (value instanceof CharSequence) {
			// String按照逗号分隔的列表对待
			iter = StrUtil.splitTrim((CharSequence) value, CharUtil.COMMA).iterator();
		} else {
			// 其它类型按照单一元素处理
			iter = CollUtil.newArrayList(value).iterator();
		}

		final ConverterRegistry convert = ConverterRegistry.getInstance();
		while (iter.hasNext()) {
			collection.add((T) convert.convert(elementType, iter.next()));
		}

		return collection;
	}
1100532
public static <T> void forEach(T[] input,boolean[] inputSkip,T[] output ,int outPutIndex,ForEachController<T> controller)
	{
		for(int i=0;i<input.length;i++)
		{
			if(inputSkip[i])
			{
				continue;
			}
			output[outPutIndex]=input[i];//输出当前位锁定值
			ComputeStatus status=controller.onOutEvent(output, outPutIndex);
			if(status.isStop())
			{
				return;
			}
			if(status.isSkip())
			{//跳过下层循环
				continue;
			}
			outPutIndex++;
			if(outPutIndex>=input.length)
			{//如果是最后一个则返回
				break;
			}
			//解锁下一个
			inputSkip[i]=true;//锁定当前位占用索引,其它位不可使用该索引
			forEach(input, inputSkip, output, outPutIndex,controller);
			outPutIndex--;//回到当前
			inputSkip[i]=false;//释放锁定
		}
	}
1041751
def list(self, kind, tag_slug, cur_p=''):
        '''
        
        '''
        # 下面用来使用关键字过滤信息，如果网站信息量不是很大不要开启
        # Todo:
        # if self.get_current_user():
        #     redisvr.sadd(config.redis_kw + self.userinfo.user_name, tag_slug)

        if cur_p == '':
            current_page_number = 1
        else:
            current_page_number = int(cur_p)

        current_page_number = 1 if current_page_number < 1 else current_page_number

        pager_num = int(MPost2Label.total_number(tag_slug, kind) / CMS_CFG['list_num'])
        tag_info = MLabel.get_by_slug(tag_slug)
        if tag_info:
            tag_name = tag_info.name
        else:
            tag_name = 'Label search results'
        kwd = {'tag_name': tag_name,
               'tag_slug': tag_slug,
               'title': tag_name,
               'current_page': current_page_number,
               'router': router_post[kind],
               'kind': kind
               }

        the_list_file = './templates/list/label_{kind}.html'.format(kind=kind)

        if os.path.exists(the_list_file):
            tmpl = 'list/label_{kind}.html'.format(kind=kind)

        else:
            tmpl = 'list/label.html'

        self.render(tmpl,
                    infos=MPost2Label.query_pager_by_slug(
                        tag_slug,
                        kind=kind,
                        current_page_num=current_page_number
                    ),
                    kwd=kwd,
                    userinfo=self.userinfo,
                    pager=self.gen_pager(kind, tag_slug, pager_num, current_page_number),
                    cfg=CMS_CFG)
131317
private function mapGroup($linkTableName, $relation, $fields = '*', $where = [], $orderBy = ''): Result
    {
        // 生成关联表模型对象
        $table = $this->makeTable($linkTableName);

        // 生成本表关联字段与关联表关联字段
        list ($field, $linkField) = $this->relation($relation);

        // 生成本表关联字段的所有值
        $keys = $this->getMapKeys($field);
        if (!$keys) {
            return $this;
        }

        $linkResult = [];
        foreach ($keys as $value) {
            $where[$linkField] = $value;
            $linkData = $table->groupBy($linkField)->select($this->append($fields, $linkField), $where, $orderBy)
                ->toArray();

            //如果没有关联数据
            if (!$linkData) {
                continue;
            }

            $key = $linkData[0][$linkField];
            if (!array_key_exists($key, $linkResult)) {
                $linkResult[$key] = [];
            }
            $linkResult[$key] = $linkData[0];
        }

        $fields = $this->table->createFields($fields);

        // 为本表每行数据补充字段
        foreach ($this->data as $key => $row) {
            // 字段补充成功
            if ($this->mapFill($linkResult, $field, $row, $key)) {
                continue;
            }

            // 没有对应成功,补充空字符串
            $this->data[$key] = $this->appendNull($row, $fields);
        }
        $this->row2Obj();
        return $this;
    }
677135
private static List<Field> getAllField(Class<?> entityClass, List<Field> fieldList) {
        if (fieldList == null) {
            fieldList = new ArrayList<Field>();
        }
        if (entityClass.equals(Object.class)) {
            return fieldList;
        }
        Field[] fields = entityClass.getDeclaredFields();
        for (Field field : fields) {
            // 排除静态字段
            if (!Modifier.isStatic(field.getModifiers())) {
                fieldList.add(field);
            }
        }
        Class<?> superClass = entityClass.getSuperclass();
        if (superClass != null && !superClass.equals(Object.class)
                && (!Map.class.isAssignableFrom(superClass) && !Collection.class.isAssignableFrom(superClass))) {
            return getAllField(entityClass.getSuperclass(), fieldList);
        }
        return fieldList;
    }