org.xoe.core.content
Class DefaultContentTypeResolver

java.lang.Object
  |
  +--org.xoe.core.content.DefaultContentTypeResolver
All Implemented Interfaces:
Constants, IContentTypeResolver, IService

public class DefaultContentTypeResolver
extends Object
implements IContentTypeResolver

The class DefaultContentTypeResolver keeps track of basic suffix->mimetype mappings. These can be installed as part of a package along with a "provider key" that can be used to remove all the mappings associated with a package. The provider key should typically be a reference to the package, or a unique String identifier.


Field Summary
static IService[] ctrs
           
 
Fields inherited from interface org.xoe.core.content.IContentTypeResolver
FUNCTIONALITY, INTERFACE
 
Fields inherited from interface org.xoe.core.Constants
ACTION_ATTR, ADD, ADD_APP, AMPERSAND_KEY, AMPERSAND_SYMBOL, AMPERSAND_SYMBOL_STRING, APOSTROPHE_KEY, APOSTROPHE_SYMBOL, ASCENDING_SORT, BACK, BANNER_ATTR, BEEP, BEEP_PROPERTY, CONTEXT_ATTR, COPYRIGHT_KEY, COPYRIGHT_SYMBOL, COUNTRY_PROPERTY, DATA_DOC, DEFAULT_BOOTSTRAP, DEFAULT_NAMESPACE, DEFAULT_THEME, DEFAULT_THEMES_DIR, DEFAULT_VIEW, DELETE, DESCENDING_SORT, DISPLAY, DISPLAY_VIEW, DOCTYPE_NAME_NS_XHTML, DOUBLE_QUOTE_KEY, DOUBLE_QUOTE_SYMBOL, EDIT, EDIT_ITEM_VIEW, EXTENSION_ALL, EXTENSION_DTD, EXTENSION_HTML, EXTENSION_LNK, EXTENSION_WML, EXTENSION_XHTML, EXTENSION_XML, EXTENSION_XOE, EXTENSION_XOE_CONFIG, EXTENSION_ZIP, FEATURE_DOCTYPE_NAME_NS, FEATURE_EXTENSION, FEATURE_MIMETYPE, FILE_PROTOCOL, FORWARD, FUNCTION_CONTENT_HANDLER, GREATER_THAN_KEY, GREATER_THAN_SYMBOL, HIDE_IF_ATTR, HOMEDIR_PROPERTY, HREF_ATTR, INSERT_BEFORE_ATTR, LANGUAGE_PROPERTY, LAUNCH, LESSER_THAN_KEY, LESSER_THAN_SYMBOL, LOADTHEME, LOGGING_PROPERTY, MID_DOT_KEY, MID_DOT_SYMBOL, MIMETYPE_ALL, MIMETYPE_APPLICATION_XOE, MIMETYPE_APPLICATION_ZIP, MIMETYPE_STASHDIR, MIMETYPE_TEXT_HTML, MIMETYPE_TEXT_PLAIN, MIMETYPE_TEXT_VND_TVT_LNK, MIMETYPE_TEXT_WML, MIMETYPE_TEXT_XML, MIMETYPE_TEXT_XML_DTD, MIMETYPE_UNKNOWN, NAME_ATTR, NAMESPACE_SEPARATOR, NEW, NEW_ITEM_VIEW, NO_PATH, NON_BREAKING_SPACE_KEY, NON_BREAKING_SPACE_SYMBOL, NUM_LAST_APPS, ONCHANGE_ATTR, ONCLICK_ATTR, ONKEYPRESS_ATTR, ONLOAD_ATTR, ONMOUSEDOWN_ATTR, ONMOUSEOUT_ATTR, ONMOUSEOVER_ATTR, ONMOUSEUP_ATTR, PACKAGE_ARCHIVE_ROOT, PARENT_FRAME, PKG_ARCHIVE_ATTR, PKG_URI_ATTR, PKG_WORKSPACE_ATTR, PREVIOUS_DIR, PROPERTY_PREFIX, QUERY_DELIMITER, REFRESH, RESET, SAVE, SCREEN_COLORS_PROPERTY, SCREEN_HEIGHT_PROPERTY, SCREEN_TYPE_PROPERTY, SCREEN_WIDTH_PROPERTY, SCRIPT_PROPERTY, SCRIPT_SUPPORT, SELECT, SORT_BANNER_ATTR, SORT_ORDER_ATTR, SRC_ATTR, STASH_DIR_PROPERTY, STASH_FILE_SEPARATOR, STASH_PROTOCOL, STOP, STYLE_ATTR, TEMP_DIR, THEME_PROPERTY, THEMES_DIR_PROPERTY, TOP, TRIGGER_ATTR, UNICODE_DECIMAL_SYMBOL, UNICODE_HEX_SYMBOL, UNKNOWN_ICON, UNSET_NODE_TYPE, URL_CONTEXT_ATTR, USER_NAME, USERDIR_PROPERTY, VALUE_ATTR, WML_NAMESPACE, XHTML_NAMESPACE, XML, XML_PREFIX_NAMESPACE, XMLNS, XMLNS_NAMESPACE, XOE_CONFIG_DOCTYPE_NAME_NS, XOE_LOCALIZE, XPATH_ATTR
 
