Class XMLObjectBuilderFactory

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

public class XMLObjectBuilderFactory extends Object
A factory for XMLObjectBuilders. 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 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(@Nullable 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(@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 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
    • getBuilderOrThrow

      @Nonnull public <XMLObjectType extends XMLObject> XMLObjectBuilder<XMLObjectType> getBuilderOrThrow(@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