当前位置: 首页>>代码示例>>Java>>正文


Java RecordStore类代码示例

本文整理汇总了Java中javax.microedition.rms.RecordStore的典型用法代码示例。如果您正苦于以下问题:Java RecordStore类的具体用法?Java RecordStore怎么用?Java RecordStore使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


RecordStore类属于javax.microedition.rms包,在下文中一共展示了RecordStore类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testAddRecordDeleteRecord1

import javax.microedition.rms.RecordStore; //导入依赖的package包/类
@Test
public void testAddRecordDeleteRecord1() throws RecordStoreException {
    assertNull(RecordStore.listRecordStores());
    String storeName = "testAddRecordDeleteRecord1";
    RecordStore store = RecordStore.openRecordStore(storeName, true);
    byte[] record = new byte[1024];
    int count = 0;
    long startingSequence = ImpGlobal.getRecordStoreManagerErasedSequenceCurrentValue();
    while ((ImpGlobal.getRecordStoreManagerErasedSequenceCurrentValue() - startingSequence) < erasedSequenceCount) {
        fill(record, count);
        int recordId = store.addRecord(record, 0, record.length);
        fill(record, (byte) (count+1));
        byte[] bytes = store.getRecord(recordId);
        assertEquals(record, record.length, (byte) (count + 1));
        assertEquals(bytes, bytes.length, (byte) count);
        store.deleteRecord(recordId);
        try {
            store.getRecord(recordId);
            fail();
        } catch (InvalidRecordIDException e) {
        }
        count++;
    }
    store.closeRecordStore();
    RecordStore.deleteRecordStore(storeName);
}
 
开发者ID:tomatsu,项目名称:squawk,代码行数:27,代码来源:RecordStoreIntegrationTest.java

示例2: testSetRecord1

import javax.microedition.rms.RecordStore; //导入依赖的package包/类
@Test
public void testSetRecord1() throws RecordStoreException {
    assertNull(RecordStore.listRecordStores());
    String storeName = "testSetRecord1";
    RecordStore store = RecordStore.openRecordStore(storeName, true);
    byte[] record = new byte[1024];
    int count = 0;
    int recordId = store.addRecord(record, 0, record.length);
    long startingSequence = ImpGlobal.getRecordStoreManagerErasedSequenceCurrentValue();
    while ((ImpGlobal.getRecordStoreManagerErasedSequenceCurrentValue() - startingSequence) < erasedSequenceCount) {
        fill(record, count);
        store.setRecord(recordId, record, 0, record.length);
        byte[] bytes = store.getRecord(recordId);
        assertEquals(bytes, bytes.length, count);
        count++;
    }
    assertTrue(count > 0);
    store.closeRecordStore();
    RecordStore.deleteRecordStore(storeName);
}
 
开发者ID:tomatsu,项目名称:squawk,代码行数:21,代码来源:RecordStoreIntegrationTest.java

示例3: readbestscore

import javax.microedition.rms.RecordStore; //导入依赖的package包/类
/**
 * ��ȡ�����Ϸ��¼
 * @return ��ѷ���
 * @throws RecordStoreException 
 * @throws  
 * @throws Exception 
 */
private int readbestscore() throws Exception
{
	RecordStore rsb=RecordStore.openRecordStore("DanceBest", true);
	RecordEnumeration renum= rsb.enumerateRecords(null, null, false);
	if(renum.hasNextElement())
	{
		System.out.println("��ȡ��Ѽ�¼��...");
		int temp= Integer.parseInt(new String(renum.nextRecord()));
		rsb.closeRecordStore();
		return temp;
	}
	else
	{
		System.out.println("û����Ѽ�¼...");
		rsb.closeRecordStore();
		return 0;
	}
	
}
 
开发者ID:cabbage89,项目名称:danceGame,代码行数:27,代码来源:Main.java

示例4: cleanup

import javax.microedition.rms.RecordStore; //导入依赖的package包/类
/**
 * @inheritDoc
 */
public void cleanup(Object o) {
    try {
        if(o != null) {
            if(o instanceof Connection) {
                ((Connection) o).close();
                return;
            } 
            if(o instanceof RecordEnumeration) {
                ((RecordEnumeration) o).destroy();
                return;
            }
            if(o instanceof RecordStore) {
                ((RecordStore) o).closeRecordStore();
                return;
            }
            super.cleanup(o);
        }
    } catch (Throwable ex) {
        ex.printStackTrace();
    }
}
 
开发者ID:codenameone,项目名称:CodenameOne,代码行数:25,代码来源:GameCanvasImplementation.java

示例5: flush

