1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/model/impl/RuntimeElementInfoImpl.java Wed Apr 27 01:27:09 2016 +0800 1.3 @@ -0,0 +1,135 @@ 1.4 +/* 1.5 + * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved. 1.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 1.7 + * 1.8 + * This code is free software; you can redistribute it and/or modify it 1.9 + * under the terms of the GNU General Public License version 2 only, as 1.10 + * published by the Free Software Foundation. Oracle designates this 1.11 + * particular file as subject to the "Classpath" exception as provided 1.12 + * by Oracle in the LICENSE file that accompanied this code. 1.13 + * 1.14 + * This code is distributed in the hope that it will be useful, but WITHOUT 1.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 1.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 1.17 + * version 2 for more details (a copy is included in the LICENSE file that 1.18 + * accompanied this code). 1.19 + * 1.20 + * You should have received a copy of the GNU General Public License version 1.21 + * 2 along with this work; if not, write to the Free Software Foundation, 1.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 1.23 + * 1.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 1.25 + * or visit www.oracle.com if you need additional information or have any 1.26 + * questions. 1.27 + */ 1.28 + 1.29 +package com.sun.xml.internal.bind.v2.model.impl; 1.30 + 1.31 +import java.lang.reflect.Field; 1.32 +import java.lang.reflect.Method; 1.33 +import java.lang.reflect.Type; 1.34 +import java.util.Collection; 1.35 +import java.util.Collections; 1.36 +import java.util.List; 1.37 + 1.38 +import javax.xml.bind.JAXBElement; 1.39 +import javax.xml.bind.annotation.adapters.XmlAdapter; 1.40 + 1.41 +import com.sun.xml.internal.bind.v2.model.core.Adapter; 1.42 +import com.sun.xml.internal.bind.v2.model.runtime.RuntimeClassInfo; 1.43 +import com.sun.xml.internal.bind.v2.model.runtime.RuntimeElementInfo; 1.44 +import com.sun.xml.internal.bind.v2.model.runtime.RuntimeElementPropertyInfo; 1.45 +import com.sun.xml.internal.bind.v2.model.runtime.RuntimeNonElement; 1.46 +import com.sun.xml.internal.bind.v2.model.runtime.RuntimePropertyInfo; 1.47 +import com.sun.xml.internal.bind.v2.model.runtime.RuntimeTypeRef; 1.48 +import com.sun.xml.internal.bind.v2.runtime.IllegalAnnotationException; 1.49 +import com.sun.xml.internal.bind.v2.runtime.Transducer; 1.50 +import com.sun.xml.internal.bind.v2.runtime.reflect.Accessor; 1.51 + 1.52 +/** 1.53 + * @author Kohsuke Kawaguchi 1.54 + */ 1.55 +final class RuntimeElementInfoImpl extends ElementInfoImpl<Type,Class,Field,Method> 1.56 + implements RuntimeElementInfo { 1.57 + 1.58 + public RuntimeElementInfoImpl(RuntimeModelBuilder modelBuilder, RegistryInfoImpl registry, Method method) throws IllegalAnnotationException { 1.59 + super(modelBuilder, registry, method); 1.60 + 1.61 + Adapter<Type,Class> a = getProperty().getAdapter(); 1.62 + 1.63 + if(a!=null) 1.64 + adapterType = a.adapterType; 1.65 + else 1.66 + adapterType = null; 1.67 + } 1.68 + 1.69 + @Override 1.70 + protected PropertyImpl createPropertyImpl() { 1.71 + return new RuntimePropertyImpl(); 1.72 + } 1.73 + 1.74 + class RuntimePropertyImpl extends PropertyImpl implements RuntimeElementPropertyInfo, RuntimeTypeRef { 1.75 + public Accessor getAccessor() { 1.76 + if(adapterType==null) 1.77 + return Accessor.JAXB_ELEMENT_VALUE; 1.78 + else 1.79 + return Accessor.JAXB_ELEMENT_VALUE.adapt( 1.80 + (Class)getAdapter().defaultType,(Class)adapterType); 1.81 + } 1.82 + 1.83 + public Type getRawType() { 1.84 + return Collection.class; 1.85 + } 1.86 + 1.87 + public Type getIndividualType() { 1.88 + return getContentType().getType(); 1.89 + } 1.90 + 1.91 + 1.92 + public boolean elementOnlyContent() { 1.93 + return false; // this method doesn't make sense here 1.94 + } 1.95 + 1.96 + public List<? extends RuntimeTypeRef> getTypes() { 1.97 + return Collections.singletonList(this); 1.98 + } 1.99 + 1.100 + public List<? extends RuntimeNonElement> ref() { 1.101 + return (List<? extends RuntimeNonElement>)super.ref(); 1.102 + } 1.103 + 1.104 + public RuntimeNonElement getTarget() { 1.105 + return (RuntimeNonElement)super.getTarget(); 1.106 + } 1.107 + 1.108 + public RuntimePropertyInfo getSource() { 1.109 + return this; 1.110 + } 1.111 + 1.112 + public Transducer getTransducer() { 1.113 + return RuntimeModelBuilder.createTransducer(this); 1.114 + } 1.115 + } 1.116 + 1.117 + /** 1.118 + * The adapter specified by <code>getProperty().getAdapter()</code>. 1.119 + */ 1.120 + private final Class<? extends XmlAdapter> adapterType; 1.121 + 1.122 + public RuntimeElementPropertyInfo getProperty() { 1.123 + return (RuntimeElementPropertyInfo)super.getProperty(); 1.124 + } 1.125 + 1.126 + public Class<? extends JAXBElement> getType() { 1.127 + //noinspection unchecked 1.128 + return (Class<? extends JAXBElement>) Utils.REFLECTION_NAVIGATOR.erasure(super.getType()); 1.129 + } 1.130 + 1.131 + public RuntimeClassInfo getScope() { 1.132 + return (RuntimeClassInfo)super.getScope(); 1.133 + } 1.134 + 1.135 + public RuntimeNonElement getContentType() { 1.136 + return (RuntimeNonElement)super.getContentType(); 1.137 + } 1.138 +}