特殊形式的规范化方法

该方法识别特殊形式的时间表达式单元的各个字段
553346
public void norm_setTotal() {
        String rule;
        Pattern pattern;
        Matcher match;
        String[] tmp_parser;
        String tmp_target;

        /*
         * 修改了函数中所有的匹配规则使之更为严格
         * modified by 曹零
         */
        rule = "(?<!(周|星期))([0-2]?[0-9]):[0-5]?[0-9]:[0-5]?[0-9]";
        pattern = Pattern.compile(rule);
        match = pattern.matcher(Time_Expression);
        if (match.find()) {
            tmp_parser = new String[3];
            tmp_target = match.group();
            tmp_parser = tmp_target.split(":");
            _tp.tunit[3] = Integer.parseInt(tmp_parser[0]);
            _tp.tunit[4] = Integer.parseInt(tmp_parser[1]);
            _tp.tunit[5] = Integer.parseInt(tmp_parser[2]);
        } /*
         * 添加了省略秒的:固定形式的时间规则匹配
         * add by 曹零
         */ else {
            rule = "(?<!(周|星期))([0-2]?[0-9]):[0-5]?[0-9]";
            pattern = Pattern.compile(rule);
            match = pattern.matcher(Time_Expression);
            if (match.find()) {
                tmp_parser = new String[2];
                tmp_target = match.group();
                tmp_parser = tmp_target.split(":");
                _tp.tunit[3] = Integer.parseInt(tmp_parser[0]);
                _tp.tunit[4] = Integer.parseInt(tmp_parser[1]);
            }
        }
        /*
         * 增加了:固定形式时间表达式的
         * 中午,午间,下午,午后,晚上,傍晚,晚间,晚,pm,PM
         * 的正确时间计算，规约同上
         * add by 曹零
         */
        rule = "(中午)|(午间)";
        pattern = Pattern.compile(rule);
        match = pattern.matcher(Time_Expression);
        if (match.find()) {
            if (_tp.tunit[3] >= 0 && _tp.tunit[3] <= 10) {
                _tp.tunit[3] += 12;
            }
        }

        rule = "(下午)|(午后)|(pm)|(PM)";
        pattern = Pattern.compile(rule);
        match = pattern.matcher(Time_Expression);
        if (match.find()) {
            if (_tp.tunit[3] >= 0 && _tp.tunit[3] <= 11) {
                _tp.tunit[3] += 12;
            }
        }

        rule = "晚";
        pattern = Pattern.compile(rule);
        match = pattern.matcher(Time_Expression);
        if (match.find()) {
            if (_tp.tunit[3] >= 1 && _tp.tunit[3] <= 11) {
                _tp.tunit[3] += 12;
            } else if (_tp.tunit[3] == 12) {
                _tp.tunit[3] = 0;
            }
        }


        rule = "[0-9]?[0-9]?[0-9]{2}-((10)|(11)|(12)|([1-9]))-((?<!\\d))([0-3][0-9]|[1-9])";
        pattern = Pattern.compile(rule);
        match = pattern.matcher(Time_Expression);
        if (match.find()) {
            tmp_parser = new String[3];
            tmp_target = match.group();
            tmp_parser = tmp_target.split("-");
            _tp.tunit[0] = Integer.parseInt(tmp_parser[0]);
            _tp.tunit[1] = Integer.parseInt(tmp_parser[1]);
            _tp.tunit[2] = Integer.parseInt(tmp_parser[2]);
        }

        rule = "((10)|(11)|(12)|([1-9]))/((?<!\\d))([0-3][0-9]|[1-9])/[0-9]?[0-9]?[0-9]{2}";
        pattern = Pattern.compile(rule);
        match = pattern.matcher(Time_Expression);
        if (match.find()) {
            tmp_parser = new String[3];
            tmp_target = match.group();
            tmp_parser = tmp_target.split("/");
            _tp.tunit[1] = Integer.parseInt(tmp_parser[0]);
            _tp.tunit[2] = Integer.parseInt(tmp_parser[1]);
            _tp.tunit[0] = Integer.parseInt(tmp_parser[2]);
        }

        /*
         * 增加了:固定形式时间表达式 年.月.日 的正确识别
         * add by 曹零
         */
        rule = "[0-9]?[0-9]?[0-9]{2}\\.((10)|(11)|(12)|([1-9]))\\.((?<!\\d))([0-3][0-9]|[1-9])";
        pattern = Pattern.compile(rule);
        match = pattern.matcher(Time_Expression);
        if (match.find()) {
            tmp_parser = new String[3];
            tmp_target = match.group();
            tmp_parser = tmp_target.split("\\.");
            _tp.tunit[0] = Integer.parseInt(tmp_parser[0]);
            _tp.tunit[1] = Integer.parseInt(tmp_parser[1]);
            _tp.tunit[2] = Integer.parseInt(tmp_parser[2]);
        }
    }
