KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jdesktop > jdic > filetypes > internal > WinAppAssociationReader


1 /*
2  * Copyright (C) 2004 Sun Microsystems, Inc. All rights reserved. Use is
3  * subject to license terms.
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the Lesser GNU General Public License as
7  * published by the Free Software Foundation; either version 2 of the
8  * License, or (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful, but
11  * WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
18  * USA.
19  */

20
21 package org.jdesktop.jdic.filetypes.internal;
22
23 import java.net.URL JavaDoc;
24 import java.util.ArrayList JavaDoc;
25 import java.util.List JavaDoc;
26
27 /**
28  * Concrete implementation of the AppAssociationReader class for Windows platform.
29  */

30 public class WinAppAssociationReader implements AppAssociationReader {
31
32     /**
33      * Retrieves the description associated with the given mime type.
34      *
35      * @param mimeType given mime type (not null)
36      * @return relevant description, or null if not available
37      */

38     public String JavaDoc getDescriptionByMimeType(String JavaDoc mimeType) {
39         String JavaDoc temFileExt = WinRegistryUtil.getFileExtByMimeType(mimeType);
40         if (temFileExt != null) {
41             return getDescriptionByFileExt(temFileExt);
42         } else {
43             return null;
44         }
45     }
46   
47     /**
48      * Retrieves the description associated with the given file extension.
49      *
50      * @param fileExt given file extension (not null)
51      * @return relevant description for the given file extension
52      */

53     public String JavaDoc getDescriptionByFileExt(String JavaDoc fileExt) {
54         return WinRegistryUtil.getDescriptionByFileExt(fileExt);
55     }
56
57     /**
58      * Retrieves the mime type associated with the given URL,
59      * by checking the content of the URL.
60      *
61      * @param url given URL (not null)
62      * @return corresponding mime type
63      */

64     public String JavaDoc getMimeTypeByURL(URL JavaDoc url) {
65         return WinRegistryUtil.getMimeTypeByURL(url);
66     }
67
68     /**
69      * Retrieves the file extension list associated with the given mime type.
70      *
71      * @param mimeType given mime type (not null)
72      * @return corresponding file list, or null if not available.
73      */

74     public List JavaDoc getFileExtListByMimeType(String JavaDoc mimeType) {
75         String JavaDoc fileExt = WinRegistryUtil.getFileExtByMimeType(mimeType);
76         if (fileExt != null) {
77           List JavaDoc fileExtList = new ArrayList JavaDoc();
78           fileExtList.add(fileExt);
79           
80           return fileExtList;
81         }
82         
83         return null;
84     }
85   
86     /**
87      * Retrieves the mime type associated with the given file extension.
88      *
89      * @param fileExt given file extension (not null)
90      * @return corresponding mime type
91      */

92     public String JavaDoc getMimeTypeByFileExt(String JavaDoc fileExt) {
93         return WinRegistryUtil.getMimeTypeByFileExt(fileExt);
94     }
95   
96     /**
97      * Retrieves the icon file name associated with the given mime type.
98      *
99      * @param mimeType given mime type (not null)
100      * @return corresponding icon file name, or null if no available
101      */

102     public String JavaDoc getIconFileNameByMimeType(String JavaDoc mimeType) {
103         String JavaDoc temFileExt = WinRegistryUtil.getFileExtByMimeType(mimeType);
104         if (temFileExt != null) {
105             return getIconFileNameByFileExt(temFileExt);
106         } else {
107             return null;
108         }
109     }
110   
111     /**
112      * Retrieves the icon file name associated with the given file extension.
113      *
114      * @param fileExt given file extension (not null)
115      * @return corresponding icon file name
116      */

117     public String JavaDoc getIconFileNameByFileExt(String JavaDoc fileExt) {
118         return WinRegistryUtil.getIconFileNameByFileExt(fileExt);
119     }
120  
121     /**
122      * Retrieves the action list associated with the given mime type.
123      *
124      * @param mimeType given mime type (not null)
125      * @return corresponding action list, or null if not available
126      */

127     public List JavaDoc getActionListByMimeType(String JavaDoc mimeType) {
128         String JavaDoc temFileExt = WinRegistryUtil.getFileExtByMimeType(mimeType);
129         if (temFileExt != null) {
130             return getActionListByFileExt(temFileExt);
131         } else {
132             return null;
133         }
134      }
135
136     /**
137      * Retrieves the action list associated with the given file extension.
138      *
139      * @param fileExt given file extension (not null)
140      * @return corresponding action list
141      */

142     public List JavaDoc getActionListByFileExt(String JavaDoc fileExt) {
143         return WinRegistryUtil.getActionListByFileExt(fileExt);
144     }
145
146     /**
147      * Returns true if the mime type exists in Windows Registry.
148      *
149      * @param mimeType given mimeType
150      * @return true if the mime type exists in the Registry
151      */

152     public boolean isMimeTypeExist(String JavaDoc mimeType) {
153         return WinRegistryUtil.isMimeTypeExist(mimeType);
154     }
155     
156     /**
157      * Returns true if the file extension exists in Windows Registry.
158      *
159      * @param fileExt given file extension
160      * @return true if the file extension exists in the Registry
161      */

162     public boolean isFileExtExist(String JavaDoc fileExt) {
163         return WinRegistryUtil.isFileExtExist(fileExt);
164     }
165 }
166
Popular Tags