Source Code Cross Referenced for Row.java in  » Database-DBMS » Quadcap-Embeddable-Database » com » quadcap » sql » 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 » Quadcap Embeddable Database » com.quadcap.sql 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package com.quadcap.sql;
002:
003:        /* Copyright 1999 - 2003 Quadcap Software.  All rights reserved.
004:         *
005:         * This software is distributed under the Quadcap Free Software License.
006:         * This software may be used or modified for any purpose, personal or
007:         * commercial.  Open Source redistributions are permitted.  Commercial
008:         * redistribution of larger works derived from, or works which bundle
009:         * this software requires a "Commercial Redistribution License"; see
010:         * http://www.quadcap.com/purchase.
011:         *
012:         * Redistributions qualify as "Open Source" under  one of the following terms:
013:         *   
014:         *    Redistributions are made at no charge beyond the reasonable cost of
015:         *    materials and delivery.
016:         *
017:         *    Redistributions are accompanied by a copy of the Source Code or by an
018:         *    irrevocable offer to provide a copy of the Source Code for up to three
019:         *    years at the cost of materials and delivery.  Such redistributions
020:         *    must allow further use, modification, and redistribution of the Source
021:         *    Code under substantially the same terms as this license.
022:         *
023:         * Redistributions of source code must retain the copyright notices as they
024:         * appear in each source code file, these license terms, and the
025:         * disclaimer/limitation of liability set forth as paragraph 6 below.
026:         *
027:         * Redistributions in binary form must reproduce this Copyright Notice,
028:         * these license terms, and the disclaimer/limitation of liability set
029:         * forth as paragraph 6 below, in the documentation and/or other materials
030:         * provided with the distribution.
031:         *
032:         * The Software is provided on an "AS IS" basis.  No warranty is
033:         * provided that the Software is free of defects, or fit for a
034:         * particular purpose.  
035:         *
036:         * Limitation of Liability. Quadcap Software shall not be liable
037:         * for any damages suffered by the Licensee or any third party resulting
038:         * from use of the Software.
039:         */
040:
041:        import java.io.Externalizable;
042:        import java.io.IOException;
043:        import java.io.ObjectInput;
044:        import java.io.ObjectOutput;
045:
046:        import java.util.ArrayList;
047:
048:        import java.sql.SQLException;
049:
050:        import com.quadcap.sql.types.Type;
051:        import com.quadcap.sql.types.Value;
052:        import com.quadcap.sql.types.ValueBlob;
053:
054:        import com.quadcap.util.Debug;
055:
056:        /**
057:         * Essentially, a vector with one-based indices.
058:         *
059:         * @author Stan Bailes
060:         */
061:        public class Row {
062:            int blobCnt = 0;
063:            ArrayList v = null;
064:
065:            /**
066:             * Default constructor
067:             */
068:            public Row() {
069:                v = new ArrayList();
070:            }
071:
072:            /**
073:             * Construct an empty row with the specified number of columns
074:             */
075:            public Row(int size) {
076:                this .v = new ArrayList(size);
077:                while (v.size() < size)
078:                    v.add(null);
079:            }
080:
081:            /**
082:             * Construct a row as a copy of another row.
083:             */
084:            public Row(Row r, Tuple tuple) throws SQLException {
085:                v = new ArrayList();
086:                for (int i = 1; i <= r.size(); i++) {
087:                    Value rv = r.item(i);
088:                    if (tuple != null) {
089:                        Type type = tuple.getColumn(i).getType();
090:                        Value v1 = type.convert(rv);
091:                        rv = v1;
092:                    }
093:                    if (rv instanceof  ValueBlob)
094:                        blobCnt++;
095:                    v.add(rv);
096:                }
097:            }
098:
099:            /**
100:             * Construct a row using a ArrayList of values.  The vector is zero-based,
101:             * even though the row is one-based!
102:             */
103:            public Row(ArrayList v) {
104:                this .v = v;
105:                for (int i = 0; i < v.size(); i++) {
106:                    if (v.get(i) instanceof  ValueBlob)
107:                        blobCnt++;
108:                }
109:            }
110:
111:            /**
112:             * Return the number of values in this row.
113:             */
114:            public int size() {
115:                return v.size();
116:            }
117:
118:            /**
119:             * Return the number of BLOB values in this row.  (We can shortcut
120:             * some possibly lengthy operations if we know there are no blobs)
121:             */
122:            public int getBlobCount() throws IOException {
123:                return blobCnt;
124:            }
125:
126:            /**
127:             * Return the specified value (one-based) from the row.
128:             */
129:            public Value item(int i) throws SQLException {
130:                if (i < 1 || i > v.size()) {
131:                    throw new SQLException("bad column: " + i, "42000");
132:                }
133:                return (Value) v.get(i - 1);
134:            }
135:
136:            /**
137:             * Non-checked access: return the specified value (one-based) from the row.
138:             */
139:            public Value getItem(int i) {
140:                return (Value) v.get(i - 1);
141:            }
142:
143:            /**
144:             * Set value in the specified position (one-based) to a new value
145:             */
146:            public void set(int i, Value val) throws SQLException {
147:                final int idx = i - 1;
148:                if (v.get(idx) instanceof  ValueBlob)
149:                    blobCnt--;
150:                if (val instanceof  ValueBlob)
151:                    blobCnt++;
152:                v.set(idx, val);
153:                //#ifdef TRACE
154:                if (Trace.bit(7)) {
155:                    Debug.println("Row.set(" + i + "), " + blobCnt + " blobs");
156:                }
157:                //#endif
158:            }
159:
160:            /**
161:             * Is the specified element updatable? 
162:             */
163:            public boolean isUpdateable(int i) {
164:                return true;
165:            }
166:
167:            public void addElement(Value val) {
168:                if (val instanceof  ValueBlob)
169:                    blobCnt++;
170:                v.add(val);
171:            }
172:
173:            //#ifdef DEBUG
174:            public String toString() {
175:                StringBuffer sb = new StringBuffer();
176:                sb.append("{");
177:                for (int i = 1; i <= size(); i++) {
178:                    if (i > 1)
179:                        sb.append(",");
180:                    try {
181:                        Value vx = item(i);
182:                        //sb.append(v.getType().getTypeName());
183:                        //sb.append(":");
184:                        sb.append(vx.toString());
185:                    } catch (Throwable e) {
186:                        sb.append("<" + e.toString() + ">");
187:                    }
188:                }
189:                sb.append("}");
190:                return sb.toString();
191:            }
192:            //#endif
193:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.