1 /* |
1 /* |
2 * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved. |
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. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
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 |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. Oracle designates this |
7 * published by the Free Software Foundation. Oracle designates this |
24 */ |
24 */ |
25 |
25 |
26 package com.sun.xml.internal.ws.spi.db; |
26 package com.sun.xml.internal.ws.spi.db; |
27 |
27 |
28 import java.lang.annotation.Annotation; |
28 import java.lang.annotation.Annotation; |
|
29 import java.lang.reflect.GenericArrayType; |
29 import java.lang.reflect.Type; |
30 import java.lang.reflect.Type; |
30 import java.util.Collection; |
31 import java.util.Collection; |
31 import java.util.HashMap; |
32 import java.util.HashMap; |
32 import java.util.Map; |
33 import java.util.Map; |
33 |
34 |
115 * Otherwise returns an identical type. |
116 * Otherwise returns an identical type. |
116 */ |
117 */ |
117 public TypeInfo toItemType() { |
118 public TypeInfo toItemType() { |
118 // if we are to reinstitute this check, check JAXB annotations only |
119 // if we are to reinstitute this check, check JAXB annotations only |
119 // assert annotations.length==0; // not designed to work with adapters. |
120 // assert annotations.length==0; // not designed to work with adapters. |
120 |
121 Type t = (genericType != null)? genericType : type; |
121 Type base = Navigator.REFLECTION.getBaseClass(type, Collection.class); |
122 Type base = Navigator.REFLECTION.getBaseClass(t, Collection.class); |
122 if(base==null) |
123 if(base==null) |
123 return this; // not a collection |
124 return this; // not a collection |
124 |
125 |
125 return new TypeInfo(tagName, |
126 return new TypeInfo(tagName, |
126 Navigator.REFLECTION.getTypeArgument(base,0)); |
127 Navigator.REFLECTION.getTypeArgument(base,0)); |
168 |
169 |
169 public String toString() { |
170 public String toString() { |
170 return new StringBuilder("TypeInfo: Type = ").append(type) |
171 return new StringBuilder("TypeInfo: Type = ").append(type) |
171 .append(", tag = ").append(tagName).toString(); |
172 .append(", tag = ").append(tagName).toString(); |
172 } |
173 } |
|
174 |
|
175 public TypeInfo getItemType() { |
|
176 // System.out.println("????? TypeInfo " + type); |
|
177 if (type instanceof Class && ((Class)type).isArray() && !byte[].class.equals(type)) { |
|
178 Type componentType = ((Class)type).getComponentType(); |
|
179 Type genericComponentType = null; |
|
180 if (genericType!= null && genericType instanceof GenericArrayType) { |
|
181 GenericArrayType arrayType = (GenericArrayType) type; |
|
182 genericComponentType = arrayType.getGenericComponentType(); |
|
183 componentType = arrayType.getGenericComponentType(); |
|
184 } |
|
185 TypeInfo ti =new TypeInfo(tagName, componentType, annotations); |
|
186 if (genericComponentType != null) ti.setGenericType(genericComponentType); |
|
187 return ti; |
|
188 } |
|
189 // if (type instanceof Class && java.util.Collection.class.isAssignableFrom((Class)type)) { |
|
190 Type t = (genericType != null)? genericType : type; |
|
191 Type base = Navigator.REFLECTION.getBaseClass(t, Collection.class); |
|
192 if ( base != null) { |
|
193 return new TypeInfo(tagName, Navigator.REFLECTION.getTypeArgument(base,0), annotations); |
|
194 } |
|
195 return null; |
|
196 } |
173 } |
197 } |