1 21 package com.db4o.test; 22 23 import java.io.*; 24 25 import com.db4o.*; 26 import com.db4o.query.*; 27 28 31 public class ParameterizedEvaluation implements Serializable { 32 33 public String str; 34 35 public void store(){ 36 Test.deleteAllInstances(this); 37 store("one"); 38 store("fun"); 39 store("ton"); 40 store("sun"); 41 } 42 43 private void store(String str){ 44 ParameterizedEvaluation pe = new ParameterizedEvaluation(); 45 pe.str = str; 46 Test.store(pe); 47 } 48 49 public void test(){ 50 Test.ensure(queryContains("un").size() == 2); 51 } 52 53 private ObjectSet queryContains(final String str){ 54 Query q = Test.query(); 55 q.constrain(ParameterizedEvaluation.class); 56 q.constrain(new Evaluation() { 57 public void evaluate(Candidate candidate) { 58 ParameterizedEvaluation pe = (ParameterizedEvaluation)candidate.getObject(); 59 boolean inc = pe.str.indexOf(str) != -1; 60 candidate.include(inc); 61 } 62 }); 63 64 return q.execute(); 65 } 66 67 } 68 | Popular Tags |