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 |
46 import com.sun.xml.internal.bind.Util; |
46 import com.sun.xml.internal.bind.Util; |
47 import com.sun.xml.internal.bind.api.AccessorException; |
47 import com.sun.xml.internal.bind.api.AccessorException; |
48 import com.sun.xml.internal.bind.v2.ClassFactory; |
48 import com.sun.xml.internal.bind.v2.ClassFactory; |
49 import com.sun.xml.internal.bind.v2.WellKnownNamespace; |
49 import com.sun.xml.internal.bind.v2.WellKnownNamespace; |
50 import com.sun.xml.internal.bind.v2.model.core.ID; |
50 import com.sun.xml.internal.bind.v2.model.core.ID; |
|
51 import com.sun.xml.internal.bind.v2.model.nav.Navigator; |
51 import com.sun.xml.internal.bind.v2.model.runtime.RuntimeClassInfo; |
52 import com.sun.xml.internal.bind.v2.model.runtime.RuntimeClassInfo; |
52 import com.sun.xml.internal.bind.v2.model.runtime.RuntimePropertyInfo; |
53 import com.sun.xml.internal.bind.v2.model.runtime.RuntimePropertyInfo; |
53 import com.sun.xml.internal.bind.v2.runtime.property.AttributeProperty; |
54 import com.sun.xml.internal.bind.v2.runtime.property.AttributeProperty; |
54 import com.sun.xml.internal.bind.v2.runtime.property.Property; |
55 import com.sun.xml.internal.bind.v2.runtime.property.Property; |
55 import com.sun.xml.internal.bind.v2.runtime.property.PropertyFactory; |
56 import com.sun.xml.internal.bind.v2.runtime.property.PropertyFactory; |
188 ClassBeanInfoImpl bi = this; |
189 ClassBeanInfoImpl bi = this; |
189 while ((bi = bi.superClazz) != null) { |
190 while ((bi = bi.superClazz) != null) { |
190 Property[] props = bi.properties; |
191 Property[] props = bi.properties; |
191 if (props == null) break; |
192 if (props == null) break; |
192 for (Property superProperty : props) { |
193 for (Property superProperty : props) { |
193 if (superProperty == null) break; |
194 if (superProperty != null) { |
194 String spName = superProperty.getFieldName(); |
195 String spName = superProperty.getFieldName(); |
195 if ((spName != null) && (spName.equals(p.getFieldName()))) { |
196 if ((spName != null) && (spName.equals(p.getFieldName()))) { |
196 superProperty.setHiddenByOverride(true); |
197 superProperty.setHiddenByOverride(true); |
|
198 } |
197 } |
199 } |
198 } |
200 } |
199 } |
201 } |
200 } |
202 } |
201 |
203 |
337 try { |
339 try { |
338 for (Property<BeanT> p : properties) { |
340 for (Property<BeanT> p : properties) { |
339 if (retainPropertyInfo) { |
341 if (retainPropertyInfo) { |
340 target.currentProperty.set(p); |
342 target.currentProperty.set(p); |
341 } |
343 } |
342 if (!(p.isHiddenByOverride() && !bean.getClass().equals(jaxbType))) { |
344 boolean isThereAnOverridingProperty = p.isHiddenByOverride(); |
|
345 if (!isThereAnOverridingProperty || bean.getClass().equals(jaxbType)) { |
343 p.serializeBody(bean, target, null); |
346 p.serializeBody(bean, target, null); |
|
347 } else if (isThereAnOverridingProperty) { |
|
348 // need to double check the override - it should be safe to do after the model has been created because it's targeted to override properties only |
|
349 Class beanClass = bean.getClass(); |
|
350 if (Navigator.REFLECTION.getDeclaredField(beanClass, p.getFieldName()) == null) { |
|
351 p.serializeBody(bean, target, null); |
|
352 } |
344 } |
353 } |
345 } |
354 } |
346 } catch (AccessorException e) { |
355 } catch (AccessorException e) { |
347 target.reportError(null, e); |
356 target.reportError(null, e); |
348 } |
357 } |