KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > derby > impl > sql > compile > OrderedColumn


1 /*
2
3    Derby - Class org.apache.derby.impl.sql.compile.OrderedColumn
4
5    Licensed to the Apache Software Foundation (ASF) under one or more
6    contributor license agreements. See the NOTICE file distributed with
7    this work for additional information regarding copyright ownership.
8    The ASF licenses this file to you under the Apache License, Version 2.0
9    (the "License"); you may not use this file except in compliance with
10    the License. You may obtain a copy of the License at
11
12       http://www.apache.org/licenses/LICENSE-2.0
13
14    Unless required by applicable law or agreed to in writing, software
15    distributed under the License is distributed on an "AS IS" BASIS,
16    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17    See the License for the specific language governing permissions and
18    limitations under the License.
19
20  */

21
22 package org.apache.derby.impl.sql.compile;
23
24 import org.apache.derby.iapi.services.sanity.SanityManager;
25
26 /**
27  * An ordered column has position. It is an
28  * abstract class for group by and order by
29  * columns.
30  *
31  * @author jamie
32  */

33 public abstract class OrderedColumn extends QueryTreeNode
34 {
35     protected static final int UNMATCHEDPOSITION = -1;
36     protected int columnPosition = UNMATCHEDPOSITION;
37
38     /**
39      * Indicate whether this column is ascending or not.
40      * By default assume that all ordered columns are
41      * necessarily ascending. If this class is inherited
42      * by someone that can be desceneded, they are expected
43      * to override this method.
44      *
45      * @return true
46      */

47     public boolean isAscending()
48     {
49         return true;
50     }
51
52     /**
53      * Convert this object to a String. See comments in QueryTreeNode.java
54      * for how this should be done for tree printing.
55      *
56      * @return This object as a String
57      */

58     public String JavaDoc toString()
59     {
60         if (SanityManager.DEBUG)
61         {
62             return "columnPosition: " + columnPosition + "\n" +
63                 super.toString();
64         }
65         else
66         {
67             return "";
68         }
69     }
70
71     /**
72      * Get the position of this column
73      *
74      * @return The position of this column
75      */

76     public int getColumnPosition()
77     {
78         return columnPosition;
79     }
80
81     /**
82      * Set the position of this column
83      */

84     public void setColumnPosition(int columnPosition)
85     {
86         this.columnPosition = columnPosition;
87         if (SanityManager.DEBUG)
88         {
89             SanityManager.ASSERT(columnPosition > 0,
90                 "Column position is " + columnPosition +
91                 ". This is a problem since the code to generate " +
92                 " ordering columns assumes it to be one based -- i.e. "+
93                 " it subtracts one");
94
95         }
96     }
97 }
98
Popular Tags