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

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

?? recordstore.java

?? 有關j2me的很好的例子可以研究一下
?? JAVA
?? 第 1 頁 / 共 5 頁
字號:
     *     * @return a new record header      *         the record store's backing file.     */    private RecordHeader allocateNewRecordStorage(int id, int dataSize)	throws RecordStoreException, RecordStoreFullException    {	int allocSize = getAllocSize(dataSize);	boolean foundBlock = false;	/*	 * Traverse the free block linked list in the file, looking	 * for the first fit	 */	RecordHeader block = new RecordHeader();	try {	    int offset = dbFirstFreeBlockOffset;	    while (offset != 0) {		block.load(offset);		// If block is big enough, use it.		if (block.blockSize >= allocSize) {		    foundBlock = true;		    break; // use this free block		}		offset = block.dataLenOrNextFree; // next free block	    }	} catch (java.io.IOException ioe) {	    throw new RecordStoreException("error finding first fit block");	}		if (foundBlock == false) {	    	    /*	     * No free block was found that would hold this record, so	     * find the last (biggest offset) record in the file and	     * append this record after it.	     */	    	    // Is there room to grow the file?	    if (RecordStoreFile.spaceAvailable() < allocSize) {		throw new RecordStoreFullException();	    }	    	    block = new RecordHeader(dbDataEnd, id, 				     dbFirstRecordOffset,				     allocSize, dataSize);	    try {		block.store();	    } catch (java.io.IOException ioe) {		throw new RecordStoreException("error writing "+					       "new record data"); 	    }	    dbFirstRecordOffset = dbDataEnd;	    dbDataEnd += allocSize;	} else { 	    // block is where the new record should be stored	    if (block.id != -1) {		throw new RecordStoreException("ALLOC ERR " + block.id +					       " is not a free block!");	    }		    removeFreeBlock(block);  // remove from free block list	    	    	    block.id = id;	    if (block.blockSize - allocSize >=		DB_BLOCK_SIZE + DB_RECORD_HEADER_LENGTH) {		splitRecord(block, allocSize); // sets block.blockSize	    }	    block.dataLenOrNextFree = dataSize;	    try {		block.store(); 	    } catch (java.io.IOException ioe) {		throw new RecordStoreException("error writing free block "+					       "after alloc"); 	    }	}	// add new record to cache	recHeadCache.insert(block);	return block;    }    /**     * Splits a free block off the tail end of a large     * record block which contains extra free space.     * After calling this method, the caller must call      * <code>storeDBState</code>.     *     * On return, <code>recHead.blockSize</code> will contain     * allocSize.     *     * @param recHead the current record header     * @param allocSize the size that <code>recHEad</code>     *        will have as its <code>blockSize</code> variable     *        when the call returns.     *     * @exception RecordStoreException if there is an error     *            splitting the record     */    private void splitRecord(RecordHeader recHead, int allocSize)	throws RecordStoreException    {	RecordHeader newfb;		int extraSpace = recHead.blockSize - allocSize;	recHead.blockSize = allocSize;		// only split records inside the linked list	if (recHead.offset != dbFirstRecordOffset) {	    int fboffset = recHead.offset + allocSize;	    newfb = new RecordHeader(fboffset, -1, recHead.offset,				     extraSpace, 0);	    try {		freeRecord(newfb); // write new free block to disk		RecordHeader prh = new RecordHeader(recHead.offset +						    recHead.blockSize);		prh.nextOffset = fboffset;		prh.store();		recHeadCache.invalidate(prh.id);		storeDBState();	    } catch (java.io.IOException ioe) {		throw new RecordStoreException("splitRecord error");	    }	} else { 	    	    // drop free space at the end of the file	    dbDataEnd = recHead.offset + recHead.blockSize;	}    }	          /**     * Free a record into the Free list.       * Turns the RecordHeader block <code>rh</code> into a free      * block, then adds it to the free block linked list.       *     * After calling this method the caller must call      * <code>storeDBState</code>.     *     * @param rh RecordHeader of record to make into a free block     *     * @exception RecordStoreException if there is an IO error updating the      *            free list     */    private void freeRecord(RecordHeader rh) 	throws RecordStoreException    {	if (rh.offset == dbFirstRecordOffset) {	    // don't put free blocks at the end of the record file	    dbFirstRecordOffset = rh.nextOffset;	    dbDataEnd = rh.offset;	} else {	    rh.id = -1;  // indicate this is a free block	    rh.dataLenOrNextFree = dbFirstFreeBlockOffset;	    // insert this new free block at front of free list	    dbFirstFreeBlockOffset = rh.offset;	    try {		rh.store();	    } catch (java.io.IOException ioe) {		throw new RecordStoreException("free record failed");	    }	}    }    /**     * Remove a free block from the free block linked list     *     * @param blockToFree record header for the free block to remove     *      * @exception recordStoreException if error occurs during the     *            update.     */    private void removeFreeBlock(RecordHeader blockToFree) 	throws RecordStoreException     {	RecordHeader block = new RecordHeader();	RecordHeader prev = new RecordHeader();	RecordHeader tmp = null;	try {	    int offset = dbFirstFreeBlockOffset;	    while (offset != 0) {		block.load(offset);		if (block.offset == blockToFree.offset) {		    if (block.id != -1) {			throw new RecordStoreException("removeFreeBlock id" +						       " is not -1");		    }		    if (prev.offset == 0) {			// Set next free block as new freelist head			dbFirstFreeBlockOffset = block.dataLenOrNextFree;		    } else {			/*			 * Update previous block's pointer to the			 * block this block was pointing to			 */			prev.dataLenOrNextFree = block.dataLenOrNextFree;			prev.store();		    }		}		offset = block.dataLenOrNextFree;		// avoid creating lots of garbage!		tmp = prev;		prev = block;		block = tmp;	    }	} catch (java.io.IOException ioe) {	    throw new RecordStoreException("removeFreeBlock block not found");	}	    }    /**     * Helper method that stores the internal state variables     * into the record store file.     *     * checkopen should have been called.  will not work     * if dbraf is not open     *     * Updates dbLastModified time to current system time     */    private void storeDBState() throws RecordStoreException    {	try {	    // set modification time	    dbLastModified = System.currentTimeMillis();	    	    // Capture the db state into the byte array	    RecordStore.putInt(dbNumLiveRecords, dbState, RS_NUM_LIVE);	    RecordStore.putInt(0, dbState, RS_RESERVED); // reserved	    RecordStore.putInt(dbVersion, dbState, RS_VERSION);	    RecordStore.putInt(dbNextRecordID, dbState, RS_NEXT_ID);	    RecordStore.putInt(dbFirstRecordOffset, dbState, RS_REC_START);	    RecordStore.putInt(dbFirstFreeBlockOffset, dbState, RS_FREE_START);	    RecordStore.putLong(dbLastModified, dbState, RS_LAST_MODIFIED);	    RecordStore.putInt(dbDataStart, dbState, RS_DATA_START);	    RecordStore.putInt(dbDataEnd, dbState, RS_DATA_END);	    // Write the state to the db file	    dbraf.seek(SIGNATURE_LENGTH); // skip RS header 8 bytes	    int numbytes = DB_INIT.length - SIGNATURE_LENGTH;	    dbraf.write(dbState, SIGNATURE_LENGTH, numbytes);	} catch (java.io.IOException ioe) {	    throw new RecordStoreException("error writing record store " +					   "attributes");	}    }    /*     * Private Utility Methods     */    /**     * Throws a RecordStoreNotOpenException if the RecordStore     * is closed.  (A RecordStore is closed if the RecordStoreFile     * instance variable <code>dbraf</code> is null.     *     * @exception RecordStoreNotOpenException if RecordStore is closed     */    private void checkOpen() throws RecordStoreNotOpenException    {	if (dbraf == null)	    throw new RecordStoreNotOpenException();    }    /**     * Notifies all registered listeners that a record changed.     *     * @param recordId the record id of the changed record.     */    private void notifyRecordChangedListeners(int recordId)    {	for (int i = 0; i < recordListener.size(); i++) {	    RecordListener rl = (RecordListener)recordListener.elementAt(i);	    rl.recordChanged(this, recordId);	}    }    /**     * Notifies all registered listeners that a record was added.     *     * @param recordId the record id of the added record.     */    private void notifyRecordAddedListeners(int recordId)    {	for (int i = 0; i < recordListener.size(); i++) {	    RecordListener rl = (RecordListener)recordListener.elementAt(i);	    rl.recordAdded(this, recordId);	}    }        /**     * Notifies all registered listeners that a record was deleted.     *     * @param recordId the record id of the changed record.     */    private void notifyRecordDeletedListeners(int recordId)    {	for (int i = 0; i < recordListener.size(); i++) {	    RecordListener rl = (RecordListener)recordListener.elementAt(i);	    rl.recordDeleted(this, recordId);	}    }    /**     * A convenience method for converting a byte array into     * an int (assumes big-endian byte ordering).     *     * @param data the byte array returned from the database.     * @param offset the offset into the array of the first byte to start from.     *     * @return an int corresponding to the first four bytes      *         of the array passed in.     */    static int getInt(byte[] data, int offset)    {	int r = data[offset++];	r = (r << 8) | ((int)(data[offset++]) & 0xff);	r = (r << 8) | ((int)(data[offset++]) & 0xff);	r = (r << 8) | ((int)(data[offset++]) & 0xff);	return r;    }    /**     * A convenience method for converting a byte array into     * a long (assumes big-endian byte ordering).     *     * @param data the byte array returned from the database.     * @param offset the offset into the array of the first byte to start from.     * @return a long corresponding to the first eight bytes      *         of the array passed in.     */    static long getLong(byte[] data, int offset)    {	long r = data[offset++];	r = (r << 8) | ((long)(data[offset++]) & 0xff);	r = (r << 8) | ((long)(data[offset++]) & 0xff);	r = (r << 8) | ((long)(data[offset++]) & 0xff);	r = (r << 8) | ((long)(data[offset++]) & 0xff);	r = (r << 8) | ((long)(data[offset++]) & 0xff);	r = (r << 8) | ((long)(data[offset++]) & 0xff);	r = (r << 8) | ((long)(data[offset++]) & 0xff);	return r;    }    /**     * A convenience method for converting an integer into     * a byte array.     *     * @param i the integer to turn into a byte array.     * @param data a place to store the bytes of <code>i</code>.     * @param offset starting point within <code>data<code> to      *        store <code>i</code>.     *     * @return the number of bytes written to the array.     */    static int putInt(int i, byte[] data, int offset)    {	data[offset++] = (byte)((i >> 24) & 0xff);	data[offset++] = (byte)((i >> 16) & 0xff);	data[offset++] = (byte)((i >> 8) & 0xff);	data[offset] = (byte)(i & 0xff);	return 4;    }    /**     * A convenience method for converting a long into     * a byte array.     *     * @param l the <code>long<code> to turn into a byte array.     * @param data a place to store the bytes of <code>l</code>.     * @param offset Starting point within <code>data</code> to      *        store <code>l</code>.     *     * @return the number of bytes written to the array.     */    static int putLong(long l, byte[] data, int offset)    {	data[offset++] = (byte)((l >> 56) & 0xff);	data[offset++] = (byte)((l >> 48) & 0xff);	data[offset++] = (byte)((l >> 40) & 0xff);	data[offset++] = (byte)((l >> 32) & 0xff);	data[offset++] = (byte)((l >> 24) & 0xff);	data[offset++] = (byte)((l >> 16) & 0xff);	data[offset++] = (byte)((l >> 8) & 0xff);	data[offset] = (byte)(l & 0xff);	return 8;

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
久久国内精品自在自线400部| 国产精品亚洲第一| 欧美大片免费久久精品三p| 国模冰冰炮一区二区| 亚洲视频网在线直播| 日韩免费性生活视频播放| 99久久精品免费看国产免费软件| 五月天亚洲精品| 日本一区二区在线不卡| 日韩视频免费观看高清完整版| 成人免费精品视频| 日韩福利视频导航| 亚洲精品伦理在线| 久久久久9999亚洲精品| 欧美美女喷水视频| 99国内精品久久| 国产suv精品一区二区三区| 日韩国产一区二| 国产精品国产三级国产普通话蜜臀 | 在线视频国产一区| 国产毛片精品视频| 五月天激情小说综合| 亚洲码国产岛国毛片在线| 2023国产精品| 91 com成人网| 在线亚洲一区二区| 亚洲一区二区三区四区不卡| 最近中文字幕一区二区三区| 精品久久久久久久久久久久包黑料| 色婷婷av一区二区三区大白胸| 国产99久久久国产精品潘金| 国产毛片精品视频| 久久99精品久久久久婷婷| 午夜电影久久久| 一区二区三区日韩精品视频| 亚洲欧美偷拍卡通变态| 久久久久久99久久久精品网站| 91精品国产综合久久精品| 91国产成人在线| 色老汉一区二区三区| jlzzjlzz亚洲日本少妇| 成人综合婷婷国产精品久久蜜臀| 韩国三级电影一区二区| 久久国产精品色| 黑人巨大精品欧美一区| 黄色日韩网站视频| 九色|91porny| 韩国一区二区在线观看| 国产精品一区2区| 国产盗摄一区二区| 国产成人精品一区二区三区四区 | 国产亚洲人成网站| 精品欧美乱码久久久久久| 91麻豆精品国产自产在线 | 国产蜜臀av在线一区二区三区| 久久综合成人精品亚洲另类欧美 | 青青青爽久久午夜综合久久午夜| 天堂成人国产精品一区| 香蕉成人啪国产精品视频综合网| 亚洲国产一二三| 性欧美疯狂xxxxbbbb| 亚洲地区一二三色| 青青草伊人久久| 久久99精品久久只有精品| 国产一区亚洲一区| 蜜桃一区二区三区在线观看| 久草精品在线观看| 国产精品一区专区| 丁香亚洲综合激情啪啪综合| 国产高清在线观看免费不卡| 91色乱码一区二区三区| 精品视频在线免费| 日韩一级免费观看| 久久精品夜夜夜夜久久| 一区二区三区四区激情| 天堂蜜桃一区二区三区| 精品综合免费视频观看| 国产亚洲精品7777| 国产成人精品1024| 亚洲影院在线观看| 亚洲不卡在线观看| 五月天一区二区三区| 日本不卡一区二区三区高清视频| 蜜臀av性久久久久蜜臀aⅴ流畅| 国产目拍亚洲精品99久久精品| 美国十次了思思久久精品导航| 最新不卡av在线| 亚洲国产精品成人综合色在线婷婷 | 蜜桃免费网站一区二区三区| 91视频一区二区| 岛国精品一区二区| 国产成人福利片| 国产成人综合在线播放| 成人自拍视频在线观看| 国产sm精品调教视频网站| 成人中文字幕在线| 91影视在线播放| 在线观看国产91| 91蝌蚪porny九色| 成人午夜在线免费| 成人97人人超碰人人99| 成人av免费网站| 91免费小视频| 精品视频在线看| 色悠悠久久综合| 91精品国产综合久久婷婷香蕉| 欧美一区二区三区在线观看| 欧美精品一区二区三区在线 | 国产精品成人一区二区艾草 | 欧美午夜电影网| 9191精品国产综合久久久久久| 51久久夜色精品国产麻豆| 精品999在线播放| 亚洲丝袜自拍清纯另类| 日本亚洲电影天堂| 成人手机电影网| 欧美理论片在线| 中文字幕成人av| 亚洲成a人v欧美综合天堂下载| 看电影不卡的网站| 色婷婷久久99综合精品jk白丝| 欧美一级搡bbbb搡bbbb| 中文av字幕一区| 另类小说一区二区三区| 99国产精品久久久久久久久久久 | 国产成人无遮挡在线视频| 亚洲精品日韩一| 精品sm捆绑视频| 亚洲同性同志一二三专区| 蜜桃久久久久久久| 在线观看日韩电影| 国产欧美日韩综合| 视频一区国产视频| 91色porny| 久久久亚洲精品一区二区三区| 午夜精品久久久| 波多野结衣中文字幕一区| 日韩精品一区二区三区三区免费| 亚洲欧美另类在线| 成人免费视频视频在线观看免费| 91精品视频网| 亚洲一二三级电影| 97se狠狠狠综合亚洲狠狠| 久久众筹精品私拍模特| 日本vs亚洲vs韩国一区三区二区 | 日本午夜精品一区二区三区电影| 一本色道综合亚洲| 久久久国产精华| 精品综合久久久久久8888| 欧美日韩国产bt| 亚洲网友自拍偷拍| 欧美在线制服丝袜| 中文字幕在线免费不卡| 国产jizzjizz一区二区| 久久丝袜美腿综合| 久久国内精品自在自线400部| 在线综合亚洲欧美在线视频| 亚洲成a人在线观看| 在线影院国内精品| 亚洲午夜影视影院在线观看| 色综合久久久网| 亚洲欧美日韩在线播放| 色8久久人人97超碰香蕉987| 亚洲精品高清视频在线观看| 色狠狠色噜噜噜综合网| 亚洲午夜久久久久久久久电影院 | 成人午夜激情视频| 国产精品入口麻豆原神| 成人污污视频在线观看| 久久久久久久国产精品影院| 国产盗摄一区二区三区| 中文一区二区在线观看| 床上的激情91.| 亚洲欧美激情视频在线观看一区二区三区 | 91高清视频在线| 亚洲sss视频在线视频| 欧美日韩成人综合天天影院 | 久久综合久色欧美综合狠狠| 亚洲一区在线视频观看| 久久精品视频在线免费观看| 91视频.com| 日韩一区二区免费视频| 欧美成人a∨高清免费观看| 成人亚洲精品久久久久软件| 天天av天天翘天天综合网| 亚洲国产成人一区二区三区| 91精品国产乱码久久蜜臀| 91论坛在线播放| eeuss鲁片一区二区三区在线看| 日韩成人精品在线| 亚洲成a人片在线不卡一二三区| 欧美精品一区二区三区在线播放 | 欧美一区二区三区在线看| 日韩黄色在线观看| 欧美精品一区二区三区在线播放| 国产精品中文字幕欧美| 亚洲欧美激情一区二区| 日韩一级成人av| 成人av在线观| 日本女优在线视频一区二区|