Interface JaxbContextBuilder


public interface JaxbContextBuilder
The jaxb context builder.
Author:
Christian Bremer
  • Field Details

    • DEFAULT_DEPENDENCIES_RESOLVER

      static final JaxbDependenciesResolver DEFAULT_DEPENDENCIES_RESOLVER
      The default dependencies resolver implementation.
  • Method Details

    • newInstance

      static JaxbContextBuilder newInstance()
      Creates a new jaxb context builder.
      Returns:
      the jaxb context builder
    • copy

      Copy jaxb context builder.
      Returns:
      the jaxb context builder
    • withSchemaMode

      JaxbContextBuilder withSchemaMode(SchemaMode schemaMode)
      Specifies whether to add a schema to the marshaller or unmarshaller. The default is to add never a schema to the marshaller or unmarshaller.
      Parameters:
      schemaMode - the schema mode
      Returns:
      the jaxb context builder
      See Also:
    • withSchemaBuilder

      JaxbContextBuilder withSchemaBuilder(SchemaBuilder schemaBuilder)
      Specifies the schema builder to generate the schema. The default is the default schema builder implementation (see SchemaBuilder.newInstance()).
      Parameters:
      schemaBuilder - the schema builder
      Returns:
      the jaxb context builder
    • withDependenciesResolver

      JaxbContextBuilder withDependenciesResolver(JaxbDependenciesResolver resolver)
      Specifies the dependencies-resolver to use. The default jaxb context builder will use a default implementation.

      To turn off dependency resolving set null here.

      Parameters:
      resolver - the resolver
      Returns:
      the jaxb context builder
    • withContextClassLoader

      JaxbContextBuilder withContextClassLoader(ClassLoader classLoader)
      Specifies the class loader to use.
      Parameters:
      classLoader - the class loader
      Returns:
      the jaxb context builder
    • withFormattedOutput

      JaxbContextBuilder withFormattedOutput(boolean formattedOutput)
      Specify whether the xml output should be formatted or not.
      Parameters:
      formattedOutput - the formatted output
      Returns:
      the jaxb context builder
    • withXmlAdapters

      JaxbContextBuilder withXmlAdapters(Collection<? extends jakarta.xml.bind.annotation.adapters.XmlAdapter<?,?>> xmlAdapters)
      Sets xml adapters of marshaller and unmarshaller.
      Parameters:
      xmlAdapters - the xml adapters
      Returns:
      the jaxb context builder
    • withAttachmentMarshaller

      JaxbContextBuilder withAttachmentMarshaller(jakarta.xml.bind.attachment.AttachmentMarshaller attachmentMarshaller)
      Set attachment marshaller.
      Parameters:
      attachmentMarshaller - the attachment marshaller
      Returns:
      the jaxb context builder
    • withAttachmentUnmarshaller

      JaxbContextBuilder withAttachmentUnmarshaller(jakarta.xml.bind.attachment.AttachmentUnmarshaller attachmentUnmarshaller)
      Set attachment unmarshaller.
      Parameters:
      attachmentUnmarshaller - the attachment unmarshaller
      Returns:
      the jaxb context builder
    • withValidationEventHandler

      JaxbContextBuilder withValidationEventHandler(jakarta.xml.bind.ValidationEventHandler validationEventHandler)
      Set validation event handler of marshaller and unmarshaller.
      Parameters:
      validationEventHandler - the validation event handler
      Returns:
      the jaxb context builder
    • add

      Add jaxb context meta-data to the jaxb context builder.
      Parameters:
      data - the data
      Returns:
      the jaxb context builder
    • addAll

      default JaxbContextBuilder addAll(Iterable<? extends JaxbContextMember> data)
      Add all jaxb context meta-data to the jaxb context builder.
      Parameters:
      data - the data
      Returns:
      the jaxb context builder
    • addAll

      default JaxbContextBuilder addAll(Iterator<? extends JaxbContextMember> data)
      Add all jaxb context meta-data to the jaxb context builder.
      Parameters:
      data - the data
      Returns:
      the jaxb context builder
    • process

      default JaxbContextBuilder process(JaxbContextDataProvider dataProvider)
      Process the jaxb context meta-data provider and add its data to the jaxb context builder.
      Parameters:
      dataProvider - the data provider
      Returns:
      the jaxb context builder
    • processAll

      default JaxbContextBuilder processAll(Iterable<? extends JaxbContextDataProvider> dataProviders)
      Process the jaxb context meta-data providers and add their data to the jaxb context builder.
      Parameters:
      dataProviders - the data providers
      Returns:
      the jaxb context builder
    • processAll

      default JaxbContextBuilder processAll(Iterator<? extends JaxbContextDataProvider> dataProviders)
      Process the jaxb context meta-data providers and add their data to the jaxb context builder.
      Parameters:
      dataProviders - the data providers
      Returns:
      the jaxb context builder
    • canUnmarshal

      default boolean canUnmarshal(Class<?> clazz)
      Determines whether the unmarshaller can decode xml into an object of the given class.
      Parameters:
      clazz - the class
      Returns:
      true if the unmarshaller can decode xml into an object of the given class, otherwise false
    • canMarshal

      default boolean canMarshal(Class<?> clazz)
      Determines whether the marshaller can encode an object of the given class into xml.
      Parameters:
      clazz - the class
      Returns:
      true if the marshaller can decode an object of the given class into xml, otherwise false
    • buildUnmarshaller

      jakarta.xml.bind.Unmarshaller buildUnmarshaller(Class<?>... classes)
      Build unmarshaller for the given classes with the specified dependencies-resolver. If dependency resolving is turned off, an unmarshaller of the default context (defined by the added meta-data) will be returned or one that is created with JAXBContext.newInstance(Class[])*.
      Parameters:
      classes - the classes that should be processed by the unmarshaller
      Returns:
      the unmarshaller
      See Also:
    • buildMarshaller

      default jakarta.xml.bind.Marshaller buildMarshaller()
      Build marshaller with the context which is defined by the added meta-data.
      Returns:
      the marshaller
    • buildMarshaller

      jakarta.xml.bind.Marshaller buildMarshaller(Object value)
      Build marshaller for the given object (POJO) or for the given class or array of classes with the specified dependencies-resolver. If dependency resolving is turned off, a marshaller of the default context (defined by the added meta-data) will be returned or one that is created with JAXBContext.newInstance(Class[]).
      Parameters:
      value - the value (POJO) that should be processed by the marshaller or a single class or an array of classes
      Returns:
      the marshaller
      See Also:
    • initJaxbContext

      JaxbContextBuilder initJaxbContext()
      Inits default jaxb context. Otherwise, the jaxb context will be created at first usage.
      Returns:
      the jaxb context builder
    • buildJaxbContext

      default JaxbContextWrapper buildJaxbContext()
      Build default jaxb context that is defined by the added meta-data.
      Returns:
      the jaxb context wrapper
    • buildJaxbContext

      JaxbContextWrapper buildJaxbContext(Object value)
      Build jaxb context for the given object (POJO) or for the given class or array of classes with the specified dependency resolver. If dependency resolving is turned off, the default jaxb context (defined by the added meta-data) will be returned or a jaxb context will be created with JAXBContext.newInstance(Class[]).
      Parameters:
      value - the value (POJO) that should be processed by the jaxb context or a single class or an array of classes
      Returns:
      the jaxb context
    • buildSchema

      default Schema buildSchema()
      Build schema of the default jaxb context (defined by the added meta-data).
      Returns:
      the schema
    • buildSchema

      Schema buildSchema(Object value)
      Build schema of the specified value (POJO), a single class or an array of classes.
      Parameters:
      value - the value (POJO), a single class or an array of classes for which the schema should be created
      Returns:
      the schema