本文整理汇总了Java中com.db4o.query.Predicate类的典型用法代码示例。如果您正苦于以下问题:Java Predicate类的具体用法?Java Predicate怎么用?Java Predicate使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Predicate类属于com.db4o.query包,在下文中一共展示了Predicate类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: checkRegIdUsed
import com.db4o.query.Predicate; //导入依赖的package包/类
public static boolean checkRegIdUsed(final String idGenerated) {
//openDb4o();
List<RegisterContextRequest> results;
//final String updateRegId = rcrNew.getRegistrationId();
results = db.query(new Predicate<RegisterContextRequest>() {
public boolean match(RegisterContextRequest req) {
String storedRegID = req.getRegistrationId();
if (storedRegID.equals(idGenerated)) {
return true;
}
return false;
}
});
if (results.size() > 0) {
// closeDb4o();
return true;
}
//closeDb4o();
return false;
}
示例2: deleteRegistration
import com.db4o.query.Predicate; //导入依赖的package包/类
public static boolean deleteRegistration(final RegisterContextRequest rcrNew) {
List<RegisterContextRequest> results;
final String updateRegId = rcrNew.getRegistrationId();
results = db.query(new Predicate<RegisterContextRequest>() {
public boolean match(RegisterContextRequest req) {
String storedRegID = req.getRegistrationId();
if (storedRegID.equals(updateRegId)) {
return true;
}
return false;
}
});
if (results.size() > 0) {
RegisterContextRequest found = results.get(0);
System.out.println("Deleting registration");
db.delete(found);
db.commit();
return true;
}
return false;
}
示例3: deleteSubscription
import com.db4o.query.Predicate; //导入依赖的package包/类
public static boolean deleteSubscription(final String subsID) {
List<SubscribeContextAvailabilityRequest> results;
//final String updateSubId = rcrNew.getSubscriptionId();
results = db.query(new Predicate<SubscribeContextAvailabilityRequest>() {
public boolean match(SubscribeContextAvailabilityRequest req) {
String storedRegID = req.getSubscriptionId();
return storedRegID.equals(subsID);
}
});
if (results.size() > 0) {
SubscribeContextAvailabilityRequest found = results.get(0);
System.out.println("Deleting SubscribeContextAvailabilityRequest");
//found.getReference();
db.delete(found);
db.commit();
return true;
}
return false;
}
示例4: checkSubIdUsed
import com.db4o.query.Predicate; //导入依赖的package包/类
public static boolean checkSubIdUsed(final String idGenerated) {
//openDb4o();
List<SubscribeContextAvailabilityRequest> results;
//final String updateRegId = rcrNew.getRegistrationId();
results = db.query(new Predicate<SubscribeContextAvailabilityRequest>() {
public boolean match(SubscribeContextAvailabilityRequest req) {
String storedRegID = req.getSubscriptionId();
if (storedRegID.equals(idGenerated)) {
return true;
}
return false;
}
});
if (results.size() > 0) {
// closeDb4o();
return true;
}
//closeDb4o();
return false;
}
示例5: deleteExpiredRegistrations
import com.db4o.query.Predicate; //导入依赖的package包/类
public boolean deleteExpiredRegistrations() {
List<RegisterContextRequest> results;
results = RegisterStoreAccess.db.query(new Predicate<RegisterContextRequest>() {
@Override
public boolean match(RegisterContextRequest req) {
Instant timestamp = req.getTimestamp();
Duration duration = Duration.parse(req.getDuration());
Instant expiry = timestamp.plus(duration);
Instant now = Instant.now();
boolean expired = now.isAfter(expiry);
//if timestamp + duration isAfter time now
return expired;
}
});
if (results.size() > 0) {
for (RegisterContextRequest found : results) {
System.out.println("Deleting expired registration");
RegisterStoreAccess.db.delete(found);
RegisterStoreAccess.db.commit();
}
return true;
}
return false;
}
示例6: deleteExpiredSubscriptions
import com.db4o.query.Predicate; //导入依赖的package包/类
public boolean deleteExpiredSubscriptions() {
List<SubscribeContextAvailabilityRequest> results;
results = SubscriptionStoreAccess.db.query(new Predicate<SubscribeContextAvailabilityRequest>() {
@Override
public boolean match(SubscribeContextAvailabilityRequest req) {
Instant timestamp = req.getTimestamp();
Duration duration = Duration.parse(req.getDuration());
Instant expiry = timestamp.plus(duration);
Instant now = Instant.now();
boolean expired = now.isAfter(expiry);
//if timestamp + duration isAfter time now
return expired;
}
});
if (results.size() > 0) {
for (SubscribeContextAvailabilityRequest found : results) {
System.out.println("Deleting expired registration");
SubscriptionStoreAccess.db.delete(found);
SubscriptionStoreAccess.db.commit();
}
return true;
}
return false;
}
示例7: getRegByEntityType
import com.db4o.query.Predicate; //导入依赖的package包/类
static public List<RegisterContextRequest> getRegByEntityType(
final String entityType) {
System.out.println("get by type: "+ entityType);
List<RegisterContextRequest> results;
results = db.query(new Predicate<RegisterContextRequest>() {
public boolean match(RegisterContextRequest req) {
final int contRegListSize = req
.getContextRegistration().size();
// System.out.println("contRegListSize: " + contRegListSize);
for (int i = 0; i < contRegListSize; i++) {
final int entityIdListSize = req
.getContextRegistration().get(i)
.getEntityId().size();
// System.out.println("entityidListSize: " + entityIdListSize);
for (int j = 0; j < entityIdListSize; j++) {
String storedEType = req
.getContextRegistration().get(i)
.getEntityId().get(j)
.getType();
//return storedEType.equals(entityType);
if (storedEType.equals(entityType)) {
return true;
}
}
}//contRegList loop
return false;
}
});
System.out.println("size of \"type\" result:" + results.size());
return results;
}
示例8: updateSubscription
import com.db4o.query.Predicate; //导入依赖的package包/类
public static boolean updateSubscription(final UpdateContextAvailabilitySubscriptionRequest updSubReq) {
List<SubscribeContextAvailabilityRequest> results;
//final String updateSubId = rcrNew.getSubscriptionId();
results = db.query(new Predicate<SubscribeContextAvailabilityRequest>() {
public boolean match(SubscribeContextAvailabilityRequest req) {
String storedRegID = req.getSubscriptionId();
return storedRegID.equals(updSubReq.getSubscriptionId());
}
});
if (results.size() > 0) {
SubscribeContextAvailabilityRequest subReqFound = results.get(0);
System.out.println("Updating SubscribeContextAvailabilityRequest");
subReqFound.getEntityId().clear();
subReqFound.getEntityId().addAll(updSubReq.getEntityId());
subReqFound.getAttribute().clear();
subReqFound.getAttribute().addAll(updSubReq.getAttribute());
subReqFound.setRestriction(updSubReq.getRestriction());
subReqFound.setDuration(updSubReq.getDuration());
try {
db.store(subReqFound);
db.commit();
} finally {
System.out.println("Stored SubscribeContextAvailabilityRequest: " + subReqFound.getSubscriptionId());
}
return true;
}
return false;
}
示例9: getKeys
import com.db4o.query.Predicate; //导入依赖的package包/类
@Override
public Collection<Integer> getKeys() throws StorageOperationException {
ObjectContainer db = Db4oEmbedded.openFile(getConfiguration(), source);
final Collection<Integer> result = new ArrayList<Integer>();
try {
db.query(new Predicate<V>() {
@Override
public boolean match(V v) {
result.add(v.hashCode());
return false;
}
});
} finally {
db.close();
}
return result;
}
示例10: getAll
import com.db4o.query.Predicate; //导入依赖的package包/类
@Override
public List<V> getAll(final K... keys) throws StorageOperationException {
ObjectContainer db = Db4oEmbedded.openFile(getConfiguration(), source);
List<V> result = null;
try {
result = db.query(new Predicate<V>() {
@Override
public boolean match(V v) {
for (K key : keys) {
if (key.match(v))
return true;
}
return false;
}
});
} finally {
db.close();
}
if (result == null)
return createList();
else
return result;
}
示例11: put
import com.db4o.query.Predicate; //导入依赖的package包/类
@Override
public void put(final K key, V value) throws StorageOperationException {
ObjectContainer db = Db4oEmbedded.openFile(getConfiguration(), source);
ObjectSet<V> set = db.query(new Predicate<V>() {
@Override
public boolean match(V v) {
if (key.match(v))
return true;
else
return false;
}
});
db.delete(set);
db.store(value);
db.close();
}
示例12: read
import com.db4o.query.Predicate; //导入依赖的package包/类
public ITransazione read(final Integer id)
{
ObjectContainer client = DbManagerSingleton.getInstance().getClient();
List<TransazioneSmartProxy> result = client.query(new Predicate<TransazioneSmartProxy>() {
@Override
public boolean match(TransazioneSmartProxy candidate) {
Integer idTrans;
try {
idTrans = candidate.getId();
}
catch (RemoteException ex) {
return false;
}
if(idTrans.intValue() == id.intValue())
return true;
else
return false;
}
});
if(result.isEmpty())
return null;
ITransazione trans = result.get(0);
return trans;
}
示例13: read
import com.db4o.query.Predicate; //导入依赖的package包/类
public IDescrizioneProdotto read(final IDProdotto code) {
ObjectContainer client = DbManagerSingleton.getInstance().getClient();
List<DescrizioneProdottoSmartProxy> result = client.query(new Predicate<DescrizioneProdottoSmartProxy>() {
@Override
public boolean match(DescrizioneProdottoSmartProxy candidate) {
IDProdotto codice;
try {
codice = candidate.getCodiceProdotto();
}
catch (RemoteException ex) {
return false;
}
if(codice.getCodice().equals(code.getCodice()))
return true;
else
return false;
}
});
if(result.isEmpty())
return null;
IDescrizioneProdotto desc = result.get(0);
client.ext().refresh(desc, 10);
return desc;
}
示例14: readBelowThreshold
import com.db4o.query.Predicate; //导入依赖的package包/类
/**
* Restituisce gli oggetti DescrizioneProdotto che si trovano al di sotto della soglia stabilita
* @return Lista delle descrizioni sotto soglia
*/
public LinkedList<IDescrizioneProdotto> readBelowThreshold(){
ObjectContainer client = DbManagerSingleton.getInstance().getClient();
ObjectSet<IDescrizioneProdotto> result = client.query(new Predicate<IDescrizioneProdotto>() {
@Override
public boolean match(IDescrizioneProdotto candidate) {
if(candidate.getClass() != DescrizioneProdottoSmartProxy.class)
return false;
else
return candidate.sottoSoglia();
}
});
if(result.isEmpty())
return new ActivatableLinkedList<>();
else{
LinkedList<IDescrizioneProdotto> list = new ActivatableLinkedList<>(result);
return list;
}
}
示例15: read
import com.db4o.query.Predicate; //导入依赖的package包/类
public IPrenotazione read(final Integer id)
{
ObjectContainer client = DbManagerSingleton.getInstance().getClient();
ObjectSet<PrenotazioneSmartProxy> result = client.query(new Predicate<PrenotazioneSmartProxy>() {
@Override
public boolean match(PrenotazioneSmartProxy candidate) {
Integer idTrans;
try {
idTrans = candidate.getId();
}
catch (RemoteException ex) {
return false;
}
if(idTrans.intValue() == id.intValue())
return true;
else
return false;
}
});
if(result.isEmpty())
return null;
return (IPrenotazione) result.get(0);
}