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

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

?? buffer.java

?? jsp數(shù)據(jù)庫(kù)系統(tǒng)
?? JAVA
字號(hào):
/*
   Copyright (C) 2002 MySQL AB

      This program is free software; you can redistribute it and/or modify
      it under the terms of the GNU General Public License as published by
      the Free Software Foundation; either version 2 of the License, or
      (at your option) any later version.

      This program is distributed in the hope that it will be useful,
      but WITHOUT ANY WARRANTY; without even the implied warranty of
      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      GNU General Public License for more details.

      You should have received a copy of the GNU General Public License
      along with this program; if not, write to the Free Software
      Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

 */
package com.mysql.jdbc;

import java.io.UnsupportedEncodingException;

import java.sql.SQLException;


/**
 * Buffer contains code to read and write packets from/to the MySQL server.
 *
 * @version $Id: Buffer.java,v 1.15.2.12 2004/01/07 01:36:34 mmatthew Exp $
 * @author Mark Matthews
 */
class Buffer {
    static final int NO_LENGTH_LIMIT = -1;
    static final long NULL_LENGTH = -1;
    private byte[] byteBuffer;
    private boolean wasMultiPacket = false;
    private int bufLength = 0;
    private int position = 0;
    private int sendLength = 0;

    Buffer(byte[] buf) {
        this.byteBuffer = buf;
        setBufLength(buf.length);
    }

    Buffer(int size) {
        this.byteBuffer = new byte[size];
        setBufLength(this.byteBuffer.length);
        this.position = MysqlIO.HEADER_LENGTH;
    }

    /**
     * Sets the array of bytes to use as a buffer to read from.
     *
     * @param byteBuffer the array of bytes to use as a buffer
     */
    public void setByteBuffer(byte[] byteBuffer) {
        this.byteBuffer = byteBuffer;
    }

    /**
     * Returns the array of bytes this Buffer is using to read from.
     *
     * @return byte array being read from
     */
    public byte[] getByteBuffer() {
        return this.byteBuffer;
    }

    /**
     * Set the current position to write to/ read from
     *
     * @param position the position (0-based index)
     */
    public void setPosition(int position) {
        this.position = position;
    }

    /**
     * Returns the current position to write to/ read from
     *
     * @return the current position to write to/ read from
     */
    public int getPosition() {
        return this.position;
    }

    /**
     * Sets whether this packet was part of a multipacket
     *
     * @param flag was this packet part of a multipacket?
     */
    public void setWasMultiPacket(boolean flag) {
        wasMultiPacket = flag;
    }

    /**
     * Skip over a length-encoded string
     *
     * @return The position past the end of the string
     */
    public int fastSkipLenString() {
        long len = this.readFieldLength();

        position += len;

        return (int) len; // this is safe, as this is only
    }

    /**
     * Was this packet part of a multipacket?
     *
     * @return was this packet part of a multipacket?
     */
    public boolean wasMultiPacket() {
        return wasMultiPacket;
    }

    protected final byte[] getBufferSource() {
        return byteBuffer;
    }

    final byte[] getBytes(int len) {
        byte[] b = new byte[len];
        System.arraycopy(this.byteBuffer, this.position, b, 0, len);
        this.position += len; // update cursor

        return b;
    }

    // 2000-06-05 Changed
    final boolean isLastDataPacket() {
        return ((getBufLength() < 9) && ((this.byteBuffer[0] & 0xff) == 254));
    }

    final void clear() {
        this.position = MysqlIO.HEADER_LENGTH;
    }

    final void dump() {
    	StringUtils.dumpAsHex(this.byteBuffer, getBufLength());
    }

    final void dumpHeader() {
        for (int i = 0; i < MysqlIO.HEADER_LENGTH; i++) {
            String hexVal = Integer.toHexString((int) this.byteBuffer[i] & 0xff);

            if (hexVal.length() == 1) {
                hexVal = "0" + hexVal;
            }

            System.out.print(hexVal + " ");
        }
    }

