📄 storageadapter.java
字号:
package eols.storage.base;
import java.util.List;
/**
* An adapter class which implements part of the functionalities
* of the storage interface, <code>IStorage</code>.
*
* <p>
* It is mainly used to provide a default implementation of some
* methods declared in the interface, like <code>java.awt.event.MouseAdapter<code>.
* </p>
*
* <p>
* In this default implementation, whether the operation on a
* specific record is successful is not checked.
* </p>
*
* @author Fasheng Qiu
* @since 11/01/2007
* @see {@link eols.storage.base.IStorage}
*/
public abstract class StorageAdapter implements IStorage {
/* The directory where the data file locates */
public static String dataPath = "";
/**
* Add a list of new records into the external storage file.
* NOTE that, in the default implementation, whether the operation
* on a specific record is successful is not checked.
*
* @param records The records to add into the external storage
* @return Whether the operation is successful. True will be returned
* if the record list is empty or null.
*/
public boolean addRecords(List records){
if (records == null || records.isEmpty())
return true;
for (int i = 0; i < records.size(); i++) {
if (records.get(i) == null)
continue;
addRecord(records.get(i));
}
return true;
}
/**
* Update a list of records in the external storage file.
* NOTE that, in the default implementation, whether the operation
* on a specific record is successful is not checked.
*
* <p>
* If either the indicator list or the record list is null or
* empty, true will be returned.
* <p>
* <p>
* If the size of the two lists is not the same, false will be returned
* since the parameters are not prepared well
* </p>
*
* @param indicatorList The list of identifiers of the records
* to be updated.
* @param records The records to be updated.
* Each record has a corresponding indicator which
* is stored in the indicatorList.
* @return Whether the operation is successful
*/
public boolean updateRecords(List indicatorList, List records){
if (indicatorList == null || indicatorList.isEmpty())
return true;
if (records == null || records.isEmpty())
return true;
if (indicatorList.size() != records.size())
return false;
for (int i = 0; i < records.size(); i++) {
if (indicatorList.get(i) == null ||
records.get(i) == null)
continue;
updateRecord(indicatorList.get(i), records.get(i));
}
return true;
}
/**
* Delete a list of records in the external storage file.
* NOTE that, in the default implementation, whether the operation
* on a specific record is successful is not checked.
*
* @param indicatorList The list of identifiers of the records
* to be deleted.
* @return Whether the operation is successful
*/
public boolean deleteRecords(List indicatorList){
if (indicatorList == null || indicatorList.isEmpty())
return true;
for (int i = 0; i < indicatorList.size(); i++) {
if (indicatorList.get(i) == null)
continue;
deleteRecord(indicatorList.get(i));
}
return true;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -