Top Description Inners Fields Constructors Methods
org.glassfish.jaxb.runtime.v2.runtime.unmarshaller

public final Class UnmarshallingContext

extends Coordinator
implements NamespaceContext, ValidationEventHandler, ErrorHandler, XmlVisitor, TextPredictor
Class Inheritance
All Implemented Interfaces
org.glassfish.jaxb.runtime.v2.runtime.unmarshaller.XmlVisitor.TextPredictor, org.glassfish.jaxb.runtime.v2.runtime.unmarshaller.XmlVisitor, org.xml.sax.ErrorHandler, jakarta.xml.bind.ValidationEventHandler, javax.xml.namespace.NamespaceContext
Imports
com.sun.istack.NotNull, .Nullable, .SAXParseException2, org.glassfish.jaxb.runtime.IDResolver, org.glassfish.jaxb.runtime.api.AccessorException, .ClassResolver, org.glassfish.jaxb.core.unmarshaller.InfosetScanner, org.glassfish.jaxb.core.v2.ClassFactory, org.glassfish.jaxb.runtime.v2.runtime.AssociationMap, .Coordinator, .JAXBContextImpl, .JaxBeanInfo, org.glassfish.jaxb.core.v2.runtime.unmarshaller.LocatorEx, jakarta.xml.bind.*, jakarta.xml.bind.helpers.ValidationEventImpl, org.xml.sax.ErrorHandler, .Locator, .SAXException, org.xml.sax.helpers.LocatorImpl, javax.xml.XMLConstants, javax.xml.namespace.NamespaceContext, .QName, java.lang.reflect.Method, java.util.*, java.util.concurrent.Callable, java.util.logging.Level, .Logger

Center of the unmarshalling.

This object is responsible for coordinating Loaders to perform the whole unmarshalling.

Author
Kohsuke Kawaguchi

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
UnmarshallingContext.DefaultRootLoader

Root loader that uses the tag name and possibly its @xsi:type to decide how to start unmarshalling.

private static class
UnmarshallingContext.ExpectedTypeRootLoader

Root loader that uses UnmarshallingContext#expectedType to decide how to start unmarshalling.

private static class
UnmarshallingContext.Factory

Stub to the user-specified factory method.

public class
UnmarshallingContext.State

State information for each element.

Field Summary

Modifier and TypeField and Description
private boolean
private final AssociationMap<XmlNode>
assoc

If the unmarshaller is doing associative unmarshalling, this field is initialized to non-null.

public ClassLoader
classLoader

User-supplied ClassLoader for converting name to Class.

public ClassResolver
classResolver

Used to discover additional classes when we hit unknown elements/types.

private UnmarshallingContext.State
current

The currently active state.

private Object
private static final Loader
private static final LocatorEx
private NamespaceContext
private static volatile int
errorsCounter

The variable introduced to avoid reporting n^10 similar errors.

private static final Loader
private JaxBeanInfo<BeanT>
expectedType

If non-null, this unmarshaller will unmarshal JAXBElement<EXPECTEDTYPE> regardless of the tag name, as opposed to deciding the root object by using the tag name.

private final Map<Class<T>, UnmarshallingContext.Factory>
factories

User-specified factory methods.

private IDResolver
idResolver

Handles ID/IDREF.

private boolean
isInplaceMode

Indicates whether we are doing in-place unmarshalling or not.

private boolean
isUnmarshalInProgress

This flag is set to true at the startDocument event and false at the endDocument event.

private LocatorEx
private static final Logger
private String[]
private int
public final UnmarshallerImpl
private Patcher[]
patchers

Submitted patchers in the order they've submitted.

private int
private Object
result

Root object that is being unmarshalled.

private final UnmarshallingContext.State
root

Root state.

private InfosetScanner<XmlNode>
scanner

This object is consulted to get the element object for the current element event.

private Scope<BeanT, PropT, ItemT, PackT>[]
private int
scopeTop

Points to the top of the scope stack (=size-1).

Constructor Summary

AccessConstructor and Description
public
UnmarshallingContext(UnmarshallerImpl _parent, AssociationMap<XmlNode>
Must be both non-null when the unmarshaller does the in-place unmarshalling. Otherwise must be both null.
assoc
)

Creates a new unmarshaller.

Method Summary

Modifier and TypeMethod and Description
private void
private void
addFactory(Object factory)

public void
addPatcher(Patcher
The run method of this object is called.
job
)

Adds a job that will be executed at the last of the unmarshalling.

public String

Returns:

Returns the value passed as the parameter. This is a hack, but this makes it easier for ID transducer to do its job.
addToIdTable
(String id)

Adds the object which is currently being unmarshalled to the ID table.

pack-priv void
public void
public Object
createInstance(Class<?> clazz)

Creates a new instance of the specified class.

public Object
createInstance(JaxBeanInfo<BeanT> beanInfo)

Creates a new instance of the specified class.

