com.flexive.shared.media.impl
Class FxMimeType

java.lang.Object
  extended by com.flexive.shared.media.impl.FxMimeType
All Implemented Interfaces:
java.io.Serializable

public class FxMimeType
extends java.lang.Object
implements java.io.Serializable

A general mime type / subtype implementation

Since:
3.1
Author:
Christopher Blasnik (c.blasnik@flexive.com), UCS - unique computing solutions gmbh (http://www.ucs.at)
See Also:
Serialized Form

Field Summary
static java.lang.String APPLICATION
          "Main/default" mime types
static java.lang.String AUDIO
           
static java.lang.String DEFAULT
           
static java.lang.String EXAMPLE
           
static java.lang.String IMAGE
           
static java.lang.String MESSAGE
           
static java.lang.String MODEL
           
static java.lang.String MULTIPART
           
static java.lang.String TEXT
           
static java.lang.String UNKNOWN
           
static java.lang.String VIDEO
           
 
Constructor Summary
FxMimeType()
          Default constructor, sets a default of "application/octet-stream"
FxMimeType(java.lang.String type)
          Constr.
FxMimeType(java.lang.String type, java.lang.String subType)
          Construct a mimeType from a given main- and sub type
 
Method Summary
static FxMimeType detectMimeType(byte[] header, java.lang.String fileName)
          This is a helper method for mime type detection based on medsea's mimeutils Mime type detection based on header bytes and filenames, the latter is used as a fallback if header detection fails
 boolean equals(java.lang.Object o)
           
static FxMimeType getMimeType(java.lang.String mimeType)
          Construct a MimeType from a given String.
 java.lang.String getSubType()
           
 java.lang.String getType()
           
 int hashCode()
           
 void setSubType(java.lang.String subType)
           
 void setType(java.lang.String type)
           
static void shutdownDetectors()
          Shutdown the MIME detectors.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

APPLICATION

public static final java.lang.String APPLICATION
"Main/default" mime types

See Also:
Constant Field Values

AUDIO

public static final java.lang.String AUDIO
See Also:
Constant Field Values

EXAMPLE

public static final java.lang.String EXAMPLE
See Also:
Constant Field Values

IMAGE

public static final java.lang.String IMAGE
See Also:
Constant Field Values

MESSAGE

public static final java.lang.String MESSAGE
See Also:
Constant Field Values

MODEL

public static final java.lang.String MODEL
See Also:
Constant Field Values

MULTIPART

public static final java.lang.String MULTIPART
See Also:
Constant Field Values

TEXT

public static final java.lang.String TEXT
See Also:
Constant Field Values

VIDEO

public static final java.lang.String VIDEO
See Also:
Constant Field Values

UNKNOWN

public static final java.lang.String UNKNOWN
See Also:
Constant Field Values

DEFAULT

public static final java.lang.String DEFAULT
See Also:
Constant Field Values
Constructor Detail

FxMimeType

public FxMimeType()
Default constructor, sets a default of "application/octet-stream"


FxMimeType

public FxMimeType(java.lang.String type)
Constr. providing a main type only, no subtype ("unknown")

Parameters:
type - the main mime type

FxMimeType

public FxMimeType(java.lang.String type,
                  java.lang.String subType)
Construct a mimeType from a given main- and sub type

Parameters:
type - the type (e.g. "application")
subType - the sub type (e.g. "msword")
Method Detail

getType

public java.lang.String getType()

setType

public void setType(java.lang.String type)

getSubType

public java.lang.String getSubType()

setSubType

public void setSubType(java.lang.String subType)

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

hashCode

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

equals

public boolean equals(java.lang.Object o)
Overrides:
equals in class java.lang.Object

getMimeType

public static FxMimeType getMimeType(java.lang.String mimeType)
Construct a MimeType from a given String. If the parameterized mime type cannot be identified, a DEFAULT mime type of "application/octet-stream" will be constructed A null input will return "unknown/unknown"

Parameters:
mimeType - the mimetype as a String, e.g. "application/pdf"
Returns:
returns a MimeType

detectMimeType

public static FxMimeType detectMimeType(byte[] header,
                                        java.lang.String fileName)
This is a helper method for mime type detection based on medsea's mimeutils Mime type detection based on header bytes and filenames, the latter is used as a fallback if header detection fails

Parameters:
header - the file header as a byte array
fileName - the file name as a String
Returns:
the FxMimeType constructed from the input
Since:
3.1.2

shutdownDetectors

public static void shutdownDetectors()
Shutdown the MIME detectors. Needed since some (OpendesktopMimeDetector!) open resources or spawn threads that must be explicitly terminated by the application.

Since:
3.1.4