com.sun.xml.bind.v2.runtime.unmarshaller
public final class UnmarshallingContext extends Coordinator implements NamespaceContext, ValidationEventHandler, ErrorHandler, XmlVisitor, XmlVisitor.TextPredictor
This object is responsible for coordinating Loaders to perform the whole unmarshalling.
Nested Class Summary | |
---|---|
class | UnmarshallingContext.State
State information for each element. |
Field Summary | |
---|---|
ClassLoader | classLoader
User-supplied ClassLoader for converting name to Class.
|
ClassResolver | classResolver
Used to discover additional classes when we hit unknown elements/types. |
LocatorEx | locator |
UnmarshallerImpl | parent |
Constructor Summary | |
---|---|
UnmarshallingContext(UnmarshallerImpl _parent, AssociationMap assoc)
Creates a new unmarshaller.
|
Method Summary | |
---|---|
void | addPatcher(Patcher job)
Adds a job that will be executed at the last of the unmarshalling.
|
String | addToIdTable(String id)
Adds the object which is currently being unmarshalled
to the ID table.
|
void | clearResult() |
void | clearStates() |
Object | createInstance(Class<?> clazz)
Creates a new instance of the specified class.
|
Object | createInstance(JaxBeanInfo beanInfo)
Creates a new instance of the specified class.
|
void | endDocument() |
void | endElement(TagName tagName) |
void | endPrefixMapping(String prefix) |
void | endScope(int frameSize)
Ends the current packing scope.
|
void | errorUnresolvedIDREF(Object bean, String idref, LocatorEx loc)
Called when there's no corresponding ID value. |
boolean | expectText()
You should be always calling this through TextPredictor. |
String[] | getAllDeclaredPrefixes()
Returns a list of all in-scope prefixes.
|
UnmarshallingContext | getContext() |
Collection<QName> | getCurrentExpectedAttributes()
Allows to access attributes which are expected in current state.
|
Collection<QName> | getCurrentExpectedElements()
Allows to access elements which are expected in current state.
|
UnmarshallingContext.State | getCurrentState() |
Object | getInnerPeer()
Gets the inner peer JAXB object associated with the current element.
|
static UnmarshallingContext | getInstance()
When called from within the realm of the unmarshaller, this method
returns the current UnmarshallingContext in charge. |
JAXBContextImpl | getJAXBContext() |
protected ValidationEventLocator | getLocation() |
LocatorEx | getLocator()
Gets the current source location information in SAX Locator.
|
String | getNamespaceURI(String prefix) |
String[] | getNewlyDeclaredPrefixes()
Returns a list of prefixes newly declared on the current element.
|
Callable | getObjectFromId(String id, Class targetType)
Looks up the ID table and gets associated object.
|
Object | getOuterPeer()
Gets the outer peer JAXB object associated with the current element.
|
TextPredictor | getPredictor()
You should be always getting TextPredictor from XmlVisitor. |
String | getPrefix(String uri) |
Iterator<String> | getPrefixes(String uri) |
Object | getResult()
Gets the result of the unmarshalling |
Scope | getScope(int offset)
Gets the currently active Scope.
|
StructureLoader | getStructureLoader()
Gets StructureLoader if used as loader.
|
String | getXMIMEContentType()
Gets the xmime:contentType value for the current object.
|
void | handleError(Exception e)
Reports an exception found during the unmarshalling to the user.
|
void | handleError(Exception e, boolean canRecover) |
void | handleError(String msg) |
void | handleEvent(ValidationEvent event, boolean canRecover)
Reports an error to the user, and asks if s/he wants
to recover. |
boolean | handleEvent(ValidationEvent event) |
void | recordInnerPeer(Object innerPeer)
Notifies the context about the inner peer of the current element.
|
void | recordOuterPeer(Object outerPeer)
Notifies the context about the outer peer of the current element.
|
void | reset(InfosetScanner scanner, boolean isInplaceMode, JaxBeanInfo expectedType, IDResolver idResolver) |
Loader | selectRootLoader(UnmarshallingContext.State state, TagName tag)
On top of JAXBContextImpl,
this method also consults ClassResolver.
|
void | setFactories(Object factoryInstances) |
void | startDocument(LocatorEx locator, NamespaceContext nsContext) |
void | startElement(TagName tagName) |
void | startPrefixMapping(String prefix, String uri) |
void | startScope(int frameSize)
Starts a new packing scope.
|
void | text(CharSequence pcdata) |
Parameters: assoc Must be both non-null when the unmarshaller does the in-place unmarshalling. Otherwise must be both null.
Parameters: job The run method of this object is called.
Returns: Returns the value passed as the parameter. This is a hack, but this makes it easier for ID transducer to do its job.
If any packing in progress will be finalized by this method.
Parameters: frameSize The same size that gets passed to the UnmarshallingContext method.
Returns: A possible zero-length array of prefixes. The default prefix is represented by the empty string.
Returns:
Returns:
Returns: null if the current element doesn't have an inner peer, or if we are not doing the in-place unmarshalling.
Sometimes the unmarshaller works against a different kind of XML source, making this information meaningless.
Returns: A possible zero-length array of prefixes. The default prefix is represented by the empty string.
The exception thrown from Callable#call() means the unmarshaller should abort right away.
See Also: IDResolver
Returns: null if the current element doesn't have an inner peer, or if we are not doing the in-place unmarshalling.
Parameters: offset a number between [0,frameSize)
Returns: always a valid Scope object.
See Also: getXMIMEContentType
If the unmarshalling is building the association, the context will use this information. Otherwise it will be just ignored.
If the unmarshalling is building the association, the context will use this information. Otherwise it will be just ignored.
Throws: SAXException if ValidationEventHandler reported a failure.
This method allocates a specified number of fresh Scope objects. They can be accessed by the UnmarshallingContext method until the corresponding UnmarshallingContext method is invoked.
A new scope will mask the currently active scope. Only one frame of Scopes can be accessed at any given time.
Parameters: frameSize The # of slots to be allocated.