com.sun.xml.bind.v2.runtime.unmarshaller

Class UnmarshallingContext.State

public final class UnmarshallingContext.State extends Object

State information for each element.
Field Summary
Objectbackup
Hack for making JAXBElement unmarshalling work.
StringelementDefaultValue
If this element has an element default value.
Intercepterintercepter
Loaderloader
Loader that owns this element.
booleannil
UnmarshallingContext.Stateprev
State for the parent element State objects form a doubly linked list.
Receiverreceiver
Once loader is completed, this receiver receives the result.
Objecttarget
Object being unmarshalled by this loader.
Method Summary
UnmarshallingContextgetContext()
Gets the context.

Field Detail

backup

public Object backup
Hack for making JAXBElement unmarshalling work.

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)

elementDefaultValue

public String elementDefaultValue
If this element has an element default value. This should be set by either a parent Loader when Loader is called or by a child Loader when Loader is called.

intercepter

public Intercepter intercepter

loader

public Loader loader
Loader that owns this element.

nil

public boolean nil

public UnmarshallingContext.State prev
State for the parent element State objects form a doubly linked list.

receiver

public Receiver receiver
Once loader is completed, this receiver receives the result.

target

public Object target
Object being unmarshalled by this loader.

Method Detail

getContext

public UnmarshallingContext getContext()
Gets the context.