Package org.opensaml.core.xml

# Class XMLObjectBuilderFactory

java.lang.Object
org.opensaml.core.xml.XMLObjectBuilderFactory

public class XMLObjectBuilderFactory extends Object
A factory for `XMLObjectBuilder`s. XMLObjectBuilders are stored and retrieved by a `QName` key. This key is either the XML Schema Type or element QName of the XML element the built XMLObject object represents.

## Field Summary

Fields
Modifier and Type
Field
Description
`private final Map<QName,XMLObjectBuilder<?>>`
`builders`
Registered builders.
`private final org.slf4j.Logger`
`log`
Class logger.

## Constructor Summary

Constructors
Constructor
Description
`XMLObjectBuilderFactory()`
Constructor.

## Method Summary

Modifier and Type
Method
Description
`XMLObjectBuilder<?>`
`deregisterBuilder(QName builderKey)`
Deregisters a builder.
`<XMLObjectType extends XMLObject>
XMLObjectBuilder<XMLObjectType>`
`ensureBuilder(QName key)`
Retrieves an `XMLObjectBuilder` using the key it was registered with, or throws a runtime error if unable to locate one.
`<XMLObjectType extends XMLObject>
XMLObjectBuilder<XMLObjectType>`
`ensureBuilder(Element domElement)`
Retrieves the `XMLObjectBuilder` for the given element.
`XMLObjectBuilder<?>`
`getBuilder(QName key)`
Retrieves an `XMLObjectBuilder` using the key it was registered with.
`XMLObjectBuilder<?>`
`getBuilder(Element domElement)`
Retrieves the XMLObject builder for the given element.
`Map<QName,XMLObjectBuilder<?>>`
`getBuilders()`
Gets an immutable list of all the builders currently registered.
`void`
`registerBuilder(QName builderKey, XMLObjectBuilder<?> builder)`
Registers a new builder for the given name.

### 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.

### builders

@Nonnull private final Map<QName,XMLObjectBuilder<?>> builders
Registered builders.

## Constructor Details

### XMLObjectBuilderFactory

public XMLObjectBuilderFactory()
Constructor.

## Method Details

### getBuilder

@Nullable public XMLObjectBuilder<?> getBuilder(@Nonnull QName key)
Retrieves an `XMLObjectBuilder` using the key it was registered with.

Parameters:
  `key` - the key used to register the builder
Returns:
  the builder, or null

### getBuilder

@Nullable public XMLObjectBuilder<?> getBuilder(@Nonnull Element domElement)
Retrieves the XMLObject builder 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 builder registered under it.

Parameters:
  `domElement` - the element to retrieve the builder for
Returns:
  the builder for the XMLObject the given element can be unmarshalled into, or null

### ensureBuilder

@Nonnull public <XMLObjectType extends XMLObject> XMLObjectBuilder<XMLObjectType> ensureBuilder(@Nonnull QName key)
Retrieves an `XMLObjectBuilder` using the key it was registered with, or throws a runtime error if unable to locate one.

Type Parameters:
  `XMLObjectType` - the type of object the builder is assumed to support
Parameters:
  `key` - the key used to register the builder
Returns:
  the builder
Throws:
  `XMLRuntimeException` - if the builder can't be obtained

### ensureBuilder

@Nonnull public <XMLObjectType extends XMLObject> XMLObjectBuilder<XMLObjectType> ensureBuilder(@Nonnull Element domElement)
Retrieves the `XMLObjectBuilder` 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 builder registered under it.

Type Parameters:
  `XMLObjectType` - the type of object the builder is assumed to support
Parameters:
  `domElement` - the element to retrieve the builder for
Returns:
  the builder for the XMLObject the given element can be unmarshalled into
Throws:
  `XMLRuntimeException` - if the builder can't be obtained

### getBuilders

@Nonnull @NotLive @Unmodifiable public Map<QName,XMLObjectBuilder<?>> getBuilders()
Gets an immutable list of all the builders currently registered.

Returns:
  list of all the builders currently registered

### registerBuilder

public void registerBuilder(@Nonnull QName builderKey, @Nonnull XMLObjectBuilder<?> builder)
Registers a new builder for the given name.

Parameters:
  `builderKey` - the key used to retrieve this builder later
  `builder` - the builder

### deregisterBuilder

@Nullable public XMLObjectBuilder<?> deregisterBuilder(@Nonnull QName builderKey)
Deregisters a builder.

Parameters:
  `builderKey` - the key for the builder to be deregistered
Returns:
  the builder that was registered for the given QName