Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.w3c.www.mime
Class MimeType

    java.lang.Object
      |
      +--org.w3c.www.mime.MimeType

public class MimeType
extends java.lang.Object
implements java.io.Serializable, java.lang.Cloneable

This class is used to represent parsed MIME types. It creates this representation from a string based representation of the MIME type, as defined in the RFC 1345.

See Also:
  Serialized Form

Field Summary
`static MimeType` | `APPLICATION_POSTSCRIPT`
`static MimeType` | `APPLICATION_X_JAVA_AGENT`
`static MimeType` | `APPLICATION_X_WWW_FORM_URLENCODED`
`protected java.lang.String` | `external` external form of this mime type
`static int` | `MATCH_SPECIFIC_SUBTYPE`
`static int` | `MATCH_SPECIFIC_TYPE`
`static int` | `MATCH_SUBTYPE`
`static int` | `MATCH_TYPE`
`static MimeType` | `MESSAGE_HTTP`
`static MimeType` | `MULTIPART_FORM_DATA`
`static int` | `NO_MATCH`
`protected java.lang.String[]` | `pnames` parameter names
`protected java.lang.String[]` | `pvalues` parameter values
`protected java.lang.String` | `subtype` String representation of subtype
`static MimeType` | `TEXT`
`static MimeType` | `TEXT_CSS`
`static MimeType` | `TEXT_HTML` List of well known MIME types:
`static MimeType` | `TEXT_PLAIN`
`protected java.lang.String` | `type` String representation of type

Constructor Summary
`MimeType(java.lang.String spec)` Construct MimeType object for the given string.
`MimeType(java.lang.String type, java.lang.String subtype)`
`MimeType(java.lang.String type, java.lang.String subtype, java.lang.String[] pnames, java.lang.String[] pvalues)`

Method Summary
`java.lang.String` | `getParameterValue(java.lang.String name)` Get a mime type parameter value.
`java.lang.String` | `getSubtype()` Get the minor type (subtype) of this mime type.
`java.lang.String` | `getType()` Get the major type of this mime type.
`boolean` | `hasParameter(java.lang.String name)` Does this MIME type has some value for the given parameter ?
`static void` | `main(java.lang.String[] args)`
`int` | `match(MimeType other)` How good the given MimeType matches the receiver of the method ? This method returns a matching level among: NO_MATCHTypes not matching, MATCH_TYPETypes match, MATCH_SPECIFIC_TYPETypes match exactly, MATCH_SUBTYPETypes match, subtypes matches too MATCH_SPECIFIC_SUBTYPETypes match, subtypes matches exactly The matches are ranked from worst match to best match, a simple Max ( match[i], matched) will give the best match.
`java.lang.String` | `toString()` A printable representation of this MimeType.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Field Detail

### TEXT_HTML

    public static MimeType TEXT_HTML

  List of well known MIME types:

### APPLICATION_POSTSCRIPT

    public static MimeType APPLICATION_POSTSCRIPT

### TEXT_PLAIN

    public static MimeType TEXT_PLAIN

### APPLICATION_X_WWW_FORM_URLENCODED

    public static MimeType APPLICATION_X_WWW_FORM_URLENCODED

### MULTIPART_FORM_DATA

    public static MimeType MULTIPART_FORM_DATA

### APPLICATION_X_JAVA_AGENT

    public static MimeType APPLICATION_X_JAVA_AGENT

### MESSAGE_HTTP

    public static MimeType MESSAGE_HTTP

### TEXT_CSS

    public static MimeType TEXT_CSS

### TEXT

    public static MimeType TEXT

### NO_MATCH

    public static final int NO_MATCH

### MATCH_TYPE

    public static final int MATCH_TYPE

### MATCH_SPECIFIC_TYPE

    public static final int MATCH_SPECIFIC_TYPE

### MATCH_SUBTYPE

    public static final int MATCH_SUBTYPE

### MATCH_SPECIFIC_SUBTYPE

    public static final int MATCH_SPECIFIC_SUBTYPE

### type

    protected java.lang.String type

  String representation of type

### subtype

    protected java.lang.String subtype

  String representation of subtype

### pnames

    protected java.lang.String[] pnames

  parameter names

### pvalues

    protected java.lang.String[] pvalues

  parameter values

### external

    protected java.lang.String external

  external form of this mime type

Constructor Detail

### MimeType

    public MimeType(java.lang.String spec)
             throws MimeTypeFormatException

  Construct MimeType object for the given string. The string should be the representation of the type. This methods tries to be compliant with HTTP1.1, p 15, although it is not (because of quoted-text not being accepted). FIXME
  Throws:
    MimeTypeFormatException - if the string couldn't be parsed.

### MimeType

    public MimeType(java.lang.String type,
                    java.lang.String subtype,
                    java.lang.String[] pnames,
                    java.lang.String[] pvalues)

### MimeType

    public MimeType(java.lang.String type,
                    java.lang.String subtype)

Method Detail

### match

    public int match(MimeType other)

  How good the given MimeType matches the receiver of the method ? This method returns a matching level among:
  NO_MATCH
    Types not matching,
  MATCH_TYPE
    Types match,
  MATCH_SPECIFIC_TYPE
    Types match exactly,
  MATCH_SUBTYPE
    Types match, subtypes matches too
  MATCH_SPECIFIC_SUBTYPE
    Types match, subtypes matches exactly
  The matches are ranked from worst match to best match, a simple Max ( match[i], matched) will give the best match.
  Parameters:
    `other` - The other MimeType to match against ourself.

### toString

    public java.lang.String toString()

  A printable representation of this MimeType. The printed representation is guaranteed to be parseable by the String constructor.
  Overrides:
    toString in class java.lang.Object

### hasParameter

    public boolean hasParameter(java.lang.String name)

  Does this MIME type has some value for the given parameter ?
  Parameters:
    `name` - The parameter to check.
  Returns:
    True if this parameter has a value, false otherwise.

### getType

    public java.lang.String getType()

  Get the major type of this mime type.
  Returns:
    The major type, encoded as a String.

### getSubtype

    public java.lang.String getSubtype()

  Get the minor type (subtype) of this mime type.
  Returns:
    The minor or subtype encoded as a String.

### getParameterValue

    public java.lang.String getParameterValue(java.lang.String name)

  Get a mime type parameter value.
  Parameters:
    `name` - The parameter whose value is to be returned.
  Returns:
    The parameter value, or null if not found.

### main

    public static void main(java.lang.String[] args)

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD