Source Code Cross Referenced for ColumnOrdering.java in  » Database-DBMS » db-derby-10.2 » org » apache » derby » impl » sql » compile » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Database DBMS » db derby 10.2 » org.apache.derby.impl.sql.compile 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:
003:           Derby - Class org.apache.derby.impl.sql.compile.ColumnOrdering
004:
005:           Licensed to the Apache Software Foundation (ASF) under one or more
006:           contributor license agreements.  See the NOTICE file distributed with
007:           this work for additional information regarding copyright ownership.
008:           The ASF licenses this file to you under the Apache License, Version 2.0
009:           (the "License"); you may not use this file except in compliance with
010:           the License.  You may obtain a copy of the License at
011:
012:              http://www.apache.org/licenses/LICENSE-2.0
013:
014:           Unless required by applicable law or agreed to in writing, software
015:           distributed under the License is distributed on an "AS IS" BASIS,
016:           WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
017:           See the License for the specific language governing permissions and
018:           limitations under the License.
019:
020:         */
021:
022:        package org.apache.derby.impl.sql.compile;
023:
024:        import org.apache.derby.iapi.sql.compile.RowOrdering;
025:        import org.apache.derby.iapi.sql.compile.Optimizable;
026:
027:        import org.apache.derby.iapi.services.sanity.SanityManager;
028:
029:        import java.util.Vector;
030:
031:        class ColumnOrdering {
032:
033:            /* See RowOrdering for possible values */
034:            int myDirection;
035:
036:            /* A vector of column numbers (Integers) */
037:            Vector columns = new Vector();
038:
039:            /*
040:             ** A vector of table numbers (Integers), corresponding to the column
041:             ** vector by position.
042:             */
043:            Vector tables = new Vector();
044:
045:            /**
046:             * @param direction	See RowOrdering for possible values
047:             */
048:            ColumnOrdering(int direction) {
049:                myDirection = direction;
050:            }
051:
052:            /**
053:             * Does this ColumnOrdering contain the given column in the given table
054:             * in the right direction?
055:             *
056:             * @param direction		See RowOrdering for possible values
057:             * @param tableNumber	The number of the table in question
058:             * @param columnNumber	The column number in the table (one-based)
059:             *
060:             * @return	true if the column is found here in the right direction
061:             */
062:            boolean ordered(int direction, int tableNumber, int columnNumber) {
063:                /*
064:                 ** Check the direction only if the direction isn't DONTCARE
065:                 */
066:                if (direction != RowOrdering.DONTCARE) {
067:                    if (direction != myDirection)
068:                        return false;
069:                }
070:
071:                /* The direction matches - see if the column is in this ordering */
072:                return contains(tableNumber, columnNumber);
073:            }
074:
075:            /**
076:             * Does this ColumnOrdering contain the given column?
077:             *
078:             * @param tableNumber	The number of table in question
079:             * @param columnNumber	The column number in the table (one-based)
080:             *
081:             * @return	true if the column is found here in the right direction
082:             */
083:            boolean contains(int tableNumber, int columnNumber) {
084:                for (int i = 0; i < columns.size(); i++) {
085:                    Integer col = (Integer) columns.elementAt(i);
086:                    Integer tab = (Integer) tables.elementAt(i);
087:
088:                    if (tab.intValue() == tableNumber
089:                            && col.intValue() == columnNumber) {
090:
091:                        return true;
092:                    }
093:                }
094:
095:                return false;
096:            }
097:
098:            /**
099:             * Get the direction of this ColumnOrdering
100:             */
101:            int direction() {
102:                return myDirection;
103:            }
104:
105:            /**
106:             * Add a column in a table to this ColumnOrdering
107:             *
108:             * @param tableNumber	The number of table in question
109:             * @param columnNumber	The column number in the table (one-based)
110:             */
111:            void addColumn(int tableNumber, int columnNumber) {
112:                tables.addElement(new Integer(tableNumber));
113:                columns.addElement(new Integer(columnNumber));
114:            }
115:
116:            /**
117:             * Remove all columns with the given table number
118:             */
119:            void removeColumns(int tableNumber) {
120:                /*
121:                 ** Walk the list backwards, so we can remove elements
122:                 ** by position.
123:                 */
124:                for (int i = tables.size() - 1; i >= 0; i--) {
125:                    Integer tab = (Integer) tables.elementAt(i);
126:                    if (tab.intValue() == tableNumber) {
127:                        tables.removeElementAt(i);
128:                        columns.removeElementAt(i);
129:                    }
130:                }
131:            }
132:
133:            /**
134:             * Tell whether this ColumnOrdering has no elements.
135:             */
136:            boolean empty() {
137:                return (tables.size() == 0);
138:            }
139:
140:            /** Return a clone of this ColumnOrdering */
141:            ColumnOrdering cloneMe() {
142:                ColumnOrdering retval = new ColumnOrdering(myDirection);
143:
144:                for (int i = 0; i < columns.size(); i++) {
145:                    /* Integers are immutable, so just copy the pointers */
146:                    retval.columns.addElement(columns.elementAt(i));
147:                    retval.tables.addElement(tables.elementAt(i));
148:                }
149:
150:                return retval;
151:            }
152:
153:            /** Is the given table number in this ColumnOrdering? */
154:            boolean hasTable(int tableNumber) {
155:                if (tables.size() == 0)
156:                    return false;
157:
158:                for (int i = 0; i < tables.size(); i++) {
159:                    Integer tab = (Integer) tables.elementAt(i);
160:
161:                    if (tab.intValue() == tableNumber)
162:                        return true;
163:                }
164:
165:                return false;
166:            }
167:
168:            /** Is there any table other than the given one in this ColumnOrdering? */
169:            boolean hasAnyOtherTable(int tableNumber) {
170:                if (tables.size() == 0)
171:                    return false;
172:
173:                for (int i = 0; i < tables.size(); i++) {
174:                    Integer tab = (Integer) tables.elementAt(i);
175:
176:                    if (tab.intValue() != tableNumber)
177:                        return true;
178:                }
179:
180:                return false;
181:            }
182:
183:            public String toString() {
184:                String retval = "";
185:
186:                if (SanityManager.DEBUG) {
187:                    retval += "Direction: " + myDirection;
188:
189:                    for (int i = 0; i < columns.size(); i++) {
190:                        retval += " Table " + tables.elementAt(i) + ", Column "
191:                                + columns.elementAt(i);
192:                    }
193:                }
194:
195:                return retval;
196:            }
197:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.