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

## org.jboss.portal.common.util
Class MediaType

    java.lang.Object
      org.jboss.portal.common.util.MediaType

    public final class MediaType

extends java.lang.Object

This is a immutable wrapper to the activation MimeTpye.

This class contains some extensions to the activation MimeType, such as the typesafe enum pattern, and allows for a mime type to specify allowed sub types.

Version:
  $LastChangedRevision: 6704 $, $LastChangedDate: 2007-03-15 23:36:31 +0100 (Thu, 15 Mar 2007) $
Author:
  Martin Holzner
See Also:
  `see also ftp://ftp.isi.edu/in-notes/iana/assignments/media-types/`

Field Summary
`static MediaType` | `ANY` Mime type 'Any' maps to an accept mime type of '*.*' (used by IE for css, images, etc.)
`static MediaType` | `CSS` Mime type css
`static MediaType` | `FORM` Mime type form (application/x-www-form-urlencoded)
`static MediaType` | `GIF` Mime type gif
`static MediaType` | `HTML` Mime type html
`static MediaType` | `ICO` Mime type ico (see http://filext.com/detaillist.php?extdetail=ICO)
`static MediaType` | `JPEG` Mime type jpeg
`static MediaType` | `JS` Mime type js
`static MediaType` | `PNG` Mime type png
`static MediaType` | `RSS` Mime type rss
`static MediaType` | `SVG` Mime type svg
`static MediaType` | `TEXT` Mime type text
`static MediaType` | `WBMP` Mime type wbmp
`static MediaType` | `WML` Mime type wml
`static MediaType` | `XHTML` Mime type xhtml
`static MediaType` | `XML` Mime type xml

Method Summary
`boolean` | `equals(java.lang.Object o)` compare the parameter with this instance and see if they are equals.
`java.util.List` | `getAllowedSubTypes()` Get a list of allowed sub types for for this mime type.
`static java.util.List` | `getAllowedSubTypes(MediaType mimeType)` Get a list of allowed sub types for the passed mime type.
`int` | `hashCode()` Get the hascode for this mime type.
`boolean` | `isAllowedSubType(MediaType other)` Return true if the allowed sub types contains the specified media type.
`static MediaType` | `parseMimeType(java.lang.String mimeType)` Get the mime type for the presented string, if the string contains a valid mime type.
`static MediaType` | `parseMimeTypeByExtension(java.lang.String extension)` Get the mime type for the presented string.
`java.lang.String` | `toString()` Get the String representation of the mime type (i.e.

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

Field Detail

### ANY

    public static final MediaType ANY

  Mime type 'Any' maps to an accept mime type of '*.*' (used by IE for css, images, etc.)

### XHTML

    public static final MediaType XHTML

  Mime type xhtml

### HTML

    public static final MediaType HTML

  Mime type html

### FORM

    public static final MediaType FORM

  Mime type form (application/x-www-form-urlencoded)

### XML

    public static final MediaType XML

  Mime type xml

### WML

    public static final MediaType WML

  Mime type wml

### CSS

    public static final MediaType CSS

  Mime type css

### TEXT

    public static final MediaType TEXT

  Mime type text

### JS

    public static final MediaType JS

  Mime type js

### SVG

    public static final MediaType SVG

  Mime type svg

### JPEG

    public static final MediaType JPEG

  Mime type jpeg

### GIF

    public static final MediaType GIF

  Mime type gif

### PNG

    public static final MediaType PNG

  Mime type png

### WBMP

    public static final MediaType WBMP

  Mime type wbmp

### RSS

    public static final MediaType RSS

  Mime type rss

### ICO

    public static final MediaType ICO

  Mime type ico (see http://filext.com/detaillist.php?extdetail=ICO)

Method Detail

### parseMimeType

    public static MediaType parseMimeType(java.lang.String mimeType)
                                   throws javax.activation.MimeTypeParseException

  Get the mime type for the presented string, if the string contains a valid mime type.

  Parameters:
    `mimeType` - the `java.lang.String` to parse into a `RegistryMimeTpye`
  Returns:
    the `RegistryMimeTpye` that matches with the presented string
  Throws:
    `javax.activation.MimeTypeParseException` - if the presented mimetype is not supported
    `java.lang.IllegalArgumentException` - if the presented string is null or empty

### parseMimeTypeByExtension

    public static MediaType parseMimeTypeByExtension(java.lang.String extension)
                                              throws javax.activation.MimeTypeParseException

  Get the mime type for the presented string.

  The string is handles as a file name extension. example: 'xml' returns MediaType.XML

  Parameters:
    `extension` - the `java.lang.String` to parse into a `RegistryMimeTpye`
  Returns:
    the `RegistryMimeTpye` that matches with the presented string
  Throws:
    `javax.activation.MimeTypeParseException` - if the presented mimetype is not supported
    `java.lang.IllegalArgumentException` - if the presented string is null or empty

### getAllowedSubTypes

    public static java.util.List getAllowedSubTypes(MediaType mimeType)

  Get a list of allowed sub types for the passed mime type.

  Parameters:
    `mimeType` - the `RegistryMimeTpye` to get the list of allowed subtypes for
  Returns:
    a `java.util.List` of `PortalMimeTpye`s

### getAllowedSubTypes

    public java.util.List getAllowedSubTypes()

  Get a list of allowed sub types for for this mime type.

  Returns:
    a `java.util.List` of `RegistryMimeTpye`s

### isAllowedSubType

    public boolean isAllowedSubType(MediaType other)

  Return true if the allowed sub types contains the specified media type.

  Parameters:
    `other` - the sub type to test
  Returns:
    true if it is an allowed sub type

### toString

    public java.lang.String toString()

  Get the String representation of the mime type (i.e. 'text/html').

  Overrides:
    `toString` in class `java.lang.Object`
  Returns:
    the mime type as a `java.lang.String`
  See Also:
    `Object.toString()`

### equals

    public boolean equals(java.lang.Object o)

  compare the parameter with this instance and see if they are equals.

  Overrides:
    `equals` in class `java.lang.Object`
  Parameters:
    `o` - the Object to compare this instance to
  Returns:
    true if this and the paramters o are equal
  See Also:
    `Object.equals(java.lang.Object)`

### hashCode

    public int hashCode()

  Get the hascode for this mime type.

  Overrides:
    `hashCode` in class `java.lang.Object`
  Returns:
    an int value representing this instance
  See Also:
    `Object.hashCode()`

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