180587
function(method) {
		 	if(typeof method === "function") {
				var args = [];
								
				for(var x = 1; x <= arguments.length; x++) {
					if(arguments[x]) {
						args.push(arguments[x]);
					}
				}
				
				method.apply(this, args);
			}
		}
185062
public static <T, K> List<T> move(List<T> list, K key, K ref,
			Function<T, K> keyMapper, boolean before,
			Function<T, Integer> orderGet, OrderSetter<T> orderSet, int orderGap) {
		if (key == ref)
			return null;

		// { 找到要移动的项和参考项所在位置
		int keyidx = -1;
		int refidx = -1;
		int idx = 0;

		for (T t : list) {
			K id = keyMapper.apply(t);
			if (id.equals(key))
				keyidx = idx;
			if (id.equals(ref))
				refidx = idx;

			if (keyidx != -1 && refidx != -1)
				break;

			idx++;
		}

		if (keyidx == -1 || refidx == -1)
			return null;
		// }

		// { 拿走要移动的项
		T t = list.remove(keyidx);
		if (refidx >= keyidx)
			refidx--;

		if (!before)
			refidx++;
		// }

		// 放回要移动的项
		list.add(refidx, t);

		// { 设置排序位置
		ArrayList<T> moved = new ArrayList<T>();

		int startOrder = 0;
		if (refidx > 0)
			startOrder = orderGet.apply(list.get(refidx - 1));

		for (int i = refidx + 1; i < list.size(); i++) {
			int order = orderGet.apply(list.get(i));
			if (order - startOrder >= i - refidx + 1) {
				int gap = (order - startOrder) / (i - refidx + 1);
				for (int j = refidx; j < i; j++) {
					T move = list.get(j);

					orderSet.apply(move, startOrder + (j - refidx + 1) * gap);
					moved.add(move);
				}

				return moved;
			}
		}

		for (int i = refidx; i < list.size(); i++) {
			T move = list.get(i);

			orderSet.apply(move, startOrder + (i - refidx + 1) * orderGap);
			moved.add(move);
		}

		return moved;
		// }
	}
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;
        }
    }
560003
@SuppressWarnings("unchecked")
	private <T> T convertSpecial(Type type, Class<T> rowType, Object value, T defaultValue) {
		if (null == rowType) {
			return null;
		}

		// 集合转换（不可以默认强转）
		if (Collection.class.isAssignableFrom(rowType)) {
			final CollectionConverter collectionConverter = new CollectionConverter(type);
			return (T) collectionConverter.convert(value, (Collection<?>) defaultValue);
		}

		// Map类型（不可以默认强转）
		if (Map.class.isAssignableFrom(rowType)) {
			final MapConverter mapConverter = new MapConverter(type);
			return (T) mapConverter.convert(value, (Map<?, ?>) defaultValue);
		}

		// 默认强转
		if (rowType.isInstance(value)) {
			return (T) value;
		}

		// 数组转换
		if (rowType.isArray()) {
			final ArrayConverter arrayConverter = new ArrayConverter(rowType);
			try {
				return (T) arrayConverter.convert(value, defaultValue);
			} catch (Exception e) {
				// 数组转换失败进行下一步
			}
		}

		// 枚举转换
		if (rowType.isEnum()) {
			return (T) new EnumConverter(rowType).convert(value, defaultValue);
		}

		// 表示非需要特殊转换的对象
		return null;
	}
