Source Code Cross Referenced for Columns.java in  » Database-JDBC-Connection-Pool » octopus » com » internetcds » jdbc » tds » 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 JDBC Connection Pool » octopus » com.internetcds.jdbc.tds 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        //                                                                            
002:        // Copyright 1998 CDS Networks, Inc., Medford Oregon                          
003:        //                                                                            
004:        // All rights reserved.                                                       
005:        //                                                                            
006:        // Redistribution and use in source and binary forms, with or without         
007:        // modification, are permitted provided that the following conditions are met:
008:        // 1. Redistributions of source code must retain the above copyright          
009:        //    notice, this list of conditions and the following disclaimer.           
010:        // 2. Redistributions in binary form must reproduce the above copyright       
011:        //    notice, this list of conditions and the following disclaimer in the     
012:        //    documentation and/or other materials provided with the distribution.    
013:        // 3. All advertising materials mentioning features or use of this software   
014:        //    must display the following acknowledgement:                             
015:        //      This product includes software developed by CDS Networks, Inc.        
016:        // 4. The name of CDS Networks, Inc.  may not be used to endorse or promote   
017:        //    products derived from this software without specific prior              
018:        //    written permission.                                                     
019:        //                                                                            
020:        // THIS SOFTWARE IS PROVIDED BY CDS NETWORKS, INC. ``AS IS'' AND              
021:        // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE      
022:        // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
023:        // ARE DISCLAIMED.  IN NO EVENT SHALL CDS NETWORKS, INC. BE LIABLE            
024:        // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 
025:        // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS    
026:        // OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)      
027:        // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
028:        // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY  
029:        // OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF     
030:        // SUCH DAMAGE.                                                               
031:        //                                                                            
032:
033:        package com.internetcds.jdbc.tds;
034:
035:        import java.util.Vector;
036:        import java.sql.Types;
037:        import com.internetcds.jdbc.tds.Column;
038:
039:        /**
040:         * Information about the columns in a result set.
041:         *
042:         * @author Craig Spannring
043:         */
044:        public class Columns {
045:            public static final String cvsVersion = "$Id: Columns.java,v 1.2 2007-10-19 13:21:40 sinisa Exp $";
046:
047:            private Vector columns = null;
048:            private int columnCount = 0;
049:
050:            public Columns() {
051:                columns = new Vector();
052:                columnCount = 0;
053:            }
054:
055:            /**
056:             * merge the data from two instances of Columns.
057:             *
058:             * The 4.2 TDS protocol gives the column information in multiple pieces.
059:             * Each piece gives us a specific piece of information for all the 
060:             * columns in the result set.  We must join those pieces of information
061:             * together to use as the basis for the ResultSetMetaData class.
062:             *
063:             * @exception TdsException thrown if the two instances of Columns can't
064:             *                         be merged.  This can happen if the number of 
065:             *                         columns isn't identical or if there is 
066:             *                         conflicting data.
067:             */
068:            public Columns merge(Columns other) throws TdsException {
069:                int tmp;
070:                int i;
071:
072:                if (this .columns.size() != other.columns.size()) {
073:                    throw new TdsException(
074:                            "Confused.  Mismatch in number of columns");
075:                }
076:
077:                for (i = 1; i <= columnCount; i++) {
078:                    if (this .getName(i) == null) {
079:                        this .setName(i, other.getName(i));
080:                    } else if (other.getName(i) == null) {
081:                        // fine
082:                    } else {
083:                        throw new TdsException(
084:                                "Trying to merge two non-null columns");
085:                    }
086:
087:                    if (this .getDisplaySize(i) == -1) {
088:                        this .setDisplaySize(i, other.getDisplaySize(i));
089:                    } else if (other.getDisplaySize(i) == -1) {
090:                        // fine
091:                    } else {
092:                        throw new TdsException(
093:                                "Trying to merge two non-null columns");
094:                    }
095:
096:                    if (this .getLabel(i) == null) {
097:                        this .setLabel(i, other.getLabel(i));
098:                    } else if (other.getLabel(i) == null) {
099:                        // fine
100:                    } else {
101:                        throw new TdsException(
102:                                "Trying to merge two non-null columns");
103:                    }
104:
105:                    if (this .getType(i) == -1) {
106:                        this .setType(i, other.getType(i));
107:                    } else if (other.getType(i) == -1) {
108:                        // fine
109:                    } else {
110:                        throw new TdsException(
111:                                "Trying to merge two non-null columns");
112:                    }
113:
114:                    if (this .getPrecision(i) == -1) {
115:                        this .setPrecision(i, other.getPrecision(i));
116:                    } else if (other.getPrecision(i) == -1) {
117:                        // fine
118:                    } else {
119:                        throw new TdsException(
120:                                "Trying to merge two non-null columns");
121:                    }
122:
123:                    if (this .getScale(i) == -1) {
124:                        this .setScale(i, other.getScale(i));
125:                    } else if (other.getScale(i) == -1) {
126:                        // fine
127:                    } else {
128:                        throw new TdsException(
129:                                "Trying to merge two non-null columns");
130:                    }
131:
132:                    if ((this .nullableWasSet(i)) && (other.nullableWasSet(i))) {
133:                        throw new TdsException(
134:                                "Trying to merge two non-null columns");
135:                    } else if ((!this .nullableWasSet(i))
136:                            && (other.nullableWasSet(i))) {
137:                        this .setNullable(i, other.isNullable(i));
138:                    } else {
139:                        // fine
140:                    }
141:
142:                    if ((this .readOnlyWasSet(i)) && (other.readOnlyWasSet(i))) {
143:                        throw new TdsException(
144:                                "Trying to merge two non-null columns");
145:                    } else if ((!this .readOnlyWasSet(i))
146:                            && (other.readOnlyWasSet(i))) {
147:                        this .setReadOnly(i, other.isReadOnly(i));
148:                    } else {
149:                        // fine
150:                    }
151:
152:                    if ((this .autoIncrementWasSet(i))
153:                            && (other.autoIncrementWasSet(i))) {
154:                        throw new TdsException(
155:                                "Trying to merge two non-null columns");
156:                    } else if ((!this .autoIncrementWasSet(i))
157:                            && (other.autoIncrementWasSet(i))) {
158:                        this .setAutoIncrement(i, other.isAutoIncrement(i));
159:                    } else {
160:                        // fine
161:                    }
162:                }
163:                return this ;
164:            } /* merge() */
165:
166:            private void resize(int columnNumber) {
167:                if (columnNumber > columnCount) {
168:                    columnCount = columnNumber;
169:                }
170:
171:                if (columns.size() <= columnNumber) {
172:                    columns.setSize(columnNumber + 1);
173:                }
174:
175:                if (columns.elementAt(columnNumber - 1) == null) {
176:                    columns.setElementAt(new Column(), columnNumber - 1);
177:                }
178:
179:            }
180:
181:            /**
182:             * 
183:             */
184:            public int getColumnCount() {
185:                return columnCount;
186:            }
187:
188:            public void setName(int columnNumber, String value) {
189:                resize(columnNumber);
190:                if (columns.elementAt(columnNumber - 1) == null) {
191:                    columns.setElementAt(new Column(), columnNumber - 1);
192:                }
193:                ((Column) (columns.elementAt(columnNumber - 1))).setName(value);
194:            }
195:
196:            public String getName(int columnNumber) {
197:                return ((Column) columns.elementAt(columnNumber - 1)).getName();
198:            }
199:
200:            public void setDisplaySize(int columnNumber, int value) {
201:                resize(columnNumber);
202:                ((Column) (columns.elementAt(columnNumber - 1)))
203:                        .setDisplaySize(value);
204:            }
205:
206:            public int getDisplaySize(int columnNumber) {
207:                return ((Column) columns.elementAt(columnNumber - 1))
208:                        .getDisplaySize();
209:            }
210:
211:            public void setLabel(int columnNumber, String value) {
212:                ((Column) (columns.elementAt(columnNumber - 1)))
213:                        .setLabel(value);
214:            }
215:
216:            public String getLabel(int columnNumber) {
217:                return ((Column) columns.elementAt(columnNumber - 1))
218:                        .getLabel();
219:            }
220:
221:            public void setType(int columnNumber, int value) {
222:                // remeber that this is the native type
223:                resize(columnNumber);
224:                ((Column) (columns.elementAt(columnNumber - 1))).setType(value);
225:            }
226:
227:            public int getType(int columnNumber) {
228:                // remeber that this is the native type
229:                return ((Column) columns.elementAt(columnNumber - 1)).getType();
230:            }
231:
232:            public void setPrecision(int columnNumber, int value) {
233:                resize(columnNumber);
234:                ((Column) (columns.elementAt(columnNumber - 1)))
235:                        .setPrecision(value);
236:            }
237:
238:            public int getPrecision(int columnNumber) {
239:                return ((Column) columns.elementAt(columnNumber - 1))
240:                        .getPrecision();
241:            }
242:
243:            public void setScale(int columnNumber, int value) {
244:                resize(columnNumber);
245:                ((Column) (columns.elementAt(columnNumber - 1)))
246:                        .setScale(value);
247:            }
248:
249:            public int getScale(int columnNumber) {
250:                return ((Column) columns.elementAt(columnNumber - 1))
251:                        .getScale();
252:            }
253:
254:            public boolean isAutoIncrement(int columnNumber) {
255:                return ((Column) columns.elementAt(columnNumber - 1))
256:                        .isAutoIncrement();
257:            }
258:
259:            public void setAutoIncrement(int columnNumber, boolean value) {
260:                resize(columnNumber);
261:                ((Column) (columns.elementAt(columnNumber - 1)))
262:                        .setAutoIncrement(value);
263:            }
264:
265:            public boolean autoIncrementWasSet(int columnNumber) {
266:                return ((Column) (columns.elementAt(columnNumber - 1)))
267:                        .autoIncrementWasSet();
268:            }
269:
270:            public int isNullable(int columnNumber) {
271:                return ((Column) columns.elementAt(columnNumber - 1))
272:                        .isNullable();
273:            }
274:
275:            public void setNullable(int columnNumber, int value) {
276:                resize(columnNumber);
277:                ((Column) (columns.elementAt(columnNumber - 1)))
278:                        .setNullable(value);
279:            }
280:
281:            public boolean nullableWasSet(int columnNumber) {
282:                return (isNullable(columnNumber) != java.sql.ResultSetMetaData.columnNullableUnknown);
283:            }
284:
285:            public boolean isReadOnly(int columnNumber) {
286:                return ((Column) columns.elementAt(columnNumber - 1))
287:                        .isReadOnly();
288:            }
289:
290:            public void setReadOnly(int columnNumber, boolean value) {
291:                resize(columnNumber);
292:                ((Column) columns.elementAt(columnNumber - 1))
293:                        .setReadOnly(value);
294:            }
295:
296:            public boolean readOnlyWasSet(int columnNumber) {
297:                return ((Column) (columns.elementAt(columnNumber - 1)))
298:                        .readOnlyWasSet();
299:            }
300:
301:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.