org.displaytag.properties
Class MediaTypeEnum

java.lang.Object
  extended by org.displaytag.properties.MediaTypeEnum

public final class MediaTypeEnum
extends java.lang.Object

Enumeration for media types.

Version:
$Revision: 1081 $ ($Author: fgiust $)
Author:
Fabrizio Giustina

Field Summary
static MediaTypeEnum CSV
          Media type CSV = 1.
static MediaTypeEnum EXCEL
          media type EXCEL = 2.
static MediaTypeEnum HTML
          media type HTML = 0.
static MediaTypeEnum XML
          media type XML = 3.
 
Method Summary
 boolean equals(java.lang.Object o)
          Only a single instance of a specific MediaTypeEnum can be created, so we can check using ==.
static MediaTypeEnum fromCode(int key)
          lookup a media type by key.
static MediaTypeEnum fromCode(java.lang.Integer key)
          lookup a media type by an Integer key.
static MediaTypeEnum fromIntegerCode(java.lang.Integer key)
          Deprecated. use fromCode(Integer)
static MediaTypeEnum fromName(java.lang.String code)
          Lookup a media type by a String key.
 int getCode()
          returns the int code.
 java.lang.String getName()
          returns the description.
static int getSize()
          Returns the number of media type currently loaded.
 int hashCode()
           
static java.util.Iterator iterator()
          returns an iterator on all the media type.
static MediaTypeEnum registerMediaType(java.lang.String name)
          Register a new MediaType.
 java.lang.String toString()
          returns the media type description.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

HTML

public static final MediaTypeEnum HTML
media type HTML = 0.


CSV

public static final MediaTypeEnum CSV
Media type CSV = 1.


EXCEL

public static final MediaTypeEnum EXCEL
media type EXCEL = 2.


XML

public static final MediaTypeEnum XML
media type XML = 3.

Method Detail

getCode

public int getCode()
returns the int code.

Returns:
int code

getName

public java.lang.String getName()
returns the description.

Returns:
String description of the media type ("excel", "xml", "csv", "html")

fromCode

public static MediaTypeEnum fromCode(int key)
lookup a media type by key.

Parameters:
key - int code
Returns:
MediaTypeEnum or null if no mediaType is found with the given key

fromCode

public static MediaTypeEnum fromCode(java.lang.Integer key)
lookup a media type by an Integer key.

Parameters:
key - Integer code - null safe: a null key returns a null Enum
Returns:
MediaTypeEnum or null if no mediaType is found with the given key

fromIntegerCode

public static MediaTypeEnum fromIntegerCode(java.lang.Integer key)
Deprecated. use fromCode(Integer)

lookup a media type by an Integer key.

Parameters:
key - Integer code - null safe: a null key returns a null Enum
Returns:
MediaTypeEnum or null if no mediaType is found with the given key

fromName

public static MediaTypeEnum fromName(java.lang.String code)
Lookup a media type by a String key.

Parameters:
code - String code - null safe: a null key returns a null Enum
Returns:
MediaTypeEnum or null if no mediaType is found with the given key

iterator

public static java.util.Iterator iterator()
returns an iterator on all the media type.

Returns:
iterator

registerMediaType

public static MediaTypeEnum registerMediaType(java.lang.String name)
Register a new MediaType. If name is already assigned the existing instance is returned, otherwise a new instance is created.

Parameters:
name - media name
Returns:
assigned MediaTypeEnum instance

getSize

public static int getSize()
Returns the number of media type currently loaded.

Returns:
number of media types loaded

toString

public java.lang.String toString()
returns the media type description.

Overrides:
toString in class java.lang.Object
See Also:
Object.toString()

equals

public boolean equals(java.lang.Object o)
Only a single instance of a specific MediaTypeEnum can be created, so we can check using ==.

Overrides:
equals in class java.lang.Object
Parameters:
o - the object to compare to
Returns:
hashCode

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object
See Also:
Object.hashCode()


Copyright © 2002-2007 the Displaytag team. All Rights Reserved.