Package org.opensaml.core.xml
Class XMLObjectBuilderFactory
- java.lang.Object
-
- org.opensaml.core.xml.XMLObjectBuilderFactory
-
public class XMLObjectBuilderFactory extends Object
A factory forXMLObjectBuilders. XMLObjectBuilders are stored and retrieved by aQNamekey. 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 Map<QName,XMLObjectBuilder<?>>buildersRegistered builders.private org.slf4j.LoggerlogClass logger.
-
Constructor Summary
Constructors Constructor Description XMLObjectBuilderFactory()Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description XMLObjectBuilder<?>deregisterBuilder(QName builderKey)Deregisters a builder.XMLObjectBuilder<?>getBuilder(QName key)Retrieves anXMLObjectBuilderusing the key it was registered with.XMLObjectBuilder<?>getBuilder(Element domElement)Retrieves the XMLObject builder for the given element.<XMLObjectType extends XMLObject>
XMLObjectBuilder<XMLObjectType>getBuilderOrThrow(QName key)Retrieves anXMLObjectBuilderusing 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 theXMLObjectBuilderfor the given element.Map<QName,XMLObjectBuilder<?>>getBuilders()Gets an immutable list of all the builders currently registered.voidregisterBuilder(QName builderKey, XMLObjectBuilder<?> builder)Registers a new builder for the given name.
-
-
-
Field Detail
-
log
@Nonnull private final org.slf4j.Logger log
Class logger.
-
builders
@Nonnull private final Map<QName,XMLObjectBuilder<?>> builders
Registered builders.
-
-
Method Detail
-
getBuilder
@Nullable public XMLObjectBuilder<?> getBuilder(@Nullable QName key)
Retrieves anXMLObjectBuilderusing 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(@Nullable 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
-
getBuilderOrThrow
@Nonnull public <XMLObjectType extends XMLObject> XMLObjectBuilder<XMLObjectType> getBuilderOrThrow(@Nonnull QName key)
Retrieves anXMLObjectBuilderusing 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 theXMLObjectBuilderfor 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 laterbuilder- 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
-
-