Source Code Cross Referenced for JVar.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.lang.annotation.Annotation;
024:        import java.util.ArrayList;
025:        import java.util.List;
026:
027:        /**
028:         * Variables and fields.
029:         */
030:
031:        public class JVar extends JExpressionImpl implements  JDeclaration,
032:                JAssignmentTarget, JAnnotatable {
033:
034:            /**
035:             * Modifiers.
036:             */
037:            private JMods mods;
038:
039:            /**
040:             * JType of the variable
041:             */
042:            private JType type;
043:
044:            /**
045:             * Name of the variable
046:             */
047:            private String name;
048:
049:            /**
050:             * Initialization of the variable in its declaration
051:             */
052:            private JExpression init;
053:
054:            /**
055:             * Annotations on this variable. Lazily created.
056:             */
057:            private List<JAnnotationUse> annotations = null;
058:
059:            /**
060:             * JVar constructor
061:             *
062:             * @param type
063:             *        Datatype of this variable
064:             *
065:             * @param name
066:             *        Name of this variable
067:             *
068:             * @param init
069:             *        Value to initialize this variable to
070:             */
071:            JVar(JMods mods, JType type, String name, JExpression init) {
072:                this .mods = mods;
073:                this .type = type;
074:                this .name = name;
075:                this .init = init;
076:            }
077:
078:            /**
079:             * Initialize this variable
080:             *
081:             * @param init
082:             *        JExpression to be used to initialize this field
083:             */
084:            public JVar init(JExpression init) {
085:                this .init = init;
086:                return this ;
087:            }
088:
089:            /**
090:             * Get the name of this variable
091:             *
092:             * @return Name of the variable
093:             */
094:            public String name() {
095:                return name;
096:            }
097:
098:            /**
099:             * Changes the name of this variable.
100:             */
101:            public void name(String name) {
102:                if (!JJavaName.isJavaIdentifier(name))
103:                    throw new IllegalArgumentException();
104:                this .name = name;
105:            }
106:
107:            /**
108:             * Return the type of this variable.
109:             * @return
110:             *      always non-null.
111:             */
112:            public JType type() {
113:                return type;
114:            }
115:
116:            /**
117:             * @return
118:             *      the current modifiers of this method.
119:             *      Always return non-null valid object.
120:             */
121:            public JMods mods() {
122:                return mods;
123:            }
124:
125:            /**
126:             * Sets the type of this variable.
127:             *
128:             * @param newType
129:             *      must not be null.
130:             *
131:             * @return
132:             *      the old type value. always non-null.
133:             */
134:            public JType type(JType newType) {
135:                JType r = type;
136:                if (newType == null)
137:                    throw new IllegalArgumentException();
138:                type = newType;
139:                return r;
140:            }
141:
142:            /**
143:             * Adds an annotation to this variable.
144:             * @param clazz
145:             *          The annotation class to annotate the field with
146:             */
147:            public JAnnotationUse annotate(JClass clazz) {
148:                if (annotations == null)
149:                    annotations = new ArrayList<JAnnotationUse>();
150:                JAnnotationUse a = new JAnnotationUse(clazz);
151:                annotations.add(a);
152:                return a;
153:            }
154:
155:            /**
156:             * Adds an annotation to this variable.
157:             *
158:             * @param clazz
159:             *          The annotation class to annotate the field with
160:             */
161:            public JAnnotationUse annotate(Class<? extends Annotation> clazz) {
162:                return annotate(type.owner().ref(clazz));
163:            }
164:
165:            public <W extends JAnnotationWriter> W annotate2(Class<W> clazz) {
166:                return TypedAnnotationWriter.create(clazz, this );
167:            }
168:
169:            protected boolean isAnnotated() {
170:                return annotations != null;
171:            }
172:
173:            public void bind(JFormatter f) {
174:                if (annotations != null) {
175:                    for (int i = 0; i < annotations.size(); i++)
176:                        f.g(annotations.get(i)).nl();
177:                }
178:                f.g(mods).g(type).id(name);
179:                if (init != null)
180:                    f.p('=').g(init);
181:            }
182:
183:            public void declare(JFormatter f) {
184:                f.b(this ).p(';').nl();
185:            }
186:
187:            public void generate(JFormatter f) {
188:                f.id(name);
189:            }
190:
191:            public JExpression assign(JExpression rhs) {
192:                return JExpr.assign(this , rhs);
193:            }
194:
195:            public JExpression assignPlus(JExpression rhs) {
196:                return JExpr.assignPlus(this, rhs);
197:            }
198:
199:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.