1 19 20 package org.netbeans.modules.javacore.jmiimpl.javamodel; 21 22 import java.lang.reflect.Modifier ; 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 34 public class ArrayCloneMethod implements Method { 35 36 private static final String typeName = "java.lang.Object"; private static final String MOF_ID_PREFIX = "ArrayCloneMethod:"; 39 private ArrayImpl parent; 40 private String 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 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 getJavadocText() { 93 return null; 94 } 95 96 public int getModifiers() { 97 return Modifier.PUBLIC; 98 } 99 100 public String getName() { 101 return "clone"; } 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; } 147 148 public Collection getReferences() { 149 return Collections.EMPTY_LIST; } 151 152 public boolean signatureEquals(Method method) { 153 return false; } 155 156 public RefClass refClass() { 157 return ((JavaModelPackage) parent.refImmediatePackage()).getMethod(); 158 } 159 160 public void refDelete() { 161 } 163 164 public Object 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 refGetValue(String str) { 172 if ("dimCount".equals(str)) { return new Integer (getDimCount()); 174 } else if ("javadoc".equals(str)) { return getJavadoc(); 176 } else if ("javadocText".equals(str)) { return getJavadocText(); 178 } else if ("modifiers".equals(str)) { return new Integer (getModifiers()); 180 } else if ("name".equals(str)) { return getName(); 182 } else if ("type".equals(str)) { return getType(); 184 } else if ("typeName".equals(str)) { return getTypeName(); 186 } else if ("exceptionNames".equals(str)) { return getExceptionNames(); 188 } else if ("parameters".equals(str)) { return getParameters(); 190 } else if ("body".equals(str)) { return getBody(); 192 } else if ("bodyText".equals(str)) { return getBodyText(); 194 } else if ("annotations".equals(str)) { return getAnnotations(); 196 } else if ("typeParameters".equals(str)) { return getTypeParameters(); 198 } 199 throw new InvalidCallException(null, null, "Invalid attribute name: " + str); } 201 202 public RefFeatured refImmediateComposite() { 203 return parent; 204 } 205 206 public RefPackage refImmediatePackage() { 207 return parent.refImmediatePackage(); 208 } 209 210 public Object refInvokeOperation(RefObject refObject, List list) throws RefException { 211 throw new InvalidCallException(null, null); 212 } 213 214 public Object refInvokeOperation(String 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 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 str, Object obj) { 254 ArrayImpl.throwIsReadOnly(this); 255 } 256 257 public void refSetValue(RefObject refObject, Object 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 newValue) { 273 } 274 275 public void setDimCount(int newValue) { 276 ArrayImpl.throwIsReadOnly(this, "dimCount"); } 278 279 public void setJavadoc(JavaDoc newValue) { 280 ArrayImpl.throwIsReadOnly(this, "javadoc"); } 282 283 public void setJavadocText(String newValue) { 284 ArrayImpl.throwIsReadOnly(this, "javadocText"); } 286 287 public void setModifiers(int newValue) { 288 ArrayImpl.throwIsReadOnly(this, "modifiers"); } 290 291 public void setName(String newValue) { 292 ArrayImpl.throwIsReadOnly(this, "name"); } 294 295 public void setType(Type newValue) { 296 ArrayImpl.throwIsReadOnly(this, "type"); } 298 299 public void setTypeName(TypeReference newValue) { 300 ArrayImpl.throwIsReadOnly(this, "typeName"); } 302 303 public Element duplicate() { 304 throw new UnsupportedOperationException (); 305 } 306 307 public void setDeprecated(boolean newValue) { 308 ArrayImpl.throwIsReadOnly(this, "typeName"); } 310 } 311 | Popular Tags |