KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > oracle > toplink > essentials > internal > parsing > SortDirectionNode


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the "License"). You may not use this file except
5  * in compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * glassfish/bootstrap/legal/CDDLv1.0.txt or
9  * https://glassfish.dev.java.net/public/CDDLv1.0.html.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * HEADER in each file and include the License file at
15  * glassfish/bootstrap/legal/CDDLv1.0.txt. If applicable,
16  * add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your
18  * own identifying information: Portions Copyright [yyyy]
19  * [name of copyright owner]
20  */

21 // Copyright (c) 1998, 2006, Oracle. All rights reserved.
22
package oracle.toplink.essentials.internal.parsing;
23
24
25 /**
26  * INTERNAL
27  * <p><b>Purpose</b>: Represent a Sort Direction for an
28  * Order By Item
29  * <p><b>Responsibilities</b>:<ul>
30  * <li> Apply itself to a query correctly
31  *
32  * This node represents either an ASC or DESC encountered on the input stream
33  * e.g SELECT ... FROM ... WHERE ... ORDER BY emp.salary ASC
34  * </ul>
35  * @author Jon Driscoll
36  * @since TopLink 5.0
37  */

38 import oracle.toplink.essentials.expressions.Expression;
39 import oracle.toplink.essentials.expressions.ExpressionOperator;
40
41 public class SortDirectionNode extends Node {
42     private int sortDirection = ExpressionOperator.Ascending;
43
44     /**
45      * INTERNAL
46      * Return the parent expression unmodified
47      */

48     public Expression addToExpression(Expression parentExpression, GenerationContext context) {
49         return parentExpression.getFunction(getSortDirection());
50     }
51
52     public void useAscending() {
53         setSortDirection(ExpressionOperator.Ascending);
54     }
55
56     public void useDescending() {
57         setSortDirection(ExpressionOperator.Descending);
58     }
59
60     // Accessors
61
public int getSortDirection() {
62         return sortDirection;
63     }
64
65     public void setSortDirection(int sortDirection) {
66         this.sortDirection = sortDirection;
67     }
68 }
69
Popular Tags