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

RE: [API] First draft of the Java API bindings

From: Rotan Hanrahan <rotan.hanrahan@mobileaware.com>
Date: Wed, 10 Oct 2007 20:25:10 +0100
Message-ID: <D5306DC72D165F488F56A9E43F2045D39C6B16@FTO.mobileaware.com>
To: Josť Manuel Cantera Fonseca <jmcf@tid.es>, <public-ddwg@w3.org>

Excellent start to this work. Thanks Jose.
 
Obviously we will have plenty to consider as we move this towards an agreed structure for the API. For example, the DDRPropertyValue may need some mechanism for determining the data type, and any data type should be considered with regard to the UWA ontology types.
 
In the example given below, the displayed value is obtained via an implied toString(). We cannot assume that strings will suffice as representations of values in a language binding. Some values will have structures, such as the value that might represent the set of supported image formats. Thus we may need to have some inspection mechanism explicit in the API. We cannot rely on an "instanceof" mechanism inherent in the target language. (Or can we? Would IDL experts care to comment?)
 
At least now we have some source code to focus our thinking. Let's keep the momentum going.
 
---Rotan.

________________________________

From: public-ddwg-request@w3.org on behalf of Josť Manuel Cantera Fonseca
Sent: Wed 10/10/2007 18:20
To: public-ddwg@w3.org
Subject: [API] First draft of the Java API bindings




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
+ DDR
+ 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");
        service.initialize();

        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,
prop,
                device);
        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 " +
                    list.item(j).getValue());
        }
Received on Wednesday, 10 October 2007 19:25:32 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Sunday, 6 December 2009 12:13:51 GMT