KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > core > filebuffers > ITextFileBufferManager


1 /*******************************************************************************
2  * Copyright (c) 2000, 2007 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 package org.eclipse.core.filebuffers;
12
13
14 import org.eclipse.core.filesystem.IFileStore;
15 import org.eclipse.core.internal.filebuffers.FileBuffersPlugin;
16
17 import org.eclipse.core.runtime.IPath;
18
19 import org.eclipse.jface.text.IDocument;
20 import org.eclipse.jface.text.source.IAnnotationModel;
21
22
23 /**
24  * A text file buffer manager manages text file buffers for files whose contents
25  * is considered text.
26  * <p>
27  * Clients are not supposed to implement that interface.
28  * </p>
29  *
30  * @since 3.0
31  */

32 public interface ITextFileBufferManager extends IFileBufferManager {
33     
34     /**
35      * The default text file buffer manager.
36      * @since 3.3
37      */

38     ITextFileBufferManager DEFAULT= FileBuffersPlugin.getDefault().getFileBufferManager();
39
40     /**
41      * Returns the text file buffer managed for the file at the given location
42      * or <code>null</code> if either there is no such text file buffer.
43      * <p>
44      * The provided location is either a full path of a workspace resource or
45      * an absolute path in the local file system. The file buffer manager does
46      * not resolve the location of workspace resources in the case of linked
47      * resources.
48      * </p>
49      *
50      * @param location the location
51      * @return the text file buffer managed for that location or <code>null</code>
52      * @deprecated As of 3.3, replaced by {@link #getTextFileBuffer(IPath, LocationKind)}
53      */

54     ITextFileBuffer getTextFileBuffer(IPath location);
55     
56     /**
57      * Returns the text file buffer managed for the file at the given location
58      * or <code>null</code> if there is no such text file buffer.
59      * <p>
60      * The type of the provided location is specified by the given
61      * <code>locationKind</code>.
62      * </p>
63      *
64      * @param location the location
65      * @param locationKind the kind of the given location
66      * @return the text file buffer managed for that location or <code>null</code>
67      * @see LocationKind
68      * @since 3.3
69      */

70     ITextFileBuffer getTextFileBuffer(IPath location, LocationKind locationKind);
71     
72     /**
73      * Returns the text file buffer managed for the given file store
74      * or <code>null</code> if there is no such text file buffer.
75      * <p>
76      * <strong>Note:</strong> This API must not be used if the given file
77      * store maps to a resource contained in the workspace. A file buffer
78      * that has been connected using a path will not be found.
79      * </p>
80      * <p>
81      * We had to use a different name than <code>getTextFileBuffer</code> for this method
82      * due to https://bugs.eclipse.org/bugs/show_bug.cgi?id=148844
83      * </p>
84      *
85      * @param fileStore the file store
86      * @return the text file buffer managed for that file store or <code>null</code>
87      * @since 3.3
88      */

89     ITextFileBuffer getFileStoreTextFileBuffer(IFileStore fileStore);
90
91     /**
92      * Returns the text file buffer managed for the given document
93      * or <code>null</code> if there is no such text file buffer.
94      * <p>
95      * <strong>Note:</strong> This method goes through the list
96      * of registered buffers and tests whether its document matches
97      * the given one. Therefore this method should not be used in
98      * performance critical code.
99      * </p>
100      *
101      * @param document the document for which to find the text file buffer
102      * @return the text file buffer managed for that document or <code>null</code>
103      * @since 3.3
104      */

105     ITextFileBuffer getTextFileBuffer(IDocument document);
106
107     /**
108      * Returns the default encoding that is used to read the contents of text files
109      * if no other encoding is specified.
110      *
111      * @return the default text file encoding
112      */

113     String JavaDoc getDefaultEncoding();
114
115     /**
116      * Creates a new empty document. The document is set up in the same way as
117      * it would be used in a text file buffer for a file at the given location.
118      * <p>
119      * The provided location is either a full path of a workspace resource or
120      * an absolute path in the local file system. The file buffer manager does
121      * not resolve the location of workspace resources in the case of linked
122      * resources.
123      * </p>
124      *
125      * @param location the location used to set up the newly created document
126      * @return a new empty document
127      * @deprecated As of 3.3, replaced by {@link #createEmptyDocument(IPath, LocationKind)}
128      */

129     IDocument createEmptyDocument(IPath location);
130     
131     /**
132      * Creates a new empty document. The document is set up in the same way as
133      * it would be used in a text file buffer for a file at the given location.
134      * <p>
135      * The type of the provided location is specified by the given
136      * <code>locationKind</code>.
137      * </p>
138      *
139      * @param location the location used to set up the newly created document
140      * @param locationKind the kind of the given location
141      * @return a new empty document
142      * @since 3.3
143      */

144     IDocument createEmptyDocument(IPath location, LocationKind locationKind);
145
146     /**
147      * Creates a new annotation for the given location.
148      * <p>
149      * The provided location is either a full path of a workspace resource or an
150      * absolute path in the local file system. The file buffer manager does not
151      * resolve the location of workspace resources in the case of linked
152      * resources.
153      * </p>
154      *
155      * @param location the location used to create the new annotation model
156      * @return the newly created annotation model
157      * @deprecated As of 3.3, replaced by {@link #createAnnotationModel(IPath, LocationKind)}
158      */

159     IAnnotationModel createAnnotationModel(IPath location);
160     
161     /**
162      * Creates a new annotation for the given location.
163      * <p>
164      * The type of the provided location is specified by the given
165      * <code>locationKind</code>.
166      * </p>
167      *
168      * @param location the location used to create the new annotation model
169      * @param locationKind the kind of the given location
170      * @return the newly created annotation model
171      * @since 3.3
172      */

173     IAnnotationModel createAnnotationModel(IPath location, LocationKind locationKind);
174
175     /**
176      * Returns whether a file at the given location is or can be considered a
177      * text file. If the file exists, the concrete content type of the file is
178      * checked. If the concrete content type for the existing file can not be
179      * determined, this method returns <code>true</code>. If the file does
180      * not exist, it is checked whether a text content type is associated with
181      * the given location. If no content type is associated with the location,
182      * this method returns <code>true</code>.
183      * <p>
184      * The provided location is either a full path of a workspace resource or an
185      * absolute path in the local file system. The file buffer manager does not
186      * resolve the location of workspace resources in the case of linked
187      * resources.
188      * </p>
189      *
190      * @param location the location to check
191      * @return <code>true</code> if the location is a text file location
192      * @since 3.1
193      * @deprecated As of 3.2, replaced by {@link #isTextFileLocation(IPath, boolean)}
194      */

195     boolean isTextFileLocation(IPath location);
196     /**
197      * Returns whether a file at the given location is or can be considered a
198      * text file. If the file exists, the concrete content type of the file is
199      * checked. If the concrete content type for the existing file can not be
200      * determined, this method returns <code>!strict</code>. If the file does
201      * not exist, it is checked whether a text content type is associated with
202      * the given location. If no content type is associated with the location,
203      * this method returns <code>!strict</code>.
204      * <p>
205      * The provided location is either a full path of a workspace resource or an
206      * absolute path in the local file system. The file buffer manager does not
207      * resolve the location of workspace resources in the case of linked
208      * resources.
209      * </p>
210      *
211      * @param location the location to check
212      * @param strict <code>true</code> if a file with unknown content type
213      * is not treated as text file, <code>false</code> otherwise
214      * @return <code>true</code> if the location is a text file location
215      * @since 3.2
216      */

217     boolean isTextFileLocation(IPath location, boolean strict);
218 }
219
Popular Tags