Source Code Cross Referenced for TKContentAttributeTableData.java in  » Content-Management-System » webman » com » teamkonzept » field » 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 » Content Management System » webman » com.teamkonzept.field.db 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package com.teamkonzept.field.db;
002:
003:        import com.teamkonzept.lib.*;
004:        import com.teamkonzept.db.*;
005:        import com.teamkonzept.field.*;
006:
007:        import java.sql.*;
008:        import java.text.*;
009:
010:        public class TKContentAttributeTableData extends TKDBTableData
011:                implements  TKSortable {
012:
013:            public static int intType = 1;
014:            public static int stringType = 2;
015:            public static int dateType = 3;
016:
017:            public static SimpleDateFormat dateFormat = new SimpleDateFormat(
018:                    "dd.MM.yyyy HH:mm:ss");
019:            public static SimpleDateFormat dateScanFormat = new SimpleDateFormat(
020:                    "d.M.y H:m:s");
021:
022:            public int content_id;
023:            public int value_id;
024:            public int attribute_id;
025:            public int type;
026:            public String name;
027:            public String value;
028:            public String classname;
029:
030:            public TKContentAttributeTableData() {
031:                this .content_id = -1;
032:                this .attribute_id = -1;
033:                this .type = stringType;
034:                this .value = null;
035:
036:                this .value_id = -1;
037:                this .name = null;
038:                this .classname = null;
039:            }
040:
041:            public TKContentAttributeTableData(int content_id,
042:                    int attribute_id, String value) {
043:                this .content_id = content_id;
044:                this .attribute_id = attribute_id;
045:                this .type = stringType;
046:                this .value = value;
047:
048:                this .value_id = -1;
049:                this .name = null;
050:                this .classname = null;
051:
052:                TKContentAttributeOption option = TKContentAttributeOption
053:                        .getOptionById(attribute_id);
054:                if (option != null) {
055:
056:                    this .name = option.name;
057:                    this .type = option.type;
058:                    this .classname = option.classname;
059:                }
060:            }
061:
062:            public TKContentAttributeTableData(int content_id) {
063:                this .content_id = content_id;
064:                this .attribute_id = -1;
065:                this .type = stringType;
066:                this .value = null;
067:
068:                this .value_id = -1;
069:                this .name = null;
070:                this .classname = null;
071:            }
072:
073:            public TKContentAttributeTableData(ResultSet r) throws SQLException {
074:                this .content_id = r.getInt("CONTENT_ID");
075:                this .value_id = r.getInt("VALUE_ID");
076:                this .attribute_id = r.getInt("ATTRIBUTE_ID");
077:                this .type = r.getInt("TYPE");
078:                this .name = r.getString("NAME");
079:                this .classname = r.getString("CLASSNAME");
080:
081:                if (this .type == intType)
082:                    this .value = Integer.toString(r.getInt("INT_VALUE"));
083:                else if (this .type == stringType)
084:                    this .value = r.getString("STR_VALUE");
085:                else if (this .type == dateType)
086:                    this .value = dateFormat
087:                            .format(r.getTimestamp("DATE_VALUE"));
088:                else
089:                    this .value = null;
090:            }
091:
092:            public static String scanValue(String value, int attribute_id)
093:                    throws Exception {
094:                TKContentAttributeOption option = TKContentAttributeOption
095:                        .getOptionById(attribute_id);
096:                if (option == null)
097:                    throw new Exception("attribute_id " + attribute_id
098:                            + " invalid");
099:
100:                if (option.type == stringType)
101:                    return value;
102:                else if (option.type == intType)
103:                    return Integer.toString(Integer.parseInt(value));
104:                else if (option.type != dateType)
105:                    throw new Exception("attribute_id " + attribute_id
106:                            + " invalid");
107:
108:                return dateFormat
109:                        .format(value == null || value.length() == 0 ? new java.util.Date()
110:                                : dateScanFormat.parse(value,
111:                                        new ParsePosition(0)));
112:            }
113:
114:            public void updatePrimary(TKDBVectorData dbData) {
115:
116:                TKContentDBData cdata = (TKContentDBData) dbData;
117:                content_id = cdata.content_id;
118:            }
119:
120:            public void insertIntoQuery(TKQuery query) throws SQLException {
121:                query.setQueryParams("CONTENT_ID", new Integer(content_id));
122:                query.setQueryParams("ATTRIBUTE_ID", new Integer(attribute_id));
123:
124:                if (this .type == intType) {
125:                    query.setQueryParams("STR_VALUE", TKNull.NULL);
126:                    query.setQueryParams("INT_VALUE", new Integer(value));
127:                    query.setQueryParams("DATE_VALUE", TKNull.NULL);
128:                } else if (this .type == stringType) {
129:                    query.setQueryParams("STR_VALUE", value);
130:                    query.setQueryParams("INT_VALUE", TKNull.NULL);
131:                    query.setQueryParams("DATE_VALUE", TKNull.NULL);
132:                } else if (this .type == dateType) {
133:                    query.setQueryParams("STR_VALUE", TKNull.NULL);
134:                    query.setQueryParams("INT_VALUE", TKNull.NULL);
135:
136:                    java.util.Date dt = value == null || value.length() == 0 ? new java.util.Date()
137:                            : dateScanFormat.parse(value, new ParsePosition(0));
138:
139:                    query.setQueryParams("DATE_VALUE", new java.sql.Timestamp(
140:                            dt.getTime()));
141:                } else {
142:                    query.setQueryParams("STR_VALUE", TKNull.NULL);
143:                    query.setQueryParams("INT_VALUE", TKNull.NULL);
144:                    query.setQueryParams("DATE_VALUE", TKNull.NULL);
145:                }
146:                query.setQueryParams("VALUE_ID", new Integer(value_id));
147:            }
148:
149:            public TKDBTableData newFromResultSet(ResultSet r)
150:                    throws SQLException {
151:                return new TKContentAttributeTableData(r);
152:            }
153:
154:            public String toString() {
155:                return "( CONTENT_ID=" + String.valueOf(content_id)
156:                        + ", ATTRIBUTE_ID=" + String.valueOf(attribute_id)
157:                        + ", VALUE_ID=" + String.valueOf(value_id) + ", TYPE="
158:                        + String.valueOf(type) + ", NAME="
159:                        + String.valueOf(name) + ", VALUE="
160:                        + String.valueOf(value) + ")<BR>";
161:            }
162:
163:            public static String typeInfo(int type) {
164:
165:                if (type == TKContentAttributeTableData.intType)
166:                    return "Integer";
167:                else if (type == TKContentAttributeTableData.stringType)
168:                    return "String";
169:                else if (type == TKContentAttributeTableData.dateType)
170:                    return "Date";
171:                else
172:                    return "*** unknown ***";
173:            }
174:
175:            public int cmp(TKSortable other) {
176:
177:                if (!(other instanceof  TKContentAttributeTableData))
178:                    return toString().compareTo(other.toString());
179:
180:                TKContentAttributeTableData otherData = (TKContentAttributeTableData) other;
181:
182:                if ((name == null) && (otherData.name != null))
183:                    return -1;
184:                else if ((name != null) && (otherData.name == null))
185:                    return 1;
186:                else if ((name == null) && (otherData.name == null))
187:                    return 0;
188:                else
189:                    return name.compareTo(otherData.name);
190:            };
191:            //{{DECLARE_CONTROLS
192:            //}}
193:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.