- java.lang.Object
-
- java.lang.Enum<MediaType>
-
- com.aoapps.encoding.MediaType
-
- All Implemented Interfaces:
Serializable
,Comparable<MediaType>
@ThreadSafe @Immutable public enum MediaType extends Enum<MediaType>
Supported content types.- Author:
- AO Industries, Inc.
-
-
Enum Constant Summary
Enum Constants Enum Constant Description 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
).MYSQL
MySQLmysql
command input (text/x-mysql
).PSQL
PostgreSQLpsql
command input (text/x-psql
).SH
A Bourne shell script (text/x-sh
).TEXT
Any plaintext document comprised of unicode characters (text/plain
).URL
A URL-encoded, & (not &) separated URL.XHTML
An (X)HTML document (application/xhtml+xml
).XHTML_ATTRIBUTE
Indicates that a value contains a XHTML attribute only.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description String
getContentType()
Gets the actual media type, such astext/html
.abstract MarkupType
getMarkupType()
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
getTrimBuffer()
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.String
toString()
Delegates togetContentType()
.static MediaType
valueOf(String name)
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 Detail
-
XHTML
public static final MediaType XHTML
An (X)HTML document (application/xhtml+xml
).
-
XHTML_ATTRIBUTE
public static final MediaType 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
public static final MediaType CSS
A CSS stylesheet (text/css
).
-
JAVASCRIPT
public static final MediaType JAVASCRIPT
A JavaScript script (application/javascript
).
-
JSON
public static final MediaType JSON
A JSON object graph (application/json
).
-
LD_JSON
public static final MediaType LD_JSON
JSON linked data (application/ld+json
).
-
TEXT
public static final MediaType TEXT
Any plaintext document comprised of unicode characters (text/plain
). This is used for any arbitrary, unknown and untrusted data.
-
URL
public static final MediaType URL
A URL-encoded, & (not &) separated URL.
-
SH
public static final MediaType SH
A Bourne shell script (text/x-sh
).
-
MYSQL
public static final MediaType MYSQL
MySQLmysql
command input (text/x-mysql
).
-
PSQL
public static final MediaType PSQL
PostgreSQLpsql
command input (text/x-psql
).
-
-
Method Detail
-
values
public static MediaType[] values()
Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:for (MediaType c : MediaType.values()) System.out.println(c);
- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
public static MediaType valueOf(String name)
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
public String toString()
Delegates togetContentType()
.
-
getContentType
public String getContentType()
Gets the actual media type, such astext/html
.
-
getMarkupType
public abstract MarkupType getMarkupType()
Gets the markup type compatible with this media type.
-
getTrimBuffer
public boolean getTrimBuffer()
Should this content type generally be trimmed before validation?.
-
getMediaTypeByName
public static MediaType getMediaTypeByName(String name)
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:
MediaWriter.DEFAULT_IS_NO_CLOSE
,MediaWriter.DEFAULT_CLOSER
-
-