T
- The type of the underlying connection widget.public abstract class VizConnection<T> extends java.lang.Object implements IVizConnection<T>
IVizConnection
interface, classes should inherit from this class.
This class provides additional functionality intended for management of viz
connections. Instances of this class should not be passed around outside a
VizConnectionManager
unless you intend to expose the connect and
disconnect operations as well as connection properties.
Constructor and Description |
---|
VizConnection()
The default constructor.
|
Modifier and Type | Method and Description |
---|---|
boolean |
addListener(IVizConnectionListener<T> listener)
Adds a listener for state changes to this connection.
|
java.util.concurrent.Future<ConnectionState> |
connect()
Attempts to establish the connection on a separate worker thread.
|
java.util.concurrent.Future<ConnectionState> |
disconnect()
Attempts to disconnect from the connection widget on a separate worker
thread.
|
java.lang.String |
getDescription()
Gets a description of the connection.
|
java.lang.String |
getHost()
Gets the current host associated with the connection.
|
java.lang.String |
getName()
Gets the name of the connection.
|
java.lang.String |
getPath()
Gets the installation path to the executable required to run the
associated connection widget.
|
int |
getPort()
Gets the port associated with the connection.
|
java.util.Map<java.lang.String,java.lang.String> |
getProperties()
Gets the current properties for this connection.
|
java.lang.String |
getProperty(java.lang.String value)
Gets the value of the property with the specified name.
|
ConnectionState |
getState()
Gets the current state of the connection.
|
java.lang.String |
getStatusMessage()
Gets a descriptive message for the current state of the connection.
|
T |
getWidget()
Gets the underlying connection widget managed by this viz connection
instance.
|
boolean |
removeListener(IVizConnectionListener<T> listener)
Removes a listener from state change notifications.
|
boolean |
setDescription(java.lang.String description)
Sets the description of the connection.
|
boolean |
setHost(java.lang.String host)
Sets the host for the connection.
|
boolean |
setName(java.lang.String name)
Sets the name of the connection.
|
boolean |
setPath(java.lang.String path)
Sets the path of the connection.
|
boolean |
setPort(int port)
Sets the port of the connection.
|
boolean |
setProperty(java.lang.String name,
java.lang.String value)
Sets the specified property to the new value, provided the value is both
allowed and new.
|
public VizConnection()
public boolean addListener(IVizConnectionListener<T> listener)
IVizConnection
addListener
in interface IVizConnection<T>
listener
- The listener to add. If null
, no listener will be
added.public java.util.concurrent.Future<ConnectionState> connect()
get()
method.public java.util.concurrent.Future<ConnectionState> disconnect()
get()
method.public java.lang.String getDescription()
IVizConnection
getDescription
in interface IVizConnection<T>
null
, but
may be an empty string.public java.lang.String getHost()
IVizConnection
getHost
in interface IVizConnection<T>
null
.public java.lang.String getName()
IVizConnection
VizConnectionManager
.getName
in interface IVizConnection<T>
public java.lang.String getPath()
IVizConnection
getPath
in interface IVizConnection<T>
public int getPort()
IVizConnection
getPort
in interface IVizConnection<T>
public java.util.Map<java.lang.String,java.lang.String> getProperties()
IVizConnection
null
and should always contain the name, description, host, port,
and path, as well as any other properties required by the implementing
class.getProperties
in interface IVizConnection<T>
public java.lang.String getProperty(java.lang.String value)
IVizConnection
getProperty
in interface IVizConnection<T>
value
- The name of the property to get.null
if it has not been set.public ConnectionState getState()
IVizConnection
This may change at any moment. If code needs to listen for the current
state, then a listener should be registered via
IVizConnection.addListener(IVizConnectionListener)
.
getState
in interface IVizConnection<T>
public java.lang.String getStatusMessage()
IVizConnection
This may change at any moment. If code needs to listen for the current
state, then a listener should be registered via
IVizConnection.addListener(IVizConnectionListener)
.
getStatusMessage
in interface IVizConnection<T>
public T getWidget()
IVizConnection
getWidget
in interface IVizConnection<T>
null
if the
connection is currently disconnected or failed.public boolean removeListener(IVizConnectionListener<T> listener)
IVizConnection
removeListener
in interface IVizConnection<T>
listener
- The listener to remove.public boolean setDescription(java.lang.String description)
setProperty(String, String)
.description
- The new description of the property.public boolean setHost(java.lang.String host)
setProperty(String, String)
.host
- The host name of the property.public boolean setName(java.lang.String name)
setProperty(String, String)
.name
- The new name of the property.public boolean setPath(java.lang.String path)
setProperty(String, String)
.path
- The new path of the property.public boolean setPort(int port)
setProperty(String, String)
.port
- The new port of the property.public boolean setProperty(java.lang.String name, java.lang.String value)
name
- The name of the property to update.value
- The new value of the property. If null
, the property
will be removed.