diff options
author | Brad Fitzpatrick <bradfitz@android.com> | 2010-09-12 13:55:18 -0700 |
---|---|---|
committer | Brad Fitzpatrick <bradfitz@android.com> | 2010-09-12 13:55:18 -0700 |
commit | 42a5ed2015461126bd012d6f8f3e1311e5721807 (patch) | |
tree | 1bc74df6e6aacdde18f3377c2db44f7729b39b74 /core/java/android/text/TextUtils.java | |
parent | 806b717bf52fdc4dfd58bb0e0b7118f63f7b7cce (diff) | |
parent | 171c83f47ddf01792371e1eb7587a99b2f192575 (diff) | |
download | frameworks_base-42a5ed2015461126bd012d6f8f3e1311e5721807.zip frameworks_base-42a5ed2015461126bd012d6f8f3e1311e5721807.tar.gz frameworks_base-42a5ed2015461126bd012d6f8f3e1311e5721807.tar.bz2 |
resolved conflicts for merge of 171c83f4 to master
Change-Id: I56a4c1838b17cf40d96763f95df3c84fc86359eb
Diffstat (limited to 'core/java/android/text/TextUtils.java')
-rw-r--r-- | core/java/android/text/TextUtils.java | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/core/java/android/text/TextUtils.java b/core/java/android/text/TextUtils.java index 2d6c7b6..7748265 100644 --- a/core/java/android/text/TextUtils.java +++ b/core/java/android/text/TextUtils.java @@ -1508,6 +1508,35 @@ public class TextUtils { return mode; } + /** + * Does a comma-delimited list 'delimitedString' contain a certain item? + * (without allocating memory) + * + * @hide + */ + public static boolean delimitedStringContains( + String delimitedString, char delimiter, String item) { + if (isEmpty(delimitedString) || isEmpty(item)) { + return false; + } + int pos = -1; + int length = delimitedString.length(); + while ((pos = delimitedString.indexOf(item, pos + 1)) != -1) { + if (pos > 0 && delimitedString.charAt(pos - 1) != delimiter) { + continue; + } + int expectedDelimiterPos = pos + item.length(); + if (expectedDelimiterPos == length) { + // Match at end of string. + return true; + } + if (delimitedString.charAt(expectedDelimiterPos) == delimiter) { + return true; + } + } + return false; + } + private static Object sLock = new Object(); private static char[] sTemp = null; } |