public final class ContentType extends Object implements Serializable
.properties
file to your classpath root, with
the word "custom" inserted: ContentType-custom-[...]
.
The actual custom names and classpath location are:
Original | Custom |
---|---|
com.norconex.commmons.lang.file.ContentType-extensions.properties | ContentType-custom-extensions.properties |
com.norconex.commmons.lang.file.ContentType-name[_locale].properties | ContentType-custom-name[_locale].propertiess |
Modifier and Type | Field and Description |
---|---|
static ContentType |
BMP |
static ContentType |
CSV |
static ContentType |
GIF |
static ContentType |
HTML |
static ContentType |
JPEG |
static ContentType |
PDF |
static ContentType |
PNG |
static ContentType |
TEXT |
static ContentType |
TSV |
static ContentType |
XML |
static ContentType |
ZIP |
Modifier and Type | Method and Description |
---|---|
boolean |
equals(Object obj) |
ContentFamily |
getContentFamily() |
String |
getDisplayName()
Gets a name for the content type suitable for display to a user.
|
String |
getDisplayName(Locale locale)
Gets a name for the content type suitable for display to a user.
|
String |
getExtension()
Gets the file extension usually associated with this content type.
|
String[] |
getExtensions()
Gets the file extensions usually associated with this content type.
|
int |
hashCode() |
boolean |
matches(String contentType)
Whether the given string matches this content type.
|
ContentType |
toBaseType()
Returns a content-type without any parameters
(removes ";" and any values afterwards).
|
String |
toBaseTypeString()
Returns the raw content-type representation without any parameters
(removes ";" and any values afterwards).
|
String |
toString()
Returns the raw content-type representation.
|
static ContentType |
valueOf(String contentType)
Creates a new content type.
|
static ContentType[] |
valuesOf(String... contentTypes)
Creates a null-safe array of content types.
|
public static final ContentType TEXT
public static final ContentType HTML
public static final ContentType PDF
public static final ContentType XML
public static final ContentType CSV
public static final ContentType TSV
public static final ContentType ZIP
public static final ContentType JPEG
public static final ContentType GIF
public static final ContentType BMP
public static final ContentType PNG
public static ContentType valueOf(String contentType)
contentType
- the official media type namenull
if content type string is
null
or blank.public static ContentType[] valuesOf(String... contentTypes)
null
value will
return an empty array. Each content types are individually obtained
by invoking valueOf(String)
.contentTypes
- the official media type namespublic String getDisplayName()
toString()
).public String getDisplayName(Locale locale)
null
, the system locale is used.
If no name has been defined for a content type with the provided locale,
the name defaults to English.
If no name has been defined for any locale, the raw content type
is returned (equivalent to toString()
).locale
- the locale to use to get the display namepublic ContentFamily getContentFamily()
public String getExtension()
public String[] getExtensions()
public boolean matches(String contentType)
contentType
- the content typetrue
if the given string matches this content typepublic String toString()
public String toBaseTypeString()
public ContentType toBaseType()
Copyright © 2008–2021 Norconex Inc.. All rights reserved.