import javax.microedition.rms.RecordStore; //导入依赖的package包/类
public void flush() throws IOException {
    if(cache != null) {
        byte[] data = cache.toByteArray();
        if(data.length > 0) {
            RecordStore r = null;
            try {
                r = RecordStore.openRecordStore("" + letter + key, true);
                r.addRecord(data, 0, data.length);
                r.closeRecordStore();
                if(letter == 'Z') {
                    letter = 'a';
                } else {
                    letter++;
                }
                cache = new ByteArrayOutputStream();
            } catch (RecordStoreException ex) {
                ex.printStackTrace();
                cleanup(r);
                throw new IOException(ex.toString());
            }
        }
    }
}
 
开发者ID:codenameone,项目名称:CodenameOne,代码行数:24,代码来源:GameCanvasImplementation.java

示例6: cleanup

import javax.microedition.rms.RecordStore; //导入依赖的package包/类
/**
 * @inheritDoc
 */
public void cleanup(Object o) {
    try {
        if (o != null) {
            if (o instanceof Connection) {
                ((Connection) o).close();
                return;
            }
            if (o instanceof RecordEnumeration) {
                ((RecordEnumeration) o).destroy();
                return;
            }
            if (o instanceof RecordStore) {
                ((RecordStore) o).closeRecordStore();
                return;
            }
            super.cleanup(o);
        }
    } catch (Throwable ex) {
        ex.printStackTrace();
    }
}
 
开发者ID:codenameone,项目名称:CodenameOne,代码行数:25,代码来源:BlackBerryImplementation.java

示例7: flush

import javax.microedition.rms.RecordStore; //导入依赖的package包/类
public void flush() throws IOException {
    if (cache != null) {
        byte[] data = cache.toByteArray();
        if (data.length > 0) {
            RecordStore r = null;
            try {
                r = RecordStore.openRecordStore("" + letter + key, true);
                r.addRecord(data, 0, data.length);
                r.closeRecordStore();
                if (letter == 'Z') {
                    letter = 'a';
                } else {
                    letter++;
                }
                cache.reset();
            } catch (RecordStoreException ex) {
                ex.printStackTrace();
                cleanup(r);
                throw new IOException(ex.toString());
            }
        }
    }
}
 
开发者ID:codenameone,项目名称:CodenameOne,代码行数:24,代码来源:BlackBerryImplementation.java

示例8: addRMSInfoJ2MEOnly

import javax.microedition.rms.RecordStore; //导入依赖的package包/类
private void addRMSInfoJ2MEOnly () {
    try {
        String[] stores = RecordStore.listRecordStores();
        for (int i = 0; i < stores.length; i++) {
            String rmsName = stores[i];
            RecordStore rms = RecordStore.openRecordStore(rmsName, false);
            int size = rms.getSize();
        //    int avail = rms.getSizeAvailable();
            int numRecs = rms.getNumRecords();
            int perRecord = (numRecs == 0 ? -1 : size / numRecs);

            this.append(new StringItem(null, rmsName));
            this.append(new StringItem(null, "Used: " + formatBytes(size)));
            this.append(new StringItem(null, "Records: " + numRecs + (numRecs > 0 ? " (" + formatBytes(perRecord) + " per record)" : "")));
            //this.append(new StringItem(null, "Available: " + formatBytes(avail)));
        }
    } catch (RecordStoreException rse) { }
}
 
开发者ID:dimagi,项目名称:commcare-j2me,代码行数:19,代码来源:PropertiesScreen.java

示例9: panic

import javax.microedition.rms.RecordStore; //导入依赖的package包/类
/**
 * called when an attempt to write to the log fails
 */
public void panic () {
    final String LOG_PANIC = "LOG_PANIC";

    try {
        RecordStore store = RecordStore.openRecordStore(LOG_PANIC, true);

        int time = (int)(System.currentTimeMillis() / 1000);
        byte[] record = new byte[] {
            (byte)((time / 16777216) % 256),
            (byte)((time / 65536) % 256),
            (byte)((time / 256) % 256),
            (byte)(time % 256)
        };
        store.addRecord(record, 0, record.length);

        store.closeRecordStore();
    } catch (RecordStoreException rse) {
        throw new WrappedException(rse);
    }
}
 
开发者ID:dimagi,项目名称:commcare-j2me,代码行数:24,代码来源:J2MELogger.java

示例10: Config

import javax.microedition.rms.RecordStore; //导入依赖的package包/类
public Config(WandersmannMIDlet midlet) {
	this.midlet = midlet;
	try {
		RecordStore config = RecordStore.openRecordStore("config", true);
		
		RecordEnumeration configKeys = config.enumerateRecords(null, null, false);
		while(configKeys.hasNextElement()) {
			String kv = new String(configKeys.nextRecord());
			Vector vkv = StringTokenizer.getVector(kv, "=");
			keys.put(vkv.elementAt(0), vkv.elementAt(1));
		}
		
		configKeys.destroy();
		config.closeRecordStore();
	} catch(RecordStoreException ex) {
		midlet.getDebugDialog().addMessage("Exception", ex.getMessage());
	}
}
 
