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


Java RecordStore.addRecord方法代码示例

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


在下文中一共展示了RecordStore.addRecord方法的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: 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

示例4: 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

示例5: 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

示例6: 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

示例7: 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

示例8: save

import javax.microedition.rms.RecordStore; //导入方法依赖的package包/类
public void save() throws IOException {
	try {
		ByteArrayOutputStream out = new ByteArrayOutputStream();
		Object[] keys = config.keys();
		for (int i=0; i<keys.length; i++) {
			IO.println(out, "" + keys[i] + '=' + config.get(keys[i]));
		}
		RecordStore rs = RecordStore.openRecordStore(INSTALLINFO, true);
		if (rs.getNextRecordID() == 1) rs.addRecord(null, 0, 0);
		byte[] data = out.toByteArray();
		rs.setRecord(1, data, 0, data.length);
		rs.closeRecordStore();
		isInstalled = true;
	} catch (Exception e) {
		throw new RuntimeException(e.toString());
	}
}
 
开发者ID:SBasalaev,项目名称:alchemy-os,代码行数:18,代码来源:InstallCfg.java

示例9: testAddRecordDeleteRecord2

import javax.microedition.rms.RecordStore; //导入方法依赖的package包/类
@Test
public void testAddRecordDeleteRecord2() throws RecordStoreException {
    assertNull(RecordStore.listRecordStores());
    String storeName = "testAddRecordDeleteRecord2";
    RecordStore store = RecordStore.openRecordStore(storeName, true);
    byte[] record = new byte[1024];
    int firstCountAdd = -1;
    for (int i=0; i < 4; i++) {
        int countAdd = 0;
        try {
            while (true) {
                fill(record, countAdd);
                store.addRecord(record, 0, record.length);
                countAdd++;
            }
        } catch (RecordStoreFullException e) {
        }
        assertTrue(countAdd > 0);
        if (firstCountAdd == -1) {
            firstCountAdd = countAdd;
        } else {
            assertEquals(firstCountAdd, countAdd);
        }
        RecordEnumeration records = store.enumerateRecords(null, null, false);
        int countDelete = 0;
        while (records.hasNextElement()) {
            int recordId = records.nextRecordId();
            byte[] bytes = store.getRecord(recordId);
            assertEquals(bytes, bytes.length, countDelete);
            store.deleteRecord(recordId);
            countDelete++;
        }
        assertEquals(countDelete, countAdd);
    }
    store.closeRecordStore();
    RecordStore.deleteRecordStore(storeName);
}
 
开发者ID:tomatsu,项目名称:squawk,代码行数:38,代码来源:RecordStoreIntegrationTest.java

示例10: testAddRecordDeleteStore1

import javax.microedition.rms.RecordStore; //导入方法依赖的package包/类
@Test
public void testAddRecordDeleteStore1() throws RecordStoreException {
    assertNull(RecordStore.listRecordStores());
    byte[] record = new byte[1024];
    int firstCountAdd = -1;
    for (int i=0; i < 4; i++) {
        String storeName = "testAddRecordDeleteStore1";
        RecordStore store = RecordStore.openRecordStore(storeName, true);
        int countAdd = 0;
        try {
            while (true) {
                fill(record, countAdd);
                store.addRecord(record, 0, record.length);
                countAdd++;
            }
        } catch (RecordStoreFullException e) {
        }
        assertTrue(countAdd > 0);
        if (firstCountAdd == -1) {
            firstCountAdd = countAdd * 90 / 100;
        } else {
            assertTrue(countAdd >= firstCountAdd);
        }
        store.closeRecordStore();
        RecordStore.deleteRecordStore(storeName);
    }
}
 
开发者ID:tomatsu,项目名称:squawk,代码行数:28,代码来源:RecordStoreIntegrationTest.java

示例11: record

import javax.microedition.rms.RecordStore; //导入方法依赖的package包/类
/**
 * ��¼�˴���Ϸ��¼
 * @throws RecordStoreException 
 * @throws RecordStoreFullException 
 * @throws RecordStoreNotOpenException 
 */
