Source Code Cross Referenced for BaseParser.java in  » Database-ORM » iBATIS » com » ibatis » sqlmap » engine » builder » xml » 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 » iBATIS » com.ibatis.sqlmap.engine.builder.xml 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package com.ibatis.sqlmap.engine.builder.xml;
002:
003:        import com.ibatis.common.beans.Probe;
004:        import com.ibatis.common.beans.ProbeFactory;
005:        import com.ibatis.common.resources.Resources;
006:
007:        import com.ibatis.sqlmap.engine.cache.CacheModel;
008:        import com.ibatis.sqlmap.engine.impl.ExtendedSqlMapClient;
009:        import com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate;
010:        import com.ibatis.sqlmap.engine.mapping.parameter.BasicParameterMap;
011:        import com.ibatis.sqlmap.engine.mapping.result.BasicResultMap;
012:        import com.ibatis.sqlmap.engine.mapping.result.Discriminator;
013:        import com.ibatis.sqlmap.engine.mapping.statement.MappedStatement;
014:        import com.ibatis.sqlmap.engine.scope.ErrorContext;
015:        import com.ibatis.sqlmap.engine.type.DomTypeMarker;
016:        import com.ibatis.sqlmap.engine.type.TypeHandler;
017:        import com.ibatis.sqlmap.engine.type.TypeHandlerFactory;
018:
019:        import javax.sql.DataSource;
020:        import java.util.HashMap;
021:        import java.util.List;
022:        import java.util.Map;
023:        import java.util.Properties;
024:
025:        public abstract class BaseParser {
026:
027:            private static final Probe PROBE = ProbeFactory.getProbe();
028:
029:            protected final Variables vars;
030:
031:            protected BaseParser(Variables vars) {
032:                this .vars = vars;
033:            }
034:
035:            public TypeHandler resolveTypeHandler(
036:                    TypeHandlerFactory typeHandlerFactory, Class clazz,
037:                    String propertyName, String javaType, String jdbcType) {
038:                return resolveTypeHandler(typeHandlerFactory, clazz,
039:                        propertyName, javaType, jdbcType, false);
040:            }
041:
042:            public TypeHandler resolveTypeHandler(
043:                    TypeHandlerFactory typeHandlerFactory, Class clazz,
044:                    String propertyName, String javaType, String jdbcType,
045:                    boolean useSetterToResolve) {
046:                TypeHandler handler = null;
047:                if (clazz == null) {
048:                    // Unknown
049:                    handler = typeHandlerFactory.getUnkownTypeHandler();
050:                } else if (DomTypeMarker.class.isAssignableFrom(clazz)) {
051:                    // DOM
052:                    handler = typeHandlerFactory.getTypeHandler(String.class,
053:                            jdbcType);
054:                } else if (java.util.Map.class.isAssignableFrom(clazz)) {
055:                    // Map
056:                    if (javaType == null) {
057:                        handler = typeHandlerFactory.getUnkownTypeHandler(); //BUG 1012591 - typeHandlerFactory.getTypeHandler(java.lang.Object.class, jdbcType);
058:                    } else {
059:                        try {
060:                            Class javaClass = Resources.classForName(javaType);
061:                            handler = typeHandlerFactory.getTypeHandler(
062:                                    javaClass, jdbcType);
063:                        } catch (Exception e) {
064:                            throw new RuntimeException(
065:                                    "Error.  Could not set TypeHandler.  Cause: "
066:                                            + e, e);
067:                        }
068:                    }
069:                } else if (typeHandlerFactory.getTypeHandler(clazz, jdbcType) != null) {
070:                    // Primitive
071:                    handler = typeHandlerFactory
072:                            .getTypeHandler(clazz, jdbcType);
073:                } else {
074:                    // JavaBean
075:                    if (javaType == null) {
076:                        if (useSetterToResolve) {
077:                            Class type = PROBE.getPropertyTypeForSetter(clazz,
078:                                    propertyName);
079:                            handler = typeHandlerFactory.getTypeHandler(type,
080:                                    jdbcType);
081:                        } else {
082:                            Class type = PROBE.getPropertyTypeForGetter(clazz,
083:                                    propertyName);
084:                            handler = typeHandlerFactory.getTypeHandler(type,
085:                                    jdbcType);
086:                        }
087:                    } else {
088:                        try {
089:                            Class javaClass = Resources.classForName(javaType);
090:                            handler = typeHandlerFactory.getTypeHandler(
091:                                    javaClass, jdbcType);
092:                        } catch (Exception e) {
093:                            throw new RuntimeException(
094:                                    "Error.  Could not set TypeHandler.  Cause: "
095:                                            + e, e);
096:                        }
097:                    }
098:                }
099:                return handler;
100:            }
101:
102:            public String applyNamespace(String id) {
103:                String newId = id;
104:                if (vars.currentNamespace != null
105:                        && vars.currentNamespace.length() > 0 && id != null
106:                        && id.indexOf('.') < 0) {
107:                    newId = vars.currentNamespace + "." + id;
108:                }
109:                return newId;
110:            }
111:
112:            /**
113:             * Variables the parser uses.  This "struct" like class is necessary because
114:             * anonymous inner classes do not have access to non-final member fields of the parent class.
115:             * This way, we can make the Variables instance final, and use all of its public fields as
116:             * variables for parsing state.
117:             */
118:            protected static class Variables {
119:                public ErrorContext errorCtx = new ErrorContext();
120:
121:                public Properties txProps = new Properties();
122:                public Properties dsProps = new Properties();
123:                public ErrorContext errorContext = new ErrorContext();
124:                public Properties properties;
125:
126:                public XmlConverter sqlMapConv;
127:                public XmlConverter sqlMapConfigConv;
128:
129:                public String currentResource = "SQL Map XML Config File";
130:                public String currentNamespace = null;
131:
132:                public ExtendedSqlMapClient client;
133:                public SqlMapExecutorDelegate delegate;
134:                public TypeHandlerFactory typeHandlerFactory;
135:                public DataSource dataSource;
136:
137:                public boolean useStatementNamespaces = false;
138:
139:                public Integer defaultStatementTimeout = null;
140:
141:                // SQL Map Vars
142:                public Properties currentProperties;
143:                public CacheModel currentCacheModel;
144:                public BasicResultMap currentResultMap;
145:                public BasicParameterMap currentParameterMap;
146:                public MappedStatement currentStatement;
147:                public List parameterMappingList;
148:                public List resultMappingList;
149:                public int resultMappingIndex;
150:                public Map sqlIncludes = new HashMap();
151:                public Discriminator discriminator;
152:            }
153:
154:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.