Eclipse Platform
Release 3.1

org.eclipse.core.filebuffers
Interface IFileBuffer

All Known Subinterfaces:
ITextFileBuffer

public interface IFileBuffer

A file buffer represents a file that can be edited by more than one client. Editing is session oriented. This means that editing is a sequence of modification steps. The start of the sequence and the end of the sequence are explicitly indicated. There are no time constraints connected with the sequence of modification steps. A file buffer reifies editing sessions and allows them to interleave.

It is not specified whether simultaneous editing sessions can be owned by different threads.

Clients are not supposed to implement that interface. Instances of this type are obtained from a IFileBufferManager.

Since:
3.0

Method Summary
 void commit(IProgressMonitor monitor, boolean overwrite)
          Commits this file buffer by changing the contents of the underlying file to the contents of this file buffer.
 ISchedulingRule computeCommitRule()
          Computes the scheduling rule that is required for committing a changed buffer.
 ISchedulingRule computeValidateStateRule()
          Computes the scheduling rule that is required for validating the state of the buffer.
 IContentType getContentType()
          Returns the content type of this file buffer or null if none could be determined.
 IPath getLocation()
          Returns the location of this file buffer.
 long getModificationStamp()
          Returns the modification stamp of the file underlying this file buffer.
 IStatus getStatus()
          Returns the status of this file buffer.
 boolean isCommitable()
          Returns whether this file buffer is commitable.
 boolean isDirty()
          Returns whether changes have been applied to this file buffer since initialization, or the most recent revert or commit call.
 boolean isShared()
          Returns whether this file buffer is shared by more than one client.
 boolean isStateValidated()
          Returns whether the state of this file buffer has been validated.
 boolean isSynchronizationContextRequested()
          Returns whether a synchronization context has been requested for this file buffer and not yet released.
 boolean isSynchronized()
          Returns whether this file buffer is synchronized with the file system.
 void releaseSynchronizationContext()
          The caller no longer requests the synchronization context for this file buffer.
 void requestSynchronizationContext()
          The caller requests that the synchronization context is used to synchronize this file buffer with its underlying file.
 void resetStateValidation()
          Resets state validation.
 void revert(IProgressMonitor monitor)
          Reverts the contents of this file buffer to the content of its underlying file.
 void setDirty(boolean isDirty)
          Sets the dirty state of the file buffer to the given value.
 void validateState(IProgressMonitor monitor, Object computationContext)
          Validates the state of this file buffer and tries to bring the buffer's underlying file into a state in which it can be modified.
 

Method Detail

getLocation

public IPath getLocation()
Returns the location of this file buffer.

The location is either a full path of a workspace resource or an absolute path in the local file system.

Returns:
the location of this file buffer

isShared

public boolean isShared()
Returns whether this file buffer is shared by more than one client.

Returns:
true if this file buffer is shared by more than one client

isSynchronized

public boolean isSynchronized()
Returns whether this file buffer is synchronized with the file system. This is when the file buffer's underlying file is in synchronization with the file system and the file buffer has been initialized after the underlying files has been modified the last time.

Returns:
true if the file buffer is synchronized with the file system

getModificationStamp

public long getModificationStamp()
Returns the modification stamp of the file underlying this file buffer.

Returns:
the modification stamp of the file underlying this file buffer

isCommitable

public boolean isCommitable()
Returns whether this file buffer is commitable. This is the case when the file buffer's state has been successfully validated.

Returns:
true if the file buffer is commitable, false otherwise
Since:
3.1

computeCommitRule

public ISchedulingRule computeCommitRule()
Computes the scheduling rule that is required for committing a changed buffer.

Returns:
the commit scheduling rule or null
Since:
3.1

commit

public void commit(IProgressMonitor monitor,
                   boolean overwrite)
            throws CoreException
Commits this file buffer by changing the contents of the underlying file to the contents of this file buffer. After that call, isDirty returns false and isSynchronized returns true.

Parameters:
monitor - the progress monitor
overwrite - indicates whether the underlying file should be overwritten if it is not synchronized with the file system
Throws:
CoreException - if writing or accessing the underlying file fails

revert

public void revert(IProgressMonitor monitor)
            throws CoreException
Reverts the contents of this file buffer to the content of its underlying file. After that call successfully returned, isDirty returns false and isSynchronized returns true.

Parameters:
monitor - the progress monitor
Throws:
CoreException - if reading or accessing the underlying file fails

isDirty

public boolean isDirty()
Returns whether changes have been applied to this file buffer since initialization, or the most recent revert or commit call.

Returns:
true if changes have been applied to this buffer

setDirty

public void setDirty(boolean isDirty)
Sets the dirty state of the file buffer to the given value. A direct subsequent call to isDirty returns the previously set value.

Parameters:
isDirty - true if the buffer should be marked dirty, false otherwise
Since:
3.1

computeValidateStateRule

public ISchedulingRule computeValidateStateRule()
Computes the scheduling rule that is required for validating the state of the buffer.

Returns:
the validate state scheduling rule or null
Since:
3.1

validateState

public void validateState(IProgressMonitor monitor,
                          Object computationContext)
                   throws CoreException
Validates the state of this file buffer and tries to bring the buffer's underlying file into a state in which it can be modified. If state validation is not supported this operation does nothing.

Parameters:
monitor - the progress monitor
computationContext - the context in which the validation is performed, e.g., a SWT shell
Throws:
CoreException - if the underlying file can not be accessed to it's state cannot be changed

isStateValidated

public boolean isStateValidated()
Returns whether the state of this file buffer has been validated. If state validation is not supported this method always returns true.

Returns:
true if the state has been validated, false otherwise

resetStateValidation

public void resetStateValidation()
Resets state validation. If state validation is supported, isStateValidated afterwards returns false until the state is revalidated.


getStatus

public IStatus getStatus()
Returns the status of this file buffer. This is the result of the last operation performed on this file buffer or internally initiated by this file buffer.

Returns:
the status of this file buffer

requestSynchronizationContext

public void requestSynchronizationContext()
The caller requests that the synchronization context is used to synchronize this file buffer with its underlying file.

Since:
3.1

releaseSynchronizationContext

public void releaseSynchronizationContext()
The caller no longer requests the synchronization context for this file buffer.

Since:
3.1

isSynchronizationContextRequested

public boolean isSynchronizationContextRequested()
Returns whether a synchronization context has been requested for this file buffer and not yet released.

Returns:
true if a synchronization context is requested, false otherwise
Since:
3.1

getContentType

public IContentType getContentType()
                            throws CoreException
Returns the content type of this file buffer or null if none could be determined. If the file buffer is dirty, the returned content type is determined by the buffer's dirty state.

Returns:
the content type or null
Throws:
CoreException - if reading or accessing the underlying file fails
Since:
3.1

Eclipse Platform
Release 3.1

Guidelines for using Eclipse APIs.

Copyright (c) IBM Corp. and others 2000, 2005. All rights reserved.