package ch.werner_randelshofer.activation;/*Copyright (C) 1999-99 Werner Randelshoferwerner.randelshofer@mythen.chhttp://www.mythen.ch/w.randelshofer/    Permission to use this release of DefaultCommandMap is herebygranted without fee provided that the complete copyrightnotice and this permission notice appear in all copiesand in supporting documentation.*/import javax.activation.CommandMap;import javax.activation.CommandInfo;import javax.activation.DataContentHandler;import java.util.Hashtable;/**Default implementation of a CommandMap.The CommandInfo objects are explicitly added to the map.@author	Werner Randelshofer, Staldenmattweg 2, CH-6405 Immensee, Switzerland.@version	1998-02-27	Created.*/public class DefaultCommandMapextends CommandMap	{	Hashtable map_ = new Hashtable();		/**	Adds a command info object to the map.	*/	public void addCommandInfo(String mimeType, CommandInfo info)		{		CommandInfo[] entry = (CommandInfo[])map_.get(mimeType);		if (entry == null)			{			map_.put(mimeType,new CommandInfo[]Ê{ info });			}		else			{			CommandInfo[] entry2 = new CommandInfo[entry.length+1];			System.arraycopy(entry,0,entry2,0,entry.length);			entry2[entry.length] = info;			map_.put(mimeType,entry2);			}		}	/**	Get the preferred command list from a MIME Type.	The actual semantics are determined by the implementation of the CommandMap.	@return the CommandInfo classes the represent the command Beans.	*/	public CommandInfo[] getPreferredCommands(String mimeType)		{ return getAllCommands(mimeType); }	/**	Get all the available commands for this type.	This method should return all the possible commands for this	MIME type.	@return returns the CommandInfo objects representing all the commands.	*/	public CommandInfo[] getAllCommands(String mimeType)		{		return (CommandInfo[])map_.get(mimeType);		}	/**	Get the default command corresponding to	the MIME type.	@return the CommandInfo corresponding to the command.	*/	public CommandInfo getCommand(String mimeType, String cmdName)		{		CommandInfo[] entry = (CommandInfo[])map_.get(mimeType);		if (entry != null)			{			for (int i=0; i < entry.length; i++)				{				if (entry[i].getCommandName().equals(cmdName)					{ return entry[i]; }				}			}		return null;		}	/**	Locate a DataContentHandler that corresponds to the MIME type.	The mechanism and semantics for determining this are determined by	the implementation of the particular CommandMap.    */	public DataContentHandler createDataContentHandler(String mimeType)		{		return null; // is this acceptable?		}	}