Package org.eclipse.angus.activation
Class MailcapFile
- java.lang.Object
-
- org.eclipse.angus.activation.MailcapFile
-
- All Implemented Interfaces:
jakarta.activation.MailcapRegistry
public class MailcapFile extends java.lang.Object implements jakarta.activation.MailcapRegistry
-
-
Field Summary
Fields Modifier and Type Field Description private static boolean
addReverse
private java.util.Map<java.lang.String,java.util.Map<java.lang.String,java.util.List<java.lang.String>>>
fallback_hash
Another Map like above, but for fallback entries.private java.util.Map<java.lang.String,java.util.List<java.lang.String>>
native_commands
A Map indexed by MIME type (string) that references a List of native commands (string) corresponding to the type.private java.util.Map<java.lang.String,java.util.Map<java.lang.String,java.util.List<java.lang.String>>>
type_hash
A Map indexed by MIME type (string) that references a Map of commands for each type.
-
Constructor Summary
Constructors Constructor Description MailcapFile()
Mailcap file default constructor.MailcapFile(java.io.InputStream is)
The constructor that takes an input stream as an argument.MailcapFile(java.lang.String new_fname)
The constructor that takes a filename as an argument.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
appendToMailcap(java.lang.String mail_cap)
appendToMailcap: Append to this Mailcap DB, use the mailcap format: Comment == "# comment string" Entry == "mimetype; javabeanclass"java.util.Map<java.lang.String,java.util.List<java.lang.String>>
getMailcapFallbackList(java.lang.String mime_type)
Get the Map of fallback MailcapEntries based on the MIME type.java.util.Map<java.lang.String,java.util.List<java.lang.String>>
getMailcapList(java.lang.String mime_type)
Get the Map of MailcapEntries based on the MIME type.private java.util.Map<java.lang.String,java.util.List<java.lang.String>>
getMailcapList(java.lang.String mime_type, java.util.Map<java.lang.String,java.util.Map<java.lang.String,java.util.List<java.lang.String>>> db)
Get the Map of MailcapEntries from given db based on the MIME type.java.lang.String[]
getMimeTypes()
Return all the MIME types known to this mailcap file.java.lang.String[]
getNativeCommands(java.lang.String mime_type)
Return all the native comands for the given MIME type.private java.util.Map<java.lang.String,java.util.List<java.lang.String>>
mergeResults(java.util.Map<java.lang.String,java.util.List<java.lang.String>> first, java.util.Map<java.lang.String,java.util.List<java.lang.String>> second)
Merge the first hash into the second.private void
parse(java.io.BufferedReader reader)
parse file into a hash table of MC Type Entry Objprotected void
parseLine(java.lang.String mailcapEntry)
A routine to parse individual entries in a Mailcap file.protected static void
reportParseError(int expectedToken, int otherExpectedToken, int anotherExpectedToken, int actualToken, java.lang.String actualTokenValue)
protected static void
reportParseError(int expectedToken, int otherExpectedToken, int actualToken, java.lang.String actualTokenValue)
protected static void
reportParseError(int expectedToken, int actualToken, java.lang.String actualTokenValue)
-
-
-
Field Detail
-
type_hash
private java.util.Map<java.lang.String,java.util.Map<java.lang.String,java.util.List<java.lang.String>>> 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 java.util.Map<java.lang.String,java.util.Map<java.lang.String,java.util.List<java.lang.String>>> fallback_hash
Another Map like above, but for fallback entries.
-
native_commands
private java.util.Map<java.lang.String,java.util.List<java.lang.String>> 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 Detail
-
MailcapFile
public MailcapFile(java.lang.String new_fname) throws java.io.IOException
The constructor that takes a filename as an argument.- Parameters:
new_fname
- The file name of the mailcap file.- Throws:
java.io.IOException
- for I/O errors
-
MailcapFile
public MailcapFile(java.io.InputStream is) throws java.io.IOException
The constructor that takes an input stream as an argument.- Parameters:
is
- the input stream- Throws:
java.io.IOException
- for I/O errors
-
MailcapFile
public MailcapFile()
Mailcap file default constructor.
-
-
Method Detail
-
getMailcapList
public java.util.Map<java.lang.String,java.util.List<java.lang.String>> getMailcapList(java.lang.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.
- Specified by:
getMailcapList
in interfacejakarta.activation.MailcapRegistry
- Parameters:
mime_type
- the MIME type- Returns:
- the map of MailcapEntries
-
getMailcapFallbackList
public java.util.Map<java.lang.String,java.util.List<java.lang.String>> getMailcapFallbackList(java.lang.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.
- Specified by:
getMailcapFallbackList
in interfacejakarta.activation.MailcapRegistry
- Parameters:
mime_type
- the MIME type- Returns:
- the map of fallback MailcapEntries
-
getMailcapList
private java.util.Map<java.lang.String,java.util.List<java.lang.String>> getMailcapList(java.lang.String mime_type, java.util.Map<java.lang.String,java.util.Map<java.lang.String,java.util.List<java.lang.String>>> db)
Get the Map of MailcapEntries from given db 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 typedb
- the db to search in- Returns:
- the map of fallback MailcapEntries
-
getMimeTypes
public java.lang.String[] getMimeTypes()
Return all the MIME types known to this mailcap file.- Specified by:
getMimeTypes
in interfacejakarta.activation.MailcapRegistry
- Returns:
- a String array of the MIME types
-
getNativeCommands
public java.lang.String[] getNativeCommands(java.lang.String mime_type)
Return all the native comands for the given MIME type.- Specified by:
getNativeCommands
in interfacejakarta.activation.MailcapRegistry
- Parameters:
mime_type
- the MIME type- Returns:
- a String array of the commands
-
mergeResults
private java.util.Map<java.lang.String,java.util.List<java.lang.String>> mergeResults(java.util.Map<java.lang.String,java.util.List<java.lang.String>> first, java.util.Map<java.lang.String,java.util.List<java.lang.String>> 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(java.lang.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
- Specified by:
appendToMailcap
in interfacejakarta.activation.MailcapRegistry
- Parameters:
mail_cap
- the mailcap string
-
parse
private void parse(java.io.BufferedReader reader) throws java.io.IOException
parse file into a hash table of MC Type Entry Obj- Throws:
java.io.IOException
-
parseLine
protected void parseLine(java.lang.String mailcapEntry) throws MailcapParseException, java.io.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 errorsjava.io.IOException
- for I/O errors
-
reportParseError
protected static void reportParseError(int expectedToken, int actualToken, java.lang.String actualTokenValue) throws MailcapParseException
- Throws:
MailcapParseException
-
reportParseError
protected static void reportParseError(int expectedToken, int otherExpectedToken, int actualToken, java.lang.String actualTokenValue) throws MailcapParseException
- Throws:
MailcapParseException
-
reportParseError
protected static void reportParseError(int expectedToken, int otherExpectedToken, int anotherExpectedToken, int actualToken, java.lang.String actualTokenValue) throws MailcapParseException
- Throws:
MailcapParseException
-
-