开发者ID:cli,项目名称:worldmap-classic,代码行数:19,代码来源:Config.java

示例11: store

import javax.microedition.rms.RecordStore; //导入依赖的package包/类
private void store() {
	try {
		RecordStore.deleteRecordStore("config");
		RecordStore config = RecordStore.openRecordStore("config", true);

		Enumeration k = this.keys.keys();
		while(k.hasMoreElements()) {
			String key = (String)k.nextElement();
			byte[] buf = (key + "=" + (String)this.keys.get(key)).getBytes();
			config.addRecord(buf, 0, buf.length);
		}

		config.closeRecordStore();
	} catch(RecordStoreException ex) {
		ex.printStackTrace();
	}
}
 
开发者ID:cli,项目名称:worldmap-classic,代码行数:18,代码来源:Config.java

示例12: initialize

import javax.microedition.rms.RecordStore; //导入依赖的package包/类
public boolean initialize() {
	try {
		this.rsIndex = RecordStore.openRecordStore("index", true);
		RecordEnumeration indices = rsIndex.enumerateRecords(null, null, false);
		this.keys.clear();
		
		while(indices.hasNextElement()) {
			byte[] buf = indices.nextRecord();
			Vector indexChunks = StringTokenizer.getVector(new String(buf), "=");
			keys.put(indexChunks.elementAt(0), indexChunks.elementAt(1));
		}

		indices.destroy();

		rsImages = RecordStore.openRecordStore("images", true);
	} catch(RecordStoreException ex) {
		ex.printStackTrace();
		this.isEnabled = false;
	}
	this.successor.initialize();
	return true;
}
 
开发者ID:cli,项目名称:worldmap-classic,代码行数:23,代码来源:RMSTileCache.java

示例13: openRecordStore

import javax.microedition.rms.RecordStore; //导入依赖的package包/类
public RecordStore openRecordStore(String recordStoreName, boolean createIfNecessary)
		throws RecordStoreNotFoundException {
	RecordStoreImpl recordStoreImpl = (RecordStoreImpl) recordStores.get(recordStoreName);
	if (recordStoreImpl == null) {
		if (!createIfNecessary) {
			throw new RecordStoreNotFoundException(recordStoreName);
		}
		recordStoreImpl = new RecordStoreImpl(this, recordStoreName);
		recordStores.put(recordStoreName, recordStoreImpl);
	}
	recordStoreImpl.setOpen(true);
	if (recordListener != null) {
		recordStoreImpl.addRecordListener(recordListener);
	}

	fireRecordStoreListener(ExtendedRecordListener.RECORDSTORE_OPEN, recordStoreName);

	return recordStoreImpl;
}
 
开发者ID:freeVM,项目名称:freeVM,代码行数:20,代码来源:MemoryRecordStoreManager.java

示例14: writeRecordStore

import javax.microedition.rms.RecordStore; //导入依赖的package包/类
public final void writeRecordStore() {
    try {
        RecordStore store;
        RecordEnumeration rEnum = (store = RecordStore.openRecordStore("options", false)).enumerateRecords((RecordFilter) null, (RecordComparator) null, false);

        while (rEnum.hasNextElement()) {
            store.deleteRecord(rEnum.nextRecordId());
        }

        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        DataOutputStream dos;
        (dos = new DataOutputStream(baos)).writeBoolean(this.field_30);
        dos.writeBoolean(this.field_31);
        dos.writeInt(this.field_9);
        dos.writeInt(this.field_10);
        store.addRecord(baos.toByteArray(), 0, baos.toByteArray().length);
        store.closeRecordStore();
    } catch (Exception e) {
        System.err.println(e);
        e.printStackTrace();
    }
}
 
开发者ID:NaikSoftware,项目名称:Blitzkrieg,代码行数:23,代码来源:GameCanvas.java

示例15: InstallCfg

import javax.microedition.rms.RecordStore; //导入依赖的package包/类
public InstallCfg() throws IOException {
	try {
		RecordStore rs = RecordStore.openRecordStore(INSTALLINFO, false);
		try {
			config = Installer.parseConfig(new ByteArrayInputStream(rs.getRecord(1)));
			// for compatibility with Release 2.1
			if (config.get("alchemy.version") != null) {
				config.set(Installer.VERSION, config.get("alchemy.version"));
				config.remove("alchemy.version");
			}
		} finally {
			rs.closeRecordStore();
		}
		isInstalled = true;
	} catch (RecordStoreNotFoundException rsnfe) {
		// ok, not installed
		config = new HashMap();
		isInstalled = false;
	} catch (Exception e) {
		throw new IOException(e.toString());
	}
}
 
开发者ID:SBasalaev,项目名称:alchemy-os,代码行数:23,代码来源:InstallCfg.java


注:本文中的javax.microedition.rms.RecordStore类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。