aoqi@0: /* aoqi@0: * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. aoqi@0: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. aoqi@0: * aoqi@0: * This code is free software; you can redistribute it and/or modify it aoqi@0: * under the terms of the GNU General Public License version 2 only, as aoqi@0: * published by the Free Software Foundation. Oracle designates this aoqi@0: * particular file as subject to the "Classpath" exception as provided aoqi@0: * by Oracle in the LICENSE file that accompanied this code. aoqi@0: * aoqi@0: * This code is distributed in the hope that it will be useful, but WITHOUT aoqi@0: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or aoqi@0: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License aoqi@0: * version 2 for more details (a copy is included in the LICENSE file that aoqi@0: * accompanied this code). aoqi@0: * aoqi@0: * You should have received a copy of the GNU General Public License version aoqi@0: * 2 along with this work; if not, write to the Free Software Foundation, aoqi@0: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. aoqi@0: * aoqi@0: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA aoqi@0: * or visit www.oracle.com if you need additional information or have any aoqi@0: * questions. aoqi@0: */ aoqi@0: aoqi@0: package com.sun.xml.internal.ws.spi.db; aoqi@0: aoqi@0: import java.lang.reflect.Type; aoqi@0: aoqi@0: //TODO SOAPVersion WebServiceFeatureList aoqi@0: import com.sun.xml.internal.bind.util.Which; aoqi@0: aoqi@0: //TODO Packet AbstractMessageImpl aoqi@0: import com.sun.xml.internal.bind.marshaller.SAX2DOMEx; aoqi@0: aoqi@0: //TODO DOMHeader DOMMessage SAAJMessage StatefulInstanceResolver aoqi@0: import com.sun.xml.internal.bind.unmarshaller.DOMScanner; aoqi@0: aoqi@0: //TODO MtomCodec aoqi@0: import com.sun.xml.internal.bind.v2.runtime.output.Encoded; aoqi@0: aoqi@0: //TODO ExceptionBean aoqi@0: import com.sun.xml.internal.bind.marshaller.NamespacePrefixMapper; aoqi@0: aoqi@0: //TODO AbstractWrapperBeanGenerator aoqi@0: import com.sun.xml.internal.bind.v2.model.annotation.AnnotationReader; aoqi@0: import com.sun.xml.internal.bind.v2.model.annotation.RuntimeInlineAnnotationReader; aoqi@0: import com.sun.xml.internal.bind.v2.model.nav.Navigator; aoqi@0: aoqi@0: //TODO WSDLGenerator aoqi@0: import static com.sun.xml.internal.bind.v2.schemagen.Util.*; aoqi@0: aoqi@0: import com.sun.xml.internal.bind.api.impl.NameConverter; aoqi@0: import com.sun.xml.internal.bind.v2.model.nav.Navigator; aoqi@0: aoqi@0: import com.sun.istack.internal.NotNull; aoqi@0: import com.sun.istack.internal.Nullable; aoqi@0: /** aoqi@0: * BindingHelper aoqi@0: * aoqi@0: * @author shih-chang.chen@oracle.com aoqi@0: */ aoqi@0: public class BindingHelper { aoqi@0: /** aoqi@0: * Computes a Java identifier from a local name. aoqi@0: * aoqi@0: *

aoqi@0: * This method faithfully implements the name mangling rule as specified in the JAXB spec. aoqi@0: * aoqi@0: *

aoqi@0: * In JAXB, a collision with a Java reserved word (such as "return") never happens. aoqi@0: * Accordingly, this method may return an identifier that collides with reserved words. aoqi@0: * aoqi@0: *

aoqi@0: * Use JJavaName.isJavaIdentifier(String) to check for such collision. aoqi@0: * aoqi@0: * @return aoqi@0: * Typically, this method returns "nameLikeThis". aoqi@0: */ aoqi@0: public static @NotNull String mangleNameToVariableName(@NotNull String localName) { aoqi@0: return NameConverter.standard.toVariableName(localName); aoqi@0: } aoqi@0: aoqi@0: /** aoqi@0: * Computes a Java class name from a local name. aoqi@0: * aoqi@0: *

aoqi@0: * This method faithfully implements the name mangling rule as specified in the JAXB spec. aoqi@0: * aoqi@0: * @return aoqi@0: * Typically, this method returns "NameLikeThis". aoqi@0: */ aoqi@0: public static @NotNull String mangleNameToClassName(@NotNull String localName) { aoqi@0: return NameConverter.standard.toClassName(localName); aoqi@0: } aoqi@0: aoqi@0: /** aoqi@0: * Computes a Java class name from a local name. aoqi@0: * aoqi@0: *

aoqi@0: * This method faithfully implements the name mangling rule as specified in the JAXB spec. aoqi@0: * This method works like {@link #mangleNameToClassName(String)} except that it looks aoqi@0: * for "getClass" and returns something else. aoqi@0: * aoqi@0: * @return aoqi@0: * Typically, this method returns "NameLikeThis". aoqi@0: */ aoqi@0: public static @NotNull String mangleNameToPropertyName(@NotNull String localName) { aoqi@0: return NameConverter.standard.toPropertyName(localName); aoqi@0: } aoqi@0: aoqi@0: /** aoqi@0: * Gets the parameterization of the given base type. aoqi@0: * aoqi@0: *

aoqi@0: * For example, given the following aoqi@0: *


aoqi@0:      * interface Foo<T> extends List<List<T>> {}
aoqi@0:      * interface Bar extends Foo<String> {}
aoqi@0:      * 
aoqi@0: * This method works like this: aoqi@0: *

aoqi@0:      * getBaseClass( Bar, List ) = List<List<String>
aoqi@0:      * getBaseClass( Bar, Foo  ) = Foo<String>
aoqi@0:      * getBaseClass( Foo<? extends Number>, Collection ) = Collection<List<? extends Number>>
aoqi@0:      * getBaseClass( ArrayList<? extends BigInteger>, List ) = List<? extends BigInteger>
aoqi@0:      * 
aoqi@0: * aoqi@0: * @param type aoqi@0: * The type that derives from {@code baseType} aoqi@0: * @param baseType aoqi@0: * The class whose parameterization we are interested in. aoqi@0: * @return aoqi@0: * The use of {@code baseType} in {@code type}. aoqi@0: * or null if the type is not assignable to the base type. aoqi@0: * @since 2.0 FCS aoqi@0: */ aoqi@0: public static @Nullable Type getBaseType(@NotNull Type type, @NotNull Class baseType) { aoqi@0: return Utils.REFLECTION_NAVIGATOR.getBaseClass(type,baseType); aoqi@0: } aoqi@0: aoqi@0: public static Class erasure(Type t) { aoqi@0: return (Class) Utils.REFLECTION_NAVIGATOR.erasure(t); aoqi@0: } aoqi@0: }