Capabilities/Virtual capabilities are generally declared as Map[String, String] but typically this is actually more similar to Map[String, Any] or a heterogeneous map. Is there anything available in the API (either Scala or Java APIs) to provide some type mapping between the capability and it's type, perhaps a matcher of type String -> Any where the returned is the concrete type of the capability (be it bool, Enumeration, String, Double...)?
This is needed for example when generating JSON out of this map as without this type info all values would be strings.
Regards
William Hill
Capabilities type metadata
Re: Capabilities type metadata
Hello,
The Java API does provide certain methods in order to retrieve the capability in its proper type that can be retrieved from a Device object. For example, the `device.getCapabilityAsBool()` method will return the capability as a boolean value and the `device.getCapabilityAsInt()` method will return an integer. We will be adding these methods to the Scala API in our next release in order to retrieve the capability in its proper type.
Thank you,
Elliot
The Java API does provide certain methods in order to retrieve the capability in its proper type that can be retrieved from a Device object. For example, the `device.getCapabilityAsBool()` method will return the capability as a boolean value and the `device.getCapabilityAsInt()` method will return an integer. We will be adding these methods to the Scala API in our next release in order to retrieve the capability in its proper type.
Thank you,
Elliot
Re: Capabilities type metadata
Hi Elliot,
Of course, you're referring to the Device interface, however converting is the easy part. What I'm after is a facade which returns the capability type given it's name, otherwise I'd have to make and maintain a map of this metadata and this might get out of date if new capabilities get added.
Currently I'm playing with a pattern matching approach like this:
Additionally being able to deal with the entire set would be desirable as well.
Of course, you're referring to the Device interface, however converting is the easy part. What I'm after is a facade which returns the capability type given it's name, otherwise I'd have to make and maintain a map of this metadata and this might get out of date if new capabilities get added.
Currently I'm playing with a pattern matching approach like this:
Code: Select all
def reshape(capabilityName: String, capabilityValue: String): Option[Any] = capabilityName match {
case "ajax_preferred_geoloc_api"
| "xhtmlmp_preferred_mime_type" => return Some(capabilityValue)
| ...
case "unique"
| "is_sencha_touch_ok" => return Some(Try(capabilityValue.toBoolean).getOrElse(false))
| ...
case "nokia_edition"
| "voices" => return Some(Try(capabilityValue.toInt).getOrElse(null))
| ...
case _ => return Some(capabilityValue)
Elliotfehr wrote:Hello,
The Java API does provide certain methods in order to retrieve the capability in its proper type that can be retrieved from a Device object. For example, the `device.getCapabilityAsBool()` method will return the capability as a boolean value and the `device.getCapabilityAsInt()` method will return an integer. We will be adding these methods to the Scala API in our next release in order to retrieve the capability in its proper type.
Thank you,
Elliot
Re: Capabilities type metadata
Hello,
This capability currently does not exist in the WURFL API, however I will certainly let you know if this is going to change. We do provide and JSON endpoing that provides a full list of WURFL capabilities along with their desired type along with all possible capability values that can be returned, which is available at: http://scientiamobile.com/download/capabilities.json.
Thank you,
Elliot
This capability currently does not exist in the WURFL API, however I will certainly let you know if this is going to change. We do provide and JSON endpoing that provides a full list of WURFL capabilities along with their desired type along with all possible capability values that can be returned, which is available at: http://scientiamobile.com/download/capabilities.json.
Thank you,
Elliot
Re: Capabilities type metadata
Thanks Elliot,
We'll use this for now and refactor later on if such a feature is added. Nice thing with the JSON documenting the API, I've actually created a scraper over you documentation page to extract this data but is much cleaner, thanks!
We'll use this for now and refactor later on if such a feature is added. Nice thing with the JSON documenting the API, I've actually created a scraper over you documentation page to extract this data but is much cleaner, thanks!
Elliotfehr wrote:Hello,
This capability currently does not exist in the WURFL API, however I will certainly let you know if this is going to change. We do provide and JSON endpoing that provides a full list of WURFL capabilities along with their desired type along with all possible capability values that can be returned, which is available at: http://scientiamobile.com/download/capabilities.json.
Thank you,
Elliot
Re: Capabilities type metadata
Do you have an equivalent json file for the virtual capabilities?
Elliotfehr wrote:Hello,
This capability currently does not exist in the WURFL API, however I will certainly let you know if this is going to change. We do provide and JSON endpoing that provides a full list of WURFL capabilities along with their desired type along with all possible capability values that can be returned, which is available at: http://scientiamobile.com/download/capabilities.json.
Thank you,
Elliot
Re: Capabilities type metadata
This JSON file is meant to provide the return values for all capabilities that are contained in the WURFL.xml. Since virtual capabilities are computed their return values can vary much more whereas the physical capabilities can be determined by parsing the WURFL.xml file.
However, you do bring up a valid point and I will look into adding our virtual capabilities to this list in for the purpose of determining the return type, however I am unable to provide any promises at this moment.
Thank you,
Elliot
However, you do bring up a valid point and I will look into adding our virtual capabilities to this list in for the purpose of determining the return type, however I am unable to provide any promises at this moment.
Thank you,
Elliot
Re: Capabilities type metadata
Thanks Elliot!
Elliotfehr wrote:This JSON file is meant to provide the return values for all capabilities that are contained in the WURFL.xml. Since virtual capabilities are computed their return values can vary much more whereas the physical capabilities can be determined by parsing the WURFL.xml file.
However, you do bring up a valid point and I will look into adding our virtual capabilities to this list in for the purpose of determining the return type, however I am unable to provide any promises at this moment.
Thank you,
Elliot
Who is online
Users browsing this forum: No registered users and 3 guests