am bcf76242
: Merge "Move FLATTENED_PATTERN to inner class."
* commit 'bcf76242134317a2f722eab5af2600fe2858f895': Move FLATTENED_PATTERN to inner class.
This commit is contained in:
@ -36,9 +36,21 @@ public final class Rect implements Parcelable {
|
|||||||
public int right;
|
public int right;
|
||||||
public int bottom;
|
public int bottom;
|
||||||
|
|
||||||
private static final Pattern FLATTENED_PATTERN = Pattern.compile(
|
/**
|
||||||
|
* A helper class for flattened rectange pattern recognition. A separate
|
||||||
|
* class to avoid an initialization dependency on a regular expression
|
||||||
|
* causing Rect to not be initializable with an ahead-of-time compilation
|
||||||
|
* scheme.
|
||||||
|
*/
|
||||||
|
private static final class UnflattenHelper {
|
||||||
|
private static final Pattern FLATTENED_PATTERN = Pattern.compile(
|
||||||
"(-?\\d+) (-?\\d+) (-?\\d+) (-?\\d+)");
|
"(-?\\d+) (-?\\d+) (-?\\d+) (-?\\d+)");
|
||||||
|
|
||||||
|
static Matcher getMatcher(String str) {
|
||||||
|
return FLATTENED_PATTERN.matcher(str);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new empty Rect. All coordinates are initialized to 0.
|
* Create a new empty Rect. All coordinates are initialized to 0.
|
||||||
*/
|
*/
|
||||||
@ -152,7 +164,7 @@ public final class Rect implements Parcelable {
|
|||||||
* or null if the string is not of that form.
|
* or null if the string is not of that form.
|
||||||
*/
|
*/
|
||||||
public static Rect unflattenFromString(String str) {
|
public static Rect unflattenFromString(String str) {
|
||||||
Matcher matcher = FLATTENED_PATTERN.matcher(str);
|
Matcher matcher = UnflattenHelper.getMatcher(str);
|
||||||
if (!matcher.matches()) {
|
if (!matcher.matches()) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user