Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| JDIC API V2006 Release 0308
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.jdesktop.jdic.filetypes
Class AssociationService

    java.lang.Object
      org.jdesktop.jdic.filetypes.AssociationService

    public class AssociationService

extends java.lang.Object

The `AssociationService` class provides several methods to access the file type associations. It includes methods to retrieve a particular file type association, to register a new file type association into the system, and to unregister a registered file type association from the system. Each file type association is represented by an `Association` object.

The file type information storage and access mechanism is platform-dependent:

- For Microsoft Windows platforms, the file type information is stored in the registry, which is a tree structure.
- For Gnome/UNIX platforms, the file type information is stored in the MIME type database, which consists of some plain text files (.keys, .mime, .applications). Each MIME text file could contain one or multiple file types. A file type could be registered in the system by providing new MIME files, or being added to existing MIME files.

See Also:
  `Association`, `Action`

Constructor Summary
`AssociationService()` Constructor of an `AssociationService` object.

Method Summary
`Association` | `getAssociationByContent(java.net.URL url)` Returns the association representing the file type of the file the given URL points to.
`Association` | `getFileExtensionAssociation(java.lang.String fileExt)` Returns the association representing the file type of the given file extension.
`Association` | `getMimeTypeAssociation(java.lang.String mimeType)` Returns the association representing the file type of the given MIME type.
`void` | `registerSystemAssociation(Association assoc)` Registers the given association in the system level.
`void` | `registerUserAssociation(Association assoc)` Registers the given association in the user specific level.
`void` | `unregisterSystemAssociation(Association assoc)` Unregisters the given association in the system level.
`void` | `unregisterUserAssociation(Association assoc)` Unregisters the given association in the user specific level.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### AssociationService

    public AssociationService()

  Constructor of an `AssociationService` object.

Method Detail

### getMimeTypeAssociation

    public Association getMimeTypeAssociation(java.lang.String mimeType)

  Returns the association representing the file type of the given MIME type.

  Parameters:
    `mimeType` - a given MIME type name.
  Returns:
    the appropriate `Association` object; `null` if the given MIME type is not found in the system.

### getFileExtensionAssociation

    public Association getFileExtensionAssociation(java.lang.String fileExt)

  Returns the association representing the file type of the given file extension.

  The file extension list in the returned `Association` object contains only this given file extension.

  Parameters:
    `fileExt` - a given file extension name.
  Returns:
    the appropriate `Association` object; `null` if the given file extension is not found in the system.

### getAssociationByContent

    public Association getAssociationByContent(java.net.URL url)

  Returns the association representing the file type of the file the given URL points to.

  Parameters:
    `url` - a given URL.
  Returns:
    the appropriate `Association` object; `null` if the file type of the file the given URL points to is not found in the system.

### registerUserAssociation

    public void registerUserAssociation(Association assoc)
                                 throws AssociationAlreadyRegisteredException,
                                        RegisterFailedException

  Registers the given association in the user specific level.

  - For Microsoft Windows platforms: the file extension list and MIME type can't both be null. If any of the description, icon file name, action list fields is not null, the file extension list couldn't be empty.

    For Windows NT, Windows Me/98/95: the registration is always system wide, since all users share the same association information.

    For Windows 2000 and Windows XP: the registration is only applied to this specific user.

  - For Gnome/Unix platforms: both the name and MIME type fields need to be specified to perform this operation.

  Parameters:
    `assoc` - a given `Association` object.
  Throws:
    `java.lang.IllegalArgumentException` - if the given association is not valid for this operation.
    `AssociationAlreadyRegisteredException` - if the given association already exists in the system.
    `RegisterFailedException` - if the given association fails to be registered in the system.

### unregisterUserAssociation

    public void unregisterUserAssociation(Association assoc)
                                   throws AssociationNotRegisteredException,
                                          RegisterFailedException

  Unregisters the given association in the user specific level.

  - For Microsoft Windows platforms: either the MIME type or the file extension list field needs to be specified to perform this operation.

    For Windows NT, Windows Me/98/95: the unregistration is always system wide, since all users share the same association information.

    For Windows 2000 and Windows XP: the unregistration is only applied to this specific user.

  - For Gnome/Unix platforms: only the name field needs to be specified to perform this operation.

  Parameters:
    `assoc` - a given Association object.
  Throws:
    `java.lang.IllegalArgumentException` - if the given association is not valid for this operation.
    `AssociationNotRegisteredException` - if the given association doesn't exist in the system.
    `RegisterFailedException` - if the given association fails to be unregistered in the system.

### registerSystemAssociation

    public void registerSystemAssociation(Association assoc)
                                   throws AssociationAlreadyRegisteredException,
                                          RegisterFailedException

  Registers the given association in the system level.

  - For Microsoft Windows platforms: the file extension list and MIME type can't all be null. If any of the description, icon file name, action list fields is not null, the file extension list couldn't be empty.

    For Windows XP: the user needs the administrator permission to access the system association information in the registry.

  - For Gnome/Unix platforms: both the name and MIME type fields need to be specified to perform this operation.

  Parameters:
    `assoc` - a given `Association` object.
  Throws:
    `java.lang.IllegalArgumentException` - if the given association is not valid for this operation.
    `AssociationAlreadyRegisteredException` - if the given association already exists in the system.
    `RegisterFailedException` - if the given association fails to be registered in the system.

### unregisterSystemAssociation

    public void unregisterSystemAssociation(Association assoc)
                                     throws AssociationNotRegisteredException,
                                            RegisterFailedException

  Unregisters the given association in the system level.

  - For Microsoft Windows platforms: either the MIME type or the file extension list field needs to be specified to perform this operation.

    For Windows XP: the user needs the administrator permission to access the system association information in the registry.

  - For Gnome/Unix platforms: only the name field needs to be specified to perform this operation.

  Parameters:
    `assoc` - a given Association object.
  Throws:
    `java.lang.IllegalArgumentException` - if the given association is not valid for this operation.
    `AssociationNotRegisteredException` - if the given association doesn't exist in the system.
    `RegisterFailedException` - if the given association fails to be unregistered in the system.

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| JDIC API V2006 Release 0308
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

For more information and documentation on JDIC, see JDIC website.

That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, working code examples, license terms and bug report information.

Copyright (c) 2004 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms.