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

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? bytearraymessageelement.java

?? jxta平臺的開發包
?? JAVA
字號:
/************************************************************************ * * $Id: ByteArrayMessageElement.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.IOException;import java.io.InputStream;import java.io.OutputStream;import java.lang.ref.SoftReference;import java.util.zip.CRC32;         // used in hashCodeimport java.util.zip.Checksum;import java.io.UnsupportedEncodingException;import org.apache.log4j.Level;import org.apache.log4j.Logger;import net.jxta.document.MimeMediaType;/** * A Message Element using byte arrays for the element data. * * <p/>This implementation does not copy the byte array provided and assumes * that the contents of the byte array will not change through out the lifetime * of the MessageElement. * * <p/>some synchronization is due to optimization in {@link #getBytes(boolean)} * which replaces value of internal member {@link #b}. * **/public class ByteArrayMessageElement extends MessageElement {        /**     *  Log4J category     **/    private static transient final Logger LOG = Logger.getLogger( ByteArrayMessageElement.class.getName() );        /**     *  The bytes of this element.     **/    protected byte [] b;        /**     *  This is the offset of our data within the array     **/    protected int offset;        /**     *  length of the element data. sometimes the same as b.length, but may be     *  lesser.     **/    protected int len;        /**     * Create a new Message Element. The contents of the provided byte array     * are <b>not</b> copied during construction.     *     * @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 b A byte array containing the contents of this element.     * @param sig optional message digest/digital signature elemnent or null if     * no signature is desired.     **/    public ByteArrayMessageElement(String name, MimeMediaType type, byte[] b, MessageElement sig) {        this( name, type, b, 0, b.length, sig );    }        /**     * Create a new MessageElement, The contents of the provided byte array are     * <b>not</b> copied during construction.     *     * @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 b A byte array containing the contents of this element.     * @param offset all bytes before this location in <code>b</code>     * will be ignored.     * @param sig optional message digest/digital signature elemnent or null if     * no signature is desired.     **/    public ByteArrayMessageElement(String name, MimeMediaType type, byte[] b, int offset, MessageElement sig) {        this( name, type, b, offset, b.length - offset, sig );    }        /**     *  Create a new Element, but dont add it to the message.  The contents of     * the byte array are <b>not</b> copied during construction.     *     * @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 b A byte array containing the contents of this Element.     * @param offset all bytes before this location will be ignored.     * @param len number of bytes to include     * @param sig optional message digest/digital signature elemnent or null if     * no signature is desired.     **/    public ByteArrayMessageElement(String name, MimeMediaType type, byte[] b, int offset, int len, MessageElement sig) {        super( name, type, sig );                if( null == b ) {            throw new IllegalArgumentException( "byte array must not be null" );        }                if( len < 0 ) {            throw new IllegalArgumentException( "len must be >= 0 : " + len );        }                if( offset < 0 ) {            throw new IllegalArgumentException( "offset must within byte array : " + offset );        }                if( (0 != len) && (offset >= b.length) ) {            throw new IllegalArgumentException( "offset must be positioned within byte array : " + offset + "," + len );        }                if( ((offset + len) > b.length) || ((offset + len) < 0) ) {            throw new IllegalArgumentException( "offset + len must be positioned within byte array" );        }                // if we get an empty request and a non-empty buffer, we don't use the provided buffer.        if( (0 == len) && (0 != b.length) ) {            b = new byte [len];            offset = 0;        }                this.b = b;        this.offset = offset;        this.len = len;    }        /**     *  {@inheritDoc}     **/    public boolean equals( Object target ) {        if( this == target ) {            return true;        }                if( target instanceof MessageElement ) {            if( !super.equals(target) ) {                return false;            }                        if( target instanceof ByteArrayMessageElement ) {                ByteArrayMessageElement likeMe = (ByteArrayMessageElement) target;                                synchronized( this ) {                    synchronized( likeMe ) {                        if( likeMe.len != len )                            return false;                                                for( int eachByte = len - 1; eachByte >= 0; eachByte-- ) {                            if( likeMe.b[likeMe.offset + eachByte] != b[offset + eachByte] )                                return false;                        }                    }                }                                return true;            } else {                // have to do a slow stream comparison.                // XXX 20020615 bondolo@jxta.org the performance of this could be much improved.                try {                    MessageElement likeMe = (MessageElement) target;                                        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 ) {                    if (LOG.isEnabledFor(Level.ERROR)) {                        LOG.error( "MessageElements could not be compared.", fatal );                    }                                        throw new IllegalStateException( "MessageElements could not be compared." + fatal );                }            }        }                return false; // not a message element    }        /**     *  {@inheritDoc}     **/    public synchronized int hashCode() {        Checksum crc = new CRC32();        crc.update( b, offset, len );        int dataHash = (int) crc.getValue();                int result = super.hashCode() *  6037 +   // a prime        dataHash;                return (0 != result) ? result : 1;    }        /**     *  {@inheritDoc}     *     *  Returns the string representation of this element. The 'charset'     *  parameter of the mimetype, if any, is used to determine encoding. If     *  the charset specified is unsupported then the default enconding will be     *  used.     *     *  @return String string representation of this message element.     **/    public synchronized String toString( ) {        String result = null;                if( null != cachedToString ) {            result = (String) cachedToString.get();                        if (null != result)                return result;        }        /*        if (LOG.isEnabledFor(Level.DEBUG)) {            LOG.debug( "creating toString of " + getClass().getName() + '@' + Integer.toHexString(hashCode()) );        } */        String charset = type.getParameter( "charset" );                try {            if( null == charset ) {                result = new String( b, offset, len );            } else {                result = new String( b, offset, len, charset );            }        } catch ( UnsupportedEncodingException caught ) {            result = new String( b, offset, len );        }                cachedToString = new SoftReference( result );                return result;    }        /**     *  {@inheritDoc}     **/    public long getByteLength() {        return len;    }        /**     *  {@inheritDoc}     *     *  <p/>synchronized so that we can replace our internal buffer with     *  the buffer we are returning if we were using a shared buffer.     **/    public synchronized byte[] getBytes( boolean copy ) {        if( (!copy) && (0 == offset ) && (b.length == len) ) {            return b;        }                byte [] result = new byte[ len ];                System.arraycopy( b, offset, result, 0, len );                // if we were using a sub-array we can switch to using this copy.        if( !copy ) {            b = result;            offset = 0;        }                return result;    }        /**     *  {@inheritDoc}     **/    public synchronized InputStream getStream() {        return new ByteArrayInputStream( b, offset, len );    }        /**     *  {@inheritDoc}     **/    public void sendToStream( OutputStream sendTo ) throws IOException {        byte [] sending;        int sendingOffset;                // locals enable us to reduce the time which the object is synchronized.        synchronized( this ) {            sending = b;            sendingOffset = offset;        }                sendTo.write( sending, sendingOffset, len );    }        /**     * Returns the contents of this element as a byte array. If this elements     * was originally constructed from a intact byte array, the array returned     * is a "shared" copy of the byte array used by this element. If this     * element was constructed with an offset of other than zero and a length     * different than the length of the source array then this function <b>WILL     * RETURN A COPY OF THE BYTE ARRAY</b>.     *     *  @return a byte array containing the contents of this element.     **/    public byte [] getBytes() {        return getBytes( false );    }}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
日本美女一区二区三区| 亚洲福利视频一区| 亚洲一区二区三区四区五区黄 | 一区二区免费在线播放| 天天爽夜夜爽夜夜爽精品视频| 高清shemale亚洲人妖| 欧美日韩另类一区| 亚洲欧洲av在线| 国产一区啦啦啦在线观看| 欧美日韩一区久久| 中文字幕一区二区三区精华液 | 在线这里只有精品| 国产午夜三级一区二区三| 日韩制服丝袜先锋影音| 欧美视频在线一区二区三区 | 国产欧美日韩不卡免费| 青青草原综合久久大伊人精品| 91亚洲精品一区二区乱码| 精品久久免费看| 免费观看日韩av| 欧美精品一二三四| 亚洲第一精品在线| 91网上在线视频| 中文字幕亚洲精品在线观看 | 欧美人动与zoxxxx乱| 中文字幕一区二区日韩精品绯色| 精品影视av免费| 欧美一区二区免费视频| 婷婷成人综合网| 欧美日韩精品综合在线| 亚洲一区二区欧美激情| 精品视频在线免费观看| 亚洲综合无码一区二区| 91国产福利在线| 一区二区理论电影在线观看| 欧美视频中文字幕| 欧洲精品在线观看| 久久久国际精品| 91丨porny丨蝌蚪视频| 在线区一区二视频| 天天色 色综合| 视频一区国产视频| 欧美mv日韩mv亚洲| 日韩一卡二卡三卡国产欧美| 久久久久国产精品厨房| 久久99国产精品久久99| 国产高清无密码一区二区三区| 亚洲综合免费观看高清完整版 | 在线精品观看国产| 高清久久久久久| 久久福利视频一区二区| 一区二区三区av电影| 中文字幕电影一区| 精品动漫一区二区三区在线观看| 欧美图区在线视频| av亚洲精华国产精华精华| 国产一区在线看| 三级亚洲高清视频| 亚洲二区视频在线| 一个色综合av| 一区二区中文视频| 国产午夜精品在线观看| 欧美一区二区三区视频| 欧美日本乱大交xxxxx| 色中色一区二区| www.性欧美| 不卡欧美aaaaa| 国产黄人亚洲片| 国产一区福利在线| 久久国产欧美日韩精品| 国产.欧美.日韩| 国产传媒日韩欧美成人| 国产精品99久久久久久久女警| 狠狠狠色丁香婷婷综合激情 | 国产精品影视网| 国产一区二区三区久久悠悠色av| 日韩精品视频网站| 午夜伦欧美伦电影理论片| 一区二区三区在线视频观看| 国产精品久久99| 欧美大片一区二区三区| 91精品婷婷国产综合久久| 欧美日韩精品一区二区天天拍小说| 色偷偷一区二区三区| 91国偷自产一区二区使用方法| 91老司机福利 在线| 97精品国产97久久久久久久久久久久| 成人黄动漫网站免费app| 成人福利视频在线| 色婷婷综合久久| 欧美视频一区二区在线观看| 在线观看国产91| 欧美情侣在线播放| 91精品国产手机| 日韩精品一区二区三区视频播放 | 中文字幕不卡在线| 26uuu色噜噜精品一区二区| 欧美大片一区二区三区| 日韩亚洲欧美成人一区| 日韩一区二区免费高清| 欧美电视剧在线看免费| 日韩精品专区在线影院重磅| 日韩精品中文字幕一区二区三区| 日韩精品一区二区在线| 久久伊人中文字幕| 欧美极品aⅴ影院| 国产精品久久久久天堂| 亚洲色图在线播放| 亚洲国产wwwccc36天堂| 亚洲午夜久久久久久久久电影院 | 91国内精品野花午夜精品| 欧日韩精品视频| 91精品国产综合久久久久久久 | 亚洲最新在线观看| 久久精品国产亚洲高清剧情介绍 | 国产综合色在线| 色婷婷精品大在线视频| 日韩精品影音先锋| 丁香一区二区三区| 国产成人啪免费观看软件| 在线观看国产一区二区| 精品国产三级a在线观看| 国产精品免费av| 亚洲福利一区二区| 成人手机在线视频| 国产精品国产三级国产专播品爱网| 亚洲一级片在线观看| 国产乱码精品一区二区三区忘忧草| 色综合久久综合网欧美综合网| 日韩一级免费观看| 亚洲综合清纯丝袜自拍| 国产精品99久| 欧美一区午夜视频在线观看| 国产精品白丝在线| 激情图片小说一区| 欧美日韩精品电影| 久久精品夜色噜噜亚洲a∨| 亚洲国产日韩a在线播放| 国产xxx精品视频大全| 9191久久久久久久久久久| 最新国产の精品合集bt伙计| 久久国产精品无码网站| 色美美综合视频| 中文字幕二三区不卡| 精品一区二区三区的国产在线播放 | 国产一区二区三区精品欧美日韩一区二区三区 | 亚洲第一会所有码转帖| 国产福利精品导航| 337p亚洲精品色噜噜| 国产亚洲婷婷免费| 调教+趴+乳夹+国产+精品| 国内不卡的二区三区中文字幕| 国产成人在线视频网站| 91精品国产综合久久婷婷香蕉| 国产精品久久久久久久久免费相片 | 国产福利一区二区三区视频在线| 9191成人精品久久| 亚洲一区影音先锋| 91偷拍与自偷拍精品| 国产精品久久久久影院亚瑟 | 日韩高清一区二区| 欧美日韩在线综合| 亚洲国产裸拍裸体视频在线观看乱了| 一本到不卡免费一区二区| 亚洲三级在线播放| 91论坛在线播放| 一区二区三区在线免费视频 | 99在线视频精品| 国产精品色婷婷久久58| 高清久久久久久| 国产精品久久看| 色综合视频一区二区三区高清| 一区二区三区在线视频观看 | 在线观看日韩高清av| 亚洲一二三四在线观看| 欧美日本精品一区二区三区| 国产乱国产乱300精品| 久久久国产精品不卡| 成人一级视频在线观看| 国产精品黄色在线观看| 色一情一乱一乱一91av| 亚洲精品视频一区| 欧美精品欧美精品系列| 久久国产夜色精品鲁鲁99| 国产婷婷色一区二区三区 | 午夜精品久久一牛影视| 日韩小视频在线观看专区| 国产久卡久卡久卡久卡视频精品| 欧美国产欧美亚州国产日韩mv天天看完整| 国产.精品.日韩.另类.中文.在线.播放 | 亚洲欧美日韩一区二区三区在线观看| 97se亚洲国产综合自在线| 午夜精品一区在线观看| 91精品国产一区二区三区 | www..com久久爱| 一区二区在线观看不卡| 91精品国产综合久久精品麻豆 | 欧美综合久久久| 日本视频在线一区| 国产丝袜欧美中文另类|