I would like to announce that Networking ME v1.1 has been released. Networking ME is a feature-rich networking library for Java ME platform. This new version comes with interesting and useful features that will make developers' life easier.
I will split this introduction into two posts: This first one, I will talk about the new content listeners. Second one, I will introduce some new components specifically designed for LWUIT.
Networking ME comes with new content listener for parsing contents, i.e, CSV, XML and JSON. See below some code snippets:
... URL url = new URL("http://www.emobtech.com/csv/file.csv"); HttpRequest req = new HttpRequest(url); // RequestOperation oper = new RequestOperation(req); oper.start(new CSVListener() { public void onCSV(String[][] csv) { String name = csv[0][1]; String email = csv[0][2]; } ... }); ...
CSVListener class delivers a CSV content parsed to a String matrix, where it is possible to navigate through the lines and columns.
... URL url = new URL("http://www.emobtech.com/xml/file.xml"); HttpRequest req = new HttpRequest(url); // RequestOperation oper = new RequestOperation(req); oper.start(new SAXListener(new UserHandler()) { public void onSAX(DefaultHandler handler) { User[] users = ((UserHandler)handler).getParsedUsers(); } ... }); ...
SAXListener class uses the Simple API for XML (SAX) implementation, from JSR 172, to deliver a XML content parsed to a handler object, which holds the content.
... URL url = new URL("http://www.emobtech.com/json/file.json"); HttpRequest req = new HttpRequest(url); // RequestOperation oper = new RequestOperation(req); oper.start(new JSONListener() { public void onJSON(JSONObject jsonObject) { String value = jsonObject.get("key"); } ... }); ...
JSONListener class uses the JSON.org Parser implementation, to deliver a JSON content parsed to a JSONObject object, where it is possible to access all keys, values, arrays, etc. In case you need, in the release package, you can find the JSON.org jar file in the lib folder.
Networking ME also provides other content listeners from previous versions, i.e, TextListener, BinaryListener and ImageListener (for LCDUI).
That's it! I invite everybody to visit the project's website, check out more code snippets about the other features and - why not? - to download the release v1.1.0. By the way, it is always good to mention, Networking ME is under MIT.
See you in the next post...
No comments:
Post a Comment