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

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

?? objectstore.java

?? SyncML的java實現類庫 funambol公司發布的
?? JAVA
字號:
/*
 * Copyright (C) 2006-2007 Funambol
 *
 * 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.funambol.storage;

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.util.Enumeration;

import javax.microedition.rms.InvalidRecordIDException;
import javax.microedition.rms.RecordEnumeration;
import javax.microedition.rms.RecordStore;
import javax.microedition.rms.RecordStoreException;
import javax.microedition.rms.RecordStoreNotOpenException;

import com.funambol.util.Log;

/** 
 * This class uses the J2ME RMS to store and retrieve objects
 * using the rms positional access.
 *
 * To persist an object using ObjectStore, it must implement the
 * com.funambol.storage.Serializable interface.
 *
 * @param name is the name of the RecordStore to be managed 
 */
public class ObjectStore {

    // ---------------------------------------------- Attributes
    private RecordStore rs;
    private RecordEnumeration re;
    private ObjectFilter of;
    private ObjectComparator oc;
    
    // ---------------------------------------------- Constructors
    /** 
     * Creates a new instance of ObjectStore.
     */
    public ObjectStore() {
        rs = null;
        re = null;
    }
    
    /**
     * Get all object of the ObjectStore
     * @param s Serializable Object to be returned
     * @return Enumeration of Serializable object found 
     */
    public Enumeration getObjects(Serializable s) {
        return new ObjectEnumeration(this.rs, this.of, this.oc, s);
    }
    /**
     * @return Store name
     */
    public String getName() throws RecordStoreNotOpenException {
        return rs.getName();
    } 

    /** 
     * Open an existing RecordStore, or throws an exception if not present.
     * If the name is the same of the currently open one, no action is
     * taken, otherwise the old one is closed.
     *
     * @param name is the name of the RecordStore to be managed 
     * @return true if the record store has been open or created
     *         false if it was cached
     */
    public boolean open(String name) throws RecordStoreException {
        return openStore(name, false);
    }
    
    /** 
     * Creates a new RecordStore, or open an existing one.
     *
     * @param name is the name of the RecordStore to be managed
     * @return true if the record store has been open or created
     *         false if it was cached
     * 
     */
    public boolean create(String name) throws RecordStoreException {
        return openStore(name, true);
    }
    
    /**
     * private method used by open and create to share code.
     */
    private boolean openStore(String name, boolean create)
    throws RecordStoreException  {
        // Check if is requested to open a new record store
        if(rs != null){
            if(rs.getName().equals(name)){
                return false; // equal: keep the old one
            }
            else {
                close();
            }
        }
        rs = RecordStore.openRecordStore(name, create);
        return true;
    }

    /** 
     * Close the current RecordStore, if open.
     *
     */
    public void close() throws RecordStoreException {
        if(rs != null){
            rs.closeRecordStore();
        }        
        rs = null;
        re = null;
    }
    
    /**
     * Return the number of records in this ObjectStore
     *
     * @return the number of records present or -1 if the ObjectStore is not
     *         open.
     */
    public int size() {
        int ret = 0;
        try {
            if(rs != null) {
                ret = rs.getNumRecords();
            } else {
                return -1;
            }
        } catch (RecordStoreNotOpenException ex) {
            Log.error("Can't get size of ObjectStore: recordstore not open.");
            ret = -1; 
        }
        return ret;
    }

    /**
     *  Get the first valid index in the record store.
     *
     *  @return the first valid index in the record store, or 0 if empty.
     */
    public int getFirstIndex() throws RecordStoreException {
        //TODO: could we use false here to improve performances?
        re = rs.enumerateRecords(null, null, true);
        return getNextIndex();
    }

    /**
     *  Get the next valid index in the record store.
     *
     *  @return the next valid index in the record store, or 0 if no
     *          more record are present.
     */
    public int getNextIndex() throws RecordStoreException {

        if(re.hasNextElement()){
            return re.nextRecordId();
        }
        else {
            return 0;
        }
    }

    /**
     *  Store the serializable object in a new record.
     *
     *  @param obj the serializable object
     *  @return the index in the recordstore
     */
    public int store(Serializable obj) throws RecordStoreException, IOException {
        ByteArrayOutputStream byteStream = new ByteArrayOutputStream();
        DataOutputStream out = new DataOutputStream(byteStream);

        obj.serialize(out);

        byte[] data = byteStream.toByteArray();
        int ret = rs.addRecord(data, 0, data.length);
        obj = null;
        data = null;
        byteStream = null;
        out = null;
        return ret; 
    }

