KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > josql > internal > OrderBy


1 /*
2  * Copyright 2004-2005 Gary Bentley
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License"); you may
5  * not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */

15 package org.josql.internal;
16
17 import org.josql.expressions.Expression;
18
19 public class OrderBy
20 {
21
22     public static final int ASC = 0;
23     public static final int DESC = 1;
24
25     private int type = -1;
26     private int ci = -1;
27     private Expression exp = null;
28
29     public void setExpression (Expression exp)
30     {
31
32     this.exp = exp;
33
34     }
35
36     public int getIndex ()
37     {
38
39     return this.ci;
40
41     }
42
43     public Expression getExpression ()
44     {
45
46     return this.exp;
47
48     }
49
50     public void setIndex (int ci)
51     {
52
53     this.ci = ci;
54
55     }
56
57     public int getType ()
58     {
59
60     return this.type;
61
62     }
63
64     public void setType (int t)
65     {
66
67     this.type = t;
68
69     }
70
71     public String JavaDoc toString ()
72     {
73
74     StringBuffer JavaDoc b = new StringBuffer JavaDoc ();
75
76     if (this.ci > -1)
77     {
78
79         b.append (this.ci);
80
81     } else {
82
83         b.append (this.exp);
84
85     }
86
87     if (this.type == OrderBy.ASC)
88     {
89
90         b.append (" ASC");
91
92     }
93
94     if (this.type == OrderBy.DESC)
95     {
96
97         b.append (" DESC");
98
99     }
100
101     return b.toString ();
102
103     }
104
105 }
106
Popular Tags