Source Code Cross Referenced for CharColumn.java in  » J2EE » hgcommons » biz » hammurapi » sql » columns » 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 » J2EE » hgcommons » biz.hammurapi.sql.columns 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * hgcommons 7
003:         * Hammurapi Group Common Library 
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/hammurapi-biz/ef/xmenu/hammurapi-group/products/products/hgcommons/index.html
021:         * e-Mail: support@hammurapi.biz
022:         */
023:        package biz.hammurapi.sql.columns;
024:
025:        import java.sql.PreparedStatement;
026:        import java.sql.ResultSet;
027:        import java.sql.ResultSetMetaData;
028:        import java.sql.SQLException;
029:
030:        import biz.hammurapi.config.Context;
031:        import biz.hammurapi.convert.CompositeConverter;
032:
033:        /**
034:         * @author Pavel Vlasov
035:         *
036:         * @version $Revision: 1.11 $
037:         */
038:        public class CharColumn extends Column {
039:            private char value;
040:
041:            // Original stuff	
042:            private char originalValue;
043:            private boolean isOriginalValueSet;
044:
045:            public char getOriginalValue() {
046:                return isOriginalValueSet ? originalValue : value;
047:            }
048:
049:            public void parameterizeOriginal(PreparedStatement ps, int idx)
050:                    throws SQLException {
051:                ps.setInt(idx, getOriginalValue());
052:            }
053:
054:            public void setOriginal() {
055:                originalValue = value;
056:                isOriginalValueSet = true;
057:            }
058:
059:            // End of original stuff
060:
061:            public char getValue() {
062:                return value;
063:            }
064:
065:            public void setValue(char value) {
066:                if (force || this .value != value) {
067:                    this .value = value;
068:                    onChange();
069:                }
070:            }
071:
072:            public CharColumn(String name, boolean isPrimaryKey) {
073:                super (name, isPrimaryKey);
074:            }
075:
076:            public CharColumn(String name, boolean isPrimaryKey, char value) {
077:                super (name, isPrimaryKey);
078:                this .value = value;
079:            }
080:
081:            public CharColumn(String name, boolean isPrimaryKey, ResultSet rs)
082:                    throws SQLException {
083:                super (name, isPrimaryKey);
084:                ResultSetMetaData metaData = rs.getMetaData();
085:                for (int i = 1, c = metaData.getColumnCount(); i <= c; i++) {
086:                    if (name.equals(metaData.getColumnName(i))) {
087:                        String strVal = rs.getString(i);
088:                        if (strVal != null && strVal.length() >= 1) {
089:                            this .value = strVal.charAt(0);
090:                        }
091:                        break;
092:                    }
093:                }
094:            }
095:
096:            protected void parameterizeInternal(PreparedStatement ps, int idx)
097:                    throws SQLException {
098:                ps.setInt(idx, value);
099:            }
100:
101:            public Object getObjectValue(boolean ov) {
102:                if (ov) {
103:                    return isOriginalValueSet ? new Character(originalValue)
104:                            : null;
105:                }
106:                return new Character(value);
107:            }
108:
109:            public String toString() {
110:                return getName() + (isModified() ? "*" : "") + "='" + value
111:                        + "'";
112:            }
113:
114:            public boolean equals(Object otherColumn) {
115:                if (otherColumn instanceof  CharColumn) {
116:                    return value == ((CharColumn) otherColumn).value;
117:                }
118:
119:                return false;
120:            }
121:
122:            public int hashCode() {
123:                return getName().hashCode() ^ value;
124:            }
125:
126:            public void load(String textValue) {
127:                setValue(textValue.length() == 0 ? 0 : textValue.charAt(0));
128:            }
129:
130:            public void clear() {
131:                setValue((char) 0);
132:                clearModified();
133:            }
134:
135:            public void configure(Context context, CompositeConverter converter) {
136:                Object o = context.get(getName());
137:                if (o != null) {
138:                    setValue(((Character) converter.convert(o, char.class,
139:                            false)).charValue());
140:                }
141:            }
142:
143:            protected String getType() {
144:                return "char";
145:            }
146:
147:            public void set(Column source) {
148:                setValue(((CharColumn) source).getValue());
149:            }
150:
151:            /**
152:             * Clears modified flag and sets original value to current value.
153:             */
154:            public void clearModified() {
155:                super.clearModified();
156:                originalValue = value;
157:            }
158:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.