Package eu.europa.esig.dss.model
Class MimeType
java.lang.Object
eu.europa.esig.dss.model.MimeType
- All Implemented Interfaces:
Serializable
public class MimeType extends Object implements Serializable
This class allows to handle different mime types. It also allows to add
(define) new mime-type.
- See Also:
- Serialized Form
-
Field Summary
Fields Modifier and Type Field Description static MimeType
ASICE
static MimeType
ASICS
static MimeType
BINARY
static MimeType
CER
static MimeType
CRL
static MimeType
HTML
static MimeType
JPEG
static MimeType
ODG
static MimeType
ODP
static MimeType
ODS
static MimeType
ODT
static MimeType
PDF
static MimeType
PKCS7
static MimeType
PNG
static MimeType
SVG
static MimeType
TEXT
static MimeType
TST
static MimeType
XML
-
Constructor Summary
-
Method Summary
Modifier and Type Method Description void
defineFileExtension(String extension)
This method allows to define a new relationship between a file extension and aMimeType
.boolean
equals(Object obj)
static MimeType
fromFile(File file)
This method returns the mime-type extrapolated from the file.static MimeType
fromFileName(String fileName)
This method returns the mime-type extrapolated from the file name.static MimeType
fromMimeTypeString(String mimeTypeString)
This method returns the first representation of theMimeType
corresponding to the given mime-type string.static String
getExtension(MimeType mimeType)
Returns the file exception for the provided MimeTypestatic String
getFileExtension(String fileName)
Returns the file extension based on the position of the '.' in the fileName.String
getMimeTypeString()
int
hashCode()
void
setMimeTypeString(String mimeTypeString)
This setter is used by the web-services.String
toString()
-
Field Details
-
Constructor Details
-
MimeType
public MimeType()This constructor is used only by the web-services. -
MimeType
This constructor allows to create a new MimeType related to given file extension. Be careful, if the file extension has already an associatedMimeType
then this relation will be lost.- Parameters:
mimeTypeString
- is a string identifier composed of two parts: a "type" and a "subtype"extension
- to be defined. Example: "txt", note that there is no point before the extension name.
-
-
Method Details
-
getMimeTypeString
- Returns:
- the mimeTypeString
-
setMimeTypeString
This setter is used by the web-services.- Parameters:
mimeTypeString
- is a string identifier composed of two parts: a "type" and a "subtype"
-
fromFileName
This method returns the mime-type extrapolated from the file name.- Parameters:
fileName
- the file name to be analysed- Returns:
- the extrapolated mime-type of the file name
-
getExtension
Returns the file exception for the provided MimeType- Parameters:
mimeType
-MimeType
to get an extension for- Returns:
- the exception
String
assigned to the given MimeType - Throws:
DSSException
- in case if the extension for the requested MimeType is not found
-
getFileExtension
Returns the file extension based on the position of the '.' in the fileName. File paths as "xxx.y/toto" are not handled.- Parameters:
fileName
- to be analysed- Returns:
- the file extension or null
-
fromFile
This method returns the mime-type extrapolated from the file.- Parameters:
file
- the file to be analysed- Returns:
- the extrapolated mime-type of the file
-
fromMimeTypeString
This method returns the first representation of theMimeType
corresponding to the given mime-type string.- Parameters:
mimeTypeString
- is a string identifier composed of two parts: a "type" and a "subtype"- Returns:
- the extrapolated mime-type from the
String
-
defineFileExtension
This method allows to define a new relationship between a file extension and aMimeType
.- Parameters:
extension
- to be defined. Example: "txt", note that there is no point before the extension name.
-
hashCode
public int hashCode() -
equals
-
toString
-