Class MimeTypeTranslationHelper
java.lang.Object
org.nuxeo.ecm.core.convert.service.MimeTypeTranslationHelper
Helper class to manage chains of converters.
- Author:
- tiry
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringprotected final Map<String,List<ConvertOption>> static final Patternprotected final Map<String,List<ConvertOption>> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidvoidclear()protected StringcomputeMimeTypeWithWildcardSubType(String mimeType) Returns a new mime type with the primary type of the givenmimeTypeand a wildcard sub type.doGetConverterNames(String sourceMimeType, String destinationMimeType) Returns the list of converter names matching exactly the givensourceMimeTypeanddestinationMimeType.getConverterName(String sourceMimeType, String destinationMimeType) Returns the last registered converter name for the givensourceMimeTypeanddestinationMimeType.getConverterName(String sourceMimeType, String destinationMimeType, boolean allowWildcard) Returns the last registered converter name for the givensourceMimeTypeanddestinationMimeType.getConverterNames(String sourceMimeType, String destinationMimeType) Returns the list of converter names handling the givensourceMimeTypeanddestinationMimeType.getConverterNames(String sourceMimeType, String destinationMimeType, boolean allowWildcard) Returns the list of converter names handling the givensourceMimeTypeanddestinationMimeType.getDestinationMimeTypes(String sourceMimeType) Deprecated.since 10.3.getSourceMimeTypes(String destinationMimeType) Deprecated.since 10.3.booleanhasCompatibleMimeType(List<String> mimeTypes, String mimeType) Returnstrueif the givenmimeTypeshas a compatible mime type withmimeType,falseotherwise.protected StringparseMimeType(String mimeType) Parses the givenmimeTypeand returns only the primary type and optionally the sub type if any.
-
Field Details
-
ANY_MIME_TYPE
- Since:
- 10.3
- See Also:
-
MIME_TYPE_PATTERN
- Since:
- 10.3
-
srcMappings
-
dstMappings
-
-
Constructor Details
-
MimeTypeTranslationHelper
public MimeTypeTranslationHelper()
-
-
Method Details
-
addConverter
-
getConverterName
Returns the last registered converter name for the givensourceMimeTypeanddestinationMimeType.Follows the algorithm of
getConverterNames(String, String). -
getConverterName
public String getConverterName(String sourceMimeType, String destinationMimeType, boolean allowWildcard) Returns the last registered converter name for the givensourceMimeTypeanddestinationMimeType.Follows the algorithm of
getConverterNames(String, String, boolean).- Since:
- 11.1
- See Also:
-
hasCompatibleMimeType
Returnstrueif the givenmimeTypeshas a compatible mime type withmimeType,falseotherwise.The
mimeTypeslist has a compatible mime type if:- it contains "*"
- it contains exactly
mimeType - it contains a mime type with the same primary type as
mimeTypeand a wildcard sub type
- Since:
- 10.3
-
getConverterNames
Returns the list of converter names handling the givensourceMimeTypeanddestinationMimeType. -
getConverterNames
public List<String> getConverterNames(String sourceMimeType, String destinationMimeType, boolean allowWildcard) Returns the list of converter names handling the givensourceMimeTypeanddestinationMimeType.Finds the converter names based on the following algorithm:
- Find the converters exactly matching the given
sourceMimeTypeand matching the givendestinationMimeType - If no converter found, find the converters matching a wildcard subtype based on the
sourceMimeType, such has "image/*", and matching the givendestinationMimeType - If no converter found and
allowWildcardistrue, find the converters matching a wildcard source mime type "*" and matching the givendestinationMimeType
- Parameters:
allowWildcard-trueto allow returning converters with '*' as source mime type.- Since:
- 11.1
- Find the converters exactly matching the given
-
parseMimeType
Parses the givenmimeTypeand returns only the primary type and optionally the sub type if any.Some input/output samples:
- "image/jpeg" => "image/jpeg"
- "image/*" => "image/*"
- "image/png; param1=foo; param2=bar" => "image/png"
- Since:
- 10.3
-
computeMimeTypeWithWildcardSubType
Returns a new mime type with the primary type of the givenmimeTypeand a wildcard sub type.Some input/output samples:
- "image/jpeg" => "image/*"
- "video/*" => "video/*"
- "application/pdf" => "application/*"
- Since:
- 10.3
-
doGetConverterNames
Returns the list of converter names matching exactly the givensourceMimeTypeanddestinationMimeType.- Since:
- 11.5
-
getDestinationMimeTypes
Deprecated.since 10.3. Not used. -
getSourceMimeTypes
Deprecated.since 10.3. Not used. -
clear
public void clear()
-