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 Client.java 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 PedroEvent.java and PedroListener.java provide support for data events from the Pedro server. Clients can add listeners to data events using the addPedroListener method. The file PedroGUI.java is similar to pedro_gui.py and contains an example of using this method.