判断异常是否由某些底层的异常引起.
14923
@SuppressWarnings("unchecked")
	public static boolean isCausedBy(@Nullable Throwable throwable,
			Class<? extends Exception>... causeExceptionClasses) {
		Throwable cause = throwable;

		while (cause != null) {
			for (Class<? extends Exception> causeClass : causeExceptionClasses) {
				if (causeClass.isInstance(cause)) {
					return true;
				}
			}
			cause = cause.getCause();
		}
		return false;
	}
664642
private int resolveTimeout(SofaRequest request, ConsumerConfig consumerConfig, ProviderInfo providerInfo) {
        // 先去调用级别配置
        Integer timeout = request.getTimeout();
        if (timeout == null) {
            // 取客户端配置（先方法级别再接口级别）
            timeout = consumerConfig.getMethodTimeout(request.getMethodName());
            if (timeout == null || timeout < 0) {
                // 再取服务端配置
                timeout = (Integer) providerInfo.getDynamicAttr(ATTR_TIMEOUT);
                if (timeout == null) {
                    // 取框架默认值
                    timeout = getIntValue(CONSUMER_INVOKE_TIMEOUT);
                }
            }
        }
        return timeout;
    }
439971
private static void loadConf(InputStream in) {
        try(BufferedReader reader = new BufferedReader(new InputStreamReader(in, "utf-8"))){
            String line;
            while((line = reader.readLine()) != null){
                line = line.trim();                
                if("".equals(line) || line.startsWith("#")){
                    continue;
                }
                int index = line.indexOf("=");
                if(index==-1){
                    LOGGER.error("错误的配置："+line);
                    continue;
                }
                //有K V
                if(index>0 && line.length()>index+1) {
                    String key = line.substring(0, index).trim();
                    String value = line.substring(index + 1, line.length()).trim();
                    conf.put(key, value);
                }
                //有K无V
                else if(index>0 && line.length()==index+1) {
                    String key = line.substring(0, index).trim();
                    conf.put(key, "");
                }else{
                    LOGGER.error("错误的配置："+line);
                }
            }
        } catch (IOException ex) {
            System.err.println("配置文件加载失败:"+ex.getMessage());
            throw new RuntimeException(ex);
        }
    }
486531
private function f1()
    {
        $_linkstr = "\n<p class=\"links\">\n"; //begin
        if ($this->totalpage < 2) {
            $nextpage = $this->cpage + 1;
            $_linkstr .= "<span class=\"disabled\">首页</span>" . " \n";
            $_linkstr .= "<span class=\"disabled\">上一页</span> \n";
            $_linkstr .= "<span class=\"disabled\">下一页</span> \n";
            $_linkstr .= "<span class=\"disabled\">尾页</span> \n";
        } elseif ($this->cpage < 2) {
            // 首页
            $nextpage = $this->cpage + 1;
            $_linkstr .= "<span class=\"disabled\">首页</span>" . " \n";
            $_linkstr .= "<span class=\"disabled\">上一页</span> \n";
            $_linkstr .= "<a href=\"" . $this->url ( $nextpage ) . "\">下一页</a> \n";
            $_linkstr .= "<a href=\"" . $this->url ( $this->totalpage ) . "\">尾页</a> \n";
        } elseif ($this->cpage >= $this->totalpage) {
            // ＝尾页
            $prepage = $this->cpage - 1;

            $_linkstr .= "<a href=\"" . $this->url ( 1 ) . "\">首页</a>\n";
            $_linkstr .= "<a href=\"" . $this->url ( $prepage ) . "\">上一页</a>\n";
            $_linkstr .= "\n<span class=\"disabled\">下一页</span>\n";
            $_linkstr .= "<span class=\"disabled\">尾页</span>" . "\n";
        } else {
            // 正常
            $prepage  = $this->cpage - 1;
            $nextpage = $this->cpage + 1;

            $_linkstr .= "<a href=\"" . $this->url ( 1 ) . "\">首页</a>\n";
            $_linkstr .= "<a href=\"" . $this->url ( $prepage ) . "\">上一页</a>\n";
            $_linkstr .= "\n<a href=\"" . $this->url ( $nextpage ) . "\">下一页</a>\n";
            $_linkstr .= "<a href=\"" . $this->url ( $this->totalpage ) . "\">尾页</a>\n";
        }
        $_linkstr .= "</p>\n"; //end div
        return $_linkstr;
    }
428021
def accept(self, key, result):
        
        self.data[key]['isAccept'] = True  # 设置为已经接受到服务端返回的消息
        self.data[key]['result'] = str(result)
        self._channel.queue_delete(self.data[key]['reply_queue_name'])
