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 |
86 * The default implementation reports an error saying an element is unexpected. |
86 * The default implementation reports an error saying an element is unexpected. |
87 */ |
87 */ |
88 public void childElement(UnmarshallingContext.State state, TagName ea) throws SAXException { |
88 public void childElement(UnmarshallingContext.State state, TagName ea) throws SAXException { |
89 // notify the error, then recover by ignoring the whole element. |
89 // notify the error, then recover by ignoring the whole element. |
90 reportUnexpectedChildElement(ea, true); |
90 reportUnexpectedChildElement(ea, true); |
91 state.loader = Discarder.INSTANCE; |
91 state.setLoader(Discarder.INSTANCE); |
92 state.receiver = null; |
92 state.setReceiver(null); |
93 } |
93 } |
94 |
94 |
95 @SuppressWarnings({"StringEquality"}) |
95 @SuppressWarnings({"StringEquality"}) |
96 protected final void reportUnexpectedChildElement(TagName ea, boolean canRecover) throws SAXException { |
96 protected final void reportUnexpectedChildElement(TagName ea, boolean canRecover) throws SAXException { |
97 if (canRecover) { |
97 if (canRecover) { |
193 protected final void fireBeforeUnmarshal(JaxBeanInfo beanInfo, Object child, UnmarshallingContext.State state) throws SAXException { |
193 protected final void fireBeforeUnmarshal(JaxBeanInfo beanInfo, Object child, UnmarshallingContext.State state) throws SAXException { |
194 if(beanInfo.lookForLifecycleMethods()) { |
194 if(beanInfo.lookForLifecycleMethods()) { |
195 UnmarshallingContext context = state.getContext(); |
195 UnmarshallingContext context = state.getContext(); |
196 Unmarshaller.Listener listener = context.parent.getListener(); |
196 Unmarshaller.Listener listener = context.parent.getListener(); |
197 if(beanInfo.hasBeforeUnmarshalMethod()) { |
197 if(beanInfo.hasBeforeUnmarshalMethod()) { |
198 beanInfo.invokeBeforeUnmarshalMethod(context.parent, child, state.prev.target); |
198 beanInfo.invokeBeforeUnmarshalMethod(context.parent, child, state.getPrev().getTarget()); |
199 } |
199 } |
200 if(listener!=null) { |
200 if(listener!=null) { |
201 listener.beforeUnmarshal(child, state.prev.target); |
201 listener.beforeUnmarshal(child, state.getPrev().getTarget()); |
202 } |
202 } |
203 } |
203 } |
204 } |
204 } |
205 |
205 |
206 /** |
206 /** |
213 // fire the event callback |
213 // fire the event callback |
214 if(beanInfo.lookForLifecycleMethods()) { |
214 if(beanInfo.lookForLifecycleMethods()) { |
215 UnmarshallingContext context = state.getContext(); |
215 UnmarshallingContext context = state.getContext(); |
216 Unmarshaller.Listener listener = context.parent.getListener(); |
216 Unmarshaller.Listener listener = context.parent.getListener(); |
217 if(beanInfo.hasAfterUnmarshalMethod()) { |
217 if(beanInfo.hasAfterUnmarshalMethod()) { |
218 beanInfo.invokeAfterUnmarshalMethod(context.parent, child, state.target); |
218 beanInfo.invokeAfterUnmarshalMethod(context.parent, child, state.getTarget()); |
219 } |
219 } |
220 if(listener!=null) |
220 if(listener!=null) |
221 listener.afterUnmarshal(child, state.target); |
221 listener.afterUnmarshal(child, state.getTarget()); |
222 } |
222 } |
223 } |
223 } |
224 |
224 |
225 |
225 |
226 /** |
226 /** |