JXTA

net.jxta.share
Class MimeTable

java.lang.Object
  |
  +--net.jxta.share.MimeTable

public class MimeTable
extends java.lang.Object

This class is used to map file extensions to their corresponding MimeInfo objects.


Constructor Summary
MimeTable()
          Creates a new empty MimeTable.
 
Method Summary
 boolean contains(java.lang.String type)
          Returns true if this mime table contains information for the specific mime type.
 MimeInfo get(java.lang.String type)
          Returns the MimeInfo object for the specified mime type, or null if not found.
 MimeInfo[] getAll()
          Returns an array of all the MimeInfo objects in this table.
 java.lang.String getBrowserApplication()
          Returns the browser application launch string or null if none.
 java.lang.String[] getBrowserCmdArray(java.lang.String arg)
          Returns an array of strings that can be used to launch the browser for the specified argument using Runtime.exec().
static java.lang.String[] getCommandArray(java.lang.String cmd, java.lang.String arg)
          Parses the specified command string into an array of strings appropriate for use with Runtime.exec().
static MimeTable getDefaultMimeTable()
          Returns default, platform-independent MimeTable.
 MimeInfo getForName(java.lang.String name)
          Returns the MimeInfo for the specified file name, or null if not found.
 void load(java.io.InputStream is)
          Loads mime types from the specified input stream.
 void put(MimeInfo mi)
          Adds a new MimeInfo object to the table, replacing any previous mapping for the mime type.
 void remove(java.lang.String type)
          Removes MimeInfo object corresponding to specified mime type.
 void save(java.io.OutputStream os)
          Saves this MimeTable to the specified output stream.
 void setBrowserApplication(java.lang.String browser)
          Sets the browser application launch string.
 int size()
          Returns the number of MimeInfo objects stored in this table.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MimeTable

public MimeTable()
Creates a new empty MimeTable.
Method Detail

getDefaultMimeTable

public static MimeTable getDefaultMimeTable()
Returns default, platform-independent MimeTable.

get

public MimeInfo get(java.lang.String type)
Returns the MimeInfo object for the specified mime type, or null if not found.

getAll

public MimeInfo[] getAll()
Returns an array of all the MimeInfo objects in this table.

contains

public boolean contains(java.lang.String type)
Returns true if this mime table contains information for the specific mime type.

put

public void put(MimeInfo mi)
Adds a new MimeInfo object to the table, replacing any previous mapping for the mime type.

remove

public void remove(java.lang.String type)
Removes MimeInfo object corresponding to specified mime type.

size

public int size()
Returns the number of MimeInfo objects stored in this table.

getForName

public MimeInfo getForName(java.lang.String name)
Returns the MimeInfo for the specified file name, or null if not found.

load

public void load(java.io.InputStream is)
          throws java.io.IOException
Loads mime types from the specified input stream.

save

public void save(java.io.OutputStream os)
          throws java.io.IOException
Saves this MimeTable to the specified output stream.

getBrowserApplication

public java.lang.String getBrowserApplication()
Returns the browser application launch string or null if none.

setBrowserApplication

public void setBrowserApplication(java.lang.String browser)
Sets the browser application launch string.

getBrowserCmdArray

public java.lang.String[] getBrowserCmdArray(java.lang.String arg)
Returns an array of strings that can be used to launch the browser for the specified argument using Runtime.exec().

getCommandArray

public static java.lang.String[] getCommandArray(java.lang.String cmd,
                                                 java.lang.String arg)
Parses the specified command string into an array of strings appropriate for use with Runtime.exec(). Arguments containing single and double quotes are properly handled. The special token '%s' if not contained in quotes will be substituted with the specified optional argument if not null.

JXTA