From f0cfe3438aea77b5193d94fb9fa0c8d37972b194 Mon Sep 17 00:00:00 2001 From: Jeff Hamilton Date: Mon, 9 Aug 2010 16:54:05 -0500 Subject: [PATCH] Add a few helpful APIs. Change-Id: Ie57aa71eb77a1e0fb058f4eb6f40d4144a6dfce7 --- api/current.xml | 41 ++++++++++++++----- core/java/android/database/DatabaseUtils.java | 14 +++++++ core/java/android/net/Uri.java | 20 ++++++++- 3 files changed, 63 insertions(+), 12 deletions(-) diff --git a/api/current.xml b/api/current.xml index a944213cc79d4..3d8375ff30e95 100644 --- a/api/current.xml +++ b/api/current.xml @@ -61923,6 +61923,21 @@ + + + + + + + + + + + + - - { throw new UnsupportedOperationException(NOT_HIERARCHICAL); } if (key == null) { - throw new NullPointerException("key"); + throw new NullPointerException("key"); } final String query = getEncodedQuery(); @@ -1608,6 +1608,24 @@ public abstract class Uri implements Parcelable, Comparable { return null; } + /** + * Searches the query string for the first value with the given key and interprets it + * as a boolean value. "false" and "0" are interpreted as false, everything + * else is interpreted as true. + * + * @param key which will be decoded + * @param defaultValue the default value to return if there is no query parameter for key + * @return the boolean interpretation of the query parameter key + */ + public boolean getBooleanQueryParameter(String key, boolean defaultValue) { + String flag = getQueryParameter(key); + if (flag == null) { + return defaultValue; + } + flag = flag.toLowerCase(); + return (!"false".equals(flag) && !"0".equals(flag)); + } + /** Identifies a null parcelled Uri. */ private static final int NULL_TYPE_ID = 0;