|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.phidgets.Dictionary
This class represents the Phidget Dictionary.
The Phidget Dictionary is a service provided by the Phidget Webservice. The Webservice maintains a centralized dictionary of key-value pairs that can be accessed and changed from any number of clients.
Note that the Webservice uses this dictionary to control access to Phidgets through the openRemote and openRemoteIP interfaces, and as such, you should never add or modify a key that starts with /PSK/ or /PCK/, unless you want to explicitly modify Phidget specific data -- and this is highly discouraged, as it's very easy to break things. Listening to these keys is fine if so desired.
The intended use for the dictionary is as a central repository for communication and persistent storage of data between several client applications. As an example - a higher level interface exposed by one application -- which controls the Phidgets, for others to access -- rather then every client talking directly to the Phidgets themselves.
The dictionary makes use of extended regular expressions for key matching.
Field Summary | |
long |
handle
|
Constructor Summary | |
Dictionary()
The default constructor. |
Method Summary | |
void |
add(java.lang.String key,
java.lang.String val)
Adds a new key to the Dictionary, or modifies the value of an existing key. |
void |
add(java.lang.String key,
java.lang.String val,
boolean persistent)
Adds a new key to the Dictionary, or modifies the value of an existing key. |
void |
addServerConnectListener(ServerConnectListener l)
Adds an serverConnect listener. |
void |
addServerDisconnectListener(ServerDisconnectListener l)
Adds an serverDisconnect listener. |
void |
close()
Closes this Dictionary. |
java.lang.String |
get(java.lang.String key)
Gets the value for a key. |
java.lang.String |
getServerAddress()
Returns the Address of a Phidget Webservice when this Dictionary was opened as remote. |
java.lang.String |
getServerID()
Returns the Server ID of a Phidget Webservice when this Dictionary was opened as remote. |
int |
getServerPort()
Returns the Port of a Phidget Webservice when this Dictionary was opened as remote. |
boolean |
isAttached()
Returns the attached status of this Dictionary. |
boolean |
isAttachedToServer()
Returns the network attached status for remotely opened Phidgets. |
void |
open(java.lang.String serverID)
Open this Dictionary remotely using a Server ID. |
void |
open(java.lang.String ipAddress,
int port)
Open this Dictionary remotely using an IP Address. |
void |
open(java.lang.String ipAddress,
int port,
java.lang.String password)
Open this Dictionary remotely and securely, using an IP Address. |
void |
open(java.lang.String serverID,
java.lang.String password)
Open this Dictionary remotely and securely, using a Server ID. |
void |
remove(java.lang.String pattern)
Removes a key, or set of keys, from the Dictionary. |
void |
removeServerConnectListener(ServerConnectListener l)
Removes an serverConnect listener. |
void |
removeServerDisconnectListener(ServerDisconnectListener l)
Removes an serverDisconnect listener. |
java.lang.String |
toString()
Return a Sring describing this dictionary. |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
public long handle
Constructor Detail |
public Dictionary() throws PhidgetException
open
still needs to be called
to actually work with it.
Method Detail |
public final java.lang.String getServerAddress() throws PhidgetException
PhidgetException
- if this Dictionary was not opened.public final java.lang.String getServerID() throws PhidgetException
PhidgetException
- if this Dictionary was not opened.public final int getServerPort() throws PhidgetException
PhidgetException
- if this Dictionary was not opened.public final boolean isAttached() throws PhidgetException
PhidgetException
- If this Dictionary is not opened.public final boolean isAttachedToServer() throws PhidgetException
PhidgetException
- If this Phidget is not opened.public final void add(java.lang.String key, java.lang.String val) throws PhidgetException
The key can only contain numbers, letters, "/", ".", "-", "_", and must begin with a letter, "_" or "/".
The value can contain any value.
The key will stay in the dictionary until explicitly removed.
PhidgetException
public final void add(java.lang.String key, java.lang.String val, boolean persistent) throws PhidgetException
The key can only contain numbers, letters, "/", ".", "-", "_", and must begin with a letter, "_" or "/".
The value can contain any value.
The persistent value controls whether a key will stay in the dictionary after the client that created it disconnects. If persistent == 0, the key is removed when the connection closes. Otherwise the key remains in the dictionary until it is explicitly removed.
PhidgetException
public final void remove(java.lang.String pattern) throws PhidgetException
The key name is a regular expressions pattern, and so care must be taken to only have it match the specific keys you want to remove.
PhidgetException
public final java.lang.String get(java.lang.String key) throws PhidgetException
PhidgetException
public final void open(java.lang.String ipAddress, int port, java.lang.String password) throws PhidgetException
This method is the same as open(String ipAddress, int port)
, except that it specifies a password.
This password can be set as a parameter when starting the Phidget Webservice.
PhidgetException
public final void open(java.lang.String ipAddress, int port) throws PhidgetException
This version of open is network based, and relies on the Phidget Webservice running at the specified Address and Port before open is called.
ipAddress
- IP Address or hostname of the Phidget Webserviceport
- Port of the Phidget Webservice
PhidgetException
- if the Phidget Webservice cannot be contactedpublic final void open(java.lang.String serverID, java.lang.String password) throws PhidgetException
This method is the same as open(String serverID)
, except that it specifies a password.
This password can be set as a parameter when starting the Phidget Webservice.
PhidgetException
public final void open(java.lang.String serverID) throws PhidgetException
This version of open is network based.
serverID
- ServerID of the Phidget Webservice
PhidgetException
public final void close() throws PhidgetException
PhidgetException
- If this Dictionary is not opened.public final void addServerConnectListener(ServerConnectListener l)
There is no limit on the number of serverConnect handlers that can be registered for a particular Manager.
l
- An implemetation of the ServerConnectListener
interfacepublic final void removeServerConnectListener(ServerConnectListener l)
public final void addServerDisconnectListener(ServerDisconnectListener l)
There is no limit on the number of serverDisconnect handlers that can be registered for a particular Manager.
l
- An implemetation of the ServerDisconnectListener
interfacepublic final void removeServerDisconnectListener(ServerDisconnectListener l)
public java.lang.String toString()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |