Package org.opensaml.core.xml
Class XMLObjectBuilderFactory
java.lang.Object
org.opensaml.core.xml.XMLObjectBuilderFactory
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
FieldsModifier and TypeFieldDescriptionprivate final Map<QName,
XMLObjectBuilder<?>> Registered builders.private final org.slf4j.Logger
Class logger. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionderegisterBuilder
(QName builderKey) Deregisters a builder.getBuilder
(QName key) Retrieves anXMLObjectBuilder
using the key it was registered with.getBuilder
(Element domElement) Retrieves the XMLObject builder for the given element.<XMLObjectType extends XMLObject>
XMLObjectBuilder<XMLObjectType>getBuilderOrThrow
(QName key) Retrieves anXMLObjectBuilder
using the key it was registered with, or throws a runtime error if unable to locate one.<XMLObjectType extends XMLObject>
XMLObjectBuilder<XMLObjectType>getBuilderOrThrow
(Element domElement) Retrieves theXMLObjectBuilder
for the given element.Map<QName,
XMLObjectBuilder<?>> Gets an immutable list of all the builders currently registered.void
registerBuilder
(QName builderKey, XMLObjectBuilder<?> builder) Registers a new builder for the given name.
-
Field Details
-
log
@Nonnull private final org.slf4j.Logger logClass logger. -
builders
Registered builders.
-
-
Constructor Details
-
XMLObjectBuilderFactory
public XMLObjectBuilderFactory()Constructor.
-
-
Method Details
-
getBuilder
Retrieves anXMLObjectBuilder
using the key it was registered with.- Parameters:
key
- the key used to register the builder- Returns:
- the builder, or null
-
getBuilder
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
-
getBuilderOrThrow
@Nonnull public <XMLObjectType extends XMLObject> XMLObjectBuilder<XMLObjectType> getBuilderOrThrow(@Nonnull QName key) Retrieves anXMLObjectBuilder
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
-
getBuilderOrThrow
@Nonnull public <XMLObjectType extends XMLObject> XMLObjectBuilder<XMLObjectType> getBuilderOrThrow(@Nonnull Element domElement) Retrieves theXMLObjectBuilder
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
Gets an immutable list of all the builders currently registered.- Returns:
- list of all the builders currently registered
-
registerBuilder
Registers a new builder for the given name.- Parameters:
builderKey
- the key used to retrieve this builder laterbuilder
- the builder
-
deregisterBuilder
Deregisters a builder.- Parameters:
builderKey
- the key for the builder to be deregistered- Returns:
- the builder that was registered for the given QName
-