    final void dumpNBytes(int start, int nBytes) {
        StringBuffer asciiBuf = new StringBuffer();

        for (int i = start;
                (i < (start + nBytes)) && (i < this.byteBuffer.length); i++) {
            String hexVal = Integer.toHexString((int) this.byteBuffer[i] & 0xff);

            if (hexVal.length() == 1) {
                hexVal = "0" + hexVal;
            }

            System.out.print(hexVal + " ");

            if ((this.byteBuffer[i] > 32) && (this.byteBuffer[i] < 127)) {
                asciiBuf.append((char) this.byteBuffer[i]);
            } else {
                asciiBuf.append(".");
            }

            asciiBuf.append(" ");
        }

        System.out.println("    " + asciiBuf.toString());
    }

    final void ensureCapacity(int additionalData) throws SQLException {
        if ((this.position + additionalData) > getBufLength()) {
            if ((this.position + additionalData) < this.byteBuffer.length) {
                // byteBuffer.length is != getBufLength() all of the time
                // due to re-using of packets (we don't shrink them)
                //
                // If we can, don't re-alloc, just set buffer length 
                // to size of current buffer
                setBufLength(this.byteBuffer.length);
            } else {
                //
                // Otherwise, re-size, and pad so we can avoid
                // allocing again in the near future
                //
                int newLength = (int) (this.byteBuffer.length * 1.25);

                if (newLength < (this.byteBuffer.length + additionalData)) {
                    newLength = this.byteBuffer.length
                        + (int) (additionalData * 1.25);
                }

                if (newLength < this.byteBuffer.length) {
                    newLength = this.byteBuffer.length + additionalData;
                }

                byte[] newBytes = new byte[newLength];

                System.arraycopy(this.byteBuffer, 0, newBytes, 0,
                    this.byteBuffer.length);
                this.byteBuffer = newBytes;
                setBufLength(this.byteBuffer.length);
            }
        }
    }

    final long newReadLength() {
        int sw = this.byteBuffer[this.position++] & 0xff;

        switch (sw) {
        case 251:
            return (long) 0;

        case 252:
            return (long) readInt();

        case 253:
            return (long) readLongInt();

        case 254: // changed for 64 bit lengths
            return (long) readLongLong();

        default:
            return (long) sw;
        }
    }

    final byte readByte() {
        return this.byteBuffer[this.position++];
    }

    final long readFieldLength() {
        int sw = this.byteBuffer[this.position++] & 0xff;

        switch (sw) {
        case 251:
            return NULL_LENGTH;

        case 252:
            return (long) readInt();

        case 253:
            return (long) readLongInt();

        case 254:
            return readLongLong();

        default:
            return (long) sw;
        }
    }

    // 2000-06-05 Changed
    final int readInt() {
        byte[] b = this.byteBuffer; // a little bit optimization

        return (b[this.position++] & 0xff) | ((b[this.position++] & 0xff) << 8);
    }

    final byte[] readLenByteArray(int offset) {
        long len = this.readFieldLength();

        if (len == NULL_LENGTH) {
            return null;
        }

        if (len == 0) {
            return new byte[0];
        }

        this.position += offset;

        return getBytes((int) len);
    }

    final long readLength() {
        int sw = this.byteBuffer[this.position++] & 0xff;

        switch (sw) {
        case 251:
            return (long) 0;

        case 252:
            return (long) readInt();

        case 253:
            return (long) readLongInt();

        case 254:
            return (long) readLong();

        default:
            return (long) sw;
        }
    }

    // 2000-06-05 Fixed
    final long readLong() {
        byte[] b = this.byteBuffer;

        return (b[this.position++] & 0xff) | ((b[this.position++] & 0xff) << 8)
        | ((b[this.position++] & 0xff) << 16)
        | ((b[this.position++] & 0xff) << 24);
    }

    // 2000-06-05 Changed
    final int readLongInt() {
        byte[] b = this.byteBuffer;

        return (b[this.position++] & 0xff) | ((b[this.position++] & 0xff) << 8)
        | ((b[this.position++] & 0xff) << 16);
    }

