- All Implemented Interfaces:
Serializable
,Comparable<MediaType>
Supported content types.
- Author:
- AO Industries, Inc.
-
Enum Constant Summary
Enum ConstantDescriptionA CSS stylesheet (text/css
).A JavaScript script (application/javascript
).A JSON object graph (application/json
).JSON linked data (application/ld+json
).MySQLmysql
command input (text/x-mysql
).PostgreSQLpsql
command input (text/x-psql
).A Bourne shell script (text/x-sh
).Any plaintext document comprised of unicode characters (text/plain
).A URL-encoded, & (not &) separated URL.An (X)HTML document (application/xhtml+xml
).Indicates that a value contains a XHTML attribute only. -
Method Summary
Modifier and TypeMethodDescriptionGets the actual media type, such astext/html
.abstract MarkupType
Gets the markup type compatible with this media type.static MediaType
getMediaTypeByName
(String name) Gets the media type for the given name using case-insensitive matching.static MediaType
getMediaTypeForContentType
(String fullContentType) Gets the media type for the provided textual content type.boolean
Should this content type generally be trimmed before validation?.abstract MediaWriter
newMediaWriter
(EncodingContext encodingContext, MediaEncoder encoder, Writer out) Creates a new instance ofMediaWriter
for this media type.abstract MediaWriter
newMediaWriter
(EncodingContext encodingContext, MediaEncoder encoder, Writer out, boolean outOptimized, Whitespace indentDelegate, Predicate<? super MediaWriter> isNoClose, IOConsumer<? super MediaWriter> closer) Creates a new instance ofMediaWriter
for this media type.toString()
Delegates togetContentType()
.static MediaType
Returns the enum constant of this type with the specified name.static MediaType[]
values()
Returns an array containing the constants of this enum type, in the order they are declared.
-
Enum Constant Details
-
XHTML
An (X)HTML document (application/xhtml+xml
). -
XHTML_ATTRIBUTE
Indicates that a value contains a XHTML attribute only. This is a non-standard media type and is only used during internal conversions. The final output should not be this type. -
CSS
A CSS stylesheet (text/css
). -
JAVASCRIPT
A JavaScript script (application/javascript
). -
JSON
A JSON object graph (application/json
). -
LD_JSON
JSON linked data (application/ld+json
). -
TEXT
Any plaintext document comprised of unicode characters (text/plain
). This is used for any arbitrary, unknown and untrusted data. -
URL
A URL-encoded, & (not &) separated URL. -
SH
A Bourne shell script (text/x-sh
). -
MYSQL
MySQLmysql
command input (text/x-mysql
). -
PSQL
PostgreSQLpsql
command input (text/x-psql
).
-
-
Method Details
-
values
Returns an array containing the constants of this enum type, in the order they are declared.- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)- Parameters:
name
- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException
- if this enum type has no constant with the specified nameNullPointerException
- if the argument is null
-
toString
Delegates togetContentType()
. -
getContentType
Gets the actual media type, such astext/html
. -
getMarkupType
Gets the markup type compatible with this media type. -
getTrimBuffer
public boolean getTrimBuffer()Should this content type generally be trimmed before validation?.- See Also:
-
getMediaTypeByName
Gets the media type for the given name using case-insensitive matching.- Returns:
- the
MediaType
ornull
if not found.
-
getMediaTypeForContentType
public static MediaType getMediaTypeForContentType(String fullContentType) throws UnsupportedEncodingException Gets the media type for the provided textual content type.- Throws:
UnsupportedEncodingException
-
newMediaWriter
public abstract MediaWriter newMediaWriter(EncodingContext encodingContext, MediaEncoder encoder, Writer out, boolean outOptimized, Whitespace indentDelegate, Predicate<? super MediaWriter> isNoClose, IOConsumer<? super MediaWriter> closer) Creates a new instance ofMediaWriter
for this media type.- Parameters:
out
- Conditionally passed throughCoercion.optimize(java.io.Writer, com.aoapps.lang.io.Encoder)
outOptimized
- Isout
already known to have been passed throughCoercion.optimize(java.io.Writer, com.aoapps.lang.io.Encoder)
?indentDelegate
- When non-null, indentation depth is get/set on the providedWhitespace
, otherwise tracks directly on this writer. This allows the indentation to be coordinated between nested content types.isNoClose
- Called to determine result ofMediaWriter.isNoClose()
closer
- Called onMediaWriter.close()
, which may optionally perform final suffix write and/or close the underlying writer, will only be called to be idempotent, implementation can assume will only be called once.
-
newMediaWriter
public abstract MediaWriter newMediaWriter(EncodingContext encodingContext, MediaEncoder encoder, Writer out) Creates a new instance ofMediaWriter
for this media type.- Parameters:
out
- Passed throughCoercion.optimize(java.io.Writer, com.aoapps.lang.io.Encoder)
- See Also:
-