Source Code Cross Referenced for TableEntry.java in  » Database-ORM » sqlc » biz » hammurapi » sqlc » 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 ORM » sqlc » biz.hammurapi.sqlc 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * sqlc 1
003:         * SQL Compiler 
004:         * Copyright (C) 2003  Hammurapi Group
005:         *
006:         * This program is free software; you can redistribute it and/or
007:         * modify it under the terms of the GNU Lesser General Public
008:         * License as published by the Free Software Foundation; either
009:         * version 2 of the License, or (at your option) any later version.
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 GNU
014:         * Lesser General Public License for more details.
015:         *
016:         * You should have received a copy of the GNU Lesser General Public
017:         * License along with this library; if not, write to the Free Software
018:         * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
019:         *
020:         * URL: http://www.hammurapi.biz/products/sqlc/index.html
021:         * e-Mail: support@hammurapi.biz
022:         */
023:        package biz.hammurapi.sqlc;
024:
025:        import java.util.ArrayList;
026:        import java.util.Collection;
027:        import java.util.Iterator;
028:
029:        import org.apache.tools.ant.BuildException;
030:
031:        import biz.hammurapi.sql.metadata.ColumnDescriptor;
032:        import biz.hammurapi.sql.metadata.KeyEntry;
033:        import biz.hammurapi.sql.metadata.Metadata.TableAcceptor;
034:
035:        /**
036:         * @author Pavel Vlasov
037:         * @version $Revision: 1.9 $
038:         */
039:        public class TableEntry implements  TableAcceptor, ColumnHolder {
040:            private String catalog;
041:            private String schema;
042:            private String table;
043:
044:            /**
045:             * Catalog. Any catalog matches if not set
046:             * @ant.non-required
047:             * @param catalog
048:             */
049:            public void setCatalog(String catalog) {
050:                this .catalog = catalog;
051:            }
052:
053:            /**
054:             * Schema. Any schema matches if not set
055:             * @ant.non-required
056:             * @param catalog
057:             */
058:            public void setSchema(String schema) {
059:                this .schema = schema;
060:            }
061:
062:            /**
063:             * Table. Any table matches if not set
064:             * @ant.non-required
065:             * @param catalog
066:             */
067:            public void setTable(String table) {
068:                this .table = table;
069:            }
070:
071:            public boolean accept(String catalog, String schema, String table) {
072:                return (this .catalog == null || this .catalog.equals(catalog))
073:                        && (this .schema == null || this .schema.equals(schema))
074:                        && (this .table == null || this .table.equals(table));
075:            }
076:
077:            /**
078:             * Column type. Overrides type reported by database.
079:             * @ant.non-required
080:             * @param paramType
081:             */
082:            public void addConfiguredColumn(ColumnType colType) {
083:                if (colType.getName() == null) {
084:                    throw new BuildException(
085:                            "Column name is not set for column type");
086:                }
087:                if (!colType.isSkip() && colType.getType() == null) {
088:                    throw new BuildException(
089:                            "Column type is not set for column "
090:                                    + colType.getName());
091:                }
092:                colTypes.add(colType);
093:            }
094:
095:            private Collection colTypes = new ArrayList();
096:
097:            /**
098:             * @ant.ignore
099:             * @param nigs
100:             */
101:            public void setColTypes(NamedInterfaceGeneratingStatement nigs) {
102:                Iterator it = colTypes.iterator();
103:                while (it.hasNext()) {
104:                    ColumnType ct = (ColumnType) it.next();
105:                    nigs.setColumnType(ct.getName(), ct.getType());
106:                }
107:            }
108:
109:            public String getColType(KeyEntry ke) {
110:                return getColType(ke.getColumnName());
111:            }
112:
113:            /**
114:             * @param columnName
115:             * @return
116:             */
117:            private String getColType(String columnName) {
118:                Iterator it = colTypes.iterator();
119:                while (it.hasNext()) {
120:                    ColumnType ct = (ColumnType) it.next();
121:                    if (columnName.equalsIgnoreCase(ct.getName())) {
122:                        return ct.getType();
123:                    }
124:                }
125:                return null;
126:            }
127:
128:            public String getColType(ColumnDescriptor cd) {
129:                return getColType(cd.getDbName());
130:            }
131:
132:            protected boolean isSkipColumn(ColumnDescriptor cd) {
133:                Iterator it = colTypes.iterator();
134:                while (it.hasNext()) {
135:                    ColumnType ct = (ColumnType) it.next();
136:                    if (cd.getDbName().equalsIgnoreCase(ct.getName())) {
137:                        return ct.isSkip();
138:                    }
139:                }
140:                return false;
141:            }
142:
143:            private boolean generateMutators = true;
144:            private boolean paramPerColumnInsert = true;
145:            private boolean qualifiedTableName;
146:            private boolean qualifiedMethodName;
147:
148:            /**
149:             * Indicates whether table name shall include Catalog and Schema names
150:             * @return
151:             */
152:            public boolean isQualifiedTableName() {
153:                return qualifiedTableName;
154:            }
155:
156:            /**
157:             * Indicates whether table name shall include Catalog and Schema names
158:             * @return
159:             */
160:            public boolean isQualifiedMethodName() {
161:                return qualifiedMethodName;
162:            }
163:
164:            /**
165:             * Indicate where to qualify table name with schema name.
166:             * Valid values are - 'none', 'table', 'method', and 'both'
167:             * @ant.non-required
168:             * @param qualifiedName
169:             */
170:            public void setQualifiedName(String qualifiedName) {
171:                if ("none".equals(qualifiedName)) {
172:                    qualifiedTableName = false;
173:                    qualifiedMethodName = false;
174:                } else if ("table".equals(qualifiedName)) {
175:                    qualifiedTableName = true;
176:                    qualifiedMethodName = false;
177:                } else if ("method".equals(qualifiedName)) {
178:                    qualifiedTableName = false;
179:                    qualifiedMethodName = true;
180:                } else if ("both".equals(qualifiedName)) {
181:                    qualifiedTableName = true;
182:                    qualifiedMethodName = true;
183:                } else {
184:                    throw new BuildException("Invalid value: '"
185:                            + "' expected 'none', 'table', 'method', or 'both'");
186:                }
187:            }
188:
189:            /**
190:             * If 'true' (default) then mutators (setters) are generated along with 
191:             * accessors (getters) in row interfaces.
192:             * @ant.non-required
193:             * @param generateMutator
194:             */
195:            public void setGenerateMutators(boolean generateMutators) {
196:                this .generateMutators = generateMutators;
197:            }
198:
199:            /**
200:             * @return
201:             */
202:            public boolean getGenerateMutators() {
203:                return generateMutators;
204:            }
205:
206:            /**
207:             * If 'true' (default) insert() method is generated for table
208:             * with all columns listed as method parameters. For tables with big number
209:             * of columns it is better off to set this attribute to false and use
210:             * insert(&lt;<I>RowInterface</I>&gt;) method. 
211:             * @ant.non-required
212:             * @param paramPerColumnInsert
213:             * @return
214:             */
215:            public void setParamPerColumnInsert(boolean paramPerColumnInsert) {
216:                this .paramPerColumnInsert = paramPerColumnInsert;
217:            }
218:
219:            /**
220:             * @return Returns the paramPerColumnInsertUpdate.
221:             */
222:            public boolean isParamPerColumnInsert() {
223:                return paramPerColumnInsert;
224:            }
225:
226:            protected StatementCompilerTask task;
227:
228:            void setTask(StatementCompilerTask task) {
229:                this .task = task;
230:            }
231:
232:            StatementCompilerTask getTask() {
233:                return task;
234:            }
235:
236:            /**
237:             * @return
238:             */
239:            boolean getUseSqlTypes() {
240:                if (task == null) {
241:                    throw new BuildException("Task is null");
242:                }
243:
244:                if (useSqlTypes == null) {
245:                    return task.getUseSqlTypes() == null ? false : task
246:                            .getUseSqlTypes().booleanValue();
247:                }
248:
249:                return useSqlTypes.booleanValue();
250:            }
251:
252:            private Boolean useSqlTypes;
253:
254:            /**
255:             * If true then generated classes will use setObject(int, Object, int) method
256:             * instead of setObject(int, Object) to set parameters of object type.
257:             * Inherits value from task. Default value is true.
258:             * @ant.non-required
259:             * @param useSqlTypes
260:             */
261:            public void setUseSqlTypes(boolean useSqlTypes) {
262:                this .useSqlTypes = useSqlTypes ? Boolean.TRUE : Boolean.FALSE;
263:            }
264:
265:            private String smartBase;
266:
267:            /**
268:             * @ant.ignore
269:             * @return Returns the smartBase.
270:             */
271:            String getSmartBase() {
272:                return smartBase == null ? getTask().getSmartBase() : smartBase;
273:            }
274:
275:            /**
276:             * Base class (fully qualified name) for generated smart implementation. Default is biz.hammurapi.sql.DatabaseObject
277:             * The base class is supposed to have same constructors and methods as DatabaseObject. The idea is
278:             * to subclass DatabaseObject to introduce additional qualities like audit, metrics, security, ... whithout
279:             * changing class' contract. If this value is not set explicitly it gets inherited from the task.
280:             * @ant.non-required 
281:             * @param smartBase The smartBase to set.
282:             */
283:            public void setSmartBase(String smartBase) {
284:                this.smartBase = smartBase;
285:            }
286:
287:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.