    /**
     *  Store the serializable object in an existent record.
     *
     *  @param obj the serializable object
     *  @return the index in the recordstore
     */
    public int store(int index, Serializable obj)
    throws RecordStoreException, IOException {
        ByteArrayOutputStream byteStream = new ByteArrayOutputStream();
        DataOutputStream out = new DataOutputStream(byteStream);

        obj.serialize(out);

        byte[] data = byteStream.toByteArray();
        rs.setRecord(index, data, 0, data.length);
        obj = null;
        return index;
    }
    
    /**
     *  Retrieve the serialize object from the record store.
     *
     *  @param obj the serializable object
     *  @param index the index in the recordstore
     * 
     *  @return a reference to the object, or null if the object is
     *          empty in the store.
     */
    public Serializable retrieve(int index, Serializable obj)
    throws RecordStoreException, IOException {
        byte data[] = rs.getRecord(index);

        if (data != null) {
            ByteArrayInputStream dataStream = new ByteArrayInputStream(data);
            DataInputStream in = new DataInputStream(dataStream);

            obj.deserialize(in);
        }
        else {
            return null;
        }

        return obj;
    }

    /**
     *  Remove the object from the store.
     *
     *  @param index the index in the recordstore
     */
    public void remove(int index) throws RecordStoreException {
        rs.deleteRecord(index);
    }
    
    /**
     *  Returns the amount of additional room (in bytes) available for this
     *  record store to grow.
     *
     *  @return the amount of storage left for this store.
     */
    public int getAvaliableStorage() {
        try {
            return rs.getSizeAvailable();

        } catch(RecordStoreNotOpenException e) {
            // Should not happen
            e.printStackTrace();
            Log.error("ObjectStore.getAvaliableStorage: "+e.toString());
            return 0;
        }
    }

    /**
     * Add a RecordListener to the recordStore
     */
    public void addStoreListener(ObjectStoreListener listener) {
        rs.addRecordListener(listener);
    }
    
    /**
     * Add a RecordListener to the recordStore
     */
    public void removeStoreListener(ObjectStoreListener listener) {
        rs.removeRecordListener(listener);
    }
    
    /**
     * Set Filter for this ObjectStore
     */
    public void setObjectFilter(ObjectFilter newOf) {
        this.of = newOf;
    }
    
    /**
     * Remove Filter after usage
     */
    public void removeObjectFilter() {
        this.of = null;
    }
    
    /**
     * Set Comparator for this ObjectStore
     */
    public void setObjectComparator(ObjectComparator newOc) {
        this.oc = newOc;
    }
    