418123
function () {
            var t = this.dpop() | 0;
            var n = this.dpop() | 0;
            var ddd = Long.fromInt(n);
            ddd = ddd.mul(Long.fromInt(t));
            this.dpush(ddd.low);
            this.dpush(ddd.high);
        }
657618
function checkBaseConstructorCall(targetClass, classname) {
        var code = targetClass.toString();
        if (!/this\.callBase/.test(code)) {
            throw new Error(classname + ' : 类构造函数没有调用父类的构造函数！为了安全，请调用父类的构造函数');
        }
    }
503479
private <T> void checkFormat(Collection<T> c) {
		Class<?> type = null;
		List<Class<?>> typeList = new ArrayList<Class<?>>();
		Iterator<T> it = c.iterator();
		while (it.hasNext()) {
			Object o = it.next();

			// check the input types for 1-dimension
			if (type != null && !type.equals(o.getClass())) {
				throw new RuntimeException("elements of input list should have the same type");
			}
			else {
				type = o.getClass();
			}

			// check the input types for 2-dimension array
			if (typeList.size() == 0 && o.getClass().isArray()) {
				for (Object s : (Object[]) o) {
					typeList.add(s.getClass());
				}
			}
			else if (o.getClass().isArray()) {
				int index = 0;
				if (((Object[]) o).length != typeList.size()) {
					throw new RuntimeException("elements of input list should have the same size");
				}
				for (Object s : (Object[]) o) {
					if (!s.getClass().equals(typeList.get(index++))) {
						throw new RuntimeException("elements of input list should have the same type");
					}
				}
			}

			// check the input types for 2-dimension collection
			if (typeList.size() == 0 && o instanceof Collection) {
				@SuppressWarnings("unchecked")
				Iterator<Object> tmpIt = ((Collection<Object>) o).iterator();
				while (tmpIt.hasNext()) {
					Object s = tmpIt.next();
					typeList.add(s.getClass());
				}
			}
			else if (o instanceof Collection) {
				int index = 0;
				@SuppressWarnings("unchecked")
				Iterator<Object> tmpIt = ((Collection<Object>) o).iterator();
				while (tmpIt.hasNext()) {
					Object s = tmpIt.next();
					if (!s.getClass().equals(typeList.get(index++))) {
						throw new RuntimeException("elements of input list should have the same type");
					}
				}

				if (index != typeList.size()) {
					throw new RuntimeException("elements of input list should have the same size");
				}
			}
		}
	}
432799
int getObjectID(Object element) {
        if (element == null) return NULL;
        else if (Cell.class.isInstance(element)) return CELL;
        else if (Table.class.isInstance(element)) return TABLE; 
        return -1;
    }
1280210
function (cell, xOrY) {
            try {
                var flag = (xOrY.toLowerCase() === "x"),
                    end = domUtils.getXY(cell)[flag ? 'x' : 'y'] + cell["offset" + (flag ? 'Width' : 'Height')],
                    rows = this.table.rows,
                    cells = null, returns = [];
                for (var i = 0; i < this.rowsNum; i++) {
                    cells = rows[i].cells;
                    for (var j = 0, tmpCell; tmpCell = cells[j++];) {
                        var tmpEnd = domUtils.getXY(tmpCell)[flag ? 'x' : 'y'] + tmpCell["offset" + (flag ? 'Width' : 'Height')];
                        //对应行的td已经被上面行rowSpan了
                        if (tmpEnd > end && flag) break;
                        if (cell == tmpCell || end == tmpEnd) {
                            //只获取单一的单元格
                            //todo 仅获取单一单元格在特定情况下会造成returns为空，从而影响后续的拖拽实现，修正这个。需考虑性能
                            if (tmpCell[flag ? "colSpan" : "rowSpan"] == 1) {
                                returns.push(tmpCell);
                            }
                            if (flag) break;
                        }
                    }
                }
                return returns;
            } catch (e) {
                showError(e);
            }
        }