1049989
function(param) {
      var step, start, res;
      //如果无参数 当成是获取第一个元素
      if (!param || !(param = param.replace(/\s+/g, ""))) {
        return {
          start: 1,
          step: 0
        };
      }
      if (res = nthCache.get(param)) return res;
      // 对even odd等转化为标准的a，b组合(即step与start)
      if (param == "even") {
        start = 2;
        step = 2;
      } else if (param == "odd") {
        step = 2;
        start = 1;
      } else {
        res = param.match(nthValueReg);
        // 对错误的nth参数抛出错误
        if (!res) step = null; // 无论其他参数，如果step为null，则永远为false
        else {
          if (res[1]) {
            step = 0;
            start = parseInt(res[1]);
          } else {
            if (res[2] == "-") res[2] = "-1";
            step = res[2] ? parseInt(res[2]) : 1;
            start = res[3] ? parseInt(res[3]) : 0;
          }
        }
      }
      if (start < 1) {
        if (step < 1) {
          step = null; //标志false
        } else {
          start = -(-start) % step + step;
        }
      }
      return nthCache.set(param, {
        start: start,
        step: step
      });
    }
1306440
static byte[] encode(int count) {
        // 计算需要填充的位数
        int amountToPad = BLOCK_SIZE - (count % BLOCK_SIZE);
        if (amountToPad == 0) {
            amountToPad = BLOCK_SIZE;
        }
        // 获得补位所用的字符
        char padChr = chr(amountToPad);
        String tmp = new String();
        for (int index = 0; index < amountToPad; index++) {
            tmp += padChr;
        }
        return tmp.getBytes(CHARSET);
    }
853918
@Override
    public Set<MetaData> decodeContent(InputStream in, Charset charset) throws IOException {
        // 解析报文内容
        byte[] bytes = new byte[(int) getContentLength()];
        int contentSize = in.read(bytes);
        if (contentSize != getContentLength()) {
            throw new IOException("读取到的数据长度与协议长度不符");
        }
        return MetadataMapper.fromByte(bytes, charset);

    }
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;
		}
	}
381869
public static boolean isAllNum(String str)
    {
        if (str == null)
            return false;

        int i = 0;
        /** 判断开头是否是+-之类的符号 */
        if ("±+-＋－—".indexOf(str.charAt(0)) != -1)
            i++;
        /** 如果是全角的０１２３４５６７８９ 字符* */
        while (i < str.length() && "０１２３４５６７８９".indexOf(str.charAt(i)) != -1)
            i++;
        // Get middle delimiter such as .
        if (i > 0 && i < str.length())
        {
            char ch = str.charAt(i);
            if ("·∶:，,．.／/".indexOf(ch) != -1)
            {// 98．1％
                i++;
                while (i < str.length() && "０１２３４５６７８９".indexOf(str.charAt(i)) != -1)
                    i++;
            }
        }
        if (i >= str.length())
            return true;

        /** 如果是半角的0123456789字符* */
        while (i < str.length() && "0123456789".indexOf(str.charAt(i)) != -1)
            i++;
        // Get middle delimiter such as .
        if (i > 0 && i < str.length())
        {
            char ch = str.charAt(i);
            if (',' == ch || '.' == ch || '/' == ch  || ':' == ch || "∶·，．／".indexOf(ch) != -1)
            {// 98．1％
                i++;
                while (i < str.length() && "0123456789".indexOf(str.charAt(i)) != -1)
                    i++;
            }
        }

        if (i < str.length())
        {
            if ("百千万亿佰仟%％‰".indexOf(str.charAt(i)) != -1)
                i++;
        }
        if (i >= str.length())
            return true;

        return false;
    }
209341
function () {
            var reg = new RegExp(domUtils.fillChar, 'g');
            //取出来的空格会有c2a0会变成乱码，处理这种情况\u00a0
            return this.body[browser.ie ? 'innerText' : 'textContent'].replace(reg, '').replace(/\u00a0/g, ' ');
        }
