Code example for UriMatcher

Methods: match

0
    private T get(Uri uri, T defaultValue, boolean shouldThrow) {
        // replace # and * with an id so the match passes 
        uri = Uri.parse(uri.toString().replace("#", "99"));
        uri = Uri.parse(uri.toString().replace("*", "99"));
 
        final int match = matcher.match(uri);
        if (match == UriMatcher.NO_MATCH) {
            if (!shouldThrow)
                return defaultValue;
            else 
                throw new NoMatchException("no match found for uri: " + uri);
        } 
        if (transformer != null) {
            return transformer.onResponse(uri, uriToUrl.get(match));
        } 
        return uriToUrl.get(match);
    } 
 
    public static class NoMatchException extends RuntimeException {
        public NoMatchException(String string) {
            super(string);