01: /*
02: * Copyright 2004-2007 Gary Bentley
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License"); you may
05: * not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: * http://www.apache.org/licenses/LICENSE-2.0
08: *
09: * 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: public static final int ASC = 0;
22: public static final int DESC = 1;
23:
24: private int type = -1;
25: private int ci = -1;
26: private Expression exp = null;
27:
28: public void setExpression(Expression exp) {
29:
30: this .exp = exp;
31:
32: }
33:
34: public int getIndex() {
35:
36: return this .ci;
37:
38: }
39:
40: public Expression getExpression() {
41:
42: return this .exp;
43:
44: }
45:
46: public void setIndex(int ci) {
47:
48: this .ci = ci;
49:
50: }
51:
52: public int getType() {
53:
54: return this .type;
55:
56: }
57:
58: public void setType(int t) {
59:
60: this .type = t;
61:
62: }
63:
64: public String toString() {
65:
66: StringBuffer b = new StringBuffer();
67:
68: if (this .ci > -1) {
69:
70: b.append(this .ci);
71:
72: } else {
73:
74: b.append(this .exp);
75:
76: }
77:
78: if (this .type == OrderBy.ASC) {
79:
80: b.append(" ASC");
81:
82: }
83:
84: if (this .type == OrderBy.DESC) {
85:
86: b.append(" DESC");
87:
88: }
89:
90: return b.toString();
91:
92: }
93:
94: }
|