src/share/jaxws_classes/com/sun/xml/internal/ws/spi/db/BindingHelper.java

Fri, 22 Nov 2013 21:11:19 +0100

author
mkos
date
Fri, 22 Nov 2013 21:11:19 +0100
changeset 450
b0c2840e2513
parent 368
0989ad8c0860
child 637
9c07ef4934dd
permissions
-rw-r--r--

8010935: Better XML handling
8027378: Two closed/javax/xml/8005432 fails with jdk7u51b04
8028382: Two javax/xml/8005433 tests still fail after the fix JDK-8028147
Summary: base fix + fixes for test regressions; fix also reviewed by Maxim Soloviev, Alexander Fomin
Reviewed-by: mchung, mgrebac, mullan

     1 /*
     2  * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.  Oracle designates this
     8  * particular file as subject to the "Classpath" exception as provided
     9  * by Oracle in the LICENSE file that accompanied this code.
    10  *
    11  * This code is distributed in the hope that it will be useful, but WITHOUT
    12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    14  * version 2 for more details (a copy is included in the LICENSE file that
    15  * accompanied this code).
    16  *
    17  * You should have received a copy of the GNU General Public License version
    18  * 2 along with this work; if not, write to the Free Software Foundation,
    19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    20  *
    21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    22  * or visit www.oracle.com if you need additional information or have any
    23  * questions.
    24  */
    26 package com.sun.xml.internal.ws.spi.db;
    28 import java.lang.reflect.Type;
    30 //TODO SOAPVersion WebServiceFeatureList
    31 import com.sun.xml.internal.bind.util.Which;
    33 //TODO Packet AbstractMessageImpl
    34 import com.sun.xml.internal.bind.marshaller.SAX2DOMEx;
    36 //TODO DOMHeader DOMMessage SAAJMessage StatefulInstanceResolver
    37 import com.sun.xml.internal.bind.unmarshaller.DOMScanner;
    39 //TODO MtomCodec
    40 import com.sun.xml.internal.bind.v2.runtime.output.Encoded;
    42 //TODO ExceptionBean
    43 import com.sun.xml.internal.bind.marshaller.NamespacePrefixMapper;
    45 //TODO AbstractWrapperBeanGenerator
    46 import com.sun.xml.internal.bind.v2.model.annotation.AnnotationReader;
    47 import com.sun.xml.internal.bind.v2.model.annotation.RuntimeInlineAnnotationReader;
    48 import com.sun.xml.internal.bind.v2.model.nav.Navigator;
    50 //TODO WSDLGenerator
    51 import static com.sun.xml.internal.bind.v2.schemagen.Util.*;
    53 import com.sun.xml.internal.bind.api.impl.NameConverter;
    54 import com.sun.xml.internal.bind.v2.model.nav.Navigator;
    56 import com.sun.istack.internal.NotNull;
    57 import com.sun.istack.internal.Nullable;
    58 /**
    59  * BindingHelper
    60  *
    61  * @author shih-chang.chen@oracle.com
    62  */
    63 public class BindingHelper {
    64     /**
    65      * Computes a Java identifier from a local name.
    66      *
    67      * <p>
    68      * This method faithfully implements the name mangling rule as specified in the JAXB spec.
    69      *
    70      * <p>
    71      * In JAXB, a collision with a Java reserved word (such as "return") never happens.
    72      * Accordingly, this method may return an identifier that collides with reserved words.
    73      *
    74      * <p>
    75      * Use <tt>JJavaName.isJavaIdentifier(String)</tt> to check for such collision.
    76      *
    77      * @return
    78      *      Typically, this method returns "nameLikeThis".
    79      */
    80     public static @NotNull String mangleNameToVariableName(@NotNull String localName) {
    81         return NameConverter.standard.toVariableName(localName);
    82     }
    84     /**
    85      * Computes a Java class name from a local name.
    86      *
    87      * <p>
    88      * This method faithfully implements the name mangling rule as specified in the JAXB spec.
    89      *
    90      * @return
    91      *      Typically, this method returns "NameLikeThis".
    92      */
    93     public static @NotNull String mangleNameToClassName(@NotNull String localName) {
    94         return NameConverter.standard.toClassName(localName);
    95     }
    97     /**
    98      * Computes a Java class name from a local name.
    99      *
   100      * <p>
   101      * This method faithfully implements the name mangling rule as specified in the JAXB spec.
   102      * This method works like {@link #mangleNameToClassName(String)} except that it looks
   103      * for "getClass" and returns something else.
   104      *
   105      * @return
   106      *      Typically, this method returns "NameLikeThis".
   107      */
   108     public static @NotNull String mangleNameToPropertyName(@NotNull String localName) {
   109         return NameConverter.standard.toPropertyName(localName);
   110     }
   112     /**
   113      * Gets the parameterization of the given base type.
   114      *
   115      * <p>
   116      * For example, given the following
   117      * <pre><xmp>
   118      * interface Foo<T> extends List<List<T>> {}
   119      * interface Bar extends Foo<String> {}
   120      * </xmp></pre>
   121      * This method works like this:
   122      * <pre><xmp>
   123      * getBaseClass( Bar, List ) = List<List<String>
   124      * getBaseClass( Bar, Foo  ) = Foo<String>
   125      * getBaseClass( Foo<? extends Number>, Collection ) = Collection<List<? extends Number>>
   126      * getBaseClass( ArrayList<? extends BigInteger>, List ) = List<? extends BigInteger>
   127      * </xmp></pre>
   128      *
   129      * @param type
   130      *      The type that derives from {@code baseType}
   131      * @param baseType
   132      *      The class whose parameterization we are interested in.
   133      * @return
   134      *      The use of {@code baseType} in {@code type}.
   135      *      or null if the type is not assignable to the base type.
   136      * @since 2.0 FCS
   137      */
   138     public static @Nullable Type getBaseType(@NotNull Type type, @NotNull Class baseType) {
   139         return Utils.REFLECTION_NAVIGATOR.getBaseClass(type,baseType);
   140     }
   142     public static <T> Class<T> erasure(Type t) {
   143         return (Class<T>) Utils.REFLECTION_NAVIGATOR.erasure(t);
   144     }
   145 }

mercurial