Source Code Cross Referenced for VirtualTable.java in  » Database-DBMS » mckoi » com » mckoi » database » 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 » mckoi » com.mckoi.database 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**
002:         * com.mckoi.database.VirtualTable  08 Mar 1998
003:         *
004:         * Mckoi SQL Database ( http://www.mckoi.com/database )
005:         * Copyright (C) 2000, 2001, 2002  Diehl and Associates, Inc.
006:         *
007:         * This program is free software; you can redistribute it and/or
008:         * modify it under the terms of the GNU General Public License
009:         * Version 2 as published by the Free Software Foundation.
010:         *
011:         * This program is distributed in the hope that it will be useful,
012:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
013:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
014:         * GNU General Public License Version 2 for more details.
015:         *
016:         * You should have received a copy of the GNU General Public License
017:         * Version 2 along with this program; if not, write to the Free Software
018:         * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
019:         *
020:         * Change Log:
021:         * 
022:         * 
023:         */package com.mckoi.database;
024:
025:        import com.mckoi.util.IntegerVector;
026:        import com.mckoi.util.BlockIntegerList;
027:
028:        /**
029:         * A VirtualTable is a representation of a table whose rows are actually
030:         * physically stored in another table.  In other words, this table just
031:         * stores pointers to rows in other tables.
032:         * <p>
033:         * We use the VirtualTable to represent temporary tables created from select,
034:         * join, etc operations.
035:         * <p>
036:         * An important note about VirtualTables:  When we perform a 'select' operation
037:         * on a virtual table, unlike a DataTable that permanently stores information
038:         * about column cell relations, we must resolve column relations between the
039:         * sub-set at select time.  This involves asking the tables parent(s) for a
040:         * scheme to describe relations in a sub-set.
041:         *
042:         * @author Tobias Downer
043:         */
044:
045:        public class VirtualTable extends JoinedTable {
046:
047:            /**
048:             * Array of IntegerVectors that represent the rows taken from the given
049:             * parents.
050:             */
051:            protected IntegerVector[] row_list;
052:
053:            /**
054:             * The number of rows in the table.
055:             */
056:            private int row_count;
057:
058:            /**
059:             * Helper function for the constructor.
060:             */
061:            protected void init(Table[] tables) {
062:                super .init(tables);
063:
064:                int table_count = tables.length;
065:                row_list = new IntegerVector[table_count];
066:                for (int i = 0; i < table_count; ++i) {
067:                    row_list[i] = new IntegerVector();
068:                }
069:            }
070:
071:            /**
072:             * The Constructor.  It is constructed with a list of tables that this
073:             * virtual table is a sub-set or join of.
074:             */
075:            VirtualTable(Table[] tables) {
076:                super (tables);
077:            }
078:
079:            VirtualTable(Table table) {
080:                super (table);
081:            }
082:
083:            protected VirtualTable() {
084:                super ();
085:            }
086:
087:            /**
088:             * Returns the list of IntegerVector that represents the rows that this
089:             * VirtualTable references.
090:             */
091:            protected IntegerVector[] getReferenceRows() {
092:                return row_list;
093:            }
094:
095:            /**
096:             * Returns the number of rows stored in the table.
097:             */
098:            public int getRowCount() {
099:                return row_count;
100:            }
101:
102:            /**
103:             * Sets the rows in this table.  We should search for the
104:             * 'table' in the 'reference_list' however we don't for efficiency.
105:             */
106:            void set(Table table, IntegerVector rows) {
107:                row_list[0] = new IntegerVector(rows);
108:                row_count = rows.size();
109:            }
110:
111:            /**
112:             * This is used in a join to set a list or joined rows and tables.  The
113:             * 'tables' array should be an exact mirror of the 'reference_list'.  The
114:             * IntegerVector[] array contains the rows to add for each respective table.
115:             * The given IntegerVector objects should have identical lengths.
116:             */
117:            void set(Table[] tables, IntegerVector[] rows) {
118:                for (int i = 0; i < tables.length; ++i) {
119:                    row_list[i] = new IntegerVector(rows[i]);
120:                }
121:                if (rows.length > 0) {
122:                    row_count = rows[0].size();
123:                }
124:            }
125:
126:            /**
127:             * Sets the rows in this table as above, but uses a BlockIntegerList as an
128:             * argument instead.
129:             */
130:            void set(Table table, BlockIntegerList rows) {
131:                row_list[0] = new IntegerVector(rows);
132:                row_count = rows.size();
133:            }
134:
135:            /**
136:             * Sets the rows in this table as above, but uses a BlockIntegerList array
137:             * as an argument instead.
138:             */
139:            void set(Table[] tables, BlockIntegerList[] rows) {
140:                for (int i = 0; i < tables.length; ++i) {
141:                    row_list[i] = new IntegerVector(rows[i]);
142:                }
143:                if (rows.length > 0) {
144:                    row_count = rows[0].size();
145:                }
146:            }
147:
148:            // ---------- Implemented from JoinedTable ----------
149:
150:            protected int resolveRowForTableAt(int row_number, int table_num) {
151:                return row_list[table_num].intAt(row_number);
152:            }
153:
154:            protected void resolveAllRowsForTableAt(IntegerVector row_set,
155:                    int table_num) {
156:                IntegerVector cur_row_list = row_list[table_num];
157:                for (int n = row_set.size() - 1; n >= 0; --n) {
158:                    int aa = row_set.intAt(n);
159:                    int bb = cur_row_list.intAt(aa);
160:                    row_set.setIntAt(bb, n);
161:                }
162:            }
163:
164:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.