Constructor Summary
DefaultContentTypeResolver()
           
 
Method Summary
static boolean checkInputStream(String mimetype)
           
static ContentType getContentType(ContentElement content)
           
static ContentType getContentType(ContentType type, InputStream in)
           
static ContentType getContentType(String suffix)
           
static ContentType getContentType(String filename, InputStream in)
           
static ContentType getContentType(URL url)
           
static ContentType getContentType(URL url, String filename)
           
static ContentType getContentType(URL url, String filename, InputStream in)
           
 String[] getFeatures(String func)
          This function may return null.
 String[] getFunctionalities()
          Functionalities are Strings that can be used to differentiate between different kinds of IServices.
 String[] getInformation()
          Returns extra meta-information about the service as an array of Strings.
static DefaultContentTypeResolver getInstance()
           
 String[] getInterfaces(String func)
          Returns the String names of all the Java interfaces that the IService implements for the given functionality.
static String getSuffix(String filename)
           
 void init(org.w3c.dom.Document configDoc)
          Services can be configued with a DOM Document.
 void processMimetypeFile(org.w3c.dom.Document doc, Object provider)
           
 void putMapping(String suffix, String mimetype)
           
 void putMapping(String suffix, String mimetype, Object provider)
           
 void removeMapping(String suffix)
           
 void removeMapping(String suffix, Object provider)
           
 void removeProvider(Object provider)
           
 ContentType resolveStream(InputStream in, ContentType type)
           
 ContentType resolveStream(InputStream in, String mimetype)
           
 ContentType resolveSuffix(String suffix)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ctrs

public static IService[] ctrs
Constructor Detail

DefaultContentTypeResolver

public DefaultContentTypeResolver()
Method Detail

getInstance

public static DefaultContentTypeResolver getInstance()

processMimetypeFile

public void processMimetypeFile(org.w3c.dom.Document doc,
                                Object provider)

init

public void init(org.w3c.dom.Document configDoc)
Description copied from interface: IService
Services can be configued with a DOM Document. configDoc may be null.
Specified by:
init in interface IService

getFunctionalities

public String[] getFunctionalities()
Description copied from interface: IService
Functionalities are Strings that can be used to differentiate between different kinds of IServices. This function must return all the Functionalities implemented by the IService. This function may return null.
Specified by:
getFunctionalities in interface IService

getInterfaces

public String[] getInterfaces(String func)
Description copied from interface: IService
Returns the String names of all the Java interfaces that the IService implements for the given functionality. This function may return null.
Specified by:
getInterfaces in interface IService

getFeatures

public String[] getFeatures(String func)
Description copied from interface: IService
This function may return null.
Specified by:
getFeatures in interface IService

getInformation

public String[] getInformation()
Description copied from interface: IService
Returns extra meta-information about the service as an array of Strings. This function may return null.
Specified by:
getInformation in interface IService

putMapping

public void putMapping(String suffix,
                       String mimetype)

putMapping

public void putMapping(String suffix,
                       String mimetype,
                       Object provider)

removeProvider

public void removeProvider(Object provider)

removeMapping

public void removeMapping(String suffix)

removeMapping

public void removeMapping(String suffix,
                          Object provider)

resolveStream

public ContentType resolveStream(InputStream in,
                                 String mimetype)
                          throws IOException
Specified by:
resolveStream in interface IContentTypeResolver

resolveStream

public ContentType resolveStream(InputStream in,
                                 ContentType type)
                          throws IOException
Specified by:
resolveStream in interface IContentTypeResolver

resolveSuffix

public ContentType resolveSuffix(String suffix)
Specified by:
resolveSuffix in interface IContentTypeResolver

getSuffix

public static String getSuffix(String filename)

getContentType

public static ContentType getContentType(String suffix)

getContentType

public static ContentType getContentType(URL url,
                                         String filename)

getContentType

public static ContentType getContentType(ContentType type,
                                         InputStream in)
                                  throws IOException

getContentType

public static ContentType getContentType(URL url)
                                  throws IOException

getContentType

public static ContentType getContentType(String filename,
                                         InputStream in)
                                  throws IOException

getContentType

public static ContentType getContentType(URL url,
                                         String filename,
                                         InputStream in)
                                  throws IOException

getContentType

public static ContentType getContentType(ContentElement content)
                                  throws IOException

checkInputStream

public static boolean checkInputStream(String mimetype)