Interface DataSource
-
- All Known Subinterfaces:
MultiStreamDataSource
,StreamDataSource
- All Known Implementing Classes:
NullDataSource
public interface DataSource
Represents a location abstraction + some means to work with data at the location. UsuallyDataSource
points to the model data sources. For example it can be based on files, internet content, database content, etc. NB: Must not contain any information on the storage format specifics -- all that belongs to theModelFactory
. For implementation consider extendingjetbrains.mps.extapi.persistence.DataSourceBase
,MultiStreamSourceBase
,StreamSourceBase
fixme rather we need to separate the location part of the accessing the data at the location right now we have both here, but no abstract means to read/write because on this level there is no common access mechanism that we could offer
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default void
addListener(DataSourceListener listener)
Registers listeners which need to be notified about changes in the underlying data source.String
getLocation()
Yields a string representation for the location of the data source (if applicable)long
getTimestamp()
Retrieves the last modification timestamp.default DataSourceType
getType()
Defines a data source type for this kind of data sources.default boolean
isAlive()
boolean
isReadOnly()
Sometimes there is a possibility to editDataSource
, though it is not available on this level.default void
refresh()
default void
removeListener(DataSourceListener listener)
-
-
-
Method Detail
-
getLocation
@NotNull String getLocation()
Yields a string representation for the location of the data source (if applicable)
-
isAlive
default boolean isAlive()
- Returns:
- if the source is alive, like the file exists or the connection is not closed
-
getTimestamp
long getTimestamp()
Retrieves the last modification timestamp. The timestamp should reliably reflect all external changes to the data source. fixme what a great idea to encode things in the timestamp, why not read-only property is denoted by -2?- Returns:
- 0 if timestamp is not supported for the source, or -1 if the source is dead (like when file is deleted)
-
getType
@Nullable default DataSourceType getType()
Defines a data source type for this kind of data sources. The data source type notion is strongly associated with the possibility to provideDataSourceFactory
andModelFactory
custom mappings. SeeDataSourceFactoryRuleService
andModelFactoryService
for the implementation details.- 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.
-
isReadOnly
boolean isReadOnly()
Sometimes there is a possibility to editDataSource
, though it is not available on this level. For examples please seeStreamDataSource
,MultiStreamDataSource
.- Returns:
- whether this data source can be changed. fixme not clear: change from api like #openOutputStream or changed externally?
-
addListener
default void addListener(@NotNull DataSourceListener listener)
Registers listeners which 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. if
-
removeListener
default void removeListener(@NotNull DataSourceListener listener)
-
refresh
default void refresh()
-
-