public final class MimeType extends java.lang.Object implements java.lang.Comparable<MimeType>, java.io.Serializable
Modifier and Type | Class and Description |
---|---|
(package private) static class |
MimeType.RootXML
Defines a RootXML description.
|
Modifier and Type | Field and Description |
---|---|
private java.lang.String |
acronym
The MimeType acronym
|
private java.lang.String |
description
Description of this media type.
|
private java.util.List<java.lang.String> |
extensions
All known file extensions of this type, in order of preference
(best first).
|
private java.util.List<java.net.URI> |
links
Documentation Links
|
private java.util.List<Magic> |
magics
The magics associated to this Mime-Type
|
private int |
minLength
The minimum length of data to provides for magic analyzis
|
private java.util.List<MimeType.RootXML> |
rootXML
The root-XML associated to this Mime-Type
|
private static long |
serialVersionUID
Serial version UID.
|
private MediaType |
type
The normalized media type name.
|
private java.lang.String |
uti
The http://en.wikipedia.org/wiki/Uniform_Type_Identifier
|
Constructor and Description |
---|
MimeType(MediaType type)
Creates a media type with the give name and containing media type
registry.
|
Modifier and Type | Method and Description |
---|---|
(package private) void |
addExtension(java.lang.String extension)
Adds a known file extension to this type.
|
(package private) void |
addLink(java.net.URI link)
Add a link to this mime type
|
(package private) void |
addMagic(Magic magic) |
(package private) void |
addRootXML(java.lang.String namespaceURI,
java.lang.String localName)
Add some rootXML info to this mime-type
|
int |
compareTo(MimeType mime) |
boolean |
equals(java.lang.Object o) |
java.lang.String |
getAcronym()
Returns an acronym for this mime type.
|
java.lang.String |
getDescription()
Returns the description of this media type.
|
java.lang.String |
getExtension()
Returns the preferred file extension of this type, or an empty string
if no extensions are known.
|
java.util.List<java.lang.String> |
getExtensions()
Returns the list of all known file extensions of this media type.
|
java.util.List<java.net.URI> |
getLinks()
Get a list of links to help document this mime type
|
(package private) java.util.List<Magic> |
getMagics() |
(package private) int |
getMinLength() |
java.lang.String |
getName()
Returns the name of this media type.
|
MediaType |
getType()
Returns the normalized media type name.
|
java.lang.String |
getUniformTypeIdentifier()
Get the UTI for this mime type.
|
int |
hashCode() |
boolean |
hasMagic() |
(package private) boolean |
hasRootXML() |
static boolean |
isValid(java.lang.String name)
Checks that the given string is a valid Internet media type name
based on rules from RFC 2054 section 5.3.
|
boolean |
matches(byte[] data) |
boolean |
matchesMagic(byte[] data) |
(package private) boolean |
matchesXML(java.lang.String namespaceURI,
java.lang.String localName) |
(package private) void |
setAcronym(java.lang.String v)
Set an acronym for the mime type
|
void |
setDescription(java.lang.String description)
Set the description of this media type.
|
(package private) void |
setUniformTypeIdentifier(java.lang.String v)
Set The Uniform Type Identifier
|
java.lang.String |
toString()
Returns the name of this media type.
|
private static final long serialVersionUID
private final MediaType type
private java.lang.String acronym
private java.lang.String uti
private java.util.List<java.net.URI> links
private java.lang.String description
private java.util.List<Magic> magics
private java.util.List<MimeType.RootXML> rootXML
private int minLength
private java.util.List<java.lang.String> extensions
MimeType(MediaType type)
MimeTypes.forName(String)
to keep the media type registry
up to date.type
- normalized media type namepublic static boolean isValid(java.lang.String name)
name := token "/" token token := 1*<any (US-ASCII) CHAR except SPACE, CTLs, or tspecials> tspecials := "(" / ")" / "<" / ">" / "@" / "," / ";" / ":" / "\" / <"> / "/" / "[" / "]" / "?" / "="
name
- name stringtrue
if the string is a valid media type name,
false
otherwisepublic MediaType getType()
public java.lang.String getName()
public java.lang.String getDescription()
public void setDescription(java.lang.String description)
description
- media type descriptionpublic java.lang.String getAcronym()
void setAcronym(java.lang.String v)
acronym
- public java.lang.String getUniformTypeIdentifier()
void setUniformTypeIdentifier(java.lang.String v)
uti
- public java.util.List<java.net.URI> getLinks()
void addLink(java.net.URI link)
link
- void addRootXML(java.lang.String namespaceURI, java.lang.String localName)
namespaceURI
- localName
- boolean matchesXML(java.lang.String namespaceURI, java.lang.String localName)
boolean hasRootXML()
java.util.List<Magic> getMagics()
void addMagic(Magic magic)
int getMinLength()
public boolean hasMagic()
public boolean matchesMagic(byte[] data)
public boolean matches(byte[] data)
public int compareTo(MimeType mime)
compareTo
in interface java.lang.Comparable<MimeType>
public boolean equals(java.lang.Object o)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
public java.lang.String toString()
toString
in class java.lang.Object
public java.lang.String getExtension()
getExtensions()
method to
get the full list of known extensions of this type.public java.util.List<java.lang.String> getExtensions()
void addExtension(java.lang.String extension)
extension
- file extension