Previous: Python API, Up: APIs

12.3 Java API

The directory src/java_api contains a definition for a Pedro client class and support for Prolog terms (including a Prolog parser).

The file contains a very simple program that connects to the Pedro server, makes a subscription based on the runtime arguments, and enters a loop that parses the received notification into Prolog terms then pretty prints them.

The Pedro client object creation and methods are the same as in the Python case from the previous section except there is no get_term method. This is replaced by the use of a parser that converts strings (from a call to get_notification()) to a Prolog term.

The files and provide support for data events from the Pedro server. Clients can add listeners to data events using the addPedroListener method. The file is similar to and contains an example of using this method.