Class MimeTypesFactory


  • public class MimeTypesFactory
    extends java.lang.Object
    Creates instances of MimeTypes.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String CUSTOM_MIMES_SYS_PROP
      System property to set a path to an additional external custom mimetypes XML file to be loaded.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static MimeTypes create()
      Creates an empty instance; same as calling new MimeTypes().
      static MimeTypes create​(java.io.InputStream stream)  
      static MimeTypes create​(java.io.InputStream... inputStreams)
      Creates and returns a MimeTypes instance from the specified input stream.
      static MimeTypes create​(java.lang.String filePath)
      Creates and returns a MimeTypes instance from the specified file path, as interpreted by the class loader in getResource().
      static MimeTypes create​(java.lang.String coreFilePath, java.lang.String extensionFilePath)
      Creates and returns a MimeTypes instance.
      static MimeTypes create​(java.lang.String coreFilePath, java.lang.String extensionFilePath, java.lang.ClassLoader classLoader)
      Creates and returns a MimeTypes instance.
      static MimeTypes create​(java.net.URL url)  
      static MimeTypes create​(java.net.URL... urls)
      Creates and returns a MimeTypes instance from the resource at the location specified by the URL.
      static MimeTypes create​(org.w3c.dom.Document document)
      Creates and returns a MimeTypes instance from the specified document.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • CUSTOM_MIMES_SYS_PROP

        public static final java.lang.String CUSTOM_MIMES_SYS_PROP
        System property to set a path to an additional external custom mimetypes XML file to be loaded.
        See Also:
        Constant Field Values
    • Constructor Detail

      • MimeTypesFactory

        public MimeTypesFactory()
    • Method Detail

      • create

        public static MimeTypes create()
        Creates an empty instance; same as calling new MimeTypes().
        Returns:
        an empty instance
      • create

        public static MimeTypes create​(org.w3c.dom.Document document)
                                throws MimeTypeException
        Creates and returns a MimeTypes instance from the specified document.
        Throws:
        MimeTypeException - if the type configuration is invalid
      • create

        public static MimeTypes create​(java.io.InputStream... inputStreams)
                                throws java.io.IOException,
                                       MimeTypeException
        Creates and returns a MimeTypes instance from the specified input stream. Does not close the input stream(s).
        Throws:
        java.io.IOException - if the stream can not be read
        MimeTypeException - if the type configuration is invalid
      • create

        public static MimeTypes create​(java.net.URL... urls)
                                throws java.io.IOException,
                                       MimeTypeException
        Creates and returns a MimeTypes instance from the resource at the location specified by the URL. Opens and closes the InputStream from the URL. If multiple URLs are supplied, then they are loaded in turn.
        Throws:
        java.io.IOException - if the URL can not be accessed
        MimeTypeException - if the type configuration is invalid
      • create

        public static MimeTypes create​(java.lang.String filePath)
                                throws java.io.IOException,
                                       MimeTypeException
        Creates and returns a MimeTypes instance from the specified file path, as interpreted by the class loader in getResource().
        Throws:
        java.io.IOException - if the file can not be accessed
        MimeTypeException - if the type configuration is invalid
      • create

        public static MimeTypes create​(java.lang.String coreFilePath,
                                       java.lang.String extensionFilePath)
                                throws java.io.IOException,
                                       MimeTypeException
        Creates and returns a MimeTypes instance. The core mimetypes will be loaded from the specified file path, and any custom override mimetypes found will loaded afterwards. The file paths will be interpreted by the default class loader in getResource().
        Parameters:
        coreFilePath - The main MimeTypes file to load
        extensionFilePath - The name of extension MimeType files to load afterwards
        Throws:
        java.io.IOException - if the file can not be accessed
        MimeTypeException - if the type configuration is invalid
      • create

        public static MimeTypes create​(java.lang.String coreFilePath,
                                       java.lang.String extensionFilePath,
                                       java.lang.ClassLoader classLoader)
                                throws java.io.IOException,
                                       MimeTypeException
        Creates and returns a MimeTypes instance. The core mimetypes will be loaded from the specified file path, and any custom override mimetypes found will loaded afterwards. The file paths will be interpreted by the specified class loader in getResource(). It will also load custom mimetypes from the system property CUSTOM_MIMES_SYS_PROP, if specified.
        Parameters:
        coreFilePath - The main MimeTypes file to load
        extensionFilePath - The name of extension MimeType files to load afterwards
        Throws:
        java.io.IOException - if the file can not be accessed
        MimeTypeException - if the type configuration is invalid