Class MimeTypeFile


  • public class MimeTypeFile
    extends java.lang.Object
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.lang.String fname  
      private java.util.Hashtable type_hash  
    • Constructor Summary

      Constructors 
      Constructor Description
      MimeTypeFile()
      Creates an empty DB.
      MimeTypeFile​(java.io.InputStream is)  
      MimeTypeFile​(java.lang.String new_fname)
      The construtor that takes a filename as an argument.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void appendToRegistry​(java.lang.String mime_types)
      Appends string of entries to the types registry, must be valid .mime.types format.
      MimeTypeEntry getMimeTypeEntry​(java.lang.String file_ext)
      get the MimeTypeEntry based on the file extension
      java.lang.String getMIMETypeString​(java.lang.String file_ext)
      Get the MIME type string corresponding to the file extension.
      private void parse​(java.io.BufferedReader buf_reader)
      Parse a stream of mime.types entries.
      private void parseEntry​(java.lang.String line)
      Parse single mime.types entry.
      • Methods inherited from class java.lang.Object

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

      • fname

        private java.lang.String fname
      • type_hash

        private java.util.Hashtable type_hash
    • Constructor Detail

      • MimeTypeFile

        public MimeTypeFile​(java.lang.String new_fname)
                     throws java.io.IOException
        The construtor that takes a filename as an argument.
        Parameters:
        new_fname - The file name of the mime types file.
        Throws:
        java.io.IOException - for I/O errors
      • MimeTypeFile

        public MimeTypeFile​(java.io.InputStream is)
                     throws java.io.IOException
        Throws:
        java.io.IOException
      • MimeTypeFile

        public MimeTypeFile()
        Creates an empty DB.
    • Method Detail

      • getMimeTypeEntry

        public MimeTypeEntry getMimeTypeEntry​(java.lang.String file_ext)
        get the MimeTypeEntry based on the file extension
        Parameters:
        file_ext - the file extension
        Returns:
        the MimeTypeEntry
      • getMIMETypeString

        public java.lang.String getMIMETypeString​(java.lang.String file_ext)
        Get the MIME type string corresponding to the file extension.
        Parameters:
        file_ext - the file extension
        Returns:
        the MIME type string
      • appendToRegistry

        public void appendToRegistry​(java.lang.String mime_types)
        Appends string of entries to the types registry, must be valid .mime.types format. A mime.types entry is one of two forms: type/subtype ext1 ext2 ... or type=type/subtype desc="description of type" exts=ext1,ext2,... Example: # this is a test audio/basic au text/plain txt text type=application/postscript exts=ps,eps
        Parameters:
        mime_types - the mime.types string
      • parse

        private void parse​(java.io.BufferedReader buf_reader)
                    throws java.io.IOException
        Parse a stream of mime.types entries.
        Throws:
        java.io.IOException
      • parseEntry

        private void parseEntry​(java.lang.String line)
        Parse single mime.types entry.