Class MimeTypeFile

java.lang.Object
org.eclipse.angus.activation.MimeTypeFile
All Implemented Interfaces:
jakarta.activation.MimeTypeRegistry

public class MimeTypeFile extends Object implements jakarta.activation.MimeTypeRegistry
  • Field Details

    • fname

      private String fname
    • type_hash

      private Hashtable<String,jakarta.activation.MimeTypeEntry> type_hash
  • Constructor Details

    • MimeTypeFile

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

      public MimeTypeFile(InputStream is) throws IOException
      Throws:
      IOException
    • MimeTypeFile

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

    • getMimeTypeEntry

      public jakarta.activation.MimeTypeEntry getMimeTypeEntry(String file_ext)
      get the MimeTypeEntry based on the file extension
      Specified by:
      getMimeTypeEntry in interface jakarta.activation.MimeTypeRegistry
      Parameters:
      file_ext - the file extension
      Returns:
      the MimeTypeEntry
    • getMIMETypeString

      public String getMIMETypeString(String file_ext)
      Get the MIME type string corresponding to the file extension.
      Specified by:
      getMIMETypeString in interface jakarta.activation.MimeTypeRegistry
      Parameters:
      file_ext - the file extension
      Returns:
      the MIME type string
    • appendToRegistry

      public void appendToRegistry(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

      Specified by:
      appendToRegistry in interface jakarta.activation.MimeTypeRegistry
      Parameters:
      mime_types - the mime.types string
    • parse

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

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