Package org.apache.tika.mime
Class MimeType
java.lang.Object
org.apache.tika.mime.MimeType
- All Implemented Interfaces:
Serializable
,Comparable<MimeType>
Internet media type.
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionint
boolean
Returns an acronym for this mime type.Returns the description of this media type.Returns the preferred file extension of this type, or an empty string if no extensions are known.Returns the list of all known file extensions of this media type.getLinks()
Get a list of links to help document this mime typegetName()
Returns the name of this media type.getType()
Returns the normalized media type name.Get the UTI for this mime type.int
hashCode()
boolean
hasMagic()
static boolean
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) void
setDescription
(String description) Set the description of this media type.toString()
Returns the name of this media type.
-
Method Details
-
isValid
Checks that the given string is a valid Internet media type name based on rules from RFC 2054 section 5.3. For validation purposes the rules can be simplified to the following:name := token "/" token token := 1*<any (US-ASCII) CHAR except SPACE, CTLs, or tspecials> tspecials := "(" / ")" / "<" / ">" / "@" / "," / ";" / ":" / "\" / <"> / "/" / "[" / "]" / "?" / "="
- Parameters:
name
- name string- Returns:
true
if the string is a valid media type name,false
otherwise
-
getType
Returns the normalized media type name.- Returns:
- media type
-
getName
Returns the name of this media type.- Returns:
- media type name (lower case)
-
getDescription
Returns the description of this media type.- Returns:
- media type description
-
setDescription
Set the description of this media type.- Parameters:
description
- media type description
-
getAcronym
Returns an acronym for this mime type.- Returns:
- mime type acronym
-
getUniformTypeIdentifier
Get the UTI for this mime type.- Returns:
- The Uniform Type Identifier
- See Also:
-
getLinks
Get a list of links to help document this mime type- Returns:
- an array of links (will never be null)
-
hasMagic
public boolean hasMagic() -
matchesMagic
public boolean matchesMagic(byte[] data) -
matches
public boolean matches(byte[] data) -
compareTo
- Specified by:
compareTo
in interfaceComparable<MimeType>
-
equals
-
hashCode
public int hashCode() -
toString
Returns the name of this media type. -
getExtension
Returns the preferred file extension of this type, or an empty string if no extensions are known. Use thegetExtensions()
method to get the full list of known extensions of this type.- Returns:
- preferred file extension or empty string
- Since:
- Apache Tika 0.9
-
getExtensions
Returns the list of all known file extensions of this media type.- Returns:
- known extensions in order of preference (best first)
- Since:
- Apache Tika 0.10
-