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 |
206 this.core = core; |
206 this.core = core; |
207 } |
207 } |
208 |
208 |
209 @Override |
209 @Override |
210 public final void startElement(UnmarshallingContext.State state, TagName ea) throws SAXException { |
210 public final void startElement(UnmarshallingContext.State state, TagName ea) throws SAXException { |
211 state.loader = core; |
211 state.setLoader(core); |
212 state.intercepter = this; |
212 state.setIntercepter(this); |
213 |
213 |
214 // TODO: make sure there aren't too many duplicate of this code |
214 // TODO: make sure there aren't too many duplicate of this code |
215 // create the object to unmarshal |
215 // create the object to unmarshal |
216 Object child; |
216 Object child; |
217 UnmarshallingContext context = state.getContext(); |
217 UnmarshallingContext context = state.getContext(); |
229 child = context.createInstance(ElementBeanInfoImpl.this); |
229 child = context.createInstance(ElementBeanInfoImpl.this); |
230 |
230 |
231 fireBeforeUnmarshal(ElementBeanInfoImpl.this, child, state); |
231 fireBeforeUnmarshal(ElementBeanInfoImpl.this, child, state); |
232 |
232 |
233 context.recordOuterPeer(child); |
233 context.recordOuterPeer(child); |
234 UnmarshallingContext.State p = state.prev; |
234 UnmarshallingContext.State p = state.getPrev(); |
235 p.backup = p.target; |
235 p.setBackup(p.getTarget()); |
236 p.target = child; |
236 p.setTarget(child); |
237 |
237 |
238 core.startElement(state,ea); |
238 core.startElement(state,ea); |
239 } |
239 } |
240 |
240 |
241 public Object intercept(UnmarshallingContext.State state, Object o) throws SAXException { |
241 public Object intercept(UnmarshallingContext.State state, Object o) throws SAXException { |
242 JAXBElement e = (JAXBElement)state.target; |
242 JAXBElement e = (JAXBElement)state.getTarget(); |
243 state.target = state.backup; |
243 state.setTarget(state.getBackup()); |
244 state.backup = null; |
244 state.setBackup(null); |
245 |
245 |
246 if (state.nil) { |
246 if (state.isNil()) { |
247 e.setNil(true); |
247 e.setNil(true); |
248 state.nil = false; |
248 state.setNil(false); |
249 } |
249 } |
250 |
250 |
251 if(o!=null) |
251 if(o!=null) |
252 // if the value is a leaf type, it's often already set to the element |
252 // if the value is a leaf type, it's often already set to the element |
253 // through Accessor. |
253 // through Accessor. |