KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > db4o > test > legacy > soda > arrays > object > STArrIntegerON


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.arrays.object;
22
23 import com.db4o.query.*;
24 import com.db4o.test.legacy.soda.*;
25
26 public class STArrIntegerON implements STClass{
27     
28     public static transient SodaTest st;
29     
30     Object JavaDoc intArr;
31     
32     public STArrIntegerON(){
33     }
34     
35     public STArrIntegerON(int[][][] arr){
36         intArr = arr;
37     }
38     
39     public Object JavaDoc[] store() {
40         STArrIntegerON[] arr = new STArrIntegerON[5];
41         
42         arr[0] = new STArrIntegerON();
43         
44         int[][][] content = new int[0][0][0];
45         arr[1] = new STArrIntegerON(content);
46         
47         content = new int[1][2][3];
48         content[0][0][1] = 0;
49         content[0][1][0] = 0;
50         arr[2] = new STArrIntegerON(content);
51         
52         content = new int[1][2][3];
53         content[0][0][0] = 1;
54         content[0][1][0] = 17;
55         content[0][1][1] = Integer.MAX_VALUE - 1;
56         arr[3] = new STArrIntegerON(content);
57         
58         content = new int[1][2][2];
59         content[0][0][0] = 3;
60         content[0][0][1] = 17;
61         content[0][1][0] = 25;
62         content[0][1][1] = Integer.MAX_VALUE - 2;
63         arr[4] = new STArrIntegerON(content);
64         
65         Object JavaDoc[] ret = new Object JavaDoc[arr.length];
66         System.arraycopy(arr, 0, ret, 0, arr.length);
67         return ret;
68     }
69     
70     
71     public void testDefaultContainsOne(){
72         Query q = st.query();
73         Object JavaDoc[] r = store();
74         int[][][] content = new int[1][1][1];
75         content[0][0][0] = 17;
76         q.constrain(new STArrIntegerON(content));
77         st.expect(q, new Object JavaDoc[] {r[3], r[4]});
78     }
79     
80     public void testDefaultContainsTwo(){
81         Query q = st.query();
82         Object JavaDoc[] r = store();
83         int[][][] content = new int[2][1][1];
84         content[0][0][0] = 17;
85         content[1][0][0] = 25;
86         q.constrain(new STArrIntegerON(content));
87         st.expect(q, new Object JavaDoc[] {r[4]});
88     }
89     
90     public void testDescendOne(){
91         Query q = st.query();
92         Object JavaDoc[] r = store();
93         q.constrain(STArrIntegerON.class);
94         q.descend("intArr").constrain(new Integer JavaDoc(17));
95         st.expect(q, new Object JavaDoc[] {r[3], r[4]});
96     }
97     
98     public void testDescendTwo(){
99         Query q = st.query();
100         Object JavaDoc[] r = store();
101         q.constrain(STArrIntegerON.class);
102         Query qElements = q.descend("intArr");
103         qElements.constrain(new Integer JavaDoc(17));
104         qElements.constrain(new Integer JavaDoc(25));
105         st.expect(q, new Object JavaDoc[] {r[4]});
106     }
107     
108     public void testDescendSmaller(){
109         Query q = st.query();
110         Object JavaDoc[] r = store();
111         q.constrain(STArrIntegerON.class);
112         Query qElements = q.descend("intArr");
113         qElements.constrain(new Integer JavaDoc(3)).smaller();
114         st.expect(q, new Object JavaDoc[] {r[2], r[3]});
115     }
116     
117     public void testDescendNotSmaller(){
118         Query q = st.query();
119         Object JavaDoc[] r = store();
120         q.constrain(STArrIntegerON.class);
121         Query qElements = q.descend("intArr");
122         qElements.constrain(new Integer JavaDoc(3)).smaller();
123         st.expect(q, new Object JavaDoc[] {r[2], r[3]});
124     }
125     
126 }
127     
128
Popular Tags