Listing 3

public class Association {
      /**
       * The file extension, such as '.txt'. Cannot be null, must start with dot.
       */
       private String m_FileExtension;
       /**
        * The XML fragment that can be inserted to the freedesktop.org shared mime info
        * databse source file, that compatible desktop managers, such as Gnome and KDE, 
        * use to recognize/associate a file / filename with the mime type. 
        * 
        * Can be null, in which case the fragment is not inserted and association/recognizing
        * is based on file name extension.
        * <p>
        * An example xml fraction:
        * <code><pre>
        * <magic priority="50"> 
        *     <match type="string" offset="0" value="diff\t"/>
        *     </magic>
        * </pre></code> 
        * 
        */
       private String m_MagicPattern;
       /**
        * The mime type for this association in the form 'type/subtype'.
        * 
        * All lower case by convention as mime types are not case sensitive.
        * 
        * See RFC4288
        * 
        * An example of a common mime type / sub type is:
        * <p><code>
        * 'text/html'
        * </p></code>
        * 
        * For custom (vendor, prorietary) mime types the recommendation is to use mime types
        * of the form
        * <p><code>
        * 'application/vnd.company-type'
        * </p></code>
        * So a conforming mime type is for example:
        * <p><code>
        * 'application/vnd.motorola.flexsuite'
        * </p></code>
        * but many vendors use forms like:
        * <p><code>
        * 'application/vnd.ms-excel'
        * </code></p>   
        */
       private String m_MimeType;
       /**
        * The application end user description for the file/association type.
        */
       private String m_Description;
       /**
        * The name of the icon for the file type association.
        * 
        * This is just the name without any path infomration as the icon
        * is loaded (in AssocitationServices class) as a resource stream from 
        * the given class.
        */
       private String m_Icon;
       /**
        * Gets the description string for this association.
        * This is a description intended for the application end user
        * and which the Desktop (Gnome/KDE/Finder/Explorer) shows
        * to the user for example in tooltips.
        * @return the decription string
        * <p>
        * Example return value:
        * <pre><code>
        * "A MyApp document"
        * </code></pre>
        */
       public String getDescription() {
          return m_Description;
       }
       /**
        * Gets the mime type for this association
        * @return the mime type string
        */
       public String getMimeType() {
          return m_MimeType;
       }
       /**
        * Gets the magic pattern xml fragment for this association.
        * @return the xml fragment
        * <p>
        * <p>
        * An example xml fraction:
        * <code><pre>
        * "<magic priority="50"> 
        *     <match type="string" offset="0" value="diff\t"/>
        *     </magic>"
        * </pre></code> 
        */
       public String getMagicPattern() {
          return m_MagicPattern;
       }
       /**
        * Gets the file name extension for this association.
        * This always includes the preceding dot.
        * @return the name extension
        * <p>
        * Example return value:
        * <pre><code>
        * ".ext"
        * </code></pre>
        */
       public String getExtension() {
          return m_FileExtension;
       }
       /**
        * Gets the icon name for this association.
        * This is the pure file name including extension but excluding path
        * because the icon will be loaded as resource stream from a class.
        * <p>
        * Example return value:
        * <pre><code>
        * "myDocumentIcon.png"
        * </code></pre>
        * 
        * @return the icon name
        */
       public String getIcon() {
          return m_Icon;
       }
       /**
        * Creates an imutable file association that relates file name extension (".myext"), 
        * mime type ("application/vnd.mycompany.myext"), icon ("myAppDocIcon.png") and
        * description ("A MyApp application Document")
        * @param extension the extension including the preceding dot
        * @param mimeType the mime type in the form type/subtype
        * @param magic the magic xml fragment, can be null
        * @param icon the icon name, including image type extension, excluding path
        * @param description end user description of this association
        */
       public Association(String extension,String mimeType,String magic,String icon,String description) {
          if (!extension.startsWith("."))
             throw new IllegalArgumentException("File type extension ('"+extension+"')should start with a '.'");
          if (mimeType==null)
             throw new IllegalArgumentException("Argument 'mimeType' must not be null");
          if (description==null)
             throw new IllegalArgumentException("Argument 'description' must not be null");
          if (icon==null)
             throw new IllegalArgumentException("Argument 'icon' must not be null");
          m_FileExtension=extension;
          m_MimeType=mimeType;
          m_Description=description;
          m_MagicPattern=magic;
          m_Icon=icon;
       }
   
}