KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > db4o > test > legacy > soda > ordered > STOInteger


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.ordered;
22
23
24 import com.db4o.query.*;
25 import com.db4o.test.legacy.soda.*;
26
27 public class STOInteger implements STClass{
28     
29     public static transient SodaTest st;
30     
31     int i_int;
32     
33     public STOInteger(){
34     }
35     
36     private STOInteger(int a_int){
37         i_int = a_int;
38     }
39     
40     public String JavaDoc toString(){
41         return "STInteger: " + i_int;
42     }
43     
44     public Object JavaDoc[] store() {
45         return new Object JavaDoc[]{
46             new STOInteger(1001),
47             new STOInteger(99),
48             new STOInteger(1),
49             new STOInteger(909),
50             new STOInteger(1001),
51             new STOInteger(0),
52             new STOInteger(1010),
53         };
54     }
55     
56     public void testAscending() {
57         Query q = st.query();
58         q.constrain(STOInteger.class);
59         q.descend("i_int").orderAscending();
60         Object JavaDoc[] r = store();
61         st.expectOrdered(q, new Object JavaDoc[] { r[5], r[2], r[1], r[3], r[0], r[4], r[6] });
62     }
63     
64     public void testDescending() {
65         Query q = st.query();
66         q.constrain(STOInteger.class);
67         q.descend("i_int").orderDescending();
68         Object JavaDoc[] r = store();
69         st.expectOrdered(q, new Object JavaDoc[] { r[6], r[4], r[0], r[3], r[1], r[2], r[5] });
70     }
71     
72     public void testAscendingGreater(){
73         Query q = st.query();
74         q.constrain(STOInteger.class);
75         Query qInt = q.descend("i_int");
76         qInt.constrain(new Integer JavaDoc(100)).greater();
77         qInt.orderAscending();
78         Object JavaDoc[] r = store();
79         st.expectOrdered(q, new Object JavaDoc[] {r[3], r[0], r[4], r[6] });
80     }
81     
82 }
83
84
Popular Tags