com.sun.xml.bind.v2.runtime.unmarshaller
public final class UnmarshallingContext.State extends Object
Field Summary | |
---|---|
Object | backup
Hack for making JAXBElement unmarshalling work.
|
String | elementDefaultValue
If this element has an element default value.
|
Intercepter | intercepter |
Loader | loader
Loader that owns this element. |
boolean | nil |
UnmarshallingContext.State | prev |
Receiver | receiver
Once loader is completed, this receiver
receives the result. |
Object | target
Object being unmarshalled by this loader. |
Method Summary | |
---|---|
UnmarshallingContext | getContext()
Gets the context. |
While the unmarshalling is in progress, the target field stores the object being unmarshalled. This makes it convenient to keep track of the unmarshalling activity in context of XML infoset, but since there's only one State per element, this mechanism only works when there's one object per element, which breaks down when we have JAXBElement, since the presence of JAXBElement requires that we have two objects unmarshalled (a JAXBElement X and a value object Y bound to an XML type.)
So to make room for storing both, this backup field is used. When we create X instance in the above example, we set that to {@code state.prev.target} and displace its old value to {@code state.prev.backup} (where Y goes to {@code state.target}.) Upon the completion of the unmarshalling of Y, we revert this.
While this attributes X incorrectly to its parent element, this preserves the parent/child relationship between unmarshalled objects and State parent/child relationship, and it thereby makes Receiver mechanism simpler.
Yes, I know this is a hack, and no, I'm not proud of it.
See Also: ElementBeanInfoImpl.IntercepterLoader#startElement(State, TagName) ElementBeanInfoImpl.IntercepterLoader#intercept(State, Object)