📄 mofiremgr.java
字号:
// Decompiled by Jad v1.5.8e2. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://kpdus.tripod.com/jad.html
// Decompiler options: packimports(3) fieldsfirst ansi space
// Source File Name: MoFireMgr.java
package com.modofo.mofire;
import java.io.PrintStream;
import java.util.Vector;
import javax.microedition.rms.*;
// Referenced classes of package com.modofo.mofire:
// Post, Storable, Setting
public class MoFireMgr
implements RecordFilter, RecordComparator
{
private RecordStore store;
private String filter;
private String STORE_POST;
private String STORE_SETTING;
public MoFireMgr()
{
STORE_POST = "moFire-post";
STORE_SETTING = "moFire-setting";
}
public int savePost(Post p)
throws RecordStoreNotOpenException, RecordStoreFullException, RecordStoreException
{
return save(p, STORE_POST);
}
public void delPost(int id)
throws RecordStoreFullException, RecordStoreNotFoundException, RecordStoreException
{
delete(id, STORE_POST);
}
public Post getPost(int id)
throws RecordStoreFullException, RecordStoreNotFoundException, RecordStoreException
{
store = RecordStore.openRecordStore(STORE_POST, true);
byte bt[] = store.getRecord(id);
Post p = null;
if (bt != null)
{
p = new Post();
p.fromByteArray(bt);
}
store.closeRecordStore();
return p;
}
public Vector getPosts(final String filter)
throws RecordStoreFullException, RecordStoreNotFoundException, RecordStoreException
{
store = RecordStore.openRecordStore(STORE_POST, true);
RecordEnumeration enu = store.enumerateRecords(new RecordFilter() {
public boolean matches(byte arg0[])
{
if (filter == null)
return true;
if (arg0 == null)
return false;
Post tmp = new Post();
tmp.fromByteArray(arg0);
if (tmp.getTitle().indexOf(filter) != -1)
return true;
return tmp.getContent().indexOf(filter) != -1;
}
}, null, true);
Post temp = null;
Vector result = new Vector();
for (; enu.hasNextElement(); result.addElement(temp))
{
temp = new Post();
temp.fromByteArray(enu.nextRecord());
}
store.closeRecordStore();
return result;
}
public int saveSetting(Setting p)
throws RecordStoreFullException, RecordStoreNotFoundException, RecordStoreException
{
return save(p, STORE_SETTING);
}
private Storable get(int id, String storename, Storable s)
throws RecordStoreFullException, RecordStoreNotFoundException, RecordStoreException
{
store = RecordStore.openRecordStore(STORE_POST, true);
byte bt[] = store.getRecord(id);
Storable ss = s;
if (bt != null)
ss.fromByteArray(bt);
store.closeRecordStore();
return ss;
}
private void delete(int id, String storename)
throws RecordStoreFullException, RecordStoreNotFoundException, RecordStoreException
{
store = RecordStore.openRecordStore(storename, true);
store.deleteRecord(id);
store.closeRecordStore();
}
private int save(Storable s, String storename)
throws RecordStoreFullException, RecordStoreNotFoundException, RecordStoreException
{
System.out.println("saving:" + s.getId() + " in store " + storename);
store = RecordStore.openRecordStore(storename, true);
int id = s.getId();
if (id == 0)
{
id = store.addRecord(s.toByteArray(), 0, s.toByteArray().length);
s.setId(id);
store.setRecord(s.getId(), s.toByteArray(), 0, s.toByteArray().length);
} else
{
store.setRecord(s.getId(), s.toByteArray(), 0, s.toByteArray().length);
}
store.closeRecordStore();
return id;
}
public void delSetting(int id)
throws RecordStoreFullException, RecordStoreNotFoundException, RecordStoreException
{
delete(id, STORE_SETTING);
}
public Setting getSetting(int id)
throws RecordStoreFullException, RecordStoreNotFoundException, RecordStoreException
{
return (Setting)get(id, STORE_SETTING, new Setting());
}
public Vector getSettings(final String filter)
throws RecordStoreFullException, RecordStoreNotFoundException, RecordStoreException
{
store = RecordStore.openRecordStore(STORE_SETTING, true);
RecordEnumeration enu = store.enumerateRecords(new RecordFilter() {
public boolean matches(byte arg0[])
{
if (filter == null)
return true;
if (arg0 == null)
return false;
Setting tmp = new Setting();
tmp.fromByteArray(arg0);
return tmp.getName().indexOf(filter) != -1;
}
}, null, true);
Setting temp = null;
Vector result = new Vector();
for (; enu.hasNextElement(); result.addElement(temp))
{
temp = new Setting();
temp.fromByteArray(enu.nextRecord());
}
store.closeRecordStore();
return result;
}
public boolean matches(byte arg0[])
{
return false;
}
public int compare(byte arg0[], byte arg1[])
{
return 0;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -