Class MimeTypeTranslationHelper
java.lang.Object
org.nuxeo.ecm.core.convert.service.MimeTypeTranslationHelper
Helper class to manage chains of converters.
- Author:
- tiry
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
protected final Map<String,
List<ConvertOption>> static final Pattern
protected final Map<String,
List<ConvertOption>> -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
void
clear()
protected String
computeMimeTypeWithWildcardSubType
(String mimeType) Returns a new mime type with the primary type of the givenmimeType
and a wildcard sub type.doGetConverterNames
(String sourceMimeType, String destinationMimeType) Returns the list of converter names matching exactly the givensourceMimeType
anddestinationMimeType
.getConverterName
(String sourceMimeType, String destinationMimeType) Returns the last registered converter name for the givensourceMimeType
anddestinationMimeType
.getConverterName
(String sourceMimeType, String destinationMimeType, boolean allowWildcard) Returns the last registered converter name for the givensourceMimeType
anddestinationMimeType
.getConverterNames
(String sourceMimeType, String destinationMimeType) Returns the list of converter names handling the givensourceMimeType
anddestinationMimeType
.getConverterNames
(String sourceMimeType, String destinationMimeType, boolean allowWildcard) Returns the list of converter names handling the givensourceMimeType
anddestinationMimeType
.getDestinationMimeTypes
(String sourceMimeType) Deprecated.since 10.3.getSourceMimeTypes
(String destinationMimeType) Deprecated.since 10.3.boolean
hasCompatibleMimeType
(List<String> mimeTypes, String mimeType) Returnstrue
if the givenmimeTypes
has a compatible mime type withmimeType
,false
otherwise.protected String
parseMimeType
(String mimeType) Parses the givenmimeType
and 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 givensourceMimeType
anddestinationMimeType
.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 givensourceMimeType
anddestinationMimeType
.Follows the algorithm of
getConverterNames(String, String, boolean)
.- Since:
- 11.1
- See Also:
-
hasCompatibleMimeType
Returnstrue
if the givenmimeTypes
has a compatible mime type withmimeType
,false
otherwise.The
mimeTypes
list has a compatible mime type if:- it contains "*"
- it contains exactly
mimeType
- it contains a mime type with the same primary type as
mimeType
and a wildcard sub type
- Since:
- 10.3
-
getConverterNames
Returns the list of converter names handling the givensourceMimeType
anddestinationMimeType
. -
getConverterNames
public List<String> getConverterNames(String sourceMimeType, String destinationMimeType, boolean allowWildcard) Returns the list of converter names handling the givensourceMimeType
anddestinationMimeType
.Finds the converter names based on the following algorithm:
- Find the converters exactly matching the given
sourceMimeType
and 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
allowWildcard
istrue
, find the converters matching a wildcard source mime type "*" and matching the givendestinationMimeType
- Parameters:
allowWildcard
-true
to allow returning converters with '*' as source mime type.- Since:
- 11.1
- Find the converters exactly matching the given
-
parseMimeType
Parses the givenmimeType
and 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 givenmimeType
and 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 givensourceMimeType
anddestinationMimeType
.- Since:
- 11.5
-
getDestinationMimeTypes
Deprecated.since 10.3. Not used. -
getSourceMimeTypes
Deprecated.since 10.3. Not used. -
clear
public void clear()
-