Fri, 24 Oct 2014 15:02:28 +0200
8054367: More references for endpoints
Summary: fix also reviewed by Iaroslav.Savytskyi@oracle.com, Alexander.Fomin@oracle.com
Reviewed-by: mullan, skoivu
ohair@286 | 1 | /* |
alanb@368 | 2 | * Copyright (c) 1997, 2012, 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.xml.internal.ws.spi.db; |
ohair@286 | 27 | |
ohair@286 | 28 | import java.lang.reflect.Type; |
ohair@286 | 29 | |
ohair@286 | 30 | //TODO SOAPVersion WebServiceFeatureList |
ohair@286 | 31 | import com.sun.xml.internal.bind.util.Which; |
ohair@286 | 32 | |
ohair@286 | 33 | //TODO Packet AbstractMessageImpl |
ohair@286 | 34 | import com.sun.xml.internal.bind.marshaller.SAX2DOMEx; |
ohair@286 | 35 | |
ohair@286 | 36 | //TODO DOMHeader DOMMessage SAAJMessage StatefulInstanceResolver |
ohair@286 | 37 | import com.sun.xml.internal.bind.unmarshaller.DOMScanner; |
ohair@286 | 38 | |
ohair@286 | 39 | //TODO MtomCodec |
ohair@286 | 40 | import com.sun.xml.internal.bind.v2.runtime.output.Encoded; |
ohair@286 | 41 | |
ohair@286 | 42 | //TODO ExceptionBean |
ohair@286 | 43 | import com.sun.xml.internal.bind.marshaller.NamespacePrefixMapper; |
ohair@286 | 44 | |
ohair@286 | 45 | //TODO AbstractWrapperBeanGenerator |
ohair@286 | 46 | import com.sun.xml.internal.bind.v2.model.annotation.AnnotationReader; |
ohair@286 | 47 | import com.sun.xml.internal.bind.v2.model.annotation.RuntimeInlineAnnotationReader; |
ohair@286 | 48 | import com.sun.xml.internal.bind.v2.model.nav.Navigator; |
ohair@286 | 49 | |
ohair@286 | 50 | //TODO WSDLGenerator |
ohair@286 | 51 | import static com.sun.xml.internal.bind.v2.schemagen.Util.*; |
ohair@286 | 52 | |
ohair@286 | 53 | import com.sun.xml.internal.bind.api.impl.NameConverter; |
ohair@286 | 54 | import com.sun.xml.internal.bind.v2.model.nav.Navigator; |
ohair@286 | 55 | |
ohair@286 | 56 | import com.sun.istack.internal.NotNull; |
ohair@286 | 57 | import com.sun.istack.internal.Nullable; |
ohair@286 | 58 | /** |
ohair@286 | 59 | * BindingHelper |
ohair@286 | 60 | * |
ohair@286 | 61 | * @author shih-chang.chen@oracle.com |
ohair@286 | 62 | */ |
ohair@286 | 63 | public class BindingHelper { |
ohair@286 | 64 | /** |
ohair@286 | 65 | * Computes a Java identifier from a local name. |
ohair@286 | 66 | * |
ohair@286 | 67 | * <p> |
ohair@286 | 68 | * This method faithfully implements the name mangling rule as specified in the JAXB spec. |
ohair@286 | 69 | * |
ohair@286 | 70 | * <p> |
ohair@286 | 71 | * In JAXB, a collision with a Java reserved word (such as "return") never happens. |
ohair@286 | 72 | * Accordingly, this method may return an identifier that collides with reserved words. |
ohair@286 | 73 | * |
ohair@286 | 74 | * <p> |
ohair@286 | 75 | * Use <tt>JJavaName.isJavaIdentifier(String)</tt> to check for such collision. |
ohair@286 | 76 | * |
ohair@286 | 77 | * @return |
ohair@286 | 78 | * Typically, this method returns "nameLikeThis". |
ohair@286 | 79 | */ |
ohair@286 | 80 | public static @NotNull String mangleNameToVariableName(@NotNull String localName) { |
ohair@286 | 81 | return NameConverter.standard.toVariableName(localName); |
ohair@286 | 82 | } |
ohair@286 | 83 | |
ohair@286 | 84 | /** |
ohair@286 | 85 | * Computes a Java class name from a local name. |
ohair@286 | 86 | * |
ohair@286 | 87 | * <p> |
ohair@286 | 88 | * This method faithfully implements the name mangling rule as specified in the JAXB spec. |
ohair@286 | 89 | * |
ohair@286 | 90 | * @return |
ohair@286 | 91 | * Typically, this method returns "NameLikeThis". |
ohair@286 | 92 | */ |
ohair@286 | 93 | public static @NotNull String mangleNameToClassName(@NotNull String localName) { |
ohair@286 | 94 | return NameConverter.standard.toClassName(localName); |
ohair@286 | 95 | } |
ohair@286 | 96 | |
ohair@286 | 97 | /** |
ohair@286 | 98 | * Computes a Java class name from a local name. |
ohair@286 | 99 | * |
ohair@286 | 100 | * <p> |
ohair@286 | 101 | * This method faithfully implements the name mangling rule as specified in the JAXB spec. |
ohair@286 | 102 | * This method works like {@link #mangleNameToClassName(String)} except that it looks |
ohair@286 | 103 | * for "getClass" and returns something else. |
ohair@286 | 104 | * |
ohair@286 | 105 | * @return |
ohair@286 | 106 | * Typically, this method returns "NameLikeThis". |
ohair@286 | 107 | */ |
ohair@286 | 108 | public static @NotNull String mangleNameToPropertyName(@NotNull String localName) { |
ohair@286 | 109 | return NameConverter.standard.toPropertyName(localName); |
ohair@286 | 110 | } |
ohair@286 | 111 | |
ohair@286 | 112 | /** |
ohair@286 | 113 | * Gets the parameterization of the given base type. |
ohair@286 | 114 | * |
ohair@286 | 115 | * <p> |
ohair@286 | 116 | * For example, given the following |
ohair@286 | 117 | * <pre><xmp> |
ohair@286 | 118 | * interface Foo<T> extends List<List<T>> {} |
ohair@286 | 119 | * interface Bar extends Foo<String> {} |
ohair@286 | 120 | * </xmp></pre> |
ohair@286 | 121 | * This method works like this: |
ohair@286 | 122 | * <pre><xmp> |
ohair@286 | 123 | * getBaseClass( Bar, List ) = List<List<String> |
ohair@286 | 124 | * getBaseClass( Bar, Foo ) = Foo<String> |
ohair@286 | 125 | * getBaseClass( Foo<? extends Number>, Collection ) = Collection<List<? extends Number>> |
ohair@286 | 126 | * getBaseClass( ArrayList<? extends BigInteger>, List ) = List<? extends BigInteger> |
ohair@286 | 127 | * </xmp></pre> |
ohair@286 | 128 | * |
ohair@286 | 129 | * @param type |
ohair@286 | 130 | * The type that derives from {@code baseType} |
ohair@286 | 131 | * @param baseType |
ohair@286 | 132 | * The class whose parameterization we are interested in. |
ohair@286 | 133 | * @return |
ohair@286 | 134 | * The use of {@code baseType} in {@code type}. |
ohair@286 | 135 | * or null if the type is not assignable to the base type. |
ohair@286 | 136 | * @since 2.0 FCS |
ohair@286 | 137 | */ |
ohair@286 | 138 | public static @Nullable Type getBaseType(@NotNull Type type, @NotNull Class baseType) { |
mkos@450 | 139 | return Utils.REFLECTION_NAVIGATOR.getBaseClass(type,baseType); |
ohair@286 | 140 | } |
ohair@286 | 141 | |
ohair@286 | 142 | public static <T> Class<T> erasure(Type t) { |
mkos@450 | 143 | return (Class<T>) Utils.REFLECTION_NAVIGATOR.erasure(t); |
ohair@286 | 144 | } |
ohair@286 | 145 | } |