public class MimeTypeTranslationHelper extends Object
Modifier and Type | Field and Description |
---|---|
static String |
ANY_MIME_TYPE |
protected Map<String,List<ConvertOption>> |
dstMappings |
static Pattern |
MIME_TYPE_PATTERN |
protected Map<String,List<ConvertOption>> |
srcMappings |
Constructor and Description |
---|
MimeTypeTranslationHelper() |
Modifier and Type | Method and Description |
---|---|
void |
addConverter(ConverterDescriptor desc) |
void |
clear() |
protected String |
computeMimeTypeWithWildcardSubType(String mimeType)
Returns a new mime type with the primary type of the given
mimeType and a wildcard sub type. |
String |
getConverterName(String sourceMimeType,
String destinationMimeType)
Returns the last registered converter name for the given
sourceMimeType and destinationMimeType . |
List<String> |
getConverterNames(String sourceMimeType,
String destinationMimeType)
Returns the list of converter names handling the given
sourceMimeType and destinationMimeType . |
List<String> |
getDestinationMimeTypes(String sourceMimeType)
Deprecated.
since 10.3. Not used.
|
List<String> |
getSourceMimeTypes(String destinationMimeType)
Deprecated.
since 10.3. Not used.
|
boolean |
hasCompatibleMimeType(List<String> mimeTypes,
String mimeType)
Returns
true if the given mimeTypes has a compatible mime type with mimeType ,
false otherwise. |
protected String |
parseMimeType(String mimeType)
Parses the given
mimeType and returns only the primary type and optionally the sub type if any. |
public static final String ANY_MIME_TYPE
public static final Pattern MIME_TYPE_PATTERN
protected final Map<String,List<ConvertOption>> srcMappings
protected final Map<String,List<ConvertOption>> dstMappings
public MimeTypeTranslationHelper()
public void addConverter(ConverterDescriptor desc)
public String getConverterName(String sourceMimeType, String destinationMimeType)
sourceMimeType
and destinationMimeType
.
Follow the algorithm of getConverterNames(String, String)
.
getConverterNames(String, String)
public boolean hasCompatibleMimeType(List<String> mimeTypes, String mimeType)
true
if the given mimeTypes
has a compatible mime type with mimeType
,
false
otherwise.
The mimeTypes
list has a compatible mime type if:
mimeType
mimeType
and a wildcard sub typepublic List<String> getConverterNames(String sourceMimeType, String destinationMimeType)
sourceMimeType
and destinationMimeType
.
Find the converter names based on the following algorithm:
sourceMimeType
sourceMimeType
,
such has "image/*"destinationMimeType
protected String parseMimeType(String mimeType)
mimeType
and returns only the primary type and optionally the sub type if any.
Some input/output samples:
protected String computeMimeTypeWithWildcardSubType(String mimeType)
mimeType
and a wildcard sub type.
Some input/output samples:
@Deprecated public List<String> getDestinationMimeTypes(String sourceMimeType)
@Deprecated public List<String> getSourceMimeTypes(String destinationMimeType)
public void clear()
Copyright © 2019 Nuxeo. All rights reserved.