Source Code Cross Referenced for JInvocation.java in  » 6.0-JDK-Modules » jaxb-xjc » com » sun » codemodel » 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 » 6.0 JDK Modules » jaxb xjc » com.sun.codemodel 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * The contents of this file are subject to the terms
003:         * of the Common Development and Distribution License
004:         * (the "License").  You may not use this file except
005:         * in compliance with the License.
006:         * 
007:         * You can obtain a copy of the license at
008:         * https://jwsdp.dev.java.net/CDDLv1.0.html
009:         * See the License for the specific language governing
010:         * permissions and limitations under the License.
011:         * 
012:         * When distributing Covered Code, include this CDDL
013:         * HEADER in each file and include the License file at
014:         * https://jwsdp.dev.java.net/CDDLv1.0.html  If applicable,
015:         * add the following below this CDDL HEADER, with the
016:         * fields enclosed by brackets "[]" replaced with your
017:         * own identifying information: Portions Copyright [yyyy]
018:         * [name of copyright owner]
019:         */
020:
021:        package com.sun.codemodel;
022:
023:        import java.util.ArrayList;
024:        import java.util.List;
025:
026:        /**
027:         * JMethod invocation
028:         */
029:        public final class JInvocation extends JExpressionImpl implements 
030:                JStatement {
031:
032:            /**
033:             * Object expression upon which this method will be invoked, or null if
034:             * this is a constructor invocation
035:             */
036:            private JGenerable object;
037:
038:            /**
039:             * Name of the method to be invoked.
040:             * Either this field is set, or {@link #method}, or {@link #type} (in which case it's a
041:             * constructor invocation.)
042:             * This allows {@link JMethod#name(String) the name of the method to be changed later}.
043:             */
044:            private String name;
045:
046:            private JMethod method;
047:
048:            private boolean isConstructor = false;
049:
050:            /**
051:             * List of argument expressions for this method invocation
052:             */
053:            private List<JExpression> args = new ArrayList<JExpression>();
054:
055:            /**
056:             * If isConstructor==true, this field keeps the type to be created.
057:             */
058:            private JType type = null;
059:
060:            /**
061:             * Invokes a method on an object.
062:             *
063:             * @param object
064:             *        JExpression for the object upon which
065:             *        the named method will be invoked,
066:             *        or null if none
067:             *
068:             * @param name
069:             *        Name of method to invoke
070:             */
071:            JInvocation(JExpression object, String name) {
072:                this ((JGenerable) object, name);
073:            }
074:
075:            JInvocation(JExpression object, JMethod method) {
076:                this ((JGenerable) object, method);
077:            }
078:
079:            /**
080:             * Invokes a static method on a class.
081:             */
082:            JInvocation(JClass type, String name) {
083:                this ((JGenerable) type, name);
084:            }
085:
086:            JInvocation(JClass type, JMethod method) {
087:                this ((JGenerable) type, method);
088:            }
089:
090:            private JInvocation(JGenerable object, String name) {
091:                this .object = object;
092:                if (name.indexOf('.') >= 0)
093:                    throw new IllegalArgumentException(
094:                            "method name contains '.': " + name);
095:                this .name = name;
096:            }
097:
098:            private JInvocation(JGenerable object, JMethod method) {
099:                this .object = object;
100:                this .method = method;
101:            }
102:
103:            /**
104:             * Invokes a constructor of an object (i.e., creates
105:             * a new object.)
106:             * 
107:             * @param c
108:             *      Type of the object to be created. If this type is
109:             *      an array type, added arguments are treated as array
110:             *      initializer. Thus you can create an expression like
111:             *      <code>new int[]{1,2,3,4,5}</code>.
112:             */
113:            JInvocation(JType c) {
114:                this .isConstructor = true;
115:                this .type = c;
116:            }
117:
118:            /**
119:             *  Add an expression to this invocation's argument list
120:             *
121:             * @param arg
122:             *        Argument to add to argument list
123:             */
124:            public JInvocation arg(JExpression arg) {
125:                if (arg == null)
126:                    throw new IllegalArgumentException();
127:                args.add(arg);
128:                return this ;
129:            }
130:
131:            /**
132:             * Adds a literal argument.
133:             *
134:             * Short for {@code arg(JExpr.lit(v))}
135:             */
136:            public JInvocation arg(String v) {
137:                return arg(JExpr.lit(v));
138:            }
139:
140:            public void generate(JFormatter f) {
141:                if (isConstructor && type.isArray()) {
142:                    // [RESULT] new T[]{arg1,arg2,arg3,...};
143:                    f.p("new").g(type).p('{');
144:                } else {
145:                    if (isConstructor)
146:                        f.p("new").g(type).p('(');
147:                    else {
148:                        String name = this .name;
149:                        if (name == null)
150:                            name = this .method.name();
151:
152:                        if (object != null)
153:                            f.g(object).p('.').p(name).p('(');
154:                        else
155:                            f.id(name).p('(');
156:                    }
157:                }
158:
159:                f.g(args);
160:
161:                if (isConstructor && type.isArray())
162:                    f.p('}');
163:                else
164:                    f.p(')');
165:
166:                if (type instanceof  JDefinedClass
167:                        && ((JDefinedClass) type).isAnonymous()) {
168:                    ((JAnonymousClass) type).declareBody(f);
169:                }
170:            }
171:
172:            public void state(JFormatter f) {
173:                f.g(this ).p(';').nl();
174:            }
175:
176:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.