Top Description Fields Constructors Methods
tools.jackson.jakarta.rs.yaml

public Class JacksonYAMLProvider

extends ProviderBase<JacksonYAMLProvider, YAMLMapper, YAMLEndpointConfig, YAMLMapperConfigurator>
Class Inheritance
Known Direct Subclasses
tools.jackson.jakarta.rs.yaml.JacksonXmlBindYAMLProvider
Annotations
@Provider
@Consumes:*/*
@Produces:application/yaml, */*
Imports
java.io.IOException, .InputStream, .PushbackInputStream, java.lang.annotation.Annotation, jakarta.ws.rs.Consumes, .Produces, jakarta.ws.rs.core.Context, .MediaType, jakarta.ws.rs.ext.*, tools.jackson.core.JacksonException, .JsonParser, .Version, tools.jackson.core.exc.JacksonIOException, tools.jackson.databind.AnnotationIntrospector, .ObjectMapper, .ObjectReader, .ObjectWriter, tools.jackson.dataformat.yaml.YAMLMapper, tools.jackson.jakarta.rs.base.ProviderBase

Basic implementation of Jakarta-RS abstractions (MessageBodyReader, MessageBodyWriter) needed for binding YAML content to and from Java Objects ("POJO"s).

Actual data binding functionality is implemented by ObjectMapper: mapper to use can be configured in multiple ways:

The last method ("do nothing specific") is often good enough; explicit passing of Mapper is simple and explicit; and Provider-based method may make sense with Dependency Injection frameworks, or if Mapper has to be configured differently for different media types.

Note that the default mapper instance will be automatically created if one of explicit configuration methods (like configure) is called: if so, Provider-based introspection is NOT used, but the resulting Mapper is used as configured.

Note that there is also a sub-class -- (JacksonXmlBindYAMLProvider) -- that is configured by default to use both Jackson and XmlBind annotations for configuration (base class when used as-is defaults to using just Jackson annotations)

Field Summary

Modifier and TypeField and Description
protected Providers
_providers

Injectable context object used to locate configured instance of YAMLMapper to use for actual serialization.

Inherited from tools.jackson.jakarta.rs.base.ProviderBase:
_cfgCustomUntouchables_defaultReadView_defaultWriteView_jakartaRSFeatures_mapperConfig_readers_unreadableClasses_untouchables_unwritableClasses_writersDEFAULT_UNREADABLESDEFAULT_UNTOUCHABLESDEFAULT_UNWRITABLESHEADER_CONTENT_TYPE_OPTIONSJAKARTA_RS_FEATURE_DEFAULTS

Constructor Summary

AccessConstructor and Description
public
JacksonYAMLProvider()

Default constructor, usually used when provider is automatically configured to be used with JAX-RS implementation.

public
public
JacksonYAMLProvider(YAMLMapper mapper, AnnotationIntrospector
AnnotationIntrospector to override default with, if any
aiOverride
)

Constructor to use when a custom mapper (usually components like serializer/deserializer factories that have been configured) is to be used.

Method Summary

Modifier and TypeMethod and Description
protected YAMLEndpointConfig
protected YAMLEndpointConfig
protected JsonParser
_createParser(ObjectReader reader, InputStream rawStream)

Overrides tools.jackson.jakarta.rs.base.ProviderBase._createParser.

Overridable helper method called to create a JsonParser for reading contents of given raw InputStream.

public YAMLMapper
_locateMapperViaProvider(Class<?>
Class of object being serialized or deserialized; not checked at this point, since it is assumed that unprocessable classes have been already weeded out, but will be passed to ContextResolver as is.
type
,
MediaType
Declared media type for the instance to process: not used by this method, but will be passed to ContextResolver as is.
mediaType
)

Implements abstract tools.jackson.jakarta.rs.base.ProviderBase._locateMapperViaProvider.

Method called to locate YAMLMapper to use for serialization and deserialization.

protected boolean
hasMatchingMediaType(MediaType mediaType)

Implements abstract tools.jackson.jakarta.rs.base.ProviderBase.hasMatchingMediaType.

Helper method used to check whether given media type is YAML type or sub type.

public Version
version()

