public class FileFormat extends Object
name
and can have one or more associated MIME types, zero
or more associated file extensions and can specify a (default) character
encoding.Constructor and Description |
---|
FileFormat(String name,
Collection<String> mimeTypes,
Charset charset,
Collection<String> fileExtensions)
Creates a new FileFormat object.
|
FileFormat(String name,
String mimeType,
Charset charset,
Collection<String> fileExtensions)
Creates a new FileFormat object.
|
FileFormat(String name,
String mimeType,
Charset charset,
String fileExtension)
Creates a new FileFormat object.
|
Modifier and Type | Method and Description |
---|---|
boolean |
equals(Object other)
Compares FileFormat objects based on their
name ,
ignoring case. |
Charset |
getCharset()
Get the (default) charset for this file format.
|
String |
getDefaultFileExtension()
Gets the default file name extension for this file format.
|
String |
getDefaultMIMEType()
Gets the default MIME type for this file format.
|
List<String> |
getFileExtensions()
Gets the file format's file extensions.
|
List<String> |
getMIMETypes()
Gets the file format's MIME types.
|
String |
getName()
Gets the name of this file format.
|
boolean |
hasCharset()
Checks if the FileFormat has a (default) charset.
|
boolean |
hasDefaultFileExtension(String extension)
Checks if the specified file name extension matches the FileFormat's
default file name extension.
|
boolean |
hasDefaultMIMEType(String mimeType)
Checks if the specified MIME type matches the FileFormat's default MIME
type.
|
boolean |
hasFileExtension(String extension)
Checks if the FileFormat's file extension is equal to the specified file
extension.
|
int |
hashCode() |
boolean |
hasMIMEType(String mimeType)
Checks if specified MIME type matches one of the FileFormat's MIME types.
|
static <FF extends FileFormat> |
matchFileName(String fileName,
Iterable<FF> fileFormats)
Tries to match the specified file name with the file extensions of the
supplied file formats.
|
static <FF extends FileFormat> |
matchMIMEType(String mimeType,
Iterable<FF> fileFormats)
Tries to match the specified MIME type with the MIME types of the supplied
file formats.
|
String |
toString() |
public FileFormat(String name, String mimeType, Charset charset, String fileExtension)
name
- The name of the file format, e.g. "PLAIN TEXT".mimeType
- The (default) MIME type of the file format, e.g.
text/plain for plain text files.charset
- The default character encoding of the file format. Specify
null if not applicable.fileExtension
- The (default) file extension for the file format, e.g. txt
for plain text files.public FileFormat(String name, String mimeType, Charset charset, Collection<String> fileExtensions)
name
- The name of the file format, e.g. "PLAIN TEXT".mimeType
- The (default) MIME type of the file format, e.g.
text/plain for plain text files.charset
- The default character encoding of the file format. Specify
null if not applicable.fileExtensions
- The file format's file extension(s), e.g. txt for plain
text files. The first item in the list is interpreted as the
default file extension for the format.public FileFormat(String name, Collection<String> mimeTypes, Charset charset, Collection<String> fileExtensions)
name
- The name of the file format, e.g. "PLAIN TEXT".mimeTypes
- The MIME type(s) of the file format, e.g. text/plain for
theplain text files. The first item in the list is interpreted as
the default MIME type for the format. The supplied list should
contain at least one MIME type.charset
- The default character encoding of the file format. Specify
null if not applicable.fileExtensions
- The file format's file extension(s), e.g. txt for plain
text files. The first item in the list is interpreted as the
default file extension for the format.public String getName()
public String getDefaultMIMEType()
public boolean hasDefaultMIMEType(String mimeType)
mimeType
- The MIME type to compare to the FileFormat's default MIME type.public List<String> getMIMETypes()
public boolean hasMIMEType(String mimeType)
mimeType
- The MIME type to compare to the FileFormat's MIME types.public String getDefaultFileExtension()
public boolean hasDefaultFileExtension(String extension)
extension
- The file extension to compare to the FileFormat's file extension.public List<String> getFileExtensions()
public boolean hasFileExtension(String extension)
extension
- The file extension to compare to the FileFormat's file extension.public Charset getCharset()
public boolean hasCharset()
public boolean equals(Object other)
name
,
ignoring case.public static <FF extends FileFormat> Optional<FF> matchMIMEType(String mimeType, Iterable<FF> fileFormats)
mimeType
- A MIME type, e.g. "text/plain".fileFormats
- The file formats to match the MIME type against.Optional.empty()
otherwise.#matchMIMEType(String, Iterable, FileFormat)
public static <FF extends FileFormat> Optional<FF> matchFileName(String fileName, Iterable<FF> fileFormats)
fileName
- A file name.fileFormats
- The file formats to match the file name extension against.Optional.empty()
otherwise.#matchFileName(String, Iterable, FileFormat)
Copyright © 2001-2016 Aduna. All Rights Reserved.