author | thurka |
Mon, 16 Nov 2009 15:33:05 +0100 | |
changeset 4240 | ca8d98aeb09e |
parent 2678 | 57cf2a1c1a05 |
permissions | -rw-r--r-- |
8 | 1 |
/* |
2678
57cf2a1c1a05
6831313: update jaxws in OpenJDK7 to 2.1 plus bug fixes from OpenJDK 6
tbell
parents:
8
diff
changeset
|
2 |
* Copyright 2005-2006 Sun Microsystems, Inc. All Rights Reserved. |
8 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
7 |
* published by the Free Software Foundation. Sun designates this |
|
8 |
* particular file as subject to the "Classpath" exception as provided |
|
9 |
* by Sun in the LICENSE file that accompanied this code. |
|
10 |
* |
|
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
15 |
* accompanied this code). |
|
16 |
* |
|
17 |
* You should have received a copy of the GNU General Public License version |
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
20 |
* |
|
21 |
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, |
|
22 |
* CA 95054 USA or visit www.sun.com if you need additional information or |
|
23 |
* have any questions. |
|
24 |
*/ |
|
25 |
||
26 |
package com.sun.codemodel.internal; |
|
27 |
||
28 |
||
29 |
||
30 |
||
31 |
/** |
|
32 |
* A field that can have a {@link JDocComment} associated with it |
|
33 |
*/ |
|
34 |
public class JFieldVar extends JVar { |
|
35 |
||
36 |
/** |
|
37 |
* javadoc comments for this JFieldVar |
|
38 |
*/ |
|
39 |
private JDocComment jdoc = null; |
|
40 |
||
41 |
private final JDefinedClass owner; |
|
42 |
||
43 |
||
44 |
/** |
|
45 |
* JFieldVar constructor |
|
46 |
* |
|
47 |
* @param type |
|
48 |
* Datatype of this variable |
|
49 |
* |
|
50 |
* @param name |
|
51 |
* Name of this variable |
|
52 |
* |
|
53 |
* @param init |
|
54 |
* Value to initialize this variable to |
|
55 |
*/ |
|
56 |
JFieldVar(JDefinedClass owner, JMods mods, JType type, String name, JExpression init) { |
|
57 |
super( mods, type, name, init ); |
|
58 |
this.owner = owner; |
|
59 |
} |
|
60 |
||
61 |
@Override |
|
62 |
public void name(String name) { |
|
63 |
// make sure that the new name is available |
|
64 |
if(owner.fields.containsKey(name)) |
|
65 |
throw new IllegalArgumentException("name "+name+" is already in use"); |
|
66 |
String oldName = name(); |
|
67 |
super.name(name); |
|
68 |
owner.fields.remove(oldName); |
|
69 |
owner.fields.put(name,this); |
|
70 |
} |
|
71 |
||
72 |
/** |
|
73 |
* Creates, if necessary, and returns the class javadoc for this |
|
74 |
* JDefinedClass |
|
75 |
* |
|
76 |
* @return JDocComment containing javadocs for this class |
|
77 |
*/ |
|
78 |
public JDocComment javadoc() { |
|
79 |
if( jdoc == null ) |
|
80 |
jdoc = new JDocComment(owner.owner()); |
|
81 |
return jdoc; |
|
82 |
} |
|
83 |
||
84 |
public void declare(JFormatter f) { |
|
85 |
if( jdoc != null ) |
|
86 |
f.g( jdoc ); |
|
87 |
super.declare( f ); |
|
88 |
} |
|
89 |
||
90 |
||
91 |
} |