Implementing the network operations and data model

The MIDlet communicates with the WordPress servers by sending and receiving XML messages with HTTP POST. For more information about the XML-RPC API, see XML-RPC wp in the WordPress Codex.

The network operations are encapsulated in their own classes, such as NewPostOperation and DeleteCommentOperation. When the MIDlet invokes the start method of an operation (starts a new thread), an HttpConnection is created, and an HTTP POST is sent using a formatted XML request. After receiving a response, the MIDlet parses it using the SAX parser from org.xml.sax. When all pertinent data has been parsed, the MIDlet calls a listener method, which updates the user interface on the screen.

The following figure shows the classes related to the GetRecentPostsOperation. The other network operations follow a similar structure.

Figure: Network operation classes

The actual blog, post, and comment data that are handled in the network operations are represented using classes, and stored in Vectors in the DataModel class. The following figure shows the class diagram related to the application data model.

Figure: Data model classes