Package jetbrains.mps.extapi.persistence
Class FileDataSource
- java.lang.Object
 - 
- jetbrains.mps.extapi.persistence.DataSourceBase
 - 
- jetbrains.mps.extapi.persistence.FileDataSource
 
 
 
- 
- All Implemented Interfaces:
 DisposableDataSource,FileSystemBasedDataSource,FileListener,FileSystemListener,DataSource,StreamDataSource
- Direct Known Subclasses:
 FileWithBackupDataSource
public class FileDataSource extends DataSourceBase implements StreamDataSource, FileSystemListener, FileSystemBasedDataSource
A data source which points explicitly to the single file location. Currently it also knows something about vfs (listens to the events) but it is going to be cleared away. Also it is worth considering the merging of this notion with theFolderDataSourceand others which points to some files on the file system. It seems that it is unnecessary to separate these entities [as soon as there is no additional vfs functionality] AP 
- 
- 
Constructor Summary
Constructors Constructor Description FileDataSource(IFile file)FileDataSource(IFile file, ModelRoot modelRoot) 
- 
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddListener(DataSourceListener listener)Registers listeners who need to be notified about changes in the underlying data source.voiddelete()Invoked with intention never come across this data source again.protected voidfireChanged(ProgressMonitor monitor)Collection<IFile>getAffectedFiles()IFilegetFile()IFilegetFileToListen()StringgetLocation()Yields a string representation for the location of the data source (if applicable)longgetTimestamp()Retrieves the last modification timestamp.DataSourceTypegetType()Defines a data source type for this kind of data sources.booleanisReadOnly()TODO Makes sense only with API which introduce changes to theDataSource.InputStreamopenInputStream()OutputStreamopenOutputStream()voidrefresh()voidremoveListener(DataSourceListener listener)voidsetFile(IFile file)protected voidstartListening()protected voidstopListening()voidupdate(ProgressMonitor monitor, FileSystemEvent event)listener gets here all the events- 
Methods inherited from class jetbrains.mps.extapi.persistence.DataSourceBase
toString 
- 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait 
- 
Methods inherited from interface jetbrains.mps.vfs.refresh.FileListener
listeningPreferences 
- 
Methods inherited from interface jetbrains.mps.vfs.refresh.FileSystemListener
getListenerDependencies 
 - 
 
 - 
 
- 
- 
Constructor Detail
- 
FileDataSource
@Deprecated public FileDataSource(@NotNull IFile file, @Nullable ModelRoot modelRoot)
Deprecated.FIXME remove modelRoot parameter- Parameters:
 modelRoot- (optional) containing model root, which should be notified before the source during the update
 
 - 
 
- 
Method Detail
- 
isReadOnly
public boolean isReadOnly()
Description copied from interface:DataSourceTODO Makes sense only with API which introduce changes to theDataSource. Currently it is incomplete. Usually there is a possibility to editDataSource. For examples please seeStreamDataSource.- Specified by:
 isReadOnlyin interfaceDataSource- Overrides:
 isReadOnlyin classDataSourceBase- Returns:
 - whether this data source can be changed.
 
 
- 
getLocation
@NotNull public String getLocation()
Description copied from interface:DataSourceYields a string representation for the location of the data source (if applicable)- Specified by:
 getLocationin interfaceDataSource- Overrides:
 getLocationin classDataSourceBase
 
- 
openInputStream
public InputStream openInputStream() throws IOException
- Specified by:
 openInputStreamin interfaceStreamDataSource- Throws:
 IOException
 
- 
openOutputStream
public OutputStream openOutputStream() throws IOException
- Specified by:
 openOutputStreamin interfaceStreamDataSource- Throws:
 IOException
 
- 
refresh
public void refresh()
- Overrides:
 refreshin classDataSourceBase
 
- 
getTimestamp
public long getTimestamp()
Description copied from interface:DataSourceRetrieves the last modification timestamp. The timestamp should reliably reflect all external changes to the data source.- Specified by:
 getTimestampin interfaceDataSource- Overrides:
 getTimestampin classDataSourceBase- Returns:
 - 0 if timestamp is not supported for the source, or -1 if the source is dead (like when file is deleted)
 
 
- 
addListener
public final void addListener(@NotNull DataSourceListener listener)
Description copied from interface:DataSourceRegisters listeners who need to be notified about changes in the underlying data source. It is the responsibility of the DataSource to detect such updates and notify the listeners.- Specified by:
 addListenerin interfaceDataSource- Overrides:
 addListenerin classDataSourceBase
 
- 
startListening
protected void startListening()
 
- 
removeListener
public final void removeListener(@NotNull DataSourceListener listener)
- Specified by:
 removeListenerin interfaceDataSource- Overrides:
 removeListenerin classDataSourceBase
 
- 
delete
public void delete()
Description copied from interface:DisposableDataSourceInvoked with intention never come across this data source again. For a file/folder/DB entry, this would mean 'wipe out'.- Specified by:
 deletein interfaceDisposableDataSource
 
- 
stopListening
protected void stopListening()
 
- 
getFileToListen
@NotNull public IFile getFileToListen()
- Specified by:
 getFileToListenin interfaceFileSystemListener
 
- 
update
public void update(ProgressMonitor monitor, @NotNull FileSystemEvent event)
Description copied from interface:FileListenerlistener gets here all the events- Specified by:
 updatein interfaceFileListener
 
- 
fireChanged
protected void fireChanged(ProgressMonitor monitor)
 
- 
getAffectedFiles
@NotNull public Collection<IFile> getAffectedFiles()
- Specified by:
 getAffectedFilesin interfaceFileSystemBasedDataSource- Returns:
 - collection of files (or folders) which comprise a set of source paths (!) for this DataSource CONTRACT: Minimality: 1. If a 'file' is in the result then 'file.getParent()' could not be among resulting files 2. All the files in the directory could not be there (the parent directory as a whole would be returned instead)
 
 
- 
getType
@NotNull public DataSourceType getType()
Description copied from interface:DataSourceDefines a data source type for this kind of data sources. The data source type notion is strongly associated with the possibility to provideDataSourceFactoryandModelFactorycustom mappings. SeeDataSourceFactoryRuleServiceandModelFactoryServicefor the implementation details.- Specified by:
 getTypein interfaceDataSource- Overrides:
 getTypein classDataSourceBase- Returns:
 - the unique data source type for this instance of data source if the developer wants others to be able to change the default behavior of this data source (register with the same key) or if he desires to associate this data source with some specific model factory.
 
 
 - 
 
 -