KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > db4o > test > legacy > soda > experiments > STCurrent


1 /* Copyright (C) 2004 - 2006 db4objects Inc. http://www.db4o.com
2
3 This file is part of the db4o open source object database.
4
5 db4o is free software; you can redistribute it and/or modify it under
6 the terms of version 2 of the GNU General Public License as published
7 by the Free Software Foundation and as clarified by db4objects' GPL
8 interpretation policy, available at
9 http://www.db4o.com/about/company/legalpolicies/gplinterpretation/
10 Alternatively you can write to db4objects, Inc., 1900 S Norfolk Street,
11 Suite 350, San Mateo, CA 94403, USA.
12
13 db4o is distributed in the hope that it will be useful, but WITHOUT ANY
14 WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 for more details.
17
18 You should have received a copy of the GNU General Public License along
19 with this program; if not, write to the Free Software Foundation, Inc.,
20 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */

21 package com.db4o.test.legacy.soda.experiments;
22
23 import java.util.*;
24
25 import com.db4o.query.*;
26 import com.db4o.test.legacy.soda.*;
27 import com.db4o.test.legacy.soda.collections.*;
28
29
30 public class STCurrent implements STClass {
31
32     public static transient SodaTest st;
33     
34     SodaTest pm;
35
36     String JavaDoc mystr;
37
38     public STCurrent() {
39     }
40
41     public STCurrent(String JavaDoc str) {
42         this.mystr = str;
43     }
44
45     public String JavaDoc toString() {
46         return "STCurrent: " + mystr;
47     }
48
49     public Object JavaDoc[] store() {
50         return new Object JavaDoc[] {
51             new STVectorEU(new Object JavaDoc[] { new Integer JavaDoc(17)}),
52             new STVectorEU(
53                 new Object JavaDoc[] {
54                     new Integer JavaDoc(3),
55                     new Integer JavaDoc(17),
56                     new Integer JavaDoc(25),
57                     new Integer JavaDoc(Integer.MAX_VALUE - 2)}),
58             new STVectorT(new Object JavaDoc[] { new Integer JavaDoc(17)}),
59             new STVectorU(
60                 new Object JavaDoc[] {
61                     new Integer JavaDoc(3),
62                     new Integer JavaDoc(17),
63                     new Integer JavaDoc(25),
64                     new Integer JavaDoc(Integer.MAX_VALUE - 2)}),
65             };
66     }
67
68     public void testDescendOne() {
69         Query q = st.query();
70         Object JavaDoc[] r = store();
71         q.constrain(STVectorEU.class);
72         q.descend("col").constrain(new Integer JavaDoc(17));
73         st.expect(q, new Object JavaDoc[] { r[0] });
74     }
75
76     // public void testIdentity(){
77
// Query q = SodaTest.query();
78
// Constraint c = q.constrain(new STCurrent("hi"));
79
// ObjectSet set = q.execute();
80
// STCurrent identityConstraint = (STCurrent)set.next();
81
// identityConstraint.mystr = "jdjdjd";
82
// q = SodaTest.query();
83
// q.constrain(identityConstraint).identity();
84
// identityConstraint.mystr = "hi";
85
// SodaTest.expectOne(q,new STCurrent("hi"));
86
// }
87

88     // public void all_Depts_that_have_no_emp(){
89
// Query q = pm.query();
90
// q.constrain(Department.class);
91
// Query qEmps = q.descendant("emps");
92
// qEmps.constrain(null).or(
93
// qEmps.constrain(new Integer(0)).length()
94
// );
95
// ObjectSet noEmps = q.execute();
96
// }
97
//
98
// public void all_Depts_that_have_exaclty_one_emp(){
99
// Query q = pm.query();
100
// q.constrain(Department.class);
101
// Query qEmps = q.descendant("emps");
102
// qEmps.constrain(new Integer(1)).length();
103
// ObjectSet oneEmp = q.execute();
104
// }
105
//
106
// public void tiger_teams(){
107
// Query q = pm.query();
108
// q.constrain(Department.class);
109
// Query qEmps = q.descendant("emps");
110
// qEmps.constrain(new Integer(2)).length().greater();
111
// qEmps.constrain(new Integer(5)).length().smaller();
112
// qEmps.descendant("salary").constrain(new Float(50000)).greater();
113
// ObjectSet tigerTeams = q.execute();
114
// }
115

116 }
117
118 class Employee {
119     String JavaDoc name;
120     Float JavaDoc salary;
121     Department dept;
122     Employee boss;
123 }
124
125 class Department {
126     String JavaDoc name;
127     Collection emps;
128     Department() {
129     }
130     Department(String JavaDoc name) {
131     }
132 }
133
Popular Tags