T
- the type of data providedpublic interface DataSource<T>
Data sources have several major properties:
The active property describes whether or not the source is connected to the backing data source and can update at any time. An active source is always connected.
The name property is a unique identifier for the data backing the source. The name of the source also
describes a path to the data and may be thought of like a filesystem structure. Forward slashes ("/"
)
delimit the separate components. If there are multiple components, each one is expected to be its own valid source
for that type of data. For example, a theoretical "file system" data source with the name /home/usr/foo.txt
would have a "File Source" for the text file, along with a "Directory Source" for each of /home/
and
/home/usr
.
The ID of a data source is simply its name encoded in a URI-like string, prefixed by a unique identifier
string for its type. "${protocol}://${name}"
, eg "file:///home/usr/foo.txt
or
network_table:///SmartDashboard/
.
The data type of a source contains the expected type of the data. The actual data may not be of this type; in this case, the source is marked as inactive (but still connected) until the actual data has this type.
The data property contains the current data for the source. This may also be set by user-controllable widgets to manipulate the data.
The type of a data source defines how the source behaves and where its data comes from. More information
can be found here
.
Connectedness simply marks whether or not the source is connected to the actual data source. For example, sources whose data resides on a remote resource like a server are not connected if there is no network connection to that remote resource.
Type | Property and Description |
---|---|
javafx.beans.property.BooleanProperty |
active
Checks if this data source is active, i.e.
|
javafx.beans.property.BooleanProperty |
connected |
javafx.beans.property.Property<T> |
data |
javafx.beans.property.StringProperty |
name |
Modifier and Type | Method and Description |
---|---|
javafx.beans.property.BooleanProperty |
activeProperty()
Checks if this data source is active, i.e.
|
void |
addClient(Sourced client)
Adds a client to this source.
|
default void |
close()
Closes this data source and frees any used resources.
|
void |
connect()
Connects this source to the underlying data stream.
|
javafx.beans.property.BooleanProperty |
connectedProperty() |
javafx.beans.property.Property<T> |
dataProperty() |
void |
disconnect()
Disconnects this source from the underlying data stream.
|
default T |
getData()
Gets the current value of this data source.
|
DataType<T> |
getDataType()
Gets the type of data that this source is providing.
|
default java.lang.String |
getId() |
default java.lang.String |
getName()
Gets the name of this data source.
|
SourceType |
getType()
Gets the type of this source.
|
boolean |
hasClients()
Checks if any clients are connected to this source.
|
default boolean |
isActive()
Gets the value of the property active.
|
boolean |
isConnected()
Checks if this source is currently connected to its underlying data stream.
|
javafx.beans.property.StringProperty |
nameProperty() |
static <T> DataSource<T> |
none()
Creates a data source with no name, no data, and is never active.
|
void |
removeClient(Sourced client)
Removes a client from this source.
|
default void |
setData(T newValue)
Sets the value of the property data.
|
javafx.beans.property.BooleanProperty activeProperty
isActive()
javafx.beans.property.StringProperty nameProperty
getName()
javafx.beans.property.Property<T> dataProperty
getData()
,
setData(T)
javafx.beans.property.BooleanProperty connectedProperty
isConnected()
static <T> DataSource<T> none()
null
.T
- the type of the data in the sourcejavafx.beans.property.BooleanProperty activeProperty()
isActive()
default boolean isActive()
javafx.beans.property.StringProperty nameProperty()
getName()
default java.lang.String getName()
javafx.beans.property.Property<T> dataProperty()
getData()
,
setData(T)
default T getData()
null
if this source isn't active, but may also just return the most recent value.default void setData(T newValue)
default void close()
SourceType getType()
default java.lang.String getId()
void connect()
void disconnect()
connect()
.javafx.beans.property.BooleanProperty connectedProperty()
isConnected()
boolean isConnected()
boolean hasClients()
void addClient(Sourced client)
client
- the client to add