private void record() throws Exception
{
	//-------------------
	//������Ѽ�¼
	RecordStore rsb=RecordStore.openRecordStore("DanceBest", true);
	RecordEnumeration renum= rsb.enumerateRecords(null, null, false);
	if(renum.hasNextElement())
	{
		int prebestscore= Integer.parseInt(new String(renum.nextRecord()));
		System.out.println("��ʷ��߷�:"+prebestscore);
		if(prebestscore<currentScore)
		{
			//renum.numRecords();//��ǰrecordid
			rsb.setRecord(renum.numRecords(), (currentScore+"").getBytes(), 0, (currentScore+"").getBytes().length);
			System.out.println("��Ѽ�¼���³ɹ�...");
		}
	}
	else
	{
		rsb.addRecord((currentScore+"").getBytes(), 0, (currentScore+"").getBytes().length);
		System.out.println("��Ѽ�¼����ɹ�...");
	}
	rsb.closeRecordStore();
	//--------------------
	RecordStore rs=RecordStore.openRecordStore("Dance", true);
	String score=currentScore+"";	//����
	String actioncount=""+ActionCount;	//�����Ѷ�
	String actionrepeat=""+ActionRepeat;	//�ظ�����
	String currentlift=currentLift+"";	//��ǰ����
	//���˳���ܱ�
	rs.addRecord(score.getBytes(), 0, score.getBytes().length);	//id:1,����
	rs.addRecord(actioncount.getBytes(), 0, actioncount.getBytes().length);	//id:2,�����Ѷ�
	rs.addRecord(actionrepeat.getBytes(), 0, actionrepeat.getBytes().length);	//�ظ�����
	rs.addRecord(currentlift.getBytes(), 0, currentlift.getBytes().length);	//��ǰ����
	rs.closeRecordStore();
	
	System.out.println("�����¼�ɹ�...");
}
 
开发者ID:cabbage89,项目名称:danceGame,代码行数:45,代码来源:MyCanvas.java

示例12: record

import javax.microedition.rms.RecordStore; //导入方法依赖的package包/类
/**
 * ��¼�˴���Ϸ��¼
 * @throws RecordStoreException 
 * @throws RecordStoreFullException 
 * @throws RecordStoreNotOpenException 
 */
private void record() throws Exception
{
	RecordStore rs=RecordStore.openRecordStore("Dance", true);
	String score=currentScore+"";	//����
	String actioncount=""+ActionCount;
	
	byte[] socrebyty=score.getBytes();
	rs.addRecord(socrebyty, 0, score.length());
}
 
开发者ID:cabbage89,项目名称:danceGame,代码行数:16,代码来源:MyCanvas.java

示例13: createStorageOutputStream

import javax.microedition.rms.RecordStore; //导入方法依赖的package包/类
/**
 * @inheritDoc
 */
public OutputStream createStorageOutputStream(String name) throws IOException {
    RecordStore r = null;
    RMSOutputStream os = null;
    DataOutputStream out = null;
    try {
        Short key = (Short)fat.get(name);
        if(key == null) {
            // need to add a key to the FAT
            key = new Short(currentKey);
            fat.put(name, key);
            r = RecordStore.openRecordStore("FAT", true);
            byte[] data = toRecord(name, currentKey);
            currentKey++;
            r.addRecord(data, 0, data.length);
            r.closeRecordStore();
            r = null;
        }
        os = new RMSOutputStream(key.shortValue());
        return os;
    } catch(Exception err) {
        cleanup(r);
        cleanup(os);
        cleanup(out);
        throw new IOException(err.getMessage());
    }
}
 
开发者ID:codenameone,项目名称:CodenameOne,代码行数:30,代码来源:GameCanvasImplementation.java

示例14: createStorageOutputStream

import javax.microedition.rms.RecordStore; //导入方法依赖的package包/类
/**
 * @inheritDoc
 */
public OutputStream createStorageOutputStream(String name) throws IOException {
    RecordStore r = null;
    RMSOutputStream os = null;
    DataOutputStream out = null;
    try {
        Short key = (Short) fat.get(name);
        if (key == null) {
            // need to add a key to the FAT
            key = new Short(currentKey);
            fat.put(name, key);
            r = RecordStore.openRecordStore("FAT", true);
            byte[] data = toRecord(name, currentKey);
            currentKey++;
            r.addRecord(data, 0, data.length);
            r.closeRecordStore();
            r = null;
        }
        os = new RMSOutputStream(key.shortValue());
        return os;
    } catch (Exception err) {
        cleanup(r);
        cleanup(os);
        cleanup(out);
        throw new IOException(err.getMessage());
    }
}
 
开发者ID:codenameone,项目名称:CodenameOne,代码行数:30,代码来源:BlackBerryImplementation.java

示例15: store

import javax.microedition.rms.RecordStore; //导入方法依赖的package包/类
private void store() {
	RecordStore recordStore = null;
	try {
		recordStore = RecordStore.openRecordStore(recordStoreName, true);
		StringBuffer buf = new StringBuffer();
		buf.append("[").append(textFiled.getString()).append("]");
		byte[] data = buf.toString().getBytes();
		int recordId;
		String message;
		if (recordStore.getNumRecords() > 0) {
			recordId = 1;
			System.out.println("setRecord " + recordId);
			recordStore.setRecord(recordId, data, 0, data.length);
			message = recordId + " updated"; 
		} else {
			recordId = recordStore.addRecord(data, 0, data.length);
			message = recordId + " created";
		}
		savedRecordId = recordId; 
		messageItem.setText(message);
	} catch (Throwable e) {
		System.out.println("error accessing RecordStore");
		e.printStackTrace();
		messageItem.setText(e.toString());
	} finally {
		closeQuietly(recordStore);
	}
}
 
开发者ID:freeVM,项目名称:freeVM,代码行数:29,代码来源:RecordStoreForm.java


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