1213221
function () {
            var me = this;
            function optimze( range ) {
                var child = me.document.body.firstChild,
                    collapsed = range.collapsed;
                while ( child && child.firstChild ) {
                    range.setStart( child, 0 );
                    child = child.firstChild;
                }
                if ( !range.startContainer ) {
                    range.setStart( me.document.body, 0 )
                }
                if ( collapsed ) {
                    range.collapse( true );
                }
            }

            if ( me._cachedRange != null ) {
                return this._cachedRange;
            }
            var range = new baidu.editor.dom.Range( me.document );

            if ( browser.ie9below ) {
                var nativeRange = me.getIERange();
                if ( nativeRange ) {
                    //备份的_bakIERange可能已经实效了，dom树发生了变化比如从源码模式切回来，所以try一下，实效就放到body开始位置
                    try{
                        transformIERangeToRange( nativeRange, range );
                    }catch(e){
                        optimze( range );
                    }

                } else {
                    optimze( range );
                }
            } else {
                var sel = me.getNative();
                if ( sel && sel.rangeCount ) {
                    var firstRange = sel.getRangeAt( 0 );
                    var lastRange = sel.getRangeAt( sel.rangeCount - 1 );
                    range.setStart( firstRange.startContainer, firstRange.startOffset ).setEnd( lastRange.endContainer, lastRange.endOffset );
                    if ( range.collapsed && domUtils.isBody( range.startContainer ) && !range.startOffset ) {
                        optimze( range );
                    }
                } else {
                    //trace:1734 有可能已经不在dom树上了，标识的节点
                    if ( this._bakRange && domUtils.inDoc( this._bakRange.startContainer, this.document ) ){
                        return this._bakRange;
                    }
                    optimze( range );
                }
            }
            return this._bakRange = range;
        }
969768
function (cmd) {
        if (!this._saveData) {
            return;
        }

        var data = this.data;
        if (this._len + arguments.length > data.length) {
            // 因为之前的数组已经转换成静态的 Float32Array
            // 所以不够用时需要扩展一个新的动态数组
            this._expandData();
            data = this.data;
        }
        for (var i = 0; i < arguments.length; i++) {
            data[this._len++] = arguments[i];
        }

        this._prevCmd = cmd;
    }
552501
private void fillCollection(Collection<?> collection) {

        int count = 0;

        // 展开  Collection 容器, 输出逗号分隔以支持 IN (...) 语法
        // "IN :varlist" --> "IN (?, ?, ...)"
        if (collection.isEmpty()) {

            // 输出  "IN (NULL)" 保证不会产生错误
            builder.append(NULL);

        } else {

            // 输出逗号分隔的参数表
            for (Object value : collection) {

                if (value != null) {

                    if (count > 0) {
                        builder.append(COMMA);
                    }

                    // 输出参数内容
                    addArg(value);

                    builder.append(QUESTION);

                    count++;
                }
            }
        }
    }
487373
@Override
	public T get() {
		T result = reference.get();

		if (result == null) {
			result = init();
			if (false == reference.compareAndSet(null, result)) {
				// 其它线程已经创建好此对象
				result = reference.get();
			}
		}

		return result;
	}
612997
private void solveConflict(int parent, int newChild)
    {
        // 找出parent的所有子节点
        TreeSet<Integer> children = new TreeSet<Integer>();
        children.add(newChild);
        final int charsetSize = this.charMap.getCharsetSize();
        for (int c = 0; c < charsetSize; ++c)
        {
            int next = getBase(parent) + c;
            if (next >= getBaseArraySize())
            {
                break;
            }
            if (getCheck(next) == parent)
            {
                children.add(c);
            }
        }
        // 移动旧子节点到新的位置
        int newBase = searchFreeBase(children);
        children.remove(newChild);
        for (Integer c : children)
        {
            int child = newBase + c;
            deleteFreeLink(child);

            setCheck(child, parent);
            int childBase = getBase(getBase(parent) + c);
            setBase(child, childBase);

            if (!isLeafValue(childBase))
            {
                for (int d = 0; d < charsetSize; ++d)
                {
                    int to = childBase + d;
                    if (to >= getBaseArraySize())
                    {
                        break;
                    }
                    if (getCheck(to) == getBase(parent) + c)
                    {
                        setCheck(to, child);
                    }
                }
            }
            addFreeLink(getBase(parent) + c);
        }
        // 更新新base值
        setBase(parent, newBase);
    }
1179341
private static void processBiGram() {
        //移除二元模型出现频率为1的情况
        Iterator<String> iter = BIGRAM.keySet().iterator();
        while(iter.hasNext()){
            String key = iter.next();
            if(BIGRAM.get(key) < 2){
                iter.remove();
            }
        }
        try(BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream("src/main/resources/bigram.txt"),"utf-8"))){
            for(Entry<String, Integer> item : BIGRAM.entrySet()){
                writer.write(item.getKey()+" "+item.getValue()+"\n");
            }
        }catch(Exception e){
            LOGGER.info("保存bigram模型失败：", e);
        }
    }