Hi all,<br>I m writing a Java class which needs to execute the "GetAllProperties" method from the org.freedesktop.Hal.Device interface with the following signature:<br> <interface name="org.freedesktop.Hal.Device"><br>
<method name="GetAllProperties"><br> <arg name="properties" direction="out" type="a{sv}"/><br> </method><br>...<br></interface><br><br>What is the correct prototype I have to use when I declare it in a DBusInterface ? <br>
This is my attempt, Is it correct ?: <br>package org.freedesktop.Hal;<br><br>import java.util.Map;<br>import org.freedesktop.dbus.DBusInterface;<br>import org.freedesktop.dbus.Variant;<br><br>public interface Device extends DBusInterface {<br>
public Map<String,Variant<Object>> GetAllProperties();<br>...<br>}<br><br><br>I invoke this method with :<br>Device d = (Device) conn.getRemoteObject("org.freedesktop.Hal","/org/freedesktop/Hal/devices/computer",Device.class);<br>
d.GetAllProperties();<br><br>I managed to get the key (String) and the value (Variant<Object>) with:<br> Variant<Map<String,Variant<Object>>> v = new Variant<Map<String,Variant<Object>>>(d.GetAllProperties(), new DBusMapType(String.class, Variant.class));<br>
Map<String,Variant<Object>> mp = v.getValue();<br>Iterator<String> iter = mp.keySet().iterator();<br>while(iter.hasNext()) {<br> s = iter.next();<br> System.out.println("Property: "+s + "- "+mp.get(s).toString());<br>
}<br><br>How can I cast the values (Variant<Object>) to their equivalent Java types (which are known in advance) ?<br><br>Thanks<br>Gilles<br><br>