public class MediaType extends Object implements Comparable<MediaType>
Modifier and Type | Class and Description |
---|---|
static class |
MediaType.Matcher
A media type matcher.
|
Modifier and Type | Field and Description |
---|---|
static MediaType |
all
Any media type.
|
static List<MediaType> |
ALL
Any media type.
|
static MediaType |
css
Stylesheet media type.
|
static MediaType |
form
Form url encoded.
|
static MediaType |
html
HTML media type.
|
static MediaType |
js
Javascript media types.
|
static MediaType |
json
A JSON media type.
|
static MediaType |
multipart
Form multipart-data media type.
|
static MediaType |
octetstream
The default binary media type.
|
static MediaType |
plain
Text plain media type.
|
static MediaType |
text
Any text media type.
|
static MediaType |
xml
Xml media type.
|
Modifier and Type | Method and Description |
---|---|
static Optional<MediaType> |
byExtension(String ext)
Get a
MediaType for a file extension. |
static Optional<MediaType> |
byFile(File file)
Get a
MediaType for a file. |
static Optional<MediaType> |
byPath(Path path)
Get a
MediaType for a file path. |
static Optional<MediaType> |
byPath(String path)
Get a
MediaType for a file path. |
int |
compareTo(MediaType that) |
boolean |
equals(Object obj) |
int |
hashCode() |
boolean |
isAny() |
boolean |
isText() |
static MediaType.Matcher |
matcher(List<MediaType> acceptable)
Produces a matcher for the given media types.
|
static MediaType.Matcher |
matcher(MediaType acceptable)
Produces a matcher for the given media type.
|
boolean |
matches(MediaType that) |
String |
name() |
Map<String,String> |
params() |
static List<MediaType> |
parse(String value)
Convert a string separated by comma into one or more
MediaType . |
float |
quality() |
String |
subtype() |
String |
toString() |
String |
type() |
static List<MediaType> |
valueOf(String... types)
Convert one or more media types expressed as String into a
MediaType . |
static MediaType |
valueOf(String type)
Convert a media type expressed as String into a
MediaType . |
public static final MediaType json
public static final MediaType text
public static final MediaType plain
public static final MediaType css
public static final MediaType js
public static final MediaType html
public static final MediaType octetstream
public static final MediaType all
public static MediaType multipart
public static MediaType form
public static MediaType xml
public float quality()
public String type()
public String subtype()
public boolean isText()
public int compareTo(MediaType that)
compareTo
in interface Comparable<MediaType>
public boolean matches(MediaType that)
that
- A media type to compare to.public boolean isAny()
* / *
.public static MediaType valueOf(String type)
MediaType
.type
- A media type to parse.MediaType
.public static List<MediaType> valueOf(String... types)
MediaType
.types
- Media types to parse.MediaType
.public static List<MediaType> parse(String value)
MediaType
.value
- The string separated by commas.MediaType
.public static MediaType.Matcher matcher(MediaType acceptable)
acceptable
- The acceptable/target media type.public static MediaType.Matcher matcher(List<MediaType> acceptable)
acceptable
- The acceptable/target media types.public static Optional<MediaType> byFile(File file)
MediaType
for a file.file
- A candidate file.MediaType
or octetstream
for unknown file extensions.public static Optional<MediaType> byPath(Path path)
MediaType
for a file path.path
- A candidate file path.MediaType
or empty optional for unknown file extensions.public static Optional<MediaType> byPath(String path)
MediaType
for a file path.path
- A candidate file path: like myfile.js
or /js/myfile.js
.MediaType
or empty optional for unknown file extensions.Copyright © 2015. All rights reserved.