W3C home > Mailing lists > Public > public-ddwg@w3.org > October 2007

[API] First draft of the Java API bindings

From: Josť Manuel Cantera Fonseca <jmcf@tid.es>
Date: Wed, 10 Oct 2007 19:20:24 +0200
To: public-ddwg@w3.org
Message-id: <470D09D8.2060306@tid.es>

Dear All,

I have created a first draft of the Java API bindings [1], even I'm 
proud to announce that I have a first version of the implementation of 
those APIs using WURFL :). I have done it as a proof of concept of the 
quality of the design.

I have designed all the functions that are in the current editor's draft 
and others that might be in subsequent drafts. Also a simple 
bootstrapping mechanism is provided.

I think this APIs should provide a good starting point for those who are 
not comfortable with IDL. Also, I'm gonna send a UML diagram 
illustrating the design of the API. I will also commit in the group's 
CVS the Java files.

The main entry points to the API are the interfaces:

+ DDRAdmin
+ DDRMetadata
+ DDRIdentification

[1] http://www.w3.org/2005/MWI/DDWG/drafts/api/DDRAPI-JavaBinding/

Using the APIs the code to call a DDR could as simple as:

        DDRServiceRegistry registry =  DDRServiceRegistryImpl.newInstance();
        DDRService service = registry.newDefaultDDRService();
        service.setProperty("WURFL_FILE", "resource/wurfl.xml");

        DDRIdentification recognition = service.getDDRIdentification();
        Map headers = new java.util.HashMap();
        headers.put("User-Agent", "MOT-T720/G_05.01.43R");
        ContextKey key = recognition.identifyByHttpHeaders(headers);

        DDRProperty prop = new DDRPropertyHelper("resolution_width");
        DCComponent device = new DeviceComponentHelper();       
        DDRPropertyValue value = service.getDDR().getPropertyValue(key, 
        System.out.println("Retrieved value:" + value.getValue());
        DDRPropertyValueList list = 
service.getDDR().getAllPropertyValues(key, device);                    
        for(int j = 0; j < list.getSize(); j++) {
            System.out.println("Capability: " + 
list.item(j).getProperty().getId() + " values " +
Received on Wednesday, 10 October 2007 17:24:52 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 6 January 2015 20:00:15 UTC