public abstract class SourceType
extends java.lang.Object
DataSource
for files, and another implementation for directories.Type | Property and Description |
---|---|
javafx.beans.property.ReadOnlyProperty<ConnectionStatus> |
connectionStatus |
Constructor and Description |
---|
SourceType(java.lang.String name,
boolean isRecordable,
java.lang.String protocol,
java.util.function.Function<java.lang.String,DataSource> sourceSupplier)
Creates a new source type.
|
Modifier and Type | Method and Description |
---|---|
void |
connect()
Connects sources of this type to the backing source interface.
|
javafx.beans.property.ReadOnlyProperty<ConnectionStatus> |
connectionStatusProperty() |
SourceEntry |
createRootSourceEntry()
Creates a root source entry.
|
SourceEntry |
createSourceEntryForUri(java.lang.String uri)
Creates a source entry corresponding to the given URI.
|
abstract DataType<?> |
dataTypeForSource(DataTypes registry,
java.lang.String sourceUri)
Gets the data type of a source for a given URI.
|
void |
disconnect()
Disconnects sources of this type from the backing source interface.
|
DataSource<?> |
forUri(java.lang.String uri)
Given a URI-like string with a protocol and a pseudo-path, return a source for the current SourceType
This function will throw an error if it doesn't support the protocol that's passed.
|
javafx.collections.ObservableMap<java.lang.String,java.lang.Object> |
getAvailableSources()
Gets a observable map of available source URIs to their values.
|
javafx.collections.ObservableList<java.lang.String> |
getAvailableSourceUris()
Gets a list of the URIs of all available sources of this type.
|
ConnectionStatus |
getConnectionStatus()
Gets the connection status of this source type.
|
java.lang.String |
getName() |
java.lang.String |
getProtocol() |
boolean |
isRecordable() |
void |
read(TimestampedData recordedData)
Reads a data point and passes it to all appropriate sources of this type.The default
behavior is to do nothing; recordable subclasses must override this method.
|
java.lang.String |
removeProtocol(java.lang.String text)
Removes the protocol prefix from a string.
|
protected void |
setConnectionStatus(ConnectionStatus connectionStatus)
Sets the connection status of this source type.
|
java.lang.String |
toUri(java.lang.String sourceName) |
public final javafx.beans.property.ReadOnlyProperty<ConnectionStatus> connectionStatusProperty
public SourceType(java.lang.String name, boolean isRecordable, java.lang.String protocol, java.util.function.Function<java.lang.String,DataSource> sourceSupplier)
name
- the name of the new source type. This must be unique among all source types.isRecordable
- if sources of this type may have their values recordedprotocol
- the protocol string for source URIs using this source type. For example, 'network_table://"sourceSupplier
- a function to use to create data sources of this type for a given name (not URI)public abstract DataType<?> dataTypeForSource(DataTypes registry, java.lang.String sourceUri)
Unknown
type. If no source is known by the given URI,
returns an None
type.registry
- the registry of the currently known data typessourceUri
- the URI of the source to look up the data type forpublic final java.lang.String getName()
public final boolean isRecordable()
public java.lang.String getProtocol()
public java.lang.String toUri(java.lang.String sourceName)
public java.lang.String removeProtocol(java.lang.String text)
text
- the text to remove the protocol string frompublic DataSource<?> forUri(java.lang.String uri)
The interpretation of paths may vary depending on any given SourceType.
public javafx.collections.ObservableList<java.lang.String> getAvailableSourceUris()
public javafx.collections.ObservableMap<java.lang.String,java.lang.Object> getAvailableSources()
public void read(TimestampedData recordedData)
protected final void setConnectionStatus(ConnectionStatus connectionStatus)
connectionStatus
- the new connection status. This cannot be null
.java.lang.NullPointerException
- if connectionStatus
is null
public final javafx.beans.property.ReadOnlyProperty<ConnectionStatus> connectionStatusProperty()
public final ConnectionStatus getConnectionStatus()
public void connect()
public void disconnect()
public SourceEntry createRootSourceEntry()
public SourceEntry createSourceEntryForUri(java.lang.String uri)
uri
- the source URI to create a source entry forjava.lang.UnsupportedOperationException
- if this method has not been overridden by a subclass.