| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
package com.android.internal.alsa; |
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
public class LineTokenizer { |
| 24 |
public static final int kTokenNotFound = -1; |
| 25 |
|
| 26 |
private final String mDelimiters; |
| 27 |
|
| 28 |
public LineTokenizer(String delimiters) { |
| 29 |
mDelimiters = delimiters; |
| 30 |
} |
| 31 |
|
| 32 |
int nextToken(String line, int startIndex) { |
| 33 |
int len = line.length(); |
| 34 |
int offset = startIndex; |
| 35 |
for (; offset < len; offset++) { |
| 36 |
if (mDelimiters.indexOf(line.charAt(offset)) == -1) { |
| 37 |
|
| 38 |
break; |
| 39 |
} |
| 40 |
} |
| 41 |
|
| 42 |
return offset < len ? offset : kTokenNotFound; |
| 43 |
} |
| 44 |
|
| 45 |
int nextDelimiter(String line, int startIndex) { |
| 46 |
int len = line.length(); |
| 47 |
int offset = startIndex; |
| 48 |
for (; offset < len; offset++) { |
| 49 |
if (mDelimiters.indexOf(line.charAt(offset)) != -1) { |
| 50 |
|
| 51 |
break; |
| 52 |
} |
| 53 |
} |
| 54 |
|
| 55 |
return offset < len ? offset : kTokenNotFound; |
| 56 |
} |
| 57 |
} |