Source Code Cross Referenced for ContextMethodBuilder.java in  » XML » jibx-1.1.5 » org » jibx » binding » classes » 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 » XML » jibx 1.1.5 » org.jibx.binding.classes 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:        Copyright (c) 2003-2005, Dennis M. Sosnoski
003:        All rights reserved.
004:
005:        Redistribution and use in source and binary forms, with or without modification,
006:        are permitted provided that the following conditions are met:
007:
008:         * Redistributions of source code must retain the above copyright notice, this
009:           list of conditions and the following disclaimer.
010:         * Redistributions in binary form must reproduce the above copyright notice,
011:           this list of conditions and the following disclaimer in the documentation
012:           and/or other materials provided with the distribution.
013:         * Neither the name of JiBX nor the names of its contributors may be used
014:           to endorse or promote products derived from this software without specific
015:           prior written permission.
016:
017:        THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
018:        ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
019:        WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
020:        DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
021:        ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
022:        (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
023:        LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
024:        ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
025:        (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
026:        SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
027:         */
028:
029:        package org.jibx.binding.classes;
030:
031:        import org.apache.bcel.Constants;
032:        import org.apache.bcel.generic.*;
033:        import org.jibx.runtime.JiBXException;
034:
035:        /**
036:         * Builder for binding methods with a context and current object. Tracks the
037:         * current object reference and the context object reference positions in the 
038:         * local variables table.
039:         *
040:         * @author Dennis M. Sosnoski
041:         * @version 1.0
042:         */
043:
044:        public class ContextMethodBuilder extends ExceptionMethodBuilder {
045:            /** Variable slot for current object reference. */
046:            private int m_objectSlot;
047:
048:            /** Object type as accessed by method. */
049:            private String m_objectType;
050:
051:            /** Variable slot for context reference. */
052:            private int m_contextSlot;
053:
054:            /** Context type as accessed by method. */
055:            private String m_contextType;
056:
057:            /** Context type as accessed by method. */
058:            private final boolean m_isStatic;
059:
060:            /**
061:             * Constructor with types specified. This sets up for constructing a
062:             * binding method that uses a current object and a marshalling or
063:             * unmarshalling context.
064:             *
065:             * @param name method name to be built
066:             * @param ret method return type
067:             * @param args types of arguments
068:             * @param cf owning class file information
069:             * @param access flags for method access
070:             * @param obj variable slot for current object (negative value if to be
071:             * defined later)
072:             * @param type current object type as defined in method
073:             * @param ctx variable slot for marshalling/unmarshalling context
074:             * @param ctype context type as defined in method
075:             * @throws JiBXException on error in initializing method construction
076:             */
077:
078:            public ContextMethodBuilder(String name, Type ret, Type[] args,
079:                    ClassFile cf, int access, int obj, String type, int ctx,
080:                    String ctype) throws JiBXException {
081:                super (name, ret, args, cf, access);
082:                m_objectSlot = obj;
083:                m_objectType = type;
084:                m_contextSlot = ctx;
085:                m_contextType = ctype;
086:                m_isStatic = (access & Constants.ACC_STATIC) != 0;
087:                addException(FRAMEWORK_EXCEPTION_CLASS);
088:            }
089:
090:            /**
091:             * Constructor from signature.
092:             *
093:             * @param name method name to be built
094:             * @param sig method signature
095:             * @param cf owning class file information
096:             * @param access flags for method access
097:             * @param obj variable slot for current object (negative value if to be
098:             * defined later)
099:             * @param type current object type
100:             * @param ctx variable slot for marshalling/unmarshalling context
101:             * @param ctype context type as defined in method
102:             * @throws JiBXException on error in initializing method construction
103:             */
104:
105:            public ContextMethodBuilder(String name, String sig, ClassFile cf,
106:                    int access, int obj, String type, int ctx, String ctype)
107:                    throws JiBXException {
108:                this (name, Type.getReturnType(sig), Type.getArgumentTypes(sig),
109:                        cf, access, obj, type, ctx, ctype);
110:            }
111:
112:            /**
113:             * Constructor from signature for public, final method.
114:             *
115:             * @param name method name to be built
116:             * @param sig method signature
117:             * @param cf owning class file information
118:             * @param obj variable slot for current object (negative value if to be
119:             * defined later)
120:             * @param type current object type
121:             * @param ctx variable slot for marshalling/unmarshalling context
122:             * @param ctype context type as defined in method
123:             * @throws JiBXException on error in initializing method construction
124:             */
125:
126:            public ContextMethodBuilder(String name, String sig, ClassFile cf,
127:                    int obj, String type, int ctx, String ctype)
128:                    throws JiBXException {
129:                this (name, sig, cf, Constants.ACC_PUBLIC | Constants.ACC_FINAL,
130:                        obj, type, ctx, ctype);
131:            }
132:
133:            /**
134:             * Set current object slot. Sets the local variable position of the current
135:             * object, as required when the object is actually created within the
136:             * method.
137:             *
138:             * @param slot local variable slot for current object
139:             */
140:
141:            public void setObjectSlot(int slot) {
142:                m_objectSlot = slot;
143:            }
144:
145:            /**
146:             * Append instruction to load object to stack.
147:             */
148:
149:            public void loadObject() {
150:                appendLoadLocal(m_objectSlot);
151:            }
152:
153:            /**
154:             * Append instruction to store object from stack.
155:             */
156:
157:            public void storeObject() {
158:                if (m_objectSlot < 0) {
159:                    LocalVariableGen var = createLocal("obj", ClassItem
160:                            .typeFromName(m_objectType));
161:                    m_objectSlot = var.getIndex();
162:                } else {
163:                    appendCreateCast(m_objectType);
164:                    appendStoreLocal(m_objectSlot);
165:                }
166:            }
167:
168:            /**
169:             * Append instruction(s) to load object to stack as specified type.
170:             *
171:             * @param type loaded type expected on stack
172:             */
173:
174:            public void loadObject(String type) {
175:                appendLoadLocal(m_objectSlot);
176:                if (!m_objectType.equals(type)) {
177:                    appendCreateCast(m_objectType, type);
178:                }
179:            }
180:
181:            /**
182:             * Append instruction to load context to stack.
183:             */
184:
185:            public void loadContext() {
186:                appendLoadLocal(m_contextSlot);
187:            }
188:
189:            /**
190:             * Append instruction(s) to load context to stack as specified type.
191:             *
192:             * @param type loaded type expected on stack
193:             */
194:
195:            public void loadContext(String type) {
196:                appendLoadLocal(m_contextSlot);
197:                if (!m_contextType.equals(type)) {
198:                    appendCreateCast(m_contextType, type);
199:                }
200:            }
201:
202:            /**
203:             * Check if method is static.
204:             * 
205:             * @return <code>true</code> if static, <code>false</code> if not
206:             */
207:            public boolean isStaticMethod() {
208:                return m_isStatic;
209:            }
210:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.