    // 2000-06-05 Fixed
    final long readLongLong() {
        byte[] b = this.byteBuffer;

        return (long) (b[this.position++] & 0xff)
        | ((long) (b[this.position++] & 0xff) << 8)
        | ((long) (b[this.position++] & 0xff) << 16)
        | ((long) (b[this.position++] & 0xff) << 24)
        | ((long) (b[this.position++] & 0xff) << 32)
        | ((long) (b[this.position++] & 0xff) << 40)
        | ((long) (b[this.position++] & 0xff) << 48)
        | ((long) (b[this.position++] & 0xff) << 56);
    }

    //
    // Read a null-terminated string
    //
    // To avoid alloc'ing a new byte array, we
    // do this by hand, rather than calling getNullTerminatedBytes()
    //
    final String readString() {
        int i = this.position;
        int len = 0;
		int maxLen = getBufLength();
		
        while ((i < maxLen) && (this.byteBuffer[i] != 0)) {
            len++;
            i++;
        }

        String s = new String(this.byteBuffer, this.position, len);
        this.position += (len + 1); // update cursor

        return s;
    }
    
    final String readString(String encoding) throws SQLException {
		int i = this.position;
		int len = 0;
		int maxLen = getBufLength();
		
		while ((i < maxLen) && (this.byteBuffer[i] != 0)) {
			len++;
			i++;
		}

		this.position += (len + 1); // update cursor
		
		try {
			return new String(this.byteBuffer, this.position, len, encoding);
			
		} catch (UnsupportedEncodingException uEE) {
			throw new SQLException("Unsupported character encoding '" + encoding + "'", SQLError.SQL_STATE_ILLEGAL_ARGUMENT);
		}
    }

    final int readnBytes() {
        int sw = this.byteBuffer[this.position++] & 0xff;

        switch (sw) {
        case 1:
            return this.byteBuffer[this.position++] & 0xff;

        case 2:
            return this.readInt();

        case 3:
            return this.readLongInt();

        case 4:
            return (int) this.readLong();

        default:
            return 255;
        }
    }

    final void writeByte(byte b) throws SQLException {
        ensureCapacity(1);

        this.byteBuffer[this.position++] = b;
    }

    // Write a byte array
    final void writeBytesNoNull(byte[] bytes) throws SQLException {
        int len = bytes.length;
        ensureCapacity(len);
        System.arraycopy(bytes, 0, this.byteBuffer, this.position, len);
        this.position += len;
    }

    // Write a byte array with the given offset and length
    final void writeBytesNoNull(byte[] bytes, int offset, int length)
        throws SQLException {
        ensureCapacity(length);
        System.arraycopy(bytes, offset, this.byteBuffer, this.position, length);
        this.position += length;
    }

    final void writeDouble(double d) {
        long l = Double.doubleToLongBits(d);
        writeLongLong(l);
    }

    final void writeFloat(float f) {
        int i = Float.floatToIntBits(f);
        byte[] b = this.byteBuffer;
        b[this.position++] = (byte) (i & 0xff);
        b[this.position++] = (byte) (i >>> 8);
        b[this.position++] = (byte) (i >>> 16);
        b[this.position++] = (byte) (i >>> 24);
    }

    // 2000-06-05 Changed
    final void writeInt(int i) {
        byte[] b = this.byteBuffer;
        b[this.position++] = (byte) (i & 0xff);
        b[this.position++] = (byte) (i >>> 8);
    }

    // 2000-06-05 Changed
    final void writeLong(long i) {
        byte[] b = this.byteBuffer;
        b[this.position++] = (byte) (i & 0xff);
        b[this.position++] = (byte) (i >>> 8);
        b[this.position++] = (byte) (i >>> 16);
        b[this.position++] = (byte) (i >>> 24);
    }

    // 2000-06-05 Changed
    final void writeLongInt(int i) {
        byte[] b = this.byteBuffer;
        b[this.position++] = (byte) (i & 0xff);
        b[this.position++] = (byte) (i >>> 8);
        b[this.position++] = (byte) (i >>> 16);
    }

    final void writeLongLong(long i) {
        byte[] b = this.byteBuffer;
        b[this.position++] = (byte) (i & 0xff);
        b[this.position++] = (byte) (i >>> 8);
        b[this.position++] = (byte) (i >>> 16);
        b[this.position++] = (byte) (i >>> 24);
        b[this.position++] = (byte) (i >>> 32);
        b[this.position++] = (byte) (i >>> 40);
        b[this.position++] = (byte) (i >>> 48);
        b[this.position++] = (byte) (i >>> 56);
    }

