org.nuiton.wikitty.publication
Class MimeTypePubHelper

java.lang.Object
  extended by org.nuiton.wikitty.publication.MimeTypePubHelper

public class MimeTypePubHelper
extends Object

Class used to determine mimetype for an extension, used to determine type of wikittypub (data or text) with the extension and the mime type. This class is the one which handle mime type <-> file extension mapping.

Author:
mfortun

Field Summary
protected  org.apache.commons.collections.BidiMap bidiMap
          Mapping between extention and mime type, key: extension, value: mimeType
static String COMMON_MIME_SEP
           
static String DEFAULT_MIME_TYPE
          The default mime type
static String JAR_TYPE
           
static String JAVA_TYPE
           
protected  ScriptEngineManager manager
           
static String MIME_PROPERTIE
          MimeType properties files name
static String PREFIX_MIME_PUB_TEXT
           
static String PUBLICATION_MIME_SEP
           
static String REGEX_PUB_TEXT_TRANSFORM
          match pub text that must be converted via ui decorateur text/\w*\.\w* as text/html.javascript
 
Constructor Summary
MimeTypePubHelper()
           
 
Method Summary
 void addExtensionMime(String extension, String mime)
          Add an entry in the map that store mapping between extension and mimeType.
 String getExtensionForMime(String mime)
          Return the corresponding mime Type for an extension, default if not recognized
 ScriptEngineManager getManager()
           
 String getMimeForExtension(String ext)
          Return the corresponding mime Type for an extension, default if not recognized
 boolean isPubTextExtension(String extension)
          used to check if a file have to be converted as a wikittyPubText with his extension similar to :
isPubTextMime(getMimeForExtension(extension))
 boolean isPubTextMime(String mimeType)
          Used to check if a file have to be converted as a wikittyPubText
 String pubUiMimeToTargetMime(String mime)
          Used to convert uiMime to the mimeType after content decoration
 void setManager(ScriptEngineManager manager)
           
 String uiMimeContentType(String mime)
           
 String uiMimeToFilterOptionKey(String mime)
          return the convert part of a mime type, part used as a key for converter option.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

JAVA_TYPE

public static final String JAVA_TYPE
See Also:
Constant Field Values

JAR_TYPE

public static final String JAR_TYPE
See Also:
Constant Field Values

bidiMap

protected org.apache.commons.collections.BidiMap bidiMap
Mapping between extention and mime type, key: extension, value: mimeType


manager

protected ScriptEngineManager manager

COMMON_MIME_SEP

public static String COMMON_MIME_SEP

PUBLICATION_MIME_SEP

public static String PUBLICATION_MIME_SEP

PREFIX_MIME_PUB_TEXT

public static String PREFIX_MIME_PUB_TEXT

MIME_PROPERTIE

public static String MIME_PROPERTIE
MimeType properties files name


REGEX_PUB_TEXT_TRANSFORM

public static String REGEX_PUB_TEXT_TRANSFORM
match pub text that must be converted via ui decorateur text/\w*\.\w* as text/html.javascript


DEFAULT_MIME_TYPE

public static String DEFAULT_MIME_TYPE
The default mime type

Constructor Detail

MimeTypePubHelper

public MimeTypePubHelper()
Method Detail

getExtensionForMime

public String getExtensionForMime(String mime)
Return the corresponding mime Type for an extension, default if not recognized

Parameters:
mime - the extension
Returns:
the corresponding mimeTypeForExt DEFAULT_MIME_TYPE if ext not recognized

getMimeForExtension

public String getMimeForExtension(String ext)
Return the corresponding mime Type for an extension, default if not recognized

Parameters:
ext - the extension
Returns:
the corresponding mimeTypeForExt DEFAULT_MIME_TYPE if ext not recognized

isPubTextMime

public boolean isPubTextMime(String mimeType)
Used to check if a file have to be converted as a wikittyPubText

Parameters:
mimeType - of the file
Returns:
if the mimetype of a file correspond to a wikittyPubText

uiMimeToFilterOptionKey

public String uiMimeToFilterOptionKey(String mime)
return the convert part of a mime type, part used as a key for converter option. for example : text/html.java return html.java

Parameters:
mime -
Returns:

uiMimeContentType

public String uiMimeContentType(String mime)

pubUiMimeToTargetMime

public String pubUiMimeToTargetMime(String mime)
Used to convert uiMime to the mimeType after content decoration

Parameters:
mime -
Returns:
the mimeType after Ui content decoration

isPubTextExtension

public boolean isPubTextExtension(String extension)
used to check if a file have to be converted as a wikittyPubText with his extension similar to :
isPubTextMime(getMimeForExtension(extension))

Parameters:
extension - the file extension
Returns:
if the extension correspond to a wikittyPubText

addExtensionMime

public void addExtensionMime(String extension,
                             String mime)
Add an entry in the map that store mapping between extension and mimeType.

Parameters:
extension -
mime -

getManager

public ScriptEngineManager getManager()

setManager

public void setManager(ScriptEngineManager manager)


Copyright © 2010-2011 CodeLutin. All Rights Reserved.