Tue, 06 Mar 2012 16:09:35 -0800
7150322: Stop using drop source bundles in jaxws
Reviewed-by: darcy, ohrstrom
ohair@286 | 1 | /* |
ohair@286 | 2 | * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved. |
ohair@286 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
ohair@286 | 4 | * |
ohair@286 | 5 | * This code is free software; you can redistribute it and/or modify it |
ohair@286 | 6 | * under the terms of the GNU General Public License version 2 only, as |
ohair@286 | 7 | * published by the Free Software Foundation. Oracle designates this |
ohair@286 | 8 | * particular file as subject to the "Classpath" exception as provided |
ohair@286 | 9 | * by Oracle in the LICENSE file that accompanied this code. |
ohair@286 | 10 | * |
ohair@286 | 11 | * This code is distributed in the hope that it will be useful, but WITHOUT |
ohair@286 | 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
ohair@286 | 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
ohair@286 | 14 | * version 2 for more details (a copy is included in the LICENSE file that |
ohair@286 | 15 | * accompanied this code). |
ohair@286 | 16 | * |
ohair@286 | 17 | * You should have received a copy of the GNU General Public License version |
ohair@286 | 18 | * 2 along with this work; if not, write to the Free Software Foundation, |
ohair@286 | 19 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
ohair@286 | 20 | * |
ohair@286 | 21 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
ohair@286 | 22 | * or visit www.oracle.com if you need additional information or have any |
ohair@286 | 23 | * questions. |
ohair@286 | 24 | */ |
ohair@286 | 25 | |
ohair@286 | 26 | package com.sun.tools.internal.xjc.model.nav; |
ohair@286 | 27 | |
ohair@286 | 28 | import java.lang.reflect.Type; |
ohair@286 | 29 | import java.util.Collection; |
ohair@286 | 30 | |
ohair@286 | 31 | import com.sun.codemodel.internal.JClass; |
ohair@286 | 32 | import com.sun.xml.internal.bind.v2.model.nav.Navigator; |
ohair@286 | 33 | import com.sun.xml.internal.bind.v2.runtime.Location; |
ohair@286 | 34 | |
ohair@286 | 35 | /** |
ohair@286 | 36 | * {@link Navigator} implementation for XJC. |
ohair@286 | 37 | * |
ohair@286 | 38 | * Most of the Navigator methods are used for parsing the model, which doesn't happen |
ohair@286 | 39 | * in XJC. So Most of the methods aren't really implemented. Implementations should |
ohair@286 | 40 | * be filled in as needed. |
ohair@286 | 41 | * |
ohair@286 | 42 | * @author Kohsuke Kawaguchi |
ohair@286 | 43 | */ |
ohair@286 | 44 | public final class NavigatorImpl implements Navigator<NType,NClass,Void,Void> { |
ohair@286 | 45 | public static final NavigatorImpl theInstance = new NavigatorImpl(); |
ohair@286 | 46 | |
ohair@286 | 47 | private NavigatorImpl() { |
ohair@286 | 48 | } |
ohair@286 | 49 | |
ohair@286 | 50 | public NClass getSuperClass(NClass nClass) { |
ohair@286 | 51 | throw new UnsupportedOperationException(); |
ohair@286 | 52 | } |
ohair@286 | 53 | |
ohair@286 | 54 | public NType getBaseClass(NType nt, NClass base) { |
ohair@286 | 55 | if(nt instanceof EagerNType) { |
ohair@286 | 56 | EagerNType ent = (EagerNType) nt; |
ohair@286 | 57 | if (base instanceof EagerNClass) { |
ohair@286 | 58 | EagerNClass enc = (EagerNClass) base; |
ohair@286 | 59 | return create(REFLECTION.getBaseClass(ent.t, enc.c)); |
ohair@286 | 60 | } |
ohair@286 | 61 | // lazy class can never be a base type of an eager type |
ohair@286 | 62 | return null; |
ohair@286 | 63 | } |
ohair@286 | 64 | if (nt instanceof NClassByJClass) { |
ohair@286 | 65 | NClassByJClass nnt = (NClassByJClass) nt; |
ohair@286 | 66 | if (base instanceof EagerNClass) { |
ohair@286 | 67 | EagerNClass enc = (EagerNClass) base; |
ohair@286 | 68 | return ref(nnt.clazz.getBaseClass(enc.c)); |
ohair@286 | 69 | } |
ohair@286 | 70 | } |
ohair@286 | 71 | |
ohair@286 | 72 | throw new UnsupportedOperationException(); |
ohair@286 | 73 | } |
ohair@286 | 74 | |
ohair@286 | 75 | public String getClassName(NClass nClass) { |
ohair@286 | 76 | throw new UnsupportedOperationException(); |
ohair@286 | 77 | } |
ohair@286 | 78 | |
ohair@286 | 79 | public String getTypeName(NType type) { |
ohair@286 | 80 | return type.fullName(); |
ohair@286 | 81 | } |
ohair@286 | 82 | |
ohair@286 | 83 | public String getClassShortName(NClass nClass) { |
ohair@286 | 84 | throw new UnsupportedOperationException(); |
ohair@286 | 85 | } |
ohair@286 | 86 | |
ohair@286 | 87 | public Collection<? extends Void> getDeclaredFields(NClass nClass) { |
ohair@286 | 88 | throw new UnsupportedOperationException(); |
ohair@286 | 89 | } |
ohair@286 | 90 | |
ohair@286 | 91 | public Void getDeclaredField(NClass clazz, String fieldName) { |
ohair@286 | 92 | throw new UnsupportedOperationException(); |
ohair@286 | 93 | } |
ohair@286 | 94 | |
ohair@286 | 95 | public Collection<? extends Void> getDeclaredMethods(NClass nClass) { |
ohair@286 | 96 | throw new UnsupportedOperationException(); |
ohair@286 | 97 | } |
ohair@286 | 98 | |
ohair@286 | 99 | public NClass getDeclaringClassForField(Void aVoid) { |
ohair@286 | 100 | throw new UnsupportedOperationException(); |
ohair@286 | 101 | } |
ohair@286 | 102 | |
ohair@286 | 103 | public NClass getDeclaringClassForMethod(Void aVoid) { |
ohair@286 | 104 | throw new UnsupportedOperationException(); |
ohair@286 | 105 | } |
ohair@286 | 106 | |
ohair@286 | 107 | public NType getFieldType(Void aVoid) { |
ohair@286 | 108 | throw new UnsupportedOperationException(); |
ohair@286 | 109 | } |
ohair@286 | 110 | |
ohair@286 | 111 | public String getFieldName(Void aVoid) { |
ohair@286 | 112 | throw new UnsupportedOperationException(); |
ohair@286 | 113 | } |
ohair@286 | 114 | |
ohair@286 | 115 | public String getMethodName(Void aVoid) { |
ohair@286 | 116 | throw new UnsupportedOperationException(); |
ohair@286 | 117 | } |
ohair@286 | 118 | |
ohair@286 | 119 | public NType getReturnType(Void aVoid) { |
ohair@286 | 120 | throw new UnsupportedOperationException(); |
ohair@286 | 121 | } |
ohair@286 | 122 | |
ohair@286 | 123 | public NType[] getMethodParameters(Void aVoid) { |
ohair@286 | 124 | throw new UnsupportedOperationException(); |
ohair@286 | 125 | } |
ohair@286 | 126 | |
ohair@286 | 127 | public boolean isStaticMethod(Void aVoid) { |
ohair@286 | 128 | throw new UnsupportedOperationException(); |
ohair@286 | 129 | } |
ohair@286 | 130 | |
ohair@286 | 131 | public boolean isFinalMethod(Void aVoid) { |
ohair@286 | 132 | throw new UnsupportedOperationException(); |
ohair@286 | 133 | } |
ohair@286 | 134 | |
ohair@286 | 135 | public boolean isSubClassOf(NType sub, NType sup) { |
ohair@286 | 136 | throw new UnsupportedOperationException(); |
ohair@286 | 137 | } |
ohair@286 | 138 | |
ohair@286 | 139 | public NClass ref(Class c) { |
ohair@286 | 140 | return create(c); |
ohair@286 | 141 | } |
ohair@286 | 142 | |
ohair@286 | 143 | public NClass ref(JClass c) { |
ohair@286 | 144 | if(c==null) return null; |
ohair@286 | 145 | return new NClassByJClass(c); |
ohair@286 | 146 | } |
ohair@286 | 147 | |
ohair@286 | 148 | public NType use(NClass nc) { |
ohair@286 | 149 | return nc; |
ohair@286 | 150 | } |
ohair@286 | 151 | |
ohair@286 | 152 | public NClass asDecl(NType nt) { |
ohair@286 | 153 | if(nt instanceof NClass) |
ohair@286 | 154 | return (NClass)nt; |
ohair@286 | 155 | else |
ohair@286 | 156 | return null; |
ohair@286 | 157 | } |
ohair@286 | 158 | |
ohair@286 | 159 | public NClass asDecl(Class c) { |
ohair@286 | 160 | return ref(c); |
ohair@286 | 161 | } |
ohair@286 | 162 | |
ohair@286 | 163 | public boolean isArray(NType nType) { |
ohair@286 | 164 | throw new UnsupportedOperationException(); |
ohair@286 | 165 | } |
ohair@286 | 166 | |
ohair@286 | 167 | public boolean isArrayButNotByteArray(NType t) { |
ohair@286 | 168 | throw new UnsupportedOperationException(); |
ohair@286 | 169 | } |
ohair@286 | 170 | |
ohair@286 | 171 | |
ohair@286 | 172 | public NType getComponentType(NType nType) { |
ohair@286 | 173 | throw new UnsupportedOperationException(); |
ohair@286 | 174 | } |
ohair@286 | 175 | |
ohair@286 | 176 | public NType getTypeArgument(NType nt, int i) { |
ohair@286 | 177 | if (nt instanceof EagerNType) { |
ohair@286 | 178 | EagerNType ent = (EagerNType) nt; |
ohair@286 | 179 | return create(REFLECTION.getTypeArgument(ent.t,i)); |
ohair@286 | 180 | } |
ohair@286 | 181 | if (nt instanceof NClassByJClass) { |
ohair@286 | 182 | NClassByJClass nnt = (NClassByJClass) nt; |
ohair@286 | 183 | return ref(nnt.clazz.getTypeParameters().get(i)); |
ohair@286 | 184 | } |
ohair@286 | 185 | |
ohair@286 | 186 | throw new UnsupportedOperationException(); |
ohair@286 | 187 | } |
ohair@286 | 188 | |
ohair@286 | 189 | public boolean isParameterizedType(NType nt) { |
ohair@286 | 190 | if (nt instanceof EagerNType) { |
ohair@286 | 191 | EagerNType ent = (EagerNType) nt; |
ohair@286 | 192 | return REFLECTION.isParameterizedType(ent.t); |
ohair@286 | 193 | } |
ohair@286 | 194 | if (nt instanceof NClassByJClass) { |
ohair@286 | 195 | NClassByJClass nnt = (NClassByJClass) nt; |
ohair@286 | 196 | return nnt.clazz.isParameterized(); |
ohair@286 | 197 | } |
ohair@286 | 198 | |
ohair@286 | 199 | throw new UnsupportedOperationException(); |
ohair@286 | 200 | } |
ohair@286 | 201 | |
ohair@286 | 202 | public boolean isPrimitive(NType type) { |
ohair@286 | 203 | throw new UnsupportedOperationException(); |
ohair@286 | 204 | } |
ohair@286 | 205 | |
ohair@286 | 206 | public NType getPrimitive(Class primitiveType) { |
ohair@286 | 207 | return create(primitiveType); |
ohair@286 | 208 | } |
ohair@286 | 209 | |
ohair@286 | 210 | |
ohair@286 | 211 | public static final NType create(Type t) { |
ohair@286 | 212 | if(t==null) return null; |
ohair@286 | 213 | if(t instanceof Class) |
ohair@286 | 214 | return create((Class)t); |
ohair@286 | 215 | |
ohair@286 | 216 | return new EagerNType(t); |
ohair@286 | 217 | } |
ohair@286 | 218 | |
ohair@286 | 219 | public static NClass create( Class c ) { |
ohair@286 | 220 | if(c==null) return null; |
ohair@286 | 221 | return new EagerNClass(c); |
ohair@286 | 222 | } |
ohair@286 | 223 | |
ohair@286 | 224 | /** |
ohair@286 | 225 | * Creates a {@link NType} representation for a parameterized type |
ohair@286 | 226 | * {@code RawType<ParamType1,ParamType2,...> }. |
ohair@286 | 227 | */ |
ohair@286 | 228 | public static NType createParameterizedType( NClass rawType, NType... args ) { |
ohair@286 | 229 | return new NParameterizedType(rawType,args); |
ohair@286 | 230 | } |
ohair@286 | 231 | |
ohair@286 | 232 | public static NType createParameterizedType( Class rawType, NType... args ) { |
ohair@286 | 233 | return new NParameterizedType(create(rawType),args); |
ohair@286 | 234 | } |
ohair@286 | 235 | |
ohair@286 | 236 | public Location getClassLocation(final NClass c) { |
ohair@286 | 237 | // not really needed for XJC but doesn't hurt to have one |
ohair@286 | 238 | return new Location() { |
ohair@286 | 239 | public String toString() { |
ohair@286 | 240 | return c.fullName(); |
ohair@286 | 241 | } |
ohair@286 | 242 | }; |
ohair@286 | 243 | } |
ohair@286 | 244 | |
ohair@286 | 245 | public Location getFieldLocation(Void _) { |
ohair@286 | 246 | throw new IllegalStateException(); |
ohair@286 | 247 | } |
ohair@286 | 248 | |
ohair@286 | 249 | public Location getMethodLocation(Void _) { |
ohair@286 | 250 | throw new IllegalStateException(); |
ohair@286 | 251 | } |
ohair@286 | 252 | |
ohair@286 | 253 | public boolean hasDefaultConstructor(NClass nClass) { |
ohair@286 | 254 | throw new UnsupportedOperationException(); |
ohair@286 | 255 | } |
ohair@286 | 256 | |
ohair@286 | 257 | public boolean isStaticField(Void aVoid) { |
ohair@286 | 258 | throw new IllegalStateException(); |
ohair@286 | 259 | } |
ohair@286 | 260 | |
ohair@286 | 261 | public boolean isPublicMethod(Void aVoid) { |
ohair@286 | 262 | throw new IllegalStateException(); |
ohair@286 | 263 | } |
ohair@286 | 264 | |
ohair@286 | 265 | public boolean isPublicField(Void aVoid) { |
ohair@286 | 266 | throw new IllegalStateException(); |
ohair@286 | 267 | } |
ohair@286 | 268 | |
ohair@286 | 269 | public boolean isEnum(NClass c) { |
ohair@286 | 270 | return isSubClassOf(c,create(Enum.class)); |
ohair@286 | 271 | } |
ohair@286 | 272 | |
ohair@286 | 273 | public <T> NType erasure(NType type) { |
ohair@286 | 274 | if(type instanceof NParameterizedType) { |
ohair@286 | 275 | NParameterizedType pt = (NParameterizedType) type; |
ohair@286 | 276 | return pt.rawType; |
ohair@286 | 277 | } |
ohair@286 | 278 | return type; |
ohair@286 | 279 | } |
ohair@286 | 280 | |
ohair@286 | 281 | public boolean isAbstract(NClass clazz) { |
ohair@286 | 282 | return clazz.isAbstract(); |
ohair@286 | 283 | } |
ohair@286 | 284 | |
ohair@286 | 285 | /** |
ohair@286 | 286 | * @deprecated |
ohair@286 | 287 | * no class generated by XJC is final. |
ohair@286 | 288 | */ |
ohair@286 | 289 | public boolean isFinal(NClass clazz) { |
ohair@286 | 290 | return false; |
ohair@286 | 291 | } |
ohair@286 | 292 | |
ohair@286 | 293 | public Void[] getEnumConstants(NClass clazz) { |
ohair@286 | 294 | throw new UnsupportedOperationException(); |
ohair@286 | 295 | } |
ohair@286 | 296 | |
ohair@286 | 297 | public NType getVoidType() { |
ohair@286 | 298 | return ref(void.class); |
ohair@286 | 299 | } |
ohair@286 | 300 | |
ohair@286 | 301 | public String getPackageName(NClass clazz) { |
ohair@286 | 302 | // TODO: implement this method later |
ohair@286 | 303 | throw new UnsupportedOperationException(); |
ohair@286 | 304 | } |
ohair@286 | 305 | |
ohair@286 | 306 | public NClass findClass(String className, NClass referencePoint) { |
ohair@286 | 307 | // TODO: implement this method later |
ohair@286 | 308 | throw new UnsupportedOperationException(); |
ohair@286 | 309 | } |
ohair@286 | 310 | |
ohair@286 | 311 | public boolean isBridgeMethod(Void method) { |
ohair@286 | 312 | throw new UnsupportedOperationException(); |
ohair@286 | 313 | } |
ohair@286 | 314 | |
ohair@286 | 315 | public boolean isOverriding(Void method,NClass clazz) { |
ohair@286 | 316 | throw new UnsupportedOperationException(); |
ohair@286 | 317 | } |
ohair@286 | 318 | |
ohair@286 | 319 | public boolean isInterface(NClass clazz) { |
ohair@286 | 320 | throw new UnsupportedOperationException(); |
ohair@286 | 321 | } |
ohair@286 | 322 | |
ohair@286 | 323 | public boolean isTransient(Void f) { |
ohair@286 | 324 | throw new UnsupportedOperationException(); |
ohair@286 | 325 | } |
ohair@286 | 326 | |
ohair@286 | 327 | public boolean isInnerClass(NClass clazz) { |
ohair@286 | 328 | throw new UnsupportedOperationException(); |
ohair@286 | 329 | } |
ohair@286 | 330 | |
ohair@286 | 331 | @Override |
ohair@286 | 332 | public boolean isSameType(NType t1, NType t2) { |
ohair@286 | 333 | throw new UnsupportedOperationException(); |
ohair@286 | 334 | } |
ohair@286 | 335 | } |