Source Code Cross Referenced for ColumnBuilder.java in  » Database-Client » Jackcess » com » healthmarketscience » jackcess » 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 Client » Jackcess » com.healthmarketscience.jackcess 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        // Copyright (c) 2008 Health Market Science, Inc.
002:
003:        package com.healthmarketscience.jackcess;
004:
005:        import java.sql.SQLException;
006:
007:        /**
008:         * Builder style class for constructing a Column.
009:         *
010:         * @author James Ahlborn
011:         */
012:        public class ColumnBuilder {
013:
014:            /** name of the new column */
015:            private String _name;
016:            /** the type of the new column */
017:            private DataType _type;
018:            /** optional length for the new column */
019:            private Integer _length;
020:            /** optional precision for the new column */
021:            private Integer _precision;
022:            /** optional scale for the new column */
023:            private Integer _scale;
024:            /** whether or not the column is auto-number */
025:            private boolean _autoNumber;
026:
027:            public ColumnBuilder(String name) {
028:                this (name, null);
029:            }
030:
031:            public ColumnBuilder(String name, DataType type) {
032:                _name = name;
033:                _type = type;
034:            }
035:
036:            /**
037:             * Sets the type for the new column.
038:             */
039:            public ColumnBuilder setType(DataType type) {
040:                _type = type;
041:                return this ;
042:            }
043:
044:            /**
045:             * Sets the type for the new column based on the given SQL type.
046:             */
047:            public ColumnBuilder setSQLType(int type) throws SQLException {
048:                return setSQLType(type, 0);
049:            }
050:
051:            /**
052:             * Sets the type for the new column based on the given SQL type and target
053:             * data length (in type specific units).
054:             */
055:            public ColumnBuilder setSQLType(int type, int lengthInUnits)
056:                    throws SQLException {
057:                return setType(DataType.fromSQLType(type, lengthInUnits));
058:            }
059:
060:            /**
061:             * Sets the precision for the new column.
062:             */
063:            public ColumnBuilder setPrecision(int newPrecision) {
064:                _precision = newPrecision;
065:                return this ;
066:            }
067:
068:            /**
069:             * Sets the scale for the new column.
070:             */
071:            public ColumnBuilder setScale(int newScale) {
072:                _scale = newScale;
073:                return this ;
074:            }
075:
076:            /**
077:             * Sets the length (in bytes) for the new column.
078:             */
079:            public ColumnBuilder setLength(int length) {
080:                _length = length;
081:                return this ;
082:            }
083:
084:            /**
085:             * Sets the length (in type specific units) for the new column.
086:             */
087:            public ColumnBuilder setLengthInUnits(int unitLength) {
088:                return setLength(_type.getUnitSize() * unitLength);
089:            }
090:
091:            /**
092:             * Sets whether of not the new column is an auto-number column.
093:             */
094:            public ColumnBuilder setAutoNumber(boolean autoNumber) {
095:                _autoNumber = autoNumber;
096:                return this ;
097:            }
098:
099:            /**
100:             * Sets all attributes except name from the given Column template.
101:             */
102:            public ColumnBuilder setFromColumn(Column template) {
103:                DataType type = template.getType();
104:                setType(type);
105:                setLength(template.getLength());
106:                setAutoNumber(template.isAutoNumber());
107:                if (type.getHasScalePrecision()) {
108:                    setScale(template.getScale());
109:                    setPrecision(template.getPrecision());
110:                }
111:
112:                return this ;
113:            }
114:
115:            /**
116:             * Creates a new Column with the currently configured attributes.
117:             */
118:            public Column toColumn() {
119:                Column col = new Column();
120:                col.setName(_name);
121:                col.setType(_type);
122:                if (_length != null) {
123:                    col.setLength(_length.shortValue());
124:                }
125:                if (_precision != null) {
126:                    col.setPrecision(_precision.byteValue());
127:                }
128:                if (_scale != null) {
129:                    col.setScale(_scale.byteValue());
130:                }
131:                if (_autoNumber) {
132:                    col.setAutoNumber(true);
133:                }
134:                return col;
135:            }
136:
137:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.