    /**
     * Set Comparator for this ObjectStore
     */
    public void removeObjectComparator() {
        this.oc = null;
    }
}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
日韩丝袜美女视频| 在线综合视频播放| 国产精品久久久久久久午夜片| 国产成人免费在线观看不卡| 国产视频在线观看一区二区三区| 国产欧美日韩中文久久| 欧美激情一区在线观看| 丁香网亚洲国际| 国产精品成人免费| 欧美亚洲综合在线| 蜜桃精品在线观看| 久久看人人爽人人| 91麻豆精东视频| 亚洲bt欧美bt精品| 欧美精品一区二区三| 懂色av一区二区三区蜜臀| 亚洲同性同志一二三专区| 欧美日韩亚洲丝袜制服| 黄色小说综合网站| 亚洲美女精品一区| 日韩精品一区二区三区在线播放 | 日日夜夜一区二区| 精品国产麻豆免费人成网站| 99久久国产综合精品色伊| 天堂久久久久va久久久久| 久久亚洲综合色一区二区三区| 国产麻豆91精品| 亚洲自拍偷拍图区| 欧美成人aa大片| 一本大道久久精品懂色aⅴ | 亚洲人成在线播放网站岛国| 在线综合+亚洲+欧美中文字幕| 国产成人精品午夜视频免费| 亚洲大尺度视频在线观看| 久久综合资源网| 欧美在线999| 国产高清久久久| 亚洲成人av一区二区三区| 国产日韩影视精品| 7777精品伊人久久久大香线蕉完整版 | 国产午夜精品一区二区三区视频 | 国产成人综合在线播放| 亚洲成av人片一区二区| 久久久国产精华| 欧美一区二区三区播放老司机| 色香蕉成人二区免费| 国产高清精品在线| 久久成人免费网站| 午夜电影久久久| 亚洲激情五月婷婷| 国产精品乱子久久久久| 精品久久五月天| 5566中文字幕一区二区电影| 色综合久久久久综合99| 成人黄色大片在线观看| 国产麻豆成人精品| 激情成人综合网| 免费成人美女在线观看.| 免费在线成人网| 亚洲一区二区av电影| 国产精品美女久久久久久久久久久| 欧美mv日韩mv国产| 欧美xfplay| 日韩欧美国产综合| 欧美一区二区视频观看视频| 欧美日韩国产在线观看| 欧美曰成人黄网| 欧美影视一区在线| 欧美色男人天堂| 欧美日韩一级二级| 911国产精品| 9191精品国产综合久久久久久| 欧美日韩一区二区三区四区| 欧美午夜精品电影| 精品视频1区2区| 欧美视频一二三区| 91精品国产综合久久婷婷香蕉| 91麻豆精品国产91久久久| 欧美日韩国产综合一区二区三区| 欧美精品黑人性xxxx| 91精品国产综合久久久久久久| 这里只有精品免费| 日韩一区二区中文字幕| 精品国产一区二区三区忘忧草| 精品毛片乱码1区2区3区| 国产亚洲精品超碰| 国产精品美日韩| 亚洲一区二三区| 日韩电影一区二区三区| 狠狠色狠狠色综合| 波多野结衣欧美| 91福利在线免费观看| 欧美精品三级日韩久久| 精品少妇一区二区三区免费观看 | 伊人夜夜躁av伊人久久| 国产精品一区一区| 国产.欧美.日韩| 99精品视频一区二区| 激情文学综合网| 亚洲人成伊人成综合网小说| 亚洲视频1区2区| 婷婷六月综合亚洲| 精品一区二区三区在线播放| 成人av网站免费观看| 欧美日韩在线一区二区| 久久亚洲免费视频| 亚洲三级久久久| 美日韩一级片在线观看| 处破女av一区二区| 在线观看三级视频欧美| 欧美mv和日韩mv的网站| 亚洲手机成人高清视频| 日韩和欧美一区二区三区| 国产精品自拍网站| 在线视频综合导航| 久久婷婷综合激情| 一级精品视频在线观看宜春院| 激情综合色播激情啊| 日本丰满少妇一区二区三区| 日韩三级视频在线观看| 国产精品福利一区二区三区| 奇米影视7777精品一区二区| av影院午夜一区| 欧美成人性福生活免费看| 亚洲精品国产品国语在线app| 老司机精品视频线观看86| 91污片在线观看| 久久综合狠狠综合| 亚洲最新在线观看| 成人激情小说网站| 日韩免费成人网| 亚洲综合精品久久| 成人免费毛片app| 久久影院午夜片一区| 亚洲mv大片欧洲mv大片精品| 不卡的av电影| 日韩精品专区在线影院观看| 亚洲成人午夜影院| 色综合久久久久网| 亚洲免费观看视频| 亚洲成人免费影院| 91麻豆6部合集magnet| 欧美激情一区二区在线| 精品中文av资源站在线观看| 欧美三级三级三级| 专区另类欧美日韩| 欧美日韩国产综合久久| 综合欧美一区二区三区| 国产一区日韩二区欧美三区| 91精品在线一区二区| 亚洲成人手机在线| 在线国产亚洲欧美| 亚洲欧美一区二区不卡| 成人做爰69片免费看网站| 久久亚洲捆绑美女| 久久av资源站| 精品女同一区二区| 美女网站色91| 日韩欧美色综合| 强制捆绑调教一区二区| 91精品蜜臀在线一区尤物| 日本欧美在线看| 91精品国产麻豆国产自产在线 | 亚洲精品午夜久久久| 91在线播放网址| 亚洲免费电影在线| 91黄色激情网站| 亚洲在线一区二区三区| 国产日韩欧美精品一区| 在线观看www91| 亚洲精品国产精华液| 91网上在线视频| 亚洲卡通动漫在线| 欧美日韩亚洲不卡| 视频一区中文字幕国产| 欧美久久久久久蜜桃| 日本不卡一二三| 久久久久久久精| gogogo免费视频观看亚洲一| 亚洲激情综合网| 欧美一级黄色录像| 国产乱子伦视频一区二区三区 | 亚洲欧洲综合另类| 欧美午夜精品久久久久久孕妇| 亚洲国产精品一区二区久久恐怖片| 欧美猛男gaygay网站| 久国产精品韩国三级视频| 国产精品久久久久影院老司| 欧美伊人久久久久久久久影院 | 偷拍日韩校园综合在线| 日韩精品一区二| 成年人网站91| 五月天激情综合| 久久久亚洲精华液精华液精华液| 成人av电影免费观看| 日韩不卡在线观看日韩不卡视频| 精品国产一区二区三区久久久蜜月| 成人免费看黄yyy456| 亚洲激情一二三区| 久久只精品国产|