public void
public void
public void
endPrefixMapping(String prefix)

Implements org.glassfish.jaxb.runtime.v2.runtime.unmarshaller.XmlVisitor.endPrefixMapping.

Called after endElement event to notify the end of a binding.

public void
endScope(int
The same size that gets passed to the startScope(int) method.
frameSize
)

Ends the current packing scope.

public void
errorUnresolvedIDREF(Object bean, String idref, LocatorEx loc)

Called when there's no corresponding ID value.

public boolean
public String[]

Returns:

A possible zero-length array of prefixes. The default prefix is represented by the empty string.
getAllDeclaredPrefixes
()

Returns a list of all in-scope prefixes.

private List<String>
public UnmarshallingContext
public Collection<QName>
getCurrentExpectedAttributes()

Allows to access attributes which are expected in current state.

public Collection<QName>
getCurrentExpectedElements()

Allows to access elements which are expected in current state.

public UnmarshallingContext.State
public Object

Returns:

null if the current element doesn't have an inner peer, or if we are not doing the in-place unmarshalling.
getInnerPeer
()

Gets the inner peer JAXB object associated with the current element.

public static UnmarshallingContext
getInstance()

When called from within the realm of the unmarshaller, this method returns the current in charge.

public JAXBContextImpl
protected ValidationEventLocator
getLocation()

Implements abstract org.glassfish.jaxb.runtime.v2.runtime.Coordinator.getLocation.

Gets the current location.

public LocatorEx
getLocator()

Gets the current source location information in SAX Locator.

public String
getNamespaceURI(String prefix)

Implements javax.xml.namespace.NamespaceContext.getNamespaceURI.

Get Namespace URI bound to a prefix in the current scope.

public String[]

Returns:

A possible zero-length array of prefixes. The default prefix is represented by the empty string.
getNewlyDeclaredPrefixes
()

Returns a list of prefixes newly declared on the current element.

public Callable<V>
getObjectFromId(String id, Class<T> targetType)

Looks up the ID table and gets associated object.

public Object

Returns:

null if the current element doesn't have an inner peer, or if we are not doing the in-place unmarshalling.
getOuterPeer
()

Gets the outer peer JAXB object associated with the current element.

public XmlVisitor.TextPredictor
public String
getPrefix(String uri)

Implements javax.xml.namespace.NamespaceContext.getPrefix.

Get prefix bound to Namespace URI in the current scope.

public Iterator<String>
getPrefixes(String uri)

Implements javax.xml.namespace.NamespaceContext.getPrefixes.

Get all prefixes bound to a Namespace URI in the current scope.

private String[]
getPrefixList(int startIndex)

public Object
getResult()

Gets the result of the unmarshalling

public Scope<BeanT, PropT, ItemT, PackT>

Returns:

always a valid Scope object.
getScope
(int
a number between [0,frameSize)
offset
)

Gets the currently active Scope.

public StructureLoader
getStructureLoader()

Gets StructureLoader if used as loader.

public String
getXMIMEContentType()

Gets the xmime:contentType value for the current object.

public void
handleError(Exception e)

Reports an exception found during the unmarshalling to the user.

public void
handleError(Exception e, boolean canRecover)

public void
public void
handleEvent(ValidationEvent event, boolean canRecover)

Reports an error to the user, and asks if s/he wants to recover.

public boolean
handleEvent(ValidationEvent event)

Implements jakarta.xml.bind.ValidationEventHandler.handleEvent.

Receive notification of a validation warning or error.

public void
recordInnerPeer(Object innerPeer)

Notifies the context about the inner peer of the current element.

public void
recordOuterPeer(Object outerPeer)

Notifies the context about the outer peer of the current element.

public void
reset(InfosetScanner<XmlNode> scanner, boolean isInplaceMode, JaxBeanInfo<BeanT> expectedType, IDResolver idResolver)

private String
private void
runPatchers()

Executes all the patchers.

public Loader
public void
setFactories(Object factoryInstances)

public boolean

Returns:

true in case if Level#FINEST is set OR we haven't exceed errors reporting limit.
shouldErrorBeReported
()

Based on current Logger Level and errorCounter value determines if error should be reported.

public void
public void
startElement(TagName tagName)

Implements org.glassfish.jaxb.runtime.v2.runtime.unmarshaller.XmlVisitor.startElement.

Notifies a start tag of a new element.

public void
startPrefixMapping(String prefix, String uri)

Implements org.glassfish.jaxb.runtime.v2.runtime.unmarshaller.XmlVisitor.startPrefixMapping.

Called before startElement event to notify a new namespace binding.

public void
startScope(int
The # of slots to be allocated.
frameSize
)

Starts a new packing scope.

public void
Inherited from org.glassfish.jaxb.runtime.v2.runtime.Coordinator:
_getInstancecontainsAdaptererrorfatalErrorgetAdapterpopCoordinatorpushCoordinatorputAdapterwarning