Package com.exedio.cope.pattern
Class MediaType
- java.lang.Object
-
- com.exedio.cope.pattern.MediaType
-
public final class MediaType extends Object
-
-
Field Summary
Fields Modifier and Type Field Description static String
DOCX
static String
EOT
static String
GIF
static String
ICON
static String
JAR
static String
JAVASCRIPT
static String
JPEG
static String
PDF
static String
PNG
static String
SVG
static String
TIFF
static String
TTF
static String
WEBP
static String
WOFF
static String
WOFF2
static String
XLSX
static String
ZIP
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static MediaType
forFileName(String fileName)
static MediaType
forMagic(byte[] magic)
Deprecated.UseforMagics(byte[])
instead.static MediaType
forMagic(File file)
Deprecated.UseforMagics(File)
instead.static Set<MediaType>
forMagics(byte[] magic)
static Set<MediaType>
forMagics(File file)
static Set<MediaType>
forMagics(Path path)
static MediaType
forName(String name)
static MediaType
forNameAndAliases(String name)
List<String>
getAliases()
String
getAllowed(Media media)
String
getDefaultExtension()
Returns the typical file extension for this media type.String
getExtension()
Deprecated.There are multiple extensions now.List<String>
getExtensions()
Returns a list of file extensions for this media type.String
getName()
boolean
hasMagic()
static int
magicMaxLength()
String
toString()
-
-
-
Field Detail
-
JPEG
public static final String JPEG
- See Also:
- Constant Field Values
-
PNG
public static final String PNG
- See Also:
- Constant Field Values
-
GIF
public static final String GIF
- See Also:
- Constant Field Values
-
WEBP
public static final String WEBP
- See Also:
- Constant Field Values
-
TIFF
public static final String TIFF
- See Also:
- Constant Field Values
-
ICON
public static final String ICON
- See Also:
- Constant Field Values
-
SVG
public static final String SVG
- See Also:
- Constant Field Values
-
ZIP
public static final String ZIP
- See Also:
- Constant Field Values
-
JAR
public static final String JAR
- See Also:
- Constant Field Values
-
PDF
public static final String PDF
- See Also:
- Constant Field Values
-
JAVASCRIPT
public static final String JAVASCRIPT
- See Also:
- Constant Field Values
-
EOT
public static final String EOT
- See Also:
- Constant Field Values
-
WOFF
public static final String WOFF
- See Also:
- Constant Field Values
-
WOFF2
public static final String WOFF2
- See Also:
- Constant Field Values
-
TTF
public static final String TTF
- See Also:
- Constant Field Values
-
DOCX
public static final String DOCX
- See Also:
- Constant Field Values
-
XLSX
public static final String XLSX
- See Also:
- Constant Field Values
-
-
Method Detail
-
hasMagic
public boolean hasMagic()
-
getExtensions
public List<String> getExtensions()
Returns a list of file extensions for this media type. The most common is used assign to index 0. The result does include the leading dot, for example ".jpg".
-
getDefaultExtension
public String getDefaultExtension()
Returns the typical file extension for this media type. The result does include the leading dot, for example ".jpg".
-
getExtension
@Deprecated public String getExtension()
Deprecated.There are multiple extensions now. Please usegetDefaultExtension()
orgetExtensions()
.
-
getName
public String getName()
-
magicMaxLength
public static int magicMaxLength()
-
forFileName
public static MediaType forFileName(String fileName)
- Parameters:
fileName
- the file name where to look for the extension
-
forMagics
public static Set<MediaType> forMagics(byte[] magic)
- Parameters:
magic
- must contain at least the firstmagicMaxLength()
bytes of the file and must not be empty.
-
forMagics
public static Set<MediaType> forMagics(File file) throws IOException
- Throws:
IOException
-
forMagics
public static Set<MediaType> forMagics(Path path) throws IOException
- Throws:
IOException
-
forMagic
@Deprecated public static MediaType forMagic(byte[] magic)
Deprecated.UseforMagics(byte[])
instead.
-
forMagic
@Deprecated public static MediaType forMagic(File file) throws IOException
Deprecated.UseforMagics(File)
instead.- Throws:
IOException
-
-