Modifier and Type | Class and Description |
---|---|
static interface |
Connection.ConnectionListener |
static class |
Connection.ConnectionStatus |
Modifier and Type | Field and Description |
---|---|
protected boolean |
connected |
Constructor and Description |
---|
Connection() |
Modifier and Type | Method and Description |
---|---|
void |
addListener(Connection.ConnectionListener listener)
Adds a connection listener to this connection.
|
abstract void |
connect()
Connects to storage.
|
abstract void |
disconnect()
Disconnects from storage.
|
protected void |
fireChanged(Connection.ConnectionStatus status)
Notifies all registered listeners of this ConnectionStatus event.
|
String |
getUrl() |
boolean |
isConnected()
May be used to determine the state of a connection if no connect or
disconnect attempt is currently in progress.
|
void |
removeListener(Connection.ConnectionListener listener)
Removes a formerly registered listener.
|
void |
setUrl(String url)
Sets the connection URL to which to connect to.
|
String |
toString() |
public void setUrl(String url)
url
- The connection URL.public String getUrl()
public abstract void connect()
ConnectionStatus.CONNECTED
: Once the connection has been made
successfully.ConnectionStatus.FAILED_TO_CONNECT
: If the connection could
not be established for some reason.public abstract void disconnect()
ConnectionStatus.DISCONNECTED
: Once disconnect has finished.public boolean isConnected()
public void addListener(Connection.ConnectionListener listener)
listener
- The listener which will be notified of connection events.public void removeListener(Connection.ConnectionListener listener)
listener
- The listener which should get removed.protected void fireChanged(Connection.ConnectionStatus status)
status
- The status which is passed on to listeners.Copyright © 2018. All rights reserved.