|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectccs.mime.MimeType
public class MimeType
A MimeType encapsulates available information about a specified MIME type.
MimeType objects are usually managed and obtained from a MimeRegistry
.
Once created, the MIME type string is invariant, but the auxiliary information
may be changed.
Field Summary | |
---|---|
static java.lang.String |
APPOCT
The application/octet-stream type. |
static int |
MAYBE
Objects of this MIME type may or may not be compressable. |
static int |
NO
Objects of this MIME type may not usefully be compressed by Zip using Zip or similar algorithms. |
static int |
YES
Objects of this MIME type may be usefully compressed using Zip or similar algorithms. |
Constructor Summary | |
---|---|
MimeType(java.lang.String type,
java.lang.String[] extns,
int compressibility,
java.lang.String description)
Build a MimeType. |
Method Summary | |
---|---|
int |
compareTo(MimeType mt)
|
boolean |
equals(java.lang.Object o)
|
int |
getCompressibility()
Returns the compressibility of this type. |
java.lang.String |
getDescription()
Get the description. |
java.lang.String[] |
getExtensions()
Returns the array of extensions that indciate this MIME type. |
java.lang.String |
getType()
The MIME type string. |
void |
setCompressibility(int compressibility)
Sets the compressibility of this type. |
void |
setDescription(java.lang.String description)
Sets the description |
void |
xmlMarshal(CXTStream cxt)
Marshal the MimeType as XML. |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String APPOCT
public static final int YES
public static final int NO
public static final int MAYBE
Constructor Detail |
---|
public MimeType(java.lang.String type, java.lang.String[] extns, int compressibility, java.lang.String description)
type
- The MIME type string. This should follow the usual MIME type/subtype
format: e.g. "text/plain", "text/html", "audio/wav" etc. Custom types - those
that either you've invented yourself, or which are more standard but have not
been approved by the IANA - should be prefixed with "x-": e.g.
"application/x-myapp-control-data" or even "x-myapp/x-control-data-stream".
"application/octet-stream" is a catchall, signifying an opaque binary which
is not recognised as being in any known format. For more information see
RFC2046.extns
- A list of filename extensions that correspond to the MIME type.
Given some file and no a exteriori metainformation, there are two
main ways to work out the most likely MIME type for the content. The first way
is to look for some identifying header - "magic" - in the file itself. This
requires the classifying app to have detailed knowledge of all the formats
which it's supposed to deal in; this is not appropriate for a transport-type
app, in the case of propriatary formats this information is unavailable, and
some types do not have a standard header. The easier and more common (although
somewhat less reliable) method is based on the filename "extension", defined
as anything in the filename after the last instance of a "." character. This
is a generalisation to UNIX of an idea from VMS, via CP/M and hence DOS. These
extensions include the preceding ".", such that java expressions of the form
filename.endsWith(extn[i])
will give the right answer. Historically,
extensions were required to have 3 characters and many have stuck with this,
but it's no longer necessary: e.g. ".html" is the standard, not ".htm".compressibility
- Whether attempting to compress streams in this format using
a general-purpose compression algorithm is useful. Compressing text streams
is generally useful in reducing bandwith and increasing cryptosecurity
(sparse plaintext can make cryptanalysis easier). Trying to compress video
streams that are highly compressed internally will usually make the stream
bigger. Allowed values are YES
, NO
and
MAYBE
, defined above.description
- A user-friendly, one-line description of the type.Method Detail |
---|
public java.lang.String getType()
public java.lang.String[] getExtensions()
MimeRegistry
of which this is a member, to their sorrow. To change the
list of extensions, callers must remove the entry from the MimeRegistry
and replace it with an updated one.
public int getCompressibility()
YES
, NO
or MAYBE
.public void setCompressibility(int compressibility)
compressibility
- One of the constants YES
, NO
or MAYBE
.public java.lang.String getDescription()
public void setDescription(java.lang.String description)
description
- The new description.public void xmlMarshal(CXTStream cxt) throws java.io.IOException
cxt
- The stream to marshal to
java.io.IOException
- If thrown by the stream.public int compareTo(MimeType mt)
compareTo
in interface java.lang.Comparable<MimeType>
public boolean equals(java.lang.Object o)
equals
in class java.lang.Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |