Source Code Cross Referenced for FieldDefinition.java in  » Web-Framework » JAT » com » jat » integration » 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 » JAT » com.jat.integration.db 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package com.jat.integration.db;
002:
003:        import com.jat.core.config.Config;
004:        import com.jat.core.log.LogManager;
005:        import com.jat.integration.GenericFieldDefinition;
006:        import com.jat.integration.IntegrationException;
007:        import com.jat.integration.db.plugin.ConverterPlugin;
008:
009:        /**
010:         * <p>Title: JAT</p>
011:         * <p>Description: </p>
012:         * <p>Copyright: Copyright (c) 2004 -2005 Stefano Fratini (stefano.fratini@gmail.com)</p>
013:         * <p>Distributed under the terms of the GNU Lesser General Public License, v2.1 or later</p>
014:         * @author stf
015:         * @version 1.0
016:         * @since 1.2
017:         */
018:
019:        public class FieldDefinition extends GenericFieldDefinition {
020:
021:            public static final String CONFIG_TYPE = ".type";
022:            public static final String CONFIG_PLUGIN = ".plugin";
023:            public static final String CONFIG_OUTPUT = ".output";
024:
025:            public final static int STRING_ARRAY = 10000;
026:            public final static int INT_ARRAY = 11000;
027:
028:            protected void init(String section, String key, String queryName)
029:                    throws IntegrationException {
030:                super .init(section, key, queryName);
031:                try {
032:                    // set type
033:                    String ft = null;
034:                    try {
035:                        ft = Config.getCurrent().getValue(section,
036:                                key + CONFIG_TYPE);
037:                    } catch (Exception ignored) {
038:                        ft = "-1";
039:                    }
040:                    this .setType(ft);
041:                    LogManager.sendDebug(this .getClass().getName() + "::init: "
042:                            + section + "/" + queryName + "/Type = "
043:                            + this .getType());
044:                    // set plugin
045:                    String fieldPlugin = null;
046:                    try {
047:                        fieldPlugin = Config.getCurrent().getValue(section,
048:                                key + CONFIG_PLUGIN);
049:                    } catch (Exception ignored) {
050:                    }
051:                    LogManager.sendDebug(this .getClass().getName() + "::init: "
052:                            + section + "/" + queryName + "/Plugin = "
053:                            + fieldPlugin);
054:                    try {
055:                        if (fieldPlugin != null)
056:                            this .setPlugin(fieldPlugin);
057:                    } catch (Exception pex) {
058:                        throw new IntegrationException(this .getClass()
059:                                .getName()
060:                                + "::init: wrong plugin '"
061:                                + fieldPlugin
062:                                + "' for field '"
063:                                + this .getName()
064:                                + "' for query '"
065:                                + section
066:                                + "/"
067:                                + queryName
068:                                + "': " + pex);
069:                    }
070:                    // set output
071:                    boolean output = false;
072:                    try {
073:                        output = (Config.getCurrent().getValue(section, key
074:                                + CONFIG_OUTPUT)).equalsIgnoreCase("true");
075:                    } catch (Exception ignored) {
076:                    }
077:                    this .setOutput(output);
078:                    LogManager.sendDebug(this .getClass().getName() + "::init: "
079:                            + section + "/" + queryName + "/Output = "
080:                            + this .isOutput());
081:                } catch (Exception ex) {
082:                    throw new IntegrationException(this .getClass().getName()
083:                            + "::init: " + ex);
084:                }
085:            }
086:
087:            public FieldDefinition() {
088:                super ();
089:                this .setOutput(false);
090:                try {
091:                    this .setType("-1");
092:                } catch (Exception ignored) {
093:                }
094:            }
095:
096:            public boolean isArrayType() {
097:                return (this .getType() == STRING_ARRAY || this .getType() == INT_ARRAY);
098:            }
099:
100:            public Object convertValue(Object value)
101:                    throws IntegrationException {
102:                if (this .getPlugin() != null) {
103:                    try {
104:                        return ((ConverterPlugin) Class.forName(
105:                                this .getPlugin()).newInstance()).convert(value);
106:                    } catch (Exception ex) {
107:                        throw new IntegrationException(this .getClass()
108:                                + ":: convertValue: exception: " + ex);
109:                    }
110:                }
111:                return value;
112:            }
113:
114:            public int getType() {
115:                try {
116:                    return Integer.parseInt(this .getProperties().getProperty(
117:                            "type"));
118:                } catch (Exception ex) {
119:                    return -1;
120:                }
121:            }
122:
123:            public void setType(String type) throws IntegrationException {
124:                try {
125:                    if (type != null) {
126:                        int t = Integer.parseInt(type);
127:                        this .getProperties().setProperty("type", type);
128:                    }
129:                } catch (Exception intEx) {
130:                    throw new IntegrationException(
131:                            "wrong field type for field '" + this .getName()
132:                                    + "': " + type);
133:                }
134:            }
135:
136:            public String getPlugin() {
137:                return this .getProperties().getProperty("plugin");
138:            }
139:
140:            public void setPlugin(String plugin) throws ClassNotFoundException {
141:                Class c = Class.forName(plugin);
142:                this .getProperties().setProperty("plugin", plugin);
143:            }
144:
145:            public boolean isOutput() {
146:                try {
147:                    return this .getProperties().getProperty("output")
148:                            .equalsIgnoreCase("true");
149:                } catch (Exception ex) {
150:                    return false;
151:                }
152:            }
153:
154:            public void setOutput(boolean output) {
155:                this .getProperties().setProperty("output", "" + output);
156:            }
157:
158:            public String toString() {
159:                return "[" + this .getName() + "|" + this .getType() + "|"
160:                        + this .getPlugin() + "|" + this .isOutput() + "]";
161:            }
162:
163:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.