Class MailcapFile

java.lang.Object
com.sun.activation.registries.MailcapFile

public class MailcapFile extends Object
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private static boolean
     
    private Map
    Another Map like above, but for fallback entries.
    private Map
    A Map indexed by MIME type (string) that references a List of native commands (string) corresponding to the type.
    private Map
    A Map indexed by MIME type (string) that references a Map of commands for each type.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Mailcap file default constructor.
    The constructor that takes an input stream as an argument.
    MailcapFile(String new_fname)
    The constructor that takes a filename as an argument.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    appendToMailcap: Append to this Mailcap DB, use the mailcap format: Comment == "# comment string" Entry == "mimetype; javabeanclass" Example: # this is a comment image/gif jaf.viewers.ImageViewer
    Get the Map of fallback MailcapEntries based on the MIME type.
    Get the Map of MailcapEntries based on the MIME type.
    Return all the MIME types known to this mailcap file.
    Return all the native comands for the given MIME type.
    private Map
    mergeResults(Map first, Map second)
    Merge the first hash into the second.
    private void
    parse(Reader reader)
    parse file into a hash table of MC Type Entry Obj
    protected void
    parseLine(String mailcapEntry)
    A routine to parse individual entries in a Mailcap file.
    protected static void
    reportParseError(int expectedToken, int otherExpectedToken, int anotherExpectedToken, int actualToken, String actualTokenValue)
     
    protected static void
    reportParseError(int expectedToken, int otherExpectedToken, int actualToken, String actualTokenValue)
     
    protected static void
    reportParseError(int expectedToken, int actualToken, String actualTokenValue)
     

    Methods inherited from class java.lang.Object

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

    • type_hash

      private Map type_hash
      A Map indexed by MIME type (string) that references a Map of commands for each type. The comand Map is indexed by the command name and references a List of class names (strings) for each command.
    • fallback_hash

      private Map fallback_hash
      Another Map like above, but for fallback entries.
    • native_commands

      private Map native_commands
      A Map indexed by MIME type (string) that references a List of native commands (string) corresponding to the type.
    • addReverse

      private static boolean addReverse
  • Constructor Details

    • MailcapFile

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

      public MailcapFile(InputStream is) throws IOException
      The constructor that takes an input stream as an argument.
      Parameters:
      is - the input stream
      Throws:
      IOException - for I/O errors
    • MailcapFile

      public MailcapFile()
      Mailcap file default constructor.
  • Method Details

    • getMailcapList

      public Map getMailcapList(String mime_type)
      Get the Map of MailcapEntries based on the MIME type.

      Semantics: First check for the literal mime type, if that fails looks for wildcard <type>/\* and return that. Return the list of all that hit.

      Parameters:
      mime_type - the MIME type
      Returns:
      the map of MailcapEntries
    • getMailcapFallbackList

      public Map getMailcapFallbackList(String mime_type)
      Get the Map of fallback MailcapEntries based on the MIME type.

      Semantics: First check for the literal mime type, if that fails looks for wildcard <type>/\* and return that. Return the list of all that hit.

      Parameters:
      mime_type - the MIME type
      Returns:
      the map of fallback MailcapEntries
    • getMimeTypes

      public String[] getMimeTypes()
      Return all the MIME types known to this mailcap file.
      Returns:
      a String array of the MIME types
    • getNativeCommands

      public String[] getNativeCommands(String mime_type)
      Return all the native comands for the given MIME type.
      Parameters:
      mime_type - the MIME type
      Returns:
      a String array of the commands
    • mergeResults

      private Map mergeResults(Map first, Map second)
      Merge the first hash into the second. This merge will only effect the hashtable that is returned, we don't want to touch the one passed in since its integrity must be maintained.
    • appendToMailcap

      public void appendToMailcap(String mail_cap)
      appendToMailcap: Append to this Mailcap DB, use the mailcap format: Comment == "# comment string" Entry == "mimetype; javabeanclass" Example: # this is a comment image/gif jaf.viewers.ImageViewer
      Parameters:
      mail_cap - the mailcap string
    • parse

      private void parse(Reader reader) throws IOException
      parse file into a hash table of MC Type Entry Obj
      Throws:
      IOException
    • parseLine

      protected void parseLine(String mailcapEntry) throws MailcapParseException, IOException
      A routine to parse individual entries in a Mailcap file. Note that this routine does not handle line continuations. They should have been handled prior to calling this routine.
      Parameters:
      mailcapEntry - the mailcap entry
      Throws:
      MailcapParseException - for parse errors
      IOException - for I/O errors
    • reportParseError

      protected static void reportParseError(int expectedToken, int actualToken, String actualTokenValue) throws MailcapParseException
      Throws:
      MailcapParseException
    • reportParseError

      protected static void reportParseError(int expectedToken, int otherExpectedToken, int actualToken, String actualTokenValue) throws MailcapParseException
      Throws:
      MailcapParseException
    • reportParseError

      protected static void reportParseError(int expectedToken, int otherExpectedToken, int anotherExpectedToken, int actualToken, String actualTokenValue) throws MailcapParseException
      Throws:
      MailcapParseException