Public Member Functions | |
final void | add (String key, String val) throws PhidgetException |
final void | add (String key, String val, boolean persistent) throws PhidgetException |
final void | addServerConnectListener (ServerConnectListener l) |
final void | addServerDisconnectListener (ServerDisconnectListener l) |
final void | close () throws PhidgetException |
Dictionary () throws PhidgetException | |
final String | get (String key) throws PhidgetException |
final native String | getServerAddress () throws PhidgetException |
final native String | getServerID () throws PhidgetException |
final native int | getServerPort () throws PhidgetException |
final native boolean | isAttached () throws PhidgetException |
final native boolean | isAttachedToServer () throws PhidgetException |
final void | open (String ipAddress, int port, String password) throws PhidgetException |
final void | open (String ipAddress, int port) throws PhidgetException |
final void | open (String serverID, String password) throws PhidgetException |
final void | open (String serverID) throws PhidgetException |
final void | remove (String pattern) throws PhidgetException |
final void | removeServerConnectListener (ServerConnectListener l) |
final void | removeServerDisconnectListener (ServerDisconnectListener l) |
String | toString () |
Public Attributes | |
long | handle = 0 |
Protected Member Functions | |
void | finalize () |
Static Package Functions | |
[static initializer] | |
Private Member Functions | |
final native long | create () throws PhidgetException |
void | enableEvents (boolean b) |
native void | enableServerConnectEvents (boolean b) |
native void | enableServerDisconnectEvents (boolean b) |
void | fireServerConnect (ServerConnectEvent e) |
void | fireServerDisconnect (ServerDisconnectEvent e) |
final native void | nativeAddKey (String key, String val, int persistent) throws PhidgetException |
final native void | nativeClose () throws PhidgetException |
final native void | nativeDelete () throws PhidgetException |
final native String | nativeGetKey (String key) throws PhidgetException |
final native void | nativeOpenRemote (String serverID, String pass) throws PhidgetException |
final native void | nativeOpenRemoteIP (String ipAddress, int port, String pass) throws PhidgetException |
final native void | nativeRemoveKey (String keyPattern) throws PhidgetException |
Private Attributes | |
long | nativeServerConnectHandler = 0 |
long | nativeServerDisconnectHandler = 0 |
LinkedList | serverConnectListeners = new LinkedList() |
LinkedList | serverDisconnectListeners = new LinkedList() |
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.
Definition at line 31 of file Dictionary.java.
com.phidgets.Dictionary.Dictionary | ( | ) | throws PhidgetException [inline] |
The default constructor. Creating a Phidget Dictionary object will initialize the dictionary handle internally, but open still needs to be called to actually work with it.
Definition at line 74 of file Dictionary.java.
com.phidgets.Dictionary.[static initializer] | ( | ) | [inline, static, package] |
final void com.phidgets.Dictionary.add | ( | String | key, |
String | val | ||
) | throws PhidgetException [inline] |
Adds a new key to the Dictionary, or modifies the value of an existing key.
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.
Definition at line 140 of file Dictionary.java.
final void com.phidgets.Dictionary.add | ( | String | key, |
String | val, | ||
boolean | persistent | ||
) | throws PhidgetException [inline] |
Adds a new key to the Dictionary, or modifies the value of an existing key.
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.
Definition at line 157 of file Dictionary.java.
final void com.phidgets.Dictionary.addServerConnectListener | ( | ServerConnectListener | l | ) | [inline] |
Adds an serverConnect listener. The serverConnect handler is a method that will be called when a connection to a server is made
There is no limit on the number of serverConnect handlers that can be registered for a particular Manager.
l | An implemetation of the ServerConnectListener interface |
Definition at line 257 of file Dictionary.java.
final void com.phidgets.Dictionary.addServerDisconnectListener | ( | ServerDisconnectListener | l | ) | [inline] |
Adds an serverDisconnect listener. The serverDisconnect handler is a method that will be called when a connection to a server is terminated.
There is no limit on the number of serverDisconnect handlers that can be registered for a particular Manager.
l | An implemetation of the ServerDisconnectListener interface |
Definition at line 299 of file Dictionary.java.
final void com.phidgets.Dictionary.close | ( | ) | throws PhidgetException [inline] |
Closes this Dictionary. This will shut down all threads dealing with this Dictionary and you won't receive any more events.
PhidgetException | If this Dictionary is not opened. |
Definition at line 235 of file Dictionary.java.
final native long com.phidgets.Dictionary.create | ( | ) | throws PhidgetException [private] |
void com.phidgets.Dictionary.enableEvents | ( | boolean | b | ) | [inline, private] |
Definition at line 241 of file Dictionary.java.
native void com.phidgets.Dictionary.enableServerConnectEvents | ( | boolean | b | ) | [private] |
native void com.phidgets.Dictionary.enableServerDisconnectEvents | ( | boolean | b | ) | [private] |
void com.phidgets.Dictionary.finalize | ( | ) | [inline, protected] |
Definition at line 338 of file Dictionary.java.
void com.phidgets.Dictionary.fireServerConnect | ( | ServerConnectEvent | e | ) | [inline, private] |
Definition at line 277 of file Dictionary.java.
void com.phidgets.Dictionary.fireServerDisconnect | ( | ServerDisconnectEvent | e | ) | [inline, private] |
Definition at line 319 of file Dictionary.java.
final String com.phidgets.Dictionary.get | ( | String | key | ) | throws PhidgetException [inline] |
Gets the value for a key.
Definition at line 175 of file Dictionary.java.
final native String com.phidgets.Dictionary.getServerAddress | ( | ) | throws PhidgetException |
Returns the Address of a Phidget Webservice when this Dictionary was opened as remote. This may be an IP Address or a hostname.
PhidgetException | if this Dictionary was not opened. |
final native String com.phidgets.Dictionary.getServerID | ( | ) | throws PhidgetException |
Returns the Server ID of a Phidget Webservice when this Dictionary was opened as remote. This is an arbitrary server identifier, independant of IP address and Port.
PhidgetException | if this Dictionary was not opened. |
final native int com.phidgets.Dictionary.getServerPort | ( | ) | throws PhidgetException |
Returns the Port of a Phidget Webservice when this Dictionary was opened as remote.
PhidgetException | if this Dictionary was not opened. |
final native boolean com.phidgets.Dictionary.isAttached | ( | ) | throws PhidgetException |
Returns the attached status of this Dictionary.
PhidgetException | If this Dictionary is not opened. |
final native boolean com.phidgets.Dictionary.isAttachedToServer | ( | ) | throws PhidgetException |
Returns the network attached status for remotely opened Phidgets. This method returns True or False, depending on whether a connection to the Phidget WebService is open - or not. If this is false for a remote Phidget then the connection is not active - either because a connection has not yet been established, or because the connection was terminated.
PhidgetException | If this Phidget is not opened. |
final native void com.phidgets.Dictionary.nativeAddKey | ( | String | key, |
String | val, | ||
int | persistent | ||
) | throws PhidgetException [private] |
final native void com.phidgets.Dictionary.nativeClose | ( | ) | throws PhidgetException [private] |
final native void com.phidgets.Dictionary.nativeDelete | ( | ) | throws PhidgetException [private] |
final native String com.phidgets.Dictionary.nativeGetKey | ( | String | key | ) | throws PhidgetException [private] |
final native void com.phidgets.Dictionary.nativeOpenRemote | ( | String | serverID, |
String | pass | ||
) | throws PhidgetException [private] |
final native void com.phidgets.Dictionary.nativeOpenRemoteIP | ( | String | ipAddress, |
int | port, | ||
String | pass | ||
) | throws PhidgetException [private] |
final native void com.phidgets.Dictionary.nativeRemoveKey | ( | String | keyPattern | ) | throws PhidgetException [private] |
final void com.phidgets.Dictionary.open | ( | String | ipAddress, |
int | port, | ||
String | password | ||
) | throws PhidgetException [inline] |
Open this Dictionary remotely and securely, using an IP Address.
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.
Definition at line 186 of file Dictionary.java.
final void com.phidgets.Dictionary.open | ( | String | ipAddress, |
int | port | ||
) | throws PhidgetException [inline] |
Open this Dictionary remotely using an IP Address.
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 Webservice |
port | Port of the Phidget Webservice |
PhidgetException | if the Phidget Webservice cannot be contacted |
Definition at line 201 of file Dictionary.java.
final void com.phidgets.Dictionary.open | ( | String | serverID, |
String | password | ||
) | throws PhidgetException [inline] |
Open this Dictionary remotely and securely, using a Server ID.
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.
Definition at line 212 of file Dictionary.java.
final void com.phidgets.Dictionary.open | ( | String | serverID | ) | throws PhidgetException [inline] |
Open this Dictionary remotely using a Server ID.
This version of open is network based.
serverID | ServerID of the Phidget Webservice |
Definition at line 224 of file Dictionary.java.
final void com.phidgets.Dictionary.remove | ( | String | pattern | ) | throws PhidgetException [inline] |
Removes a key, or set of keys, from the Dictionary.
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.
Definition at line 167 of file Dictionary.java.
final void com.phidgets.Dictionary.removeServerConnectListener | ( | ServerConnectListener | l | ) | [inline] |
Removes an serverConnect listener. This will remove a previously added serverConnect listener.
Definition at line 269 of file Dictionary.java.
final void com.phidgets.Dictionary.removeServerDisconnectListener | ( | ServerDisconnectListener | l | ) | [inline] |
Removes an serverDisconnect listener. This will remove a previously added serverDisconnect listener.
Definition at line 311 of file Dictionary.java.
String com.phidgets.Dictionary.toString | ( | ) | [inline] |
Return a Sring describing this dictionary.
Definition at line 333 of file Dictionary.java.
long com.phidgets.Dictionary.handle = 0 |
Definition at line 68 of file Dictionary.java.
long com.phidgets.Dictionary.nativeServerConnectHandler = 0 [private] |
Definition at line 248 of file Dictionary.java.
long com.phidgets.Dictionary.nativeServerDisconnectHandler = 0 [private] |
Definition at line 290 of file Dictionary.java.
LinkedList com.phidgets.Dictionary.serverConnectListeners = new LinkedList() [private] |
Definition at line 247 of file Dictionary.java.
LinkedList com.phidgets.Dictionary.serverDisconnectListeners = new LinkedList() [private] |
Definition at line 289 of file Dictionary.java.