Implements tools.jackson.core.Versioned.version.

Method that will return version information stored in and read from jar that contains this class.

Inherited from tools.jackson.jakarta.rs.base.ProviderBase:
_addSuperTypes_configForReading_configForWriting_containedIn_createGenerator_createNoContentException_endpointForReading_endpointForWriting_findCustomUntouchable_isIgnorableForReading_isIgnorableForWriting_isSpecialReadable_modifyHeadersaddUntouchableconfigureconfigureconfiguredisabledisabledisabledisableenableenableenableenablefindEncodingfindSuperTypesfindSuperTypesgetSizehasMatchingMediaTypeForReadinghasMatchingMediaTypeForWritingisEnabledisReadableisWriteablelocateMapperreadFromremoveUntouchablesetAnnotationsToUsesetDefaultReadViewsetDefaultViewsetDefaultWriteViewsetMapperwriteTo

Field Detail

_providersback to summary
protected Providers _providers

Injectable context object used to locate configured instance of YAMLMapper to use for actual serialization.

Annotations
@Context

Constructor Detail

JacksonYAMLProviderback to summary
public JacksonYAMLProvider()

Default constructor, usually used when provider is automatically configured to be used with JAX-RS implementation.

JacksonYAMLProviderback to summary
public JacksonYAMLProvider(YAMLMapper mapper)
JacksonYAMLProviderback to summary
public JacksonYAMLProvider(YAMLMapper mapper, AnnotationIntrospector aiOverride)

Constructor to use when a custom mapper (usually components like serializer/deserializer factories that have been configured) is to be used.

Parameters
aiOverride:AnnotationIntrospector

AnnotationIntrospector to override default with, if any

Method Detail

_configForReadingback to summary
protected YAMLEndpointConfig _configForReading(ObjectReader reader, Annotation[] annotations)

Implements abstract tools.jackson.jakarta.rs.base.ProviderBase._configForReading.

Annotations
@Override
_configForWritingback to summary
protected YAMLEndpointConfig _configForWriting(ObjectWriter writer, Annotation[] annotations)

Implements abstract tools.jackson.jakarta.rs.base.ProviderBase._configForWriting.

Annotations
@Override
_createParserback to summary
protected JsonParser _createParser(ObjectReader reader, InputStream rawStream) throws JacksonException

Overrides tools.jackson.jakarta.rs.base.ProviderBase._createParser.

Doc from tools.jackson.jakarta.rs.base.ProviderBase._createParser.

Overridable helper method called to create a JsonParser for reading contents of given raw InputStream. May return null to indicate that Stream is empty; that is, contains no content.

Annotations
@Override
_locateMapperViaProviderback to summary
public YAMLMapper _locateMapperViaProvider(Class<?> type, MediaType mediaType)

Implements abstract tools.jackson.jakarta.rs.base.ProviderBase._locateMapperViaProvider.

Method called to locate YAMLMapper to use for serialization and deserialization. If an instance has been explicitly defined by setMapper (or non-null instance passed in constructor), that will be used. If not, will try to locate it using standard JAX-RS ContextResolver mechanism, if it has been properly configured to access it (by JAX-RS runtime). Finally, if no mapper is found, will return a default unconfigured ObjectMapper instance (one constructed with default constructor and not modified in any way)

Parameters
type:Class<?>

Class of object being serialized or deserialized; not checked at this point, since it is assumed that unprocessable classes have been already weeded out, but will be passed to ContextResolver as is.

mediaType:MediaType

Declared media type for the instance to process: not used by this method, but will be passed to ContextResolver as is.

Annotations
@Override
hasMatchingMediaTypeback to summary
protected boolean hasMatchingMediaType(MediaType mediaType)

Implements abstract tools.jackson.jakarta.rs.base.ProviderBase.hasMatchingMediaType.

Helper method used to check whether given media type is YAML type or sub type. Current implementation essentially checks to see whether MediaType#getSubtype returns "xml" or something ending with "+yaml".

Annotations
@Override
versionback to summary
public Version version()

Implements tools.jackson.core.Versioned.version.

Method that will return version information stored in and read from jar that contains this class.

Annotations
@Override