KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > javacore > jmiimpl > javamodel > ArrayCloneMethod


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.netbeans.modules.javacore.jmiimpl.javamodel;
21
22 import java.lang.reflect.Modifier JavaDoc;
23 import java.util.*;
24 import javax.jmi.reflect.*;
25 import javax.jmi.model.Attribute;
26 import javax.jmi.model.GeneralizableElement;
27
28 import org.netbeans.jmi.javamodel.*;
29
30 /**
31  *
32  * @author Dusan Balek
33  */

34 public class ArrayCloneMethod implements Method {
35
36     private static final String JavaDoc typeName = "java.lang.Object"; // NOI18N
37
private static final String JavaDoc MOF_ID_PREFIX = "ArrayCloneMethod:"; // NOI18N
38

39     private ArrayImpl parent;
40     private String JavaDoc mofId;
41
42     private Type type;
43     private MultipartId typeRef;
44
45     ArrayCloneMethod(ArrayImpl parent) {
46         this.parent = parent;
47         mofId = MOF_ID_PREFIX + parent.refMofId();
48         type = ((JavaModelPackage) parent.refImmediatePackage()).getType().resolve(typeName);
49         typeRef = new SyntheticMultipartId(this);
50     }
51
52     public List getAnnotations() {
53         return Collections.EMPTY_LIST;
54     }
55
56     public StatementBlock getBody() {
57         return null;
58     }
59
60     public String JavaDoc getBodyText() {
61         return null;
62     }
63
64     public ClassDefinition getDeclaringClass() {
65         return parent;
66     }
67
68     public int getDimCount() {
69         return 0;
70     }
71
72     public int getEndOffset() {
73         return 0;
74     }
75
76     public boolean isDeprecated() {
77         return false;
78     }
79
80     public List getExceptionNames() {
81         return Collections.EMPTY_LIST;
82     }
83
84     public List getExceptions() {
85         return Collections.EMPTY_LIST;
86     }
87
88     public JavaDoc getJavadoc() {
89         return null;
90     }
91
92     public String JavaDoc getJavadocText() {
93         return null;
94     }
95
96     public int getModifiers() {
97         return Modifier.PUBLIC;
98     }
99
100     public String JavaDoc getName() {
101         return "clone"; // NOI18N
102
}
103
104     public List getParameters() {
105         return Collections.EMPTY_LIST;
106     }
107
108     public int getPartEndOffset(ElementPartKind part) {
109         return 0;
110     }
111
112     public int getPartStartOffset(ElementPartKind part) {
113         return 0;
114     }
115
116     public Resource getResource() {
117         return parent.getResource();
118     }
119
120     public int getStartOffset() {
121         return 0;
122     }
123
124     public Type getType() {
125         return type;
126     }
127
128     public TypeReference getTypeName() {
129         return typeRef;
130     }
131
132     public List getTypeParameters() {
133         return Collections.EMPTY_LIST;
134     }
135
136     public List getChildren() {
137         return Collections.EMPTY_LIST;
138     }
139
140     public boolean isValid() {
141         return true;
142     }
143
144     public Collection findDependencies(boolean usages, boolean overridingMethods, boolean fromBaseClass) {
145         return Collections.EMPTY_LIST; // [TODO]
146
}
147
148     public Collection getReferences() {
149         return Collections.EMPTY_LIST; // [TODO]
150
}
151
152     public boolean signatureEquals(Method method) {
153         return false; // [TODO]
154
}
155
156     public RefClass refClass() {
157         return ((JavaModelPackage) parent.refImmediatePackage()).getMethod();
158     }
159
160     public void refDelete() {
161         // do nothing
162
}
163
164     public Object JavaDoc refGetValue(RefObject refObject) {
165         if (!(refObject instanceof Attribute)) {
166             throw new InvalidCallException(null, refObject);
167         }
168         return refGetValue(((Attribute) refObject).getName());
169     }
170
171     public Object JavaDoc refGetValue(String JavaDoc str) {
172         if ("dimCount".equals(str)) { // NOI18N
173
return new Integer JavaDoc(getDimCount());
174         } else if ("javadoc".equals(str)) { // NOI18N
175
return getJavadoc();
176         } else if ("javadocText".equals(str)) { // NOI18N
177
return getJavadocText();
178         } else if ("modifiers".equals(str)) { // NOI18N
179
return new Integer JavaDoc(getModifiers());
180         } else if ("name".equals(str)) { // NOI18N
181
return getName();
182         } else if ("type".equals(str)) { // NOI18N
183
return getType();
184         } else if ("typeName".equals(str)) { // NOI18N
185
return getTypeName();
186         } else if ("exceptionNames".equals(str)) { // NOI18N
187
return getExceptionNames();
188         } else if ("parameters".equals(str)) { // NOI18N
189
return getParameters();
190         } else if ("body".equals(str)) { // NOI18N
191
return getBody();
192         } else if ("bodyText".equals(str)) { // NOI18N
193
return getBodyText();
194         } else if ("annotations".equals(str)) { // NOI18N
195
return getAnnotations();
196         } else if ("typeParameters".equals(str)) { // NOI18N
197
return getTypeParameters();
198         }
199         throw new InvalidCallException(null, null, "Invalid attribute name: " + str); // NOI18N
200
}
201
202     public RefFeatured refImmediateComposite() {
203         return parent;
204     }
205
206     public RefPackage refImmediatePackage() {
207         return parent.refImmediatePackage();
208     }
209
210     public Object JavaDoc refInvokeOperation(RefObject refObject, List list) throws RefException {
211         throw new InvalidCallException(null, null);
212     }
213
214     public Object JavaDoc refInvokeOperation(String JavaDoc str, List list) throws RefException {
215         throw new InvalidCallException(null, null);
216     }
217
218     public boolean refIsInstanceOf(RefObject objType, boolean considerSubtypes) {
219         GeneralizableElement metaObject = (GeneralizableElement) refMetaObject();
220         return isInstanceOf(metaObject, objType, considerSubtypes);
221     }
222
223     private boolean isInstanceOf(GeneralizableElement metaObject, RefObject objType, boolean considerSubtypes) {
224         if (metaObject.equals(objType))
225             return true;
226         if (considerSubtypes) {
227             Iterator it = metaObject.getSupertypes().iterator();
228             while (it.hasNext()) {
229                 if (isInstanceOf(((GeneralizableElement) it.next()), objType, true)) {
230                     return true;
231                 }
232             }
233         }
234         return false;
235     }
236
237     public RefObject refMetaObject() {
238         return refClass().refMetaObject();
239     }
240
241     public String JavaDoc refMofId() {
242         return mofId;
243     }
244
245     public RefFeatured refOutermostComposite() {
246         return parent.refOutermostComposite();
247     }
248
249     public RefPackage refOutermostPackage() {
250         return parent.refOutermostPackage();
251     }
252
253     public void refSetValue(String JavaDoc str, Object JavaDoc obj) {
254         ArrayImpl.throwIsReadOnly(this);
255     }
256
257     public void refSetValue(RefObject refObject, Object JavaDoc obj) {
258         ArrayImpl.throwIsReadOnly(this);
259     }
260
261     public Collection refVerifyConstraints(boolean param) {
262         return Collections.EMPTY_LIST;
263     }
264
265     public void replaceChild(Element oldChild, Element newChild) {
266         ArrayImpl.throwIsReadOnly(this);
267     }
268
269     public void setBody(StatementBlock newValue) {
270     }
271
272     public void setBodyText(String JavaDoc newValue) {
273     }
274
275     public void setDimCount(int newValue) {
276         ArrayImpl.throwIsReadOnly(this, "dimCount"); // NOI18N
277
}
278
279     public void setJavadoc(JavaDoc newValue) {
280         ArrayImpl.throwIsReadOnly(this, "javadoc"); // NOI18N
281
}
282
283     public void setJavadocText(String JavaDoc newValue) {
284         ArrayImpl.throwIsReadOnly(this, "javadocText"); // NOI18N
285
}
286
287     public void setModifiers(int newValue) {
288         ArrayImpl.throwIsReadOnly(this, "modifiers"); // NOI18N
289
}
290
291     public void setName(String JavaDoc newValue) {
292         ArrayImpl.throwIsReadOnly(this, "name"); // NOI18N
293
}
294
295     public void setType(Type newValue) {
296         ArrayImpl.throwIsReadOnly(this, "type"); // NOI18N
297
}
298
299     public void setTypeName(TypeReference newValue) {
300         ArrayImpl.throwIsReadOnly(this, "typeName"); // NOI18N
301
}
302
303     public Element duplicate() {
304         throw new UnsupportedOperationException JavaDoc();
305     }
306
307     public void setDeprecated(boolean newValue) {
308         ArrayImpl.throwIsReadOnly(this, "typeName"); // NOI18N
309
}
310 }
311
Popular Tags