Package dev.enola.common.io.mediatype
Class MediaTypeProviders
java.lang.Object
dev.enola.common.io.mediatype.MediaTypeProviders
- All Implemented Interfaces:
MediaTypeProvider,ResourceMediaTypeDetector
Aggregates other
MediaTypeProviders, from an explicit list provided to constructor. (This
intentionally does NOT use ServiceLoader; reasons include requiring a specific priority
order.) Typically used via SINGLETON.-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiondetect(String uri, ByteSource byteSource, MediaType original) ResourceMediaTypeDetector.detect(String, ByteSource, MediaType)default implementation usingMediaTypeProvider.extensionsToTypes().Maps the URI path "extension" (WITH the dot; or not, filenames such as "README" are also permitted!) to its "canonical" Media Types.Maps "canonical" (primary) Media Types to a set of its "also known as alternatives".Attempts to "normalize" usingMediaTypeProvider.knownTypesWithAlternatives().static Singleton<MediaTypeProviders> set(MediaTypeProvider... providers) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface dev.enola.common.io.mediatype.ResourceMediaTypeDetector
detect
-
Field Details
-
SINGLETON
-
-
Constructor Details
-
MediaTypeProviders
-
-
Method Details
-
set
-
knownTypesWithAlternatives
Description copied from interface:MediaTypeProviderMaps "canonical" (primary) Media Types to a set of its "also known as alternatives".- Specified by:
knownTypesWithAlternativesin interfaceMediaTypeProvider
-
extensionsToTypes
Description copied from interface:MediaTypeProviderMaps the URI path "extension" (WITH the dot; or not, filenames such as "README" are also permitted!) to its "canonical" Media Types. This should only be used for "informational" listing kind of output. To actually determine a MediaType, please useMediaTypeProvider.detect(String, ByteSource, MediaType)instead.- Specified by:
extensionsToTypesin interfaceMediaTypeProvider
-
detect
Description copied from interface:MediaTypeProviderResourceMediaTypeDetector.detect(String, ByteSource, MediaType)default implementation usingMediaTypeProvider.extensionsToTypes(). This matches the "longest" filename extension (if required).- Specified by:
detectin interfaceMediaTypeProvider- Specified by:
detectin interfaceResourceMediaTypeDetector
-
normalize
Attempts to "normalize" usingMediaTypeProvider.knownTypesWithAlternatives().- Parameters:
mediaType- the one to try to replace- Returns:
- a "canonical" one, if found; else the argument
-