855650
function(itemSet){

            this.closureCount = this.closureCount || 0;
            this.closureCount++;

            var self = this,
            closureItemSet = new DataTypes.ItemSet();

            var set = itemSet,
                itemQueue;
            do{         //C0
                itemQueue = new DataTypes.ItemSet();
                closureItemSet.union(set);

                _.each(set.subItems, function(item){        //each closureItems
                    if(item.dotSymbol && self.nonterminals[item.dotSymbol]){
                        /*
                        if(!closureSymbolHash[item.dotSymbol]){         //exists un derivation nonterminal
                        */
                            var afterRhs = item.production.rhs.slice(item.dotPosition+1);
                            lookaheads = self._first(afterRhs);
                            if(lookaheads.length === 0 || item.production.nullable || self._nullable(afterRhs)){
                                lookaheads = _.union(lookaheads, item.lookaheads);
                            }

                            _.each(self.nonterminals[item.dotSymbol].productions, function(p){
                                    var item = new DataTypes.Item(p, 0, lookaheads);
                                    if(!closureItemSet.contains(item) && !itemQueue.contains(item)){
                                        itemQueue.push(item); //new clsoure-item
                                    }
                            });


                            /**
                             * 求闭包的项的输入点非终结符后面的RHS 和 求闭包的项的每个lookahead符号 连接
                             * 然后进行FIRSTS运算，拿到lookaheads
                             * 每个lookaheads，进行并集运算，得到最终的lookaheads
                             */
                            /*
                            var lookaheads = [];
                            _.each(item.lookaheads, function(fchr){
                                var afterRHS = item.production.rhs.slice(item.dotPosition+1)
                                    afterRHS.push(fchr);
                                    lookaheads = _.union(lookaheads, self._first(afterRHS));
                            });
                            */

                            //求闭包的项的输入点非终结符，的每个产生式p
                            //查找闭包集合中是否已经存在相同核心的产生式
                            //存在则合并lookaheads
                            //不存在则创建
                            /*
                            _.each(self.nonterminals[item.dotSymbol].productions, function(p){
                                    var item = new DataTypes.Item(p, 0, lookaheads),
                                    itemIdx;
                                    if((itemIdx = closureItemSet.coreIndexOf(item)) === -1){
                                        itemSet.push(item); //new clsoure-item
                                        cont = true;                            //C0不动点循环继续
                                    }else{
                                        item = closureItemSet.subItems[itemIdx];
                                        item.lookaheads = _.union(item.lookaheads, lookaheads);
                                    }
                            });
                            */
                            //closureSymbolHash[item.dotSymbol] = true;   //cur nonterminal derivated
                            /*
                        }
                        */
                    }
                });
                set = itemQueue;
            }while(set.subItems.length);

            return closureItemSet;
        }
509827
function(textOrData) {

            // 指针
            this.parent = null;
            this.root = this;
            this.children = [];

            // 数据
            this.data = {
                id: utils.guid(),
                created: +new Date()
            };

            // 绘图容器
            this.initContainers();

            if (utils.isString(textOrData)) {
                this.setText(textOrData);
            } else if (utils.isObject(textOrData)) {
                utils.extend(this.data, textOrData);
            }
        }
