本文整理汇总了Java中javax.microedition.rms.RecordEnumeration类的典型用法代码示例。如果您正苦于以下问题:Java RecordEnumeration类的具体用法?Java RecordEnumeration怎么用?Java RecordEnumeration使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
RecordEnumeration类属于javax.microedition.rms包,在下文中一共展示了RecordEnumeration类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: readbestscore
import javax.microedition.rms.RecordEnumeration; //导入依赖的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;
}
}
示例2: cleanup
import javax.microedition.rms.RecordEnumeration; //导入依赖的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();
}
}
示例3: cleanup
import javax.microedition.rms.RecordEnumeration; //导入依赖的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();
}
}
示例4: Config
import javax.microedition.rms.RecordEnumeration; //导入依赖的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());
}
}
示例5: initialize
import javax.microedition.rms.RecordEnumeration; //导入依赖的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;
}
示例6: getSizeAvailable
import javax.microedition.rms.RecordEnumeration; //导入依赖的package包/类
public int getSizeAvailable(RecordStoreImpl recordStoreImpl) {
int size = MAX_COOKIE_SIZE * MAX_SPLIT_COOKIES;
size -= recordStoreImpl.getHeaderSize();
try {
RecordEnumeration en = recordStoreImpl.enumerateRecords(null, null, false);
while (en.hasNextElement()) {
size -= en.nextRecord().length + recordStoreImpl.getRecordHeaderSize();
}
} catch (RecordStoreException ex) {
Logger.error(ex);
}
// TODO Auto-generated method stub
System.out.println("getSizeAvailable: " + size);
return size;
}
示例7: writeRecordStore
import javax.microedition.rms.RecordEnumeration; //导入依赖的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();
}
}
示例8: getTweets
import javax.microedition.rms.RecordEnumeration; //导入依赖的package包/类
public Tweet[] getTweets(TweetFilter filter) {
try {
RecordEnumeration enum = tweetStore.enumerateRecords(filter, new TweetComparator(), false);
Vector tweetList = new Vector();
while(enum.hasNextElement()) {
int id = enum.nextRecordId();
Tweet tw = new Tweet(tweetStore.getRecord(id));
tw.setStoreId(id);
tweetList.addElement(tw);
}
Tweet[] res = new Tweet[tweetList.size()];
tweetList.copyInto(res);
return res;
} catch (RecordStoreException e) {
e.printStackTrace();
return null;
}
}
示例9: getUsers
import javax.microedition.rms.RecordEnumeration; //导入依赖的package包/类
public User[] getUsers(UserFilter filter) {
try {
RecordEnumeration enum = userStore.enumerateRecords(filter, null, false);
Vector uList = new Vector();
while(enum.hasNextElement()) {
int id = enum.nextRecordId();
User u = new User(userStore.getRecord(id));
u.setStoreId(id);
uList.addElement(u);
}
User[] res = new User[uList.size()];
uList.copyInto(res);
return res;
} catch (RecordStoreException e) {
e.printStackTrace();
return null;
}
}
示例10: getAccounts
import javax.microedition.rms.RecordEnumeration; //导入依赖的package包/类
public Account[] getAccounts() {
try {
Vector accounts = new Vector();
RecordEnumeration enum = accountStore.enumerateRecords(null, null, false);
while(enum.hasNextElement()) {
int id = enum.nextRecordId();
Account acc = new Account(accountStore.getRecord(id));
acc.setStoreId(id);
accounts.addElement(acc);
}
Account[] arr = new Account[accounts.size()];
accounts.copyInto(arr);
return arr;
} catch (RecordStoreException e) {
e.printStackTrace();
return null;
}
}
示例11: testAddRecordDeleteRecord2
import javax.microedition.rms.RecordEnumeration; //导入依赖的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);
}
示例12: record
import javax.microedition.rms.RecordEnumeration; //导入依赖的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("�����¼�ɹ�...");
}
示例13: RMSInputStream
import javax.microedition.rms.RecordEnumeration; //导入依赖的package包/类
public RMSInputStream(short key) throws IOException {
this.key = key;
RecordStore r = null;
RecordEnumeration e = null;
char letter = 'A';
try {
ByteArrayOutputStream os = new ByteArrayOutputStream();
r = open("" + letter + key);
while(r != null) {
e = r.enumerateRecords(null, null, false);
while(e.hasNextElement()) {
byte[] data = e.nextRecord();
os.write(data);
}
e.destroy();
r.closeRecordStore();
letter++;
r = open("" + letter + key);
if(letter == 'Z') {
letter = 'a' - ((char)1);
}
}
os.close();
current = new ByteArrayInputStream(os.toByteArray());
} catch (RecordStoreException ex) {
//#ifndef RIM
ex.printStackTrace();
//#else
//# System.out.println("Exception in object store input stream constructor: " + ex);
//#endif
cleanup(r);
cleanup(e);
throw new IOException(ex.toString());
}
}
示例14: RMSInputStream
import javax.microedition.rms.RecordEnumeration; //导入依赖的package包/类
public RMSInputStream(short key) throws IOException {
this.key = key;
RecordStore r = null;
RecordEnumeration e = null;
char letter = 'A';
try {
ByteArrayOutputStream os = new ByteArrayOutputStream();
r = open("" + letter + key);
while (r != null) {
e = r.enumerateRecords(null, null, false);
while (e.hasNextElement()) {
byte[] data = e.nextRecord();
os.write(data);
}
e.destroy();
r.closeRecordStore();
letter++;
r = open("" + letter + key);
if (letter == 'Z') {
letter = 'a' - ((char) 1);
}
}
os.close();
current = new ByteArrayInputStream(os.toByteArray());
} catch (RecordStoreException ex) {
ex.printStackTrace();
cleanup(r);
cleanup(e);
throw new IOException(ex.toString());
}
}
示例15: readRecordStore
import javax.microedition.rms.RecordEnumeration; //导入依赖的package包/类
public final void readRecordStore() {
try {
RecordStore store;
RecordEnumeration rEnum = (store = RecordStore.openRecordStore("options", true)).enumerateRecords((RecordFilter) null, (RecordComparator) null, false);
ByteArrayInputStream bais = new ByteArrayInputStream(rEnum.nextRecord());
DataInputStream dis = new DataInputStream(bais);
this.field_30 = dis.readBoolean();
this.field_31 = dis.readBoolean();
this.field_9 = dis.readInt();
this.field_10 = dis.readInt();
store.closeRecordStore();
} catch (Exception e) {
e.printStackTrace();
}
}