    // Write null-terminated string
    final void writeString(String s) throws SQLException {
    	ensureCapacity(s.length() + 1);
    	
        writeStringNoNull(s);
        this.byteBuffer[this.position++] = 0;
    }

    // Write string, with no termination
    final void writeStringNoNull(String s) throws SQLException {
        int len = s.length();
        ensureCapacity(len);
        System.arraycopy(s.getBytes(), 0, byteBuffer, position, len);
        position += len;

        //         for (int i = 0; i < len; i++)
        //         {
        //             this.byteBuffer[this.position++] = (byte)s.charAt(i);
        //         }
    }

    // Write a String using the specified character
    // encoding
    final void writeStringNoNull(String s, String encoding, SingleByteCharsetConverter converter)
        throws UnsupportedEncodingException, SQLException {
        byte[] b = null;
        
        if (converter != null) {
            b = converter.toBytes(s);
        } else {
            b = StringUtils.getBytes(s, encoding);
        }

        int len = b.length;
        ensureCapacity(len);
        System.arraycopy(b, 0, this.byteBuffer, this.position, len);
        this.position += len;
    }

    void setBufLength(int bufLength) {
        this.bufLength = bufLength;
    }

    int getBufLength() {
        return bufLength;
    }

    void setSendLength(int sendLength) {
        this.sendLength = sendLength;
    }
}

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
91精品久久久久久久91蜜桃| 亚洲欧洲另类国产综合| 欧美精品v国产精品v日韩精品| 成人高清免费在线播放| 国产成a人亚洲| 国产传媒久久文化传媒| 国产精品91xxx| 国产精品18久久久久久久久久久久 | 国内精品国产成人国产三级粉色| 日韩成人免费看| 日韩精品电影一区亚洲| 亚洲成人av电影| 日韩电影在线观看电影| 男男gaygay亚洲| 精久久久久久久久久久| 精品一区二区在线视频| 国产乱人伦偷精品视频免下载| 国产精品一二三区在线| 成人免费视频视频在线观看免费| 成人91在线观看| 在线观看国产精品网站| 在线视频一区二区三| 欧美日韩一区二区三区在线| 欧美肥妇free| 国产亚洲视频系列| 中文字幕中文字幕一区二区| 亚洲精品欧美激情| 天涯成人国产亚洲精品一区av| 日韩va欧美va亚洲va久久| 激情综合网av| 成年人国产精品| 精品视频1区2区3区| 欧美一区二区三区视频在线| 欧美精品一区二区三| 国产欧美精品一区二区色综合朱莉| 国产精品久久久爽爽爽麻豆色哟哟| 亚洲区小说区图片区qvod| 日本一道高清亚洲日美韩| 黄网站免费久久| 97se亚洲国产综合自在线| 欧美片在线播放| 久久久精品蜜桃| 一区二区三区在线视频播放| 日本vs亚洲vs韩国一区三区二区 | 国产老女人精品毛片久久| 成人性生交大合| 91福利资源站| 欧美精品一区二区三区在线 | 一区二区三区在线免费| 免费视频最近日韩| 91影院在线观看| 日韩一区二区三区四区| 国产精品美女久久久久久久久| 午夜日韩在线电影| 不卡av在线免费观看| 欧美日韩国产不卡| 国产精品视频一区二区三区不卡| 亚洲国产日韩一级| 国产激情偷乱视频一区二区三区| 欧美日韩一区 二区 三区 久久精品| 精品国产91九色蝌蚪| 一区二区视频在线| 国产成a人亚洲精品| 欧美一区二区精美| 亚洲综合免费观看高清完整版在线 | 99vv1com这只有精品| 欧美一区二区日韩| 亚洲精品中文字幕乱码三区| 精品一区二区综合| 欧美日韩激情一区二区三区| 国产精品嫩草影院av蜜臀| 热久久久久久久| 色综合久久九月婷婷色综合| 久久婷婷色综合| 日韩精品久久久久久| 91在线观看成人| 国产香蕉久久精品综合网| 日韩av电影免费观看高清完整版 | 久久66热偷产精品| 欧美日韩国产一级| 亚洲人xxxx| av电影在线不卡| 久久婷婷国产综合国色天香| 日韩综合在线视频| 在线亚洲一区二区| 成人免费在线播放视频| 国产精品1区2区3区| 欧美va日韩va| 日av在线不卡| 91精品国产综合久久蜜臀| 亚洲一区欧美一区| 色综合久久99| 亚洲精品免费在线观看| 成人自拍视频在线观看| 久久精品亚洲精品国产欧美 | 欧美日韩精品一区二区天天拍小说| 亚洲欧美日韩久久| 99re66热这里只有精品3直播 | 日产国产欧美视频一区精品| 欧美日韩视频专区在线播放| 一区二区三区美女| 在线亚洲精品福利网址导航| 亚洲精品成人少妇| 在线免费视频一区二区| 一区二区高清免费观看影视大全| 91小视频在线观看| 亚洲精品国产高清久久伦理二区| 91浏览器在线视频| 亚洲精品菠萝久久久久久久| 色狠狠色噜噜噜综合网| 亚洲国产精品自拍| 欧美日韩激情在线| 久久精品国产亚洲a| 久久久综合九色合综国产精品| 国产一区二区美女| 欧美国产1区2区| 色乱码一区二区三区88| 亚洲国产日日夜夜| 6080亚洲精品一区二区| 久久精品国产亚洲a| 国产日产精品一区| 99精品国产一区二区三区不卡| 亚洲免费在线看| 欧美三日本三级三级在线播放| 天天亚洲美女在线视频| 日韩欧美国产电影| 国产精品一区二区91| **欧美大码日韩| 欧美亚洲愉拍一区二区| 毛片av一区二区| 国产清纯白嫩初高生在线观看91| 99精品久久只有精品| 亚洲国产成人av网| 欧美第一区第二区| 国产成人亚洲综合a∨婷婷| 国产精品免费视频一区| 欧美色手机在线观看| 久久精品999| 国产精品高潮久久久久无| 在线观看中文字幕不卡| 免费久久精品视频| 国产精品视频免费看| 欧美亚洲国产bt| 久久超级碰视频| 成人欧美一区二区三区白人| 3751色影院一区二区三区| 久久99精品久久久久| 18成人在线视频| 欧美精品三级在线观看| 国产一区二区三区黄视频 | 综合欧美亚洲日本| 666欧美在线视频| 成人深夜福利app| 亚洲.国产.中文慕字在线| 久久久高清一区二区三区| 色综合天天做天天爱| 久久精品国产免费| 一区二区三区**美女毛片| 精品日韩在线一区| 色老汉一区二区三区| 激情文学综合丁香| 亚洲精选在线视频| 国产婷婷色一区二区三区| 欧美日韩亚洲综合| 成人激情黄色小说| 免费人成网站在线观看欧美高清| 国产精品久久久久一区二区三区共| 欧美欧美欧美欧美| www.亚洲国产| 激情欧美一区二区| 亚洲gay无套男同| 中文字幕日韩一区二区| 日韩欧美中文一区| 精品视频一区二区不卡| 成人黄色一级视频| 九色|91porny| 午夜精品在线视频一区| 一区精品在线播放| 精品国产sm最大网站| 欧美揉bbbbb揉bbbbb| av影院午夜一区| 国产一区二区剧情av在线| 日韩精品一卡二卡三卡四卡无卡| 日韩国产欧美一区二区三区| 国产精品私人影院| 精品少妇一区二区三区在线视频| 欧美日韩国产大片| 欧美艳星brazzers| 在线免费观看视频一区| 91网站在线观看视频| 成人性生交大片免费看中文 | 欧美久久久久免费| 91行情网站电视在线观看高清版| 成人小视频免费观看| 国产精品自拍三区| 卡一卡二国产精品| 肉丝袜脚交视频一区二区| 亚洲国产乱码最新视频| 亚洲一二三四区| 亚洲一区二区三区美女|