323133
public void showConflict(){
        int emptySlot=0;
        //key:冲突长度 value:冲突个数
        Map<Integer, Integer> map = new HashMap<>();
        for(TrieNode<V> node : ROOT_NODES_INDEX){
            if(node == null){
                emptySlot++;
            }else{
                int i=0;
                while((node = node.getSibling()) != null){
                    i++;
                }
                if(i > 0){
                    Integer count = map.get(i);
                    if(count == null){
                        count = 1;
                    }else{
                        count++;
                    }
                    map.put(i, count);
                }
            }
        }
        int count=0;
        for(int key : map.keySet()){
            int value = map.get(key);
            count += key*value;
            LOGGER.info("冲突次数为："+key+" 的元素个数："+value);
        }
        LOGGER.info("冲突次数："+count);
        LOGGER.info("总槽数："+INDEX_LENGTH);
        LOGGER.info("用槽数："+(INDEX_LENGTH-emptySlot));
        LOGGER.info("使用率："+(float)(INDEX_LENGTH-emptySlot)/INDEX_LENGTH*100+"%");
        LOGGER.info("剩槽数："+emptySlot);
    }
1141616
function Type(/* function | RegExp */ matcher) {
		// 参数合法性检查。
		if (arguments.length != 1) {
			throw new ERR.Arguments(1, arguments.length);
		}
		if (!(typeof matcher == 'function' || matcher instanceof RegExp)) {
			throw new ERR.Type('Type matcher', [ 'Function', 'RegExp' ], matcher);
		}

		// Type() 构造函数参数确定，故毋须使用类似 ParamList.parse 这样的构建器。
		if (!(this instanceof Type)) return new Type(matcher);

		if (matcher instanceof RegExp) {
			this.match = function(value) {
				return matcher.test(value);
			};
		}
		else {
			this.match = matcher;
		}
	}
357976
function( object, method ) {
            return function(){
                var args = arguments;
                if ( args === undefined ){
                    args = [];
                }
                return method.apply( object, args );
            };
        }
215406
function () {
                var self = this, cs = [], i, c = self.constructor, attrs = self.getAttrs();
                while (c) {
                    cs.push(c);
                    c = c.superclass && c.superclass.constructor;
                }
                cs.reverse();    // from super class to sub class
                // from super class to sub class
                for (i = 0; i < cs.length; i++) {
                    var ATTRS = cs[i].ATTRS || {};
                    for (var attributeName in ATTRS) {
                        if (attributeName in attrs) {
                            var attributeValue, onSetMethod;
                            var onSetMethodName = ON_SET + ucfirst(attributeName);    // 存在方法，并且用户设置了初始值或者存在默认值，就同步状态
                            // 存在方法，并且用户设置了初始值或者存在默认值，就同步状态
                            if ((onSetMethod = self[onSetMethodName]) && // 用户如果设置了显式不同步，就不同步，
                                // 比如一些值从 html 中读取，不需要同步再次设置
                                attrs[attributeName].sync !== 0 && (attributeValue = self.get(attributeName)) !== undefined) {
                                onSetMethod.call(self, attributeValue);
                            }
                        }
                    }
                }
            }
604068
function (name, value) {
            var self = this, setValue,
                // if host does not have meta info corresponding to (name,value)
                // then register on demand in order to collect all data meta info
                // 一定要注册属性元数据，否则其他模块通过 _attrs 不能枚举到所有有效属性
                // 因为属性在声明注册前可以直接设置值
                attrConfig = ensureNonEmpty(self.getAttrs(), name), setter = attrConfig.setter;    // if setter has effect
            // if setter has effect
            if (setter && (setter = normalFn(self, setter))) {
                setValue = setter.call(self, value, name);
            }
            if (setValue === INVALID) {
                return FALSE;
            }
            if (setValue !== undefined) {
                value = setValue;
            }    // finally set
            // finally set
            getAttrVals(self)[name] = value;
            return undefined;
        }