src/share/jaxws_classes/com/sun/xml/internal/bind/v2/model/impl/RuntimeElementInfoImpl.java

Tue, 06 Mar 2012 16:09:35 -0800

author
ohair
date
Tue, 06 Mar 2012 16:09:35 -0800
changeset 286
f50545b5e2f1
child 450
b0c2840e2513
permissions
-rw-r--r--

7150322: Stop using drop source bundles in jaxws
Reviewed-by: darcy, ohrstrom

     1 /*
     2  * Copyright (c) 1997, 2011, 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.bind.v2.model.impl;
    28 import java.lang.reflect.Field;
    29 import java.lang.reflect.Method;
    30 import java.lang.reflect.Type;
    31 import java.util.Collection;
    32 import java.util.Collections;
    33 import java.util.List;
    35 import javax.xml.bind.JAXBElement;
    36 import javax.xml.bind.annotation.adapters.XmlAdapter;
    38 import com.sun.xml.internal.bind.v2.model.core.Adapter;
    39 import com.sun.xml.internal.bind.v2.model.runtime.RuntimeClassInfo;
    40 import com.sun.xml.internal.bind.v2.model.runtime.RuntimeElementInfo;
    41 import com.sun.xml.internal.bind.v2.model.runtime.RuntimeElementPropertyInfo;
    42 import com.sun.xml.internal.bind.v2.model.runtime.RuntimeNonElement;
    43 import com.sun.xml.internal.bind.v2.model.runtime.RuntimePropertyInfo;
    44 import com.sun.xml.internal.bind.v2.model.runtime.RuntimeTypeRef;
    45 import com.sun.xml.internal.bind.v2.model.nav.Navigator;
    46 import com.sun.xml.internal.bind.v2.runtime.IllegalAnnotationException;
    47 import com.sun.xml.internal.bind.v2.runtime.Transducer;
    48 import com.sun.xml.internal.bind.v2.runtime.reflect.Accessor;
    50 /**
    51  * @author Kohsuke Kawaguchi
    52  */
    53 final class RuntimeElementInfoImpl extends ElementInfoImpl<Type,Class,Field,Method>
    54     implements RuntimeElementInfo {
    56     public RuntimeElementInfoImpl(RuntimeModelBuilder modelBuilder, RegistryInfoImpl registry, Method method) throws IllegalAnnotationException {
    57         super(modelBuilder, registry, method);
    59         Adapter<Type,Class> a = getProperty().getAdapter();
    61         if(a!=null)
    62             adapterType = a.adapterType;
    63         else
    64             adapterType = null;
    65     }
    67     @Override
    68     protected PropertyImpl createPropertyImpl() {
    69         return new RuntimePropertyImpl();
    70     }
    72     class RuntimePropertyImpl extends PropertyImpl implements RuntimeElementPropertyInfo, RuntimeTypeRef {
    73         public Accessor getAccessor() {
    74             if(adapterType==null)
    75                 return Accessor.JAXB_ELEMENT_VALUE;
    76             else
    77                 return Accessor.JAXB_ELEMENT_VALUE.adapt(
    78                         (Class)getAdapter().defaultType,(Class)adapterType);
    79         }
    81         public Type getRawType() {
    82             return Collection.class;
    83         }
    85         public Type getIndividualType() {
    86              return getContentType().getType();
    87         }
    90         public boolean elementOnlyContent() {
    91             return false;   // this method doesn't make sense here
    92         }
    94         public List<? extends RuntimeTypeRef> getTypes() {
    95             return Collections.singletonList(this);
    96         }
    98         public List<? extends RuntimeNonElement> ref() {
    99             return (List<? extends RuntimeNonElement>)super.ref();
   100         }
   102         public RuntimeNonElement getTarget() {
   103             return (RuntimeNonElement)super.getTarget();
   104         }
   106         public RuntimePropertyInfo getSource() {
   107             return this;
   108         }
   110         public Transducer getTransducer() {
   111             return RuntimeModelBuilder.createTransducer(this);
   112         }
   113     }
   115     /**
   116      * The adapter specified by <code>getProperty().getAdapter()</code>.
   117      */
   118     private final Class<? extends XmlAdapter> adapterType;
   120     public RuntimeElementPropertyInfo getProperty() {
   121         return (RuntimeElementPropertyInfo)super.getProperty();
   122     }
   124     public Class<? extends JAXBElement> getType() {
   125         return Navigator.REFLECTION.erasure(super.getType());
   126     }
   128     public RuntimeClassInfo getScope() {
   129         return (RuntimeClassInfo)super.getScope();
   130     }
   132     public RuntimeNonElement getContentType() {
   133         return (RuntimeNonElement)super.getContentType();
   134     }
   135 }

mercurial