1 /* |
1 /* |
2 * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved. |
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. |
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 |
60 |
60 |
61 if (b != null && b) { |
61 if (b != null && b) { |
62 onNil(state); |
62 onNil(state); |
63 boolean hasOtherAttributes = (ea.atts.getLength() - 1) > 0; |
63 boolean hasOtherAttributes = (ea.atts.getLength() - 1) > 0; |
64 // see issues 6759703 and 565 - need to preserve attributes even if the element is nil; only when the type is stored in JAXBElement |
64 // see issues 6759703 and 565 - need to preserve attributes even if the element is nil; only when the type is stored in JAXBElement |
65 if (!(hasOtherAttributes && (state.prev.target instanceof JAXBElement))) { |
65 if (!(hasOtherAttributes && (state.getPrev().getTarget() instanceof JAXBElement))) { |
66 return Discarder.INSTANCE; |
66 return Discarder.INSTANCE; |
67 } |
67 } |
68 } |
68 } |
69 } |
69 } |
70 return defaultLoader; |
70 return defaultLoader; |
94 } |
94 } |
95 |
95 |
96 @Override |
96 @Override |
97 protected void onNil(UnmarshallingContext.State state) throws SAXException { |
97 protected void onNil(UnmarshallingContext.State state) throws SAXException { |
98 try { |
98 try { |
99 acc.set(state.prev.target,null); |
99 acc.set(state.getPrev().getTarget(),null); |
100 state.prev.nil = true; |
100 state.getPrev().setNil(true); |
101 } catch (AccessorException e) { |
101 } catch (AccessorException e) { |
102 handleGenericException(e,true); |
102 handleGenericException(e,true); |
103 } |
103 } |
104 } |
104 } |
105 |
105 |