I have been tasked with designing my web services client code to use the utility class UriMatcher in the Android SDK. Unfortunately, the example in the Dev Guide does not relate to anything in my mind. I know I am missing some fundamental points to the functionality and possibly about Uri itself. If you can tie it to some web APIs that are accessible with HTTP POST request, that would be ideal.
A:
I have been tasked with designing my web services client code to use the utility class UriMatcher in the Android SDK.
UriMatcher
and a Web services client are as related as a snowplow and a cheese grater. UriMatcher
is used in implementing a ContentProvider
, and little else.
CommonsWare
2010-03-12 01:31:39
Can you expand on the snowplow? I think I get the UriMatcher as a way to match a content-uri to an integer for a switch statement. Then the switch statement can implement the specific data-content-value fetch. For example a vnd-cursor if in the Android's SQLite3 db or an http: //webservice....q?.../alt=json.Is that correct? Please set me straight.
mobibob
2010-03-12 17:21:56
"I think I get the UriMatcher as a way to match a content-uri to an integer for a switch statement." Mapping `Uri` values to integers is what `UriMatcher` does. Whether you use it in a `switch()` statement is up to you. "Then the switch statement can implement the specific data-content-value fetch." Even better: get rid of the `Uri` objects and just use the integers in the first place.
CommonsWare
2010-03-12 18:22:03
A:
UriMatcher is a convenience class that allows a many-to-one mapping by using pattern matching. It simplifies the design communication in a list-style representation. The numeric assignment allows one to insert, remove and rearrange patterns without effecting the match. This is especially useful when the match is used in a switch statement as the 'case' value -- the handling logic does not have to change.
mobibob
2010-03-19 03:03:38