KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > db > sql > visualeditor > querymodel > SortSpecification


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19 package org.netbeans.modules.db.sql.visualeditor.querymodel;
20
21
22 import java.util.Collection JavaDoc;
23
24 /**
25  * Represents a column in an ORDER BY clause
26  */

27 public final class SortSpecification implements QueryItem {
28
29     // Fields
30

31     private ColumnItem _column;
32
33     // direction is one of standard SQL 'ASC' or DESC'
34
private String JavaDoc _direction;
35
36
37     // Constructors
38

39     public SortSpecification(ColumnItem col, String JavaDoc direction) {
40         _column = col;
41         _direction = direction;
42     }
43
44     public SortSpecification(ColumnItem col) {
45         this(col, "ASC"); // NOI18N
46
}
47
48
49     // Methods
50

51     public String JavaDoc genText() {
52         return _column.genText() + " " + // NOI18N
53
_direction;
54     }
55
56
57     // Accessors/Mutators
58

59     public String JavaDoc getDirection() {
60         return _direction;
61     }
62
63     public Column getColumn() {
64         if (_column instanceof ColumnNode) return (Column)_column; return null;
65     }
66
67     public void getReferencedColumns(Collection JavaDoc columns) {
68         columns.add(_column.getReferencedColumn());
69     }
70
71     void renameTableSpec(String JavaDoc oldTableSpec, String JavaDoc corrName) {
72         _column.renameTableSpec(oldTableSpec, corrName);
73     }
74
75     public void getQueryItems(Collection JavaDoc items) {
76         items.add(_column);
77     }
78
79 // public String getCorrName() {
80
// return _corrName;
81
// }
82

83 // public String getTableName() {
84
// return _tableName;
85
// }
86

87 // public String getColumnName() {
88
// return _columnName;
89
// }
90

91 // public String getTableSpec() {
92
// return (_corrName != null ?
93
// _corrName :
94
// _tableName);
95
// }
96
}
97
98
99
Popular Tags