亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? inputstreammessageelement.java

?? jxta平臺的開發(fā)包
?? JAVA
字號:
/************************************************************************ * * $Id: InputStreamMessageElement.java,v 1.13 2004/08/06 17:42:29 bondolo Exp $ * * Copyright (c) 2001 Sun Microsystems, Inc.  All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright *    notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright *    notice, this list of conditions and the following disclaimer in *    the documentation and/or other materials provided with the *    distribution. * * 3. The end-user documentation included with the redistribution, *    if any, must include the following acknowledgment: *       "This product includes software developed by the *       Sun Microsystems, Inc. for Project JXTA." *    Alternately, this acknowledgment may appear in the software itself, *    if and wherever such third-party acknowledgments normally appear. * * 4. The names "Sun", "Sun Microsystems, Inc.", "JXTA" and "Project JXTA" *    must not be used to endorse or promote products derived from this *    software without prior written permission. For written *    permission, please contact Project JXTA at http://www.jxta.org. * * 5. Products derived from this software may not be called "JXTA", *    nor may "JXTA" appear in their name, without prior written *    permission of Sun. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED.  IN NO EVENT SHALL SUN MICROSYSTEMS OR * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * ==================================================================== * * This software consists of voluntary contributions made by many * individuals on behalf of Project JXTA.  For more * information on Project JXTA, please see * <http://www.jxta.org/>. * * This license is based on the BSD license adopted by the Apache Foundation. *********************************************************************************/package net.jxta.endpoint;import java.io.ByteArrayInputStream;import java.io.InputStream;import java.io.OutputStream;import java.io.SequenceInputStream;import java.util.ArrayList;import java.util.Collections;import java.util.Iterator;import java.util.List;import java.util.zip.CRC32;         // used in hashCodeimport java.util.zip.Checksum;import java.io.IOException;import net.jxta.document.MimeMediaType;/** * A Message Element using {@link java.io.InputStream} as the source for the * element data. This implementation copies all of the data from the stream at * the time of creation. **/public class InputStreamMessageElement extends MessageElement {        /**     *  The bytes of this element.     **/    protected List databytes = null;        /**     *  The length of the data.     **/    protected long length = 0;        /**     *  Cached Hash Code     **/    protected transient int cachedHashCode = 0;        /**     *  Create a new MessageElement. This constructor copies the data as needed     *  and closes the stream upon completion. If the stream does not support     *  the "mark" operation then the data is copied immediately and the stream     *  will be closed.     *     * @param name Name of the MessageElement. May be the empty string ("") if     * the MessageElement is not named.     * @param type Type of the MessageElement. null is the same as specifying     * the type "Application/Octet-stream".     * @param in the stream containing the body of the MessageElement. The     * stream will be closed by the MessageElement.     * @param sig optional message digest/digital signature elemnent or null if     * no signature is desired.     * @throws IOException If there is a problem reading from the source stream.     **/    public InputStreamMessageElement(String name, MimeMediaType type, InputStream in, MessageElement sig) throws IOException {        this( name, type, in, Long.MAX_VALUE, sig );    }        /**     * Create a new Message Element.     *     * @param name Name of the MessageElement. May be the empty string ("") if     * the MessageElement is not named.     * @param type Type of the MessageElement. null is the same as specifying     * the type "Application/Octet-stream".     * @param in the stream containing the body of the MessageElement.     * The stream will <b>NOT</b> be closed unless EOF is unexpectedly reached.     * @param len The size of the Element will be limited to len bytes     *    from the stream. If you are using the stream interface and know     *    the size of the stream, specifying it here improves performance     * and space effciency a lot. The stream must contain at least     * <code>len</code> bytes.     * @param sig optional message digest/digital signature elemnent or null if     * no signature is desired.     * @throws IOException if there is a problem reading from the source stream     **/    public InputStreamMessageElement( String name, MimeMediaType type, InputStream in, long len, MessageElement sig ) throws IOException {        super( name, type, sig );                if( (len < 0) ) {            throw new IllegalArgumentException( "len must be >= 0" );        }                // copy the data from the stream        databytes = CopyToDataBytes( in, len );                // calculate the length        length = 0;        Iterator eachBuffer = databytes.iterator();        while(  eachBuffer.hasNext() ) {            byte [] aBuffer = (byte []) eachBuffer.next();                        length += aBuffer.length;        }                // fail if the length is not as promised.        if( (len != Long.MAX_VALUE) && (len != length)) {            throw new IllegalArgumentException( "Stream was shorter than promised length." );        }    }        /**     *  {@inheritDoc}     **/    public boolean equals( Object target ) {        if( this == target ) {            return true;        }                if( target instanceof MessageElement ) {            if( !super.equals(target) )                return false;                        if( target instanceof InputStreamMessageElement ) {                // have to do a slow stream comparison.                // XXX 20020615 bondolo@jxta.org the performance of this could be much improved.                                MessageElement likeMe = (MessageElement) target;                                try {                    InputStream myStream = getStream();                    InputStream itsStream = likeMe.getStream();                                        int mine;                    int its;                    do {                        mine = myStream.read();                        its = itsStream.read();                                                if( mine != its )                            return false;       // content didn't match                                            } while( (-1 != mine) && (-1 != its) );                                        return ( (-1 == mine) && (-1 == its) ); // end at the same time?                } catch( IOException fatal ) {                    throw new IllegalStateException( "MessageElements could not be compared." + fatal );                }            }        }                return false; // not a new message element    }        /**     *  {@inheritDoc}     **/    public synchronized int hashCode() {        if ( 0 == cachedHashCode ) {            Checksum crc = new CRC32();                        Iterator eachBuffer = databytes.iterator();            while( eachBuffer.hasNext() ) {                byte [] aBuffer = (byte []) eachBuffer.next();                                crc.update( aBuffer, 0, aBuffer.length );            }                        int result = super.hashCode() +            (int) crc.getValue() * 6037;   // a prime            cachedHashCode = 0 != result ? result : 1;        }                return cachedHashCode;    }        /**     *  {@inheritDoc}     **/    public long getByteLength() {        return length;    }        /**     *  {@inheritDoc}     **/    public InputStream getStream() throws IOException {        List buffers = new ArrayList();                Iterator eachBuffer = databytes.iterator();        while( eachBuffer.hasNext() ) {            byte [] aBuffer = (byte []) eachBuffer.next();            buffers.add( new ByteArrayInputStream(aBuffer) );        }                return new SequenceInputStream( Collections.enumeration(buffers) );    }        /**     *  {@inheritDoc}     **/    public void sendToStream(OutputStream sendTo) throws IOException {                Iterator eachBuffer = databytes.iterator();        while( eachBuffer.hasNext() ) {            byte [] aBuffer = (byte []) eachBuffer.next();            sendTo.write( aBuffer );        }    }        /**     *  Copy data from a stream with best possible effciency. Unfortunately,     *  this still results in a lot of copying since we have often have no     * fore-knowledge of the length of the stream.     *     * @return an array of byte arrays containing the data.     * @param in the stream to copy from     * @param limit the maximum number of bytes to copy from the stream.     * Long.LONG_MAX will read until EOF.     * @throws IOException if there is a problem reading from the stream.     **/    protected List CopyToDataBytes( InputStream in, long limit ) throws IOException {        final long INITIAL_INTERMEDIATE_BUFFERSIZE = 6;        final long MAXIMUM_INTERMEDIATE_BUFFERSIZE = 18;                List buffs = new ArrayList();        boolean atEOF = false;        long read = 0;        long currentIntermediateBufferSize = INITIAL_INTERMEDIATE_BUFFERSIZE;                // build a list of buffers containing all the element data.        do {            long readRequest = (limit - read);            if( Long.MAX_VALUE == limit ) {                readRequest = Math.min( readRequest, (1L << currentIntermediateBufferSize) );            }            readRequest = Math.min( readRequest, Integer.MAX_VALUE ); // limited by size of arrays which are Integer indexed.                        byte [] nextBuffer = new byte [(int) readRequest];            int offsetInThisBuffer = 0;                        // fully read the buffer if we can.            do {                int readLength = in.read( nextBuffer, offsetInThisBuffer, nextBuffer.length - offsetInThisBuffer );                                if( readLength == -1) {                    atEOF = true;                    break;                }                                offsetInThisBuffer += readLength;            } while( offsetInThisBuffer < nextBuffer.length );                        // handle the final buffer.            if( atEOF ) {                byte [] anotherBuffer = new byte[offsetInThisBuffer];                System.arraycopy( nextBuffer, 0, anotherBuffer, 0, offsetInThisBuffer );                nextBuffer = anotherBuffer;            }                        read += nextBuffer.length;            buffs.add( nextBuffer );                        if( currentIntermediateBufferSize < MAXIMUM_INTERMEDIATE_BUFFERSIZE ) {                currentIntermediateBufferSize++;            }        } while ( !atEOF && (read < limit) );                // we are done, close if we are at EOF.        if( atEOF ) {            in.close();            in = null;        }                return buffs;    }}

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
jlzzjlzz亚洲女人18| 五月婷婷综合网| 成人午夜电影久久影院| 国产欧美一区二区在线观看| 精品亚洲国产成人av制服丝袜| 日韩情涩欧美日韩视频| 日韩激情在线观看| 久久综合色婷婷| 国产精品99久久久| 亚洲天堂av一区| 色狠狠色狠狠综合| 日韩一区欧美二区| 国产喷白浆一区二区三区| 国产成人无遮挡在线视频| 中文字幕中文字幕在线一区 | 精品在线亚洲视频| 国产性色一区二区| 色吧成人激情小说| 亚洲成av人片一区二区梦乃| 日韩一级片网址| 国产成人av一区二区三区在线观看| 国产欧美日韩另类视频免费观看| 91偷拍与自偷拍精品| 无码av中文一区二区三区桃花岛| 精品久久久久久亚洲综合网| 北条麻妃一区二区三区| 亚洲成a人片在线观看中文| 91精品欧美一区二区三区综合在| 色婷婷久久综合| 日韩av一区二区在线影视| 精品剧情v国产在线观看在线| 国产经典欧美精品| 亚洲欧美视频在线观看| 91福利视频网站| 青青草伊人久久| 久久精品人人爽人人爽| av一区二区三区黑人| 日韩电影一区二区三区四区| 久久精品夜色噜噜亚洲a∨| 在线视频观看一区| 国产精品自产自拍| 亚洲第一搞黄网站| 国产精品久久福利| 精品国产1区二区| 一本色道a无线码一区v| 国产一二精品视频| 日韩在线一区二区| 亚洲蜜臀av乱码久久精品| 欧美成人在线直播| 在线观看日韩电影| 成人av一区二区三区| 蜜桃在线一区二区三区| 一区二区三区成人| 国产日韩欧美麻豆| 精品久久久久久久久久久久久久久| 欧美视频在线一区二区三区 | voyeur盗摄精品| 91丨九色丨尤物| 国产成人精品午夜视频免费| 亚洲成人一二三| 亚洲精品写真福利| 国产精品丝袜91| 精品久久人人做人人爽| 91精品久久久久久久91蜜桃| 欧美伊人久久久久久久久影院| 成人一区二区三区在线观看| 蜜桃一区二区三区在线| 亚洲va欧美va人人爽| 一区二区三区四区在线免费观看| 国产精品不卡在线| 中文字幕在线不卡国产视频| 国产欧美日韩激情| 国产午夜精品一区二区三区视频| 欧美v国产在线一区二区三区| 欧美日韩国产高清一区| 欧美日韩大陆在线| 欧美日韩免费一区二区三区视频| 色88888久久久久久影院按摩| 成人av综合一区| 成人黄色大片在线观看| 国产传媒欧美日韩成人| 懂色av中文字幕一区二区三区| 国产黄色91视频| 粉嫩av一区二区三区| 菠萝蜜视频在线观看一区| 成人免费视频caoporn| 国产白丝精品91爽爽久久 | 成人午夜私人影院| 粉嫩久久99精品久久久久久夜| 国产成人免费在线观看| 不卡视频在线观看| 色婷婷综合久久久久中文| 欧美在线视频日韩| 666欧美在线视频| 欧美不卡视频一区| 国产欧美精品一区| 亚洲色图自拍偷拍美腿丝袜制服诱惑麻豆 | 欧美国产精品v| 亚洲欧美在线高清| 亚洲综合在线第一页| 亚洲va欧美va人人爽| 韩国毛片一区二区三区| 波多野结衣中文字幕一区二区三区 | 欧美精选一区二区| 日韩欧美成人午夜| 国产日韩欧美综合一区| 一区二区三区四区不卡在线| 丝袜美腿亚洲一区二区图片| 紧缚奴在线一区二区三区| 成人丝袜视频网| 91成人网在线| 日韩精品资源二区在线| 国产精品久久久久精k8| 午夜在线电影亚洲一区| 国产一区二区剧情av在线| 成人h版在线观看| 欧美日韩国产片| 国产欧美一区二区精品秋霞影院 | 欧美三级电影精品| 精品国产一区二区三区久久影院 | 99精品欧美一区二区蜜桃免费 | 日韩精品中文字幕一区二区三区| 国产精品少妇自拍| 日本91福利区| 91在线免费播放| 欧美一区二区三区视频免费播放| 欧美国产国产综合| 麻豆精品视频在线观看免费| 99国产精品一区| 日韩精品在线网站| 一区2区3区在线看| 国产一本一道久久香蕉| 欧美午夜精品电影| 欧美高清一级片在线观看| 日本亚洲电影天堂| 色偷偷成人一区二区三区91 | 国产精品进线69影院| 亚洲午夜私人影院| 99久久免费精品高清特色大片| 欧美一级理论片| 亚洲一区在线视频观看| 不卡视频一二三| 国产网站一区二区| 蜜臀a∨国产成人精品| 欧美亚洲丝袜传媒另类| 综合网在线视频| 粉嫩av一区二区三区在线播放| 69成人精品免费视频| 国产精品的网站| 国产91精品久久久久久久网曝门 | 久久你懂得1024| 日韩精品91亚洲二区在线观看| 色天天综合色天天久久| 中文字幕在线不卡国产视频| 国产在线播放一区三区四| 欧美一三区三区四区免费在线看| 亚洲精品乱码久久久久久久久| 成人午夜伦理影院| 日韩欧美在线网站| 日韩va欧美va亚洲va久久| 欧美日韩国产综合草草| 亚洲一二三专区| 91久久精品一区二区三| 亚洲人吸女人奶水| 99久久99久久免费精品蜜臀| 中国av一区二区三区| 福利一区福利二区| 久久精品免费在线观看| 国产成人在线电影| 国产精品全国免费观看高清 | 亚洲丝袜制服诱惑| 91视频www| 亚洲欧洲综合另类在线| 91蜜桃网址入口| 亚洲精品国产无套在线观| 色综合久久中文综合久久牛| 亚洲精品欧美激情| 欧美色综合网站| 丝袜美腿亚洲一区二区图片| 欧美一区二区三区视频在线观看| 毛片av中文字幕一区二区| 亚洲精品一区二区三区在线观看| 精品夜夜嗨av一区二区三区| 国产视频一区二区三区在线观看| 福利一区二区在线观看| 亚洲日本青草视频在线怡红院 | 成熟亚洲日本毛茸茸凸凹| 国产精品国产三级国产三级人妇| 91丨porny丨户外露出| 亚洲午夜在线电影| 51精品视频一区二区三区| 韩国精品一区二区| 亚洲欧洲国产日本综合| 欧美三级电影在线观看| 激情图区综合网| 综合久久国产九一剧情麻豆| 欧美视频日韩视频| 国产乱国产乱300精品| 亚洲人成影院在线观看| 91精品国产综合久久久蜜臀粉嫩 |