本文整理汇总了Java中javax.microedition.rms.RecordStoreNotOpenException类的典型用法代码示例。如果您正苦于以下问题:Java RecordStoreNotOpenException类的具体用法?Java RecordStoreNotOpenException怎么用?Java RecordStoreNotOpenException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
RecordStoreNotOpenException类属于javax.microedition.rms包,在下文中一共展示了RecordStoreNotOpenException类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: getTotalSize
import javax.microedition.rms.RecordStoreNotOpenException; //导入依赖的package包/类
/**
* Return total size used by this StorageUtility, including all underlying RMSes
*
* @return total size (bytes)
*/
public int getTotalSize () {
int size = 0;
synchronized (getAccessLock()) {
checkNotCorrupt();
RMSStorageInfo info = getInfoRecord();
try {
size += index.getIndexStoreSize();
for (int i = 0; i < info.numDataStores; i++) {
size += getDataStore(i).rms.getSize();
}
} catch (RecordStoreNotOpenException e) {
throw new RuntimeException("can't happen");
}
}
return size;
}
开发者ID:dimagi,项目名称:commcare-j2me,代码行数:27,代码来源:RMSStorageUtility.java
示例2: closeRecordStore
import javax.microedition.rms.RecordStoreNotOpenException; //导入依赖的package包/类
public void closeRecordStore()
throws RecordStoreNotOpenException, RecordStoreException
{
if (!open) {
throw new RecordStoreNotOpenException();
}
if (recordListeners != null) {
recordListeners.removeAllElements();
}
recordStoreManager.fireRecordStoreListener(ExtendedRecordListener.RECORDSTORE_CLOSE, this.getName());
records.clear();
open = false;
}
开发者ID:BombusMod,项目名称:BombusMod,代码行数:17,代码来源:RecordStoreImpl.java
示例3: deleteRecord
import javax.microedition.rms.RecordStoreNotOpenException; //导入依赖的package包/类
public void deleteRecord(int recordId)
throws RecordStoreNotOpenException, InvalidRecordIDException, RecordStoreException
{
if (!open) {
throw new RecordStoreNotOpenException();
}
synchronized (this) {
// throws InvalidRecordIDException when no record found
getRecord(recordId);
records.remove(new Integer(recordId));
version++;
lastModified = System.currentTimeMillis();
size--;
}
recordStoreManager.deleteRecord(this, recordId);
fireRecordListener(ExtendedRecordListener.RECORD_DELETE, recordId);
}
开发者ID:BombusMod,项目名称:BombusMod,代码行数:21,代码来源:RecordStoreImpl.java
示例4: getRecordSize
import javax.microedition.rms.RecordStoreNotOpenException; //导入依赖的package包/类
public int getRecordSize(int recordId)
throws RecordStoreNotOpenException, InvalidRecordIDException, RecordStoreException
{
if (!open) {
throw new RecordStoreNotOpenException();
}
synchronized (this) {
byte[] data = (byte[]) records.get(new Integer(recordId));
if (data == null) {
recordStoreManager.loadRecord(this, recordId);
data = (byte[]) records.get(new Integer(recordId));
if (data == null) {
throw new InvalidRecordIDException();
}
}
return data.length;
}
}
开发者ID:BombusMod,项目名称:BombusMod,代码行数:21,代码来源:RecordStoreImpl.java
示例5: getRecord
import javax.microedition.rms.RecordStoreNotOpenException; //导入依赖的package包/类
public byte[] getRecord(int recordId)
throws RecordStoreNotOpenException, InvalidRecordIDException, RecordStoreException
{
if (!open) {
throw new RecordStoreNotOpenException();
}
byte[] data;
synchronized (this) {
data = new byte[getRecordSize(recordId)];
getRecord(recordId, data, 0);
}
return data.length < 1 ? null : data;
}
开发者ID:BombusMod,项目名称:BombusMod,代码行数:17,代码来源:RecordStoreImpl.java
示例6: nextRecord
import javax.microedition.rms.RecordStoreNotOpenException; //导入依赖的package包/类
public byte[] nextRecord()
throws InvalidRecordIDException, RecordStoreNotOpenException, RecordStoreException
{
if (!recordStoreImpl.isOpen()) {
throw new RecordStoreNotOpenException();
}
if (currentRecord >= numRecords()) {
throw new InvalidRecordIDException();
}
byte[] result = ((EnumerationRecord) enumerationRecords.elementAt(currentRecord)).value;
currentRecord++;
return result;
}
开发者ID:BombusMod,项目名称:BombusMod,代码行数:17,代码来源:RecordEnumerationImpl.java
示例7: ensureOpen
import javax.microedition.rms.RecordStoreNotOpenException; //导入依赖的package包/类
/**
* Check that the record store is open, and reopen it if not. (It may have
* been closed by other threads or StorageUtilitys)
*/
public void ensureOpen() {
try {
rms.getName(); // presumably the simplest operation that will
// trigger a 'not open' exception
} catch (RecordStoreNotOpenException e) {
try {
rms = RecordStore.openRecordStore(name, false);
} catch (RecordStoreException e1) {
throw new RuntimeException("error");
}
}
}
开发者ID:dimagi,项目名称:commcare-j2me,代码行数:17,代码来源:RMS.java
示例8: getRMSSize
import javax.microedition.rms.RecordStoreNotOpenException; //导入依赖的package包/类
private int getRMSSize (RecordStore rms) {
int n = -1;
try {
n = rms.getSize();
} catch (RecordStoreNotOpenException e) {
fail("getRMSSize", e);
}
return n;
}
开发者ID:dimagi,项目名称:commcare-j2me,代码行数:10,代码来源:RMSTestMidlet.java
示例9: getRMSAvailSpace
import javax.microedition.rms.RecordStoreNotOpenException; //导入依赖的package包/类
private int getRMSAvailSpace (RecordStore rms) {
int n = -1;
try {
n = rms.getSizeAvailable();
} catch (RecordStoreNotOpenException e) {
fail("getRMSAvailSpace", e);
}
return n;
}
开发者ID:dimagi,项目名称:commcare-j2me,代码行数:10,代码来源:RMSTestMidlet.java
示例10: hasAnyRecord
import javax.microedition.rms.RecordStoreNotOpenException; //导入依赖的package包/类
public boolean hasAnyRecord() {
try {
return recordStore.getNumRecords() != 0;
} catch (RecordStoreNotOpenException ex) {
//#debug debug
ex.printStackTrace();
throw new ComcraftException("Exception while checking if record store has any records! Record strore isn't opened.", ex);
}
}
开发者ID:queader,项目名称:Comcraft,代码行数:10,代码来源:RMS.java
示例11: saveChanges
import javax.microedition.rms.RecordStoreNotOpenException; //导入依赖的package包/类
public void saveChanges(RecordStoreImpl recordStoreImpl) throws RecordStoreNotOpenException {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
DataOutputStream dos = new DataOutputStream(baos);
try {
recordStoreImpl.write(dos);
CookieContent cookieContent = new CookieContent(Base64Coder.encode(baos.toByteArray()));
CookieContent previousCookie = (CookieContent) cookies.get(recordStoreImpl.getName());
if (previousCookie != null) {
removeCookie(recordStoreImpl.getName(), previousCookie);
}
cookies.put(recordStoreImpl.getName(), cookieContent);
String[] parts = cookieContent.getParts();
if (parts.length == 1) {
document.setMember("cookie", "x" + recordStoreImpl.getName() + "=a" + parts[0] + expires);
} else {
for (int i = 0; i < parts.length; i++) {
document.setMember("cookie", i + recordStoreImpl.getName() + "=a" + parts[i] + expires);
}
}
System.out.println("saveChanges: " + recordStoreImpl.getName() + " (" + cookieContent.getParts().length
+ ")");
} catch (IOException ex) {
Logger.error(ex);
}
}
开发者ID:freeVM,项目名称:freeVM,代码行数:30,代码来源:CookieRecordStoreManager.java
示例12: getName
import javax.microedition.rms.RecordStoreNotOpenException; //导入依赖的package包/类
public String getName()
throws RecordStoreNotOpenException
{
if (!open) {
throw new RecordStoreNotOpenException();
}
return recordStoreName;
}
开发者ID:BombusMod,项目名称:BombusMod,代码行数:10,代码来源:RecordStoreImpl.java
示例13: getVersion
import javax.microedition.rms.RecordStoreNotOpenException; //导入依赖的package包/类
public int getVersion()
throws RecordStoreNotOpenException
{
if (!open) {
throw new RecordStoreNotOpenException();
}
synchronized (this) {
return version;
}
}
开发者ID:BombusMod,项目名称:BombusMod,代码行数:12,代码来源:RecordStoreImpl.java
示例14: getNumRecords
import javax.microedition.rms.RecordStoreNotOpenException; //导入依赖的package包/类
public int getNumRecords()
throws RecordStoreNotOpenException
{
if (!open) {
throw new RecordStoreNotOpenException();
}
return size;
}
开发者ID:BombusMod,项目名称:BombusMod,代码行数:10,代码来源:RecordStoreImpl.java
示例15: getSize
import javax.microedition.rms.RecordStoreNotOpenException; //导入依赖的package包/类
public int getSize()
throws RecordStoreNotOpenException
{
if (!open) {
throw new RecordStoreNotOpenException();
}
// TODO include size overhead such as the data structures used to hold the state of the record store
// Preload all records
enumerateRecords(null, null, false);
int result = 0;
Enumeration keys = records.keys();
while (keys.hasMoreElements()) {
int key = ((Integer) keys.nextElement()).intValue();
try {
byte[] data = getRecord(key);
if (data != null) {
result += data.length;
}
} catch (RecordStoreException e) {
e.printStackTrace();
}
}
return result;
}
开发者ID:BombusMod,项目名称:BombusMod,代码行数:28,代码来源:RecordStoreImpl.java
示例16: getSizeAvailable
import javax.microedition.rms.RecordStoreNotOpenException; //导入依赖的package包/类
public int getSizeAvailable()
throws RecordStoreNotOpenException
{
if (!open) {
throw new RecordStoreNotOpenException();
}
return recordStoreManager.getSizeAvailable(this);
}
开发者ID:BombusMod,项目名称:BombusMod,代码行数:10,代码来源:RecordStoreImpl.java
示例17: getLastModified
import javax.microedition.rms.RecordStoreNotOpenException; //导入依赖的package包/类
public long getLastModified()
throws RecordStoreNotOpenException
{
if (!open) {
throw new RecordStoreNotOpenException();
}
synchronized (this) {
return lastModified;
}
}
开发者ID:BombusMod,项目名称:BombusMod,代码行数:12,代码来源:RecordStoreImpl.java
示例18: getNextRecordID
import javax.microedition.rms.RecordStoreNotOpenException; //导入依赖的package包/类
public int getNextRecordID()
throws RecordStoreNotOpenException, RecordStoreException
{
if (!open) {
throw new RecordStoreNotOpenException();
}
// lastRecordId needs to hold correct number, all records have to be preloaded
enumerateRecords(null, null, false);
synchronized (this) {
return lastRecordId + 1;
}
}
开发者ID:BombusMod,项目名称:BombusMod,代码行数:15,代码来源:RecordStoreImpl.java
示例19: addRecord
import javax.microedition.rms.RecordStoreNotOpenException; //导入依赖的package包/类
public int addRecord(byte[] data, int offset, int numBytes)
throws RecordStoreNotOpenException, RecordStoreException, RecordStoreFullException
{
if (!open) {
throw new RecordStoreNotOpenException();
}
if (data == null && numBytes > 0) {
throw new NullPointerException();
}
if (numBytes > recordStoreManager.getSizeAvailable(this)) {
throw new RecordStoreFullException();
}
// lastRecordId needs to hold correct number, all records have to be preloaded
enumerateRecords(null, null, false);
byte[] recordData = new byte[numBytes];
if (data != null) {
System.arraycopy(data, offset, recordData, 0, numBytes);
}
int nextRecordID = getNextRecordID();
synchronized (this) {
records.put(new Integer(nextRecordID), recordData);
version++;
lastModified = System.currentTimeMillis();
lastRecordId++;
size++;
}
recordStoreManager.saveRecord(this, nextRecordID);
fireRecordListener(ExtendedRecordListener.RECORD_ADD, nextRecordID);
return nextRecordID;
}
开发者ID:BombusMod,项目名称:BombusMod,代码行数:37,代码来源:RecordStoreImpl.java
示例20: setRecord
import javax.microedition.rms.RecordStoreNotOpenException; //导入依赖的package包/类
public void setRecord(int recordId, byte[] newData, int offset, int numBytes)
throws RecordStoreNotOpenException, InvalidRecordIDException, RecordStoreException, RecordStoreFullException
{
if (!open) {
throw new RecordStoreNotOpenException();
}
// FIXME fixit
if (numBytes > recordStoreManager.getSizeAvailable(this)) {
throw new RecordStoreFullException();
}
byte[] recordData = new byte[numBytes];
System.arraycopy(newData, offset, recordData, 0, numBytes);
synchronized (this) {
// throws InvalidRecordIDException when no record found
getRecord(recordId);
records.put(new Integer(recordId), recordData);
version++;
lastModified = System.currentTimeMillis();
}
recordStoreManager.saveRecord(this, recordId);
fireRecordListener(ExtendedRecordListener.RECORD_CHANGE, recordId);
}
开发者ID:BombusMod,项目名称:BombusMod,代码行数:28,代码来源:RecordStoreImpl.java
注:本文中的javax.microedition.rms.RecordStoreNotOpenException类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论