1 /*
2 * Copyright (c) 1997, 2013, 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
272 XmlSeeAlso sa = reader.getClassAnnotation(XmlSeeAlso.class, clazz, upstream);
273 if(sa!=null) {
274 for( T t : reader.getClassArrayValue(sa,"value") ) {
275 getTypeInfo(t,(Locatable)sa);
276 }
277 }
278
279
280 return r;
281 }
282
283 /**
284 * Adding package's ObjectFactory methods to registry
285 * @param clazz which package will be used
286 * @param p location
287 */
288 private void addToRegistry(C clazz, Locatable p) {
289 String pkg = nav.getPackageName(clazz);
290 if (!registries.containsKey(pkg)) {
291 // insert the package's object factory
292 C c = loadObjectFactory(clazz, pkg);
293 if (c != null)
294 addRegistry(c, p);
295 }
296 }
297
298 private C loadObjectFactory(C clazz, String pkg) {
299 C c;
300 try {
301 c = nav.findClass(pkg + ".ObjectFactory", clazz);
302 } catch (SecurityException ignored) {
303 // treat SecurityException in same way as ClassNotFoundException in this case
304 c = null;
305 }
306 return c;
307 }
308
309 /**
310 * Getting parametrized classes of {@code JAXBElement<...>} property
311 * @param p property which parametrized types we will try to get
312 * @return null - if it's not JAXBElement property, or it's not parametrized, and array of parametrized classes in other case
313 */
314 private Class[] getParametrizedTypes(PropertyInfo p) {
315 try {
316 Type pType = ((RuntimePropertyInfo) p).getIndividualType();
317 if (pType instanceof ParameterizedType) {
318 ParameterizedType prmzdType = (ParameterizedType) pType;
319 if (prmzdType.getRawType() == JAXBElement.class) {
320 Type[] actualTypes = prmzdType.getActualTypeArguments();
321 Class[] result = new Class[actualTypes.length];
322 for (int i = 0; i < actualTypes.length; i++) {
323 result[i] = (Class) actualTypes[i];
324 }
325 return result;
326 }
327 }
328 } catch (Exception e) {
|
1 /*
2 * Copyright (c) 1997, 2014, 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
272 XmlSeeAlso sa = reader.getClassAnnotation(XmlSeeAlso.class, clazz, upstream);
273 if(sa!=null) {
274 for( T t : reader.getClassArrayValue(sa,"value") ) {
275 getTypeInfo(t,(Locatable)sa);
276 }
277 }
278
279
280 return r;
281 }
282
283 /**
284 * Adding package's ObjectFactory methods to registry
285 * @param clazz which package will be used
286 * @param p location
287 */
288 private void addToRegistry(C clazz, Locatable p) {
289 String pkg = nav.getPackageName(clazz);
290 if (!registries.containsKey(pkg)) {
291 // insert the package's object factory
292 C c = nav.loadObjectFactory(clazz, pkg);
293 if (c != null)
294 addRegistry(c, p);
295 }
296 }
297
298 /**
299 * Getting parametrized classes of {@code JAXBElement<...>} property
300 * @param p property which parametrized types we will try to get
301 * @return null - if it's not JAXBElement property, or it's not parametrized, and array of parametrized classes in other case
302 */
303 private Class[] getParametrizedTypes(PropertyInfo p) {
304 try {
305 Type pType = ((RuntimePropertyInfo) p).getIndividualType();
306 if (pType instanceof ParameterizedType) {
307 ParameterizedType prmzdType = (ParameterizedType) pType;
308 if (prmzdType.getRawType() == JAXBElement.class) {
309 Type[] actualTypes = prmzdType.getActualTypeArguments();
310 Class[] result = new Class[actualTypes.length];
311 for (int i = 0; i < actualTypes.length; i++) {
312 result[i] = (Class) actualTypes[i];
313 }
314 return result;
315 }
316 }
317 } catch (Exception e) {
|