Package org.bremersee.xml
Interface JaxbContextBuilder
public interface JaxbContextBuilder
The jaxb context builder.
- Author:
- Christian Bremer
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final JaxbDependenciesResolver
The default dependencies resolver implementation. -
Method Summary
Modifier and TypeMethodDescriptionadd
(JaxbContextMember data) Add jaxb context meta-data to the jaxb context builder.default JaxbContextBuilder
addAll
(Iterable<? extends JaxbContextMember> data) Add all jaxb context meta-data to the jaxb context builder.default JaxbContextBuilder
addAll
(Iterator<? extends JaxbContextMember> data) Add all jaxb context meta-data to the jaxb context builder.default JaxbContextWrapper
Build default jaxb context that is defined by the added meta-data.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.default jakarta.xml.bind.Marshaller
Build marshaller with the context which is defined by the added meta-data.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.default Schema
Build schema of the default jaxb context (defined by the added meta-data).buildSchema
(Object value) Build schema of the specified value (POJO), a single class or an array of classes.jakarta.xml.bind.Unmarshaller
buildUnmarshaller
(Class<?>... classes) Build unmarshaller for the given classes with the specified dependencies-resolver.default boolean
canMarshal
(Class<?> clazz) Determines whether the marshaller can encode an object of the given class into xml.default boolean
canUnmarshal
(Class<?> clazz) Determines whether the unmarshaller can decode xml into an object of the given class.copy()
Copy jaxb context builder.Inits default jaxb context.static JaxbContextBuilder
Creates a new jaxb context builder.default JaxbContextBuilder
process
(JaxbContextDataProvider dataProvider) Process the jaxb context meta-data provider and add its data to the jaxb context builder.default JaxbContextBuilder
processAll
(Iterable<? extends JaxbContextDataProvider> dataProviders) Process the jaxb context meta-data providers and add their data to the jaxb context builder.default JaxbContextBuilder
processAll
(Iterator<? extends JaxbContextDataProvider> dataProviders) Process the jaxb context meta-data providers and add their data to the jaxb context builder.withAttachmentMarshaller
(jakarta.xml.bind.attachment.AttachmentMarshaller attachmentMarshaller) Set attachment marshaller.withAttachmentUnmarshaller
(jakarta.xml.bind.attachment.AttachmentUnmarshaller attachmentUnmarshaller) Set attachment unmarshaller.withContextClassLoader
(ClassLoader classLoader) Specifies the class loader to use.Specifies the dependencies-resolver to use.withFormattedOutput
(boolean formattedOutput) Specify whether the xml output should be formatted or not.withSchemaBuilder
(SchemaBuilder schemaBuilder) Specifies the schema builder to generate the schema.withSchemaMode
(SchemaMode schemaMode) Specifies whether to add a schema to the marshaller or unmarshaller.withValidationEventHandler
(jakarta.xml.bind.ValidationEventHandler validationEventHandler) Set validation event handler of marshaller and unmarshaller.withXmlAdapters
(Collection<? extends jakarta.xml.bind.annotation.adapters.XmlAdapter<?, ?>> xmlAdapters) Sets xml adapters of marshaller and unmarshaller.
-
Field Details
-
DEFAULT_DEPENDENCIES_RESOLVER
The default dependencies resolver implementation.
-
-
Method Details
-
newInstance
Creates a new jaxb context builder.- Returns:
- the jaxb context builder
-
copy
JaxbContextBuilder copy()Copy jaxb context builder.- Returns:
- the jaxb context builder
-
withSchemaMode
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
Specifies the schema builder to generate the schema. The default is the default schema builder implementation (seeSchemaBuilder.newInstance()
).- Parameters:
schemaBuilder
- the schema builder- Returns:
- the jaxb context builder
-
withDependenciesResolver
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
Specifies the class loader to use.- Parameters:
classLoader
- the class loader- Returns:
- the jaxb context builder
-
withFormattedOutput
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
Add all jaxb context meta-data to the jaxb context builder.- Parameters:
data
- the data- Returns:
- the jaxb context builder
-
addAll
Add all jaxb context meta-data to the jaxb context builder.- Parameters:
data
- the data- Returns:
- the jaxb context builder
-
process
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
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
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
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, otherwisefalse
-
canMarshal
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, otherwisefalse
-
buildUnmarshaller
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 withJAXBContext.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
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 withJAXBContext.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
Build default jaxb context that is defined by the added meta-data.- Returns:
- the jaxb context wrapper
-
buildJaxbContext
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 withJAXBContext.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
Build schema of the default jaxb context (defined by the added meta-data).- Returns:
- the schema
-
buildSchema
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
-