KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > team > core > IFileContentManager


1 /*******************************************************************************
2  * Copyright (c) 2000, 2005 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11
12 package org.eclipse.team.core;
13
14 import org.eclipse.core.resources.IStorage;
15
16 /**
17  * This is the API to define mappings between file names, file extensions and
18  * content types, typically used by repository providers in order to determine
19  * whether a given file can be treated as text or must be considered binary.
20  *
21  * Mappings for names and extensions can either be contributed via an extension
22  * point or via this interface.
23  *
24  * For methods that determine the content type for a given file, the following
25  * rules apply:
26  * <li>
27  * <ul>
28  * Mappings for the entire file name take precedence over mappings for the file
29  * extension only.
30  * </ul>
31  * <ul>
32  * User-defined mappings take precedence over plugin-contributed mappings
33  * </ul>
34  * </li>
35  *
36  * If a mapping is added for a name or an extension that already has a mapping
37  * which has been contributed by a plugin, it overrides the one contributed by the plugin.
38  * If the user-defined mapping is deleted, the plugin-contributed mapping is valid again.
39  * This interface is not intended to be implemented by clients.
40  *
41  * <p>
42  * This interface is not intended to be implemented by clients.
43  *
44  * @see org.eclipse.team.core.Team#getFileContentManager()
45  *
46  * @since 3.1
47  */

48 public interface IFileContentManager {
49
50     /**
51      * Get the content type for a given instance of <code>IStorage</code>. User-defined mappings
52      * take precedence over plugin-contributed mappings; further, mappings for the entire file name
53      * take precedence over mappings for the file extension only.
54      *
55      * @param storage the instance of <code>IStorage</code>.
56      * @return one of <code>Team.UNKNOWN</code>, <code>Team.TEXT</code> or <code>Team.BINARY</code>.
57      *
58      * @since 3.1
59      */

60     int getType(IStorage storage);
61
62     /**
63      * Check whether the given file name is assigned to a specific type in the content type registry.
64      * @param filename the file name to check for
65      * @return True if the file name is registered in the system and assigned to a content type, false
66      * if the file name is unknown.
67      *
68      * @since 3.1
69      */

70     boolean isKnownFilename(String JavaDoc filename);
71
72     /**
73      * Check whether the given file extension is assigned to a specific type in the content type registry.
74      * @param extension the extension to check for
75      * @return True if the extension is registered in the system and assigned to a content type, false
76      * if the extension is unknown.
77      *
78      * @since 3.1
79      */

80     boolean isKnownExtension(String JavaDoc extension);
81
82     /**
83      * Get the content type for a given file name.
84      * @param filename The file name
85      * @return one of <code>Team.UNKNOWN</code>, <code>Team.TEXT</code> or <code>Team.BINARY</code>.
86      *
87      * @since 3.1
88      */

89     int getTypeForName(String JavaDoc filename);
90
91     /**
92      * Get the content type for a given file extension.
93      * @param extension The extension
94      * @return one of <code>Team.UNKNOWN</code>, <code>Team.TEXT</code> or <code>Team.BINARY</code>.
95      *
96      * @since 3.1
97      */

98     int getTypeForExtension(String JavaDoc extension);
99
100     /**
101      * Map a set of file names to a set of content types and save the mappings in
102      * the preferences. Already existing mappings for these file names are updated
103      * with the new ones, other mappings will be preserved.
104      *
105      * @param names The file names
106      * @param types The corresponding types, each one being one of
107      * <code>Team.UNKNOWN</code>,<code>Team.TEXT</code> or
108      * <code>Team.BINARY</code>.
109      *
110      * @since 3.1
111      */

112     void addNameMappings(String JavaDoc[] names, int[] types);
113
114     /**
115      * Map a set of file extensions to a set of content types and save the mapping in
116      * the preferences. Already existing mappings for these extensions are updated
117      * with the new ones, other mappings will be preserved.
118      *
119      * @param extensions The extensions
120      * @param types The corresponding types, each one being one of
121      * <code>Team.UNKNOWN</code>,<code>Team.TEXT</code> or
122      * <code>Team.BINARY</code>.
123      *
124      * @since 3.1
125      */

126     void addExtensionMappings(String JavaDoc[] extensions, int[] types);
127
128     /**
129      * Map a set of file names to a set of content types and save the mappings in
130      * the preferences. All existing user-defined mappings for <b>any
131      * </b> file names are deleted and replaced by the new ones.
132      *
133      * @param names The file names
134      * @param types The corresponding types, each one being one of
135      * <code>Team.UNKNOWN</code>,<code>Team.TEXT</code> or
136      * <code>Team.BINARY</code>.
137      *
138      * @since 3.1
139      */

140     void setNameMappings(String JavaDoc[] names, int[] types);
141
142     /**
143      * Map a set of file extensions to a set of content types and save the
144      * mapping in the preferences. All existing user-defined mappings for <b>any
145      * </b> file extensions are deleted and replaced by the new ones.
146      *
147      * @param extensions The extensions
148      * @param types The corresponding types, each one being one of
149      * <code>Team.UNKNOWN</code>,<code>Team.TEXT</code> or
150      * <code>Team.BINARY</code>.
151      *
152      * @since 3.1
153      */

154     void setExtensionMappings(String JavaDoc[] extensions, int[] types);
155
156     /**
157      * Get all the currently defined mappings from file names to content types.
158      *
159      * @return the mappings
160      *
161      * @since 3.1
162      */

163     IStringMapping [] getNameMappings();
164
165     /**
166      * Get all the currently defined mappings from file names to content types.
167      *
168      * @return the mappings
169      *
170      * @since 3.1
171      */

172     IStringMapping [] getExtensionMappings();
173
174     /**
175      * Get all the plugin-contributed mappings from file names to content types.
176      *
177      * @return the mappings
178      *
179      * @since 3.1
180      */

181     IStringMapping [] getDefaultNameMappings();
182
183     /**
184      * Get all the plugin-contributed mappings from file extensions to content types.
185      *
186      * @return the mappings
187
188      * @since 3.1
189      */

190     IStringMapping [] getDefaultExtensionMappings();
191 }
192
Popular Tags