Source Code Cross Referenced for DbColumn.java in  » Web-Framework » helma » helma » objectmodel » db » 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 » Web Framework » helma » helma.objectmodel.db 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Helma License Notice
003:         *
004:         * The contents of this file are subject to the Helma License
005:         * Version 2.0 (the "License"). You may not use this file except in
006:         * compliance with the License. A copy of the License is available at
007:         * http://adele.helma.org/download/helma/license.txt
008:         *
009:         * Copyright 1998-2003 Helma Software. All Rights Reserved.
010:         *
011:         * $RCSfile$
012:         * $Author: root $
013:         * $Revision: 8604 $
014:         * $Date: 2007-09-28 15:16:38 +0200 (Fre, 28 Sep 2007) $
015:         */
016:
017:        package helma.objectmodel.db;
018:
019:        import java.sql.Types;
020:
021:        /**
022:         * A class that encapsulates the Column name and data type of a column in a
023:         * relational table.
024:         */
025:        public final class DbColumn {
026:            private final String name;
027:            private final int type;
028:            private final Relation relation;
029:
030:            private final boolean isId;
031:            private final boolean isPrototype;
032:            private final boolean isName;
033:
034:            /**
035:             * Constructor
036:             */
037:            public DbColumn(String name, int type, Relation rel, DbMapping dbmap) {
038:                this .name = name;
039:                this .type = type;
040:                this .relation = rel;
041:
042:                if (relation != null) {
043:                    relation.setColumnType(type);
044:                }
045:
046:                isId = name.equalsIgnoreCase(dbmap.getIDField());
047:                isPrototype = name.equalsIgnoreCase(dbmap.getPrototypeField());
048:                isName = name.equalsIgnoreCase(dbmap.getNameField());
049:            }
050:
051:            /**
052:             * Get the column name.
053:             */
054:            public String getName() {
055:                return name;
056:            }
057:
058:            /**
059:             * Get this columns SQL data type.
060:             */
061:            public int getType() {
062:                return type;
063:            }
064:
065:            /**
066:             * Return the relation associated with this column. May be null.
067:             */
068:            public Relation getRelation() {
069:                return relation;
070:            }
071:
072:            /**
073:             * Returns true if this column serves as ID field for the prototype.
074:             */
075:            public boolean isIdField() {
076:                return isId;
077:            }
078:
079:            /**
080:             * Returns true if this column serves as prototype field for the prototype.
081:             */
082:            public boolean isPrototypeField() {
083:                return isPrototype;
084:            }
085:
086:            /**
087:             * Returns true if this column serves as name field for the prototype.
088:             */
089:            public boolean isNameField() {
090:                return isName;
091:            }
092:
093:            /**
094:             * Returns true if this field is mapped by the prototype's db mapping.
095:             */
096:            public boolean isMapped() {
097:                // Note: not sure if check for primitive or reference relation is really
098:                // needed, but we did it before, so we leave it in for safety.
099:                return isId
100:                        || isPrototype
101:                        || isName
102:                        || (relation != null && relation
103:                                .isPrimitiveOrReference());
104:            }
105:
106:            /**
107:             * Checks whether values for this column need to be quoted in insert/update
108:             * stmts
109:             * 
110:             * @return true if values need to be wrapped in quotes
111:             */
112:            public boolean needsQuotes() {
113:                switch (type) {
114:                case Types.CHAR:
115:                case Types.VARCHAR:
116:                case Types.LONGVARCHAR:
117:                case Types.BINARY:
118:                case Types.VARBINARY:
119:                case Types.LONGVARBINARY:
120:                case Types.DATE:
121:                case Types.TIME:
122:                case Types.TIMESTAMP:
123:                    return true;
124:                default:
125:                    return false;
126:                }
127:            }
128:
129:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.