Package org.opensaml.core.xml.io

# Class UnmarshallerFactory

java.lang.Object
org.opensaml.core.xml.io.UnmarshallerFactory

public class UnmarshallerFactory extends Object
This thread-safe factory creates `Unmarshaller`s that can be used to convert W3C DOM elements into `XMLObject`s. Unmarshallers are stored and retrieved by a `QName` key. This key is either the XML Schema Type or element QName of the XML element being unmarshalled.

## Field Summary

Fields
Modifier and Type
Field
Description
`private final org.slf4j.Logger`
`log`
Class logger.
`private final Map<QName,Unmarshaller>`
`unmarshallers`
Map of unmarshallers to the elements they are for.

## Constructor Summary

Constructors
Constructor
Description
`UnmarshallerFactory()`
Constructor.

## Method Summary

Modifier and Type
Method
Description
`Unmarshaller`
`deregisterUnmarshaller(QName key)`
Deregisters the unmarshaller for the given element.
`Unmarshaller`
`ensureUnmarshaller(QName key)`
Call `getUnmarshaller(QName)` and raise an exception if no unmarshaller is registered.
`Unmarshaller`
`ensureUnmarshaller(Element domElement)`
Call `getUnmarshaller(Element)` and raise an exception if no unmarshaller is registered.
`Unmarshaller`
`getUnmarshaller(QName key)`
Gets the Unmarshaller for a particular element or null if no unmarshaller is registered for an element.
`Unmarshaller`
`getUnmarshaller(Element domElement)`
Retrieves the unmarshaller for the given element.
`Map<QName,Unmarshaller>`
`getUnmarshallers()`
Gets an immutable listing of all the Unarshallers currently registered.
`void`
`registerUnmarshaller(QName key, Unmarshaller unmarshaller)`
Registers an Unmarshaller with this factory.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Field Details

### log

@Nonnull private final org.slf4j.Logger log
Class logger.

### unmarshallers

@Nonnull private final Map<QName,Unmarshaller> unmarshallers
Map of unmarshallers to the elements they are for.

## Constructor Details

### UnmarshallerFactory

public UnmarshallerFactory()
Constructor.

## Method Details

### getUnmarshaller

@Nullable public Unmarshaller getUnmarshaller(@Nonnull QName key)
Gets the Unmarshaller for a particular element or null if no unmarshaller is registered for an element.

Parameters:
  `key` - the key the unmarshaller was registered under
Returns:
  the Unmarshaller

### getUnmarshaller

@Nullable public Unmarshaller getUnmarshaller(@Nonnull Element domElement)
Retrieves the unmarshaller for the given element. The schema type, if present, is tried first as the key with the element QName used if no schema type is present or does not have a unmarshaller registered under it.

Parameters:
  `domElement` - the element to retrieve the unmarshaller for
Returns:
  the unmarshaller for the XMLObject the given element can be unmarshalled into

### ensureUnmarshaller

@Nonnull public Unmarshaller ensureUnmarshaller(@Nonnull QName key)
Call `getUnmarshaller(QName)` and raise an exception if no unmarshaller is registered.

Parameters:
  `key` - type of unmarshaller to fetch
Returns:
  the registered unmarshaller
Throws:
  `XMLRuntimeException` - if no unmarshaller is registered
Since:
  5.0.0

### ensureUnmarshaller

@Nonnull public Unmarshaller ensureUnmarshaller(@Nonnull Element domElement)
Call `getUnmarshaller(Element)` and raise an exception if no unmarshaller is registered.

Parameters:
  `domElement` - element to find unmarshaller for
Returns:
  the registered unmarshaller
Throws:
  `XMLRuntimeException` - if no unmarshaller is registered
Since:
  5.0.0

### getUnmarshallers

@Nonnull @Unmodifiable @NotLive public Map<QName,Unmarshaller> getUnmarshallers()
Gets an immutable listing of all the Unarshallers currently registered.

Returns:
  a listing of all the Unmarshallers currently registered

### registerUnmarshaller

public void registerUnmarshaller(@Nonnull QName key, @Nonnull Unmarshaller unmarshaller)
Registers an Unmarshaller with this factory. If an Unmarshaller exist for the Qname given it is replaced with the given unmarshaller.

Parameters:
  `key` - the key the unmarshaller was registered under
  `unmarshaller` - the Unmarshaller

### deregisterUnmarshaller

@Nullable public Unmarshaller deregisterUnmarshaller(@Nonnull QName key)
Deregisters the unmarshaller for the given element.

Parameters:
  `key` - the key the unmarshaller was registered under
Returns:
  the Unmarshaller previously registered or null