KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > xquark > extractor > sql > SqlSortSpecification


1 /*
2  * This file belongs to the XQuark distribution.
3  * Copyright (C) 2003 Universite de Versailles Saint-Quentin.
4  *
5  * This program is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this program; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307.
18  * You can also get it at http://www.gnu.org/licenses/lgpl.html
19  *
20  * For more information on this software, see http://www.xquark.org.
21  */

22
23 package org.xquark.extractor.sql;
24
25
26 public class SqlSortSpecification extends SqlExpression
27 {
28
29     private static final String JavaDoc RCSRevision = "$Revision: 1.4 $";
30     private static final String JavaDoc RCSName = "$Name: $";
31
32     protected static final String JavaDoc SORT_DIRECTIONS[] = {"ASC","DESC"};
33     private int _sortDirection;
34     private SqlExpression _sortExpression;
35
36     /**
37     @param sortExpression
38     @param sortDirection
39     @roseuid 3BD178000228
40      */

41     public SqlSortSpecification(SqlExpression sortExpression, int sortDirection)
42     {
43         setSortExpression ( sortExpression );
44         setSortDirection ( sortDirection ) ;
45     }
46
47     /**
48     @roseuid 3BD1780001F6
49      */

50     public SqlSortSpecification()
51     {
52     }
53
54     /**
55     Access method for the _sortExpression property.
56
57     @return the current value of the _sortExpression property
58      */

59     public SqlExpression getSortExpression()
60     {
61      return _sortExpression;
62     }
63
64     /**
65     Sets the value of the _sortExpression property.
66
67     @param aSortExpression the new value of the _sortExpression property
68      */

69     public void setSortExpression(SqlExpression aSortExpression)
70     {
71         _sortExpression = aSortExpression;
72     }
73
74
75
76     /**
77     Access method for the _sortDirection property.
78     @return the current value of the _sortDirection property
79     @roseuid 3BD1780100B7
80      */

81     public int getSortDirection()
82     {
83         return _sortDirection;
84     }
85
86     /**
87     Sets the value of the _sortDirection property.
88     @param aSortDirection the new value of the _sortDirection property
89     @roseuid 3BD1780100F3
90      */

91     public void setSortDirection(int aSortDirection)
92     {
93         _sortDirection = aSortDirection;
94     }
95
96     /**
97     @return String
98     @roseuid 3BD178010193
99      */

100     public String JavaDoc toSql(Context context)
101     {
102         //Trace.enter(this,"toSql(Context context)");
103

104         StringBuffer JavaDoc retVal = new StringBuffer JavaDoc();
105         retVal.append("(");
106         retVal.append(_sortExpression.toSql(context));
107         retVal.append(") ") ;
108         retVal.append(SORT_DIRECTIONS [_sortDirection]);
109
110         //Trace.exit(this,"toSql(Context context)", retVal);
111
return retVal.toString();
112     }
113 }
114
Popular Tags