| OLD | NEW |
| 1 library java.core; | 1 library java.core; |
| 2 | 2 |
| 3 const int LONG_MAX_VALUE = 0x7fffffffffffffff; | 3 const int LONG_MAX_VALUE = 0x7fffffffffffffff; |
| 4 | 4 |
| 5 final Stopwatch nanoTimeStopwatch = new Stopwatch(); | 5 final Stopwatch nanoTimeStopwatch = new Stopwatch(); |
| 6 | 6 |
| 7 /** | 7 /** |
| 8 * Inserts the given arguments into [pattern]. | 8 * Inserts the given arguments into [pattern]. |
| 9 * | 9 * |
| 10 * format('Hello, {0}!', 'John') = 'Hello, John!' | 10 * format('Hello, {0}!', 'John') = 'Hello, John!' |
| 11 * format('{0} are you {1}ing?', 'How', 'do') = 'How are you doing?' | 11 * format('{0} are you {1}ing?', 'How', 'do') = 'How are you doing?' |
| 12 * format('{0} are you {1}ing?', 'What', 'read') = 'What are you reading?' | 12 * format('{0} are you {1}ing?', 'What', 'read') = 'What are you reading?' |
| 13 */ | 13 */ |
| 14 String format(String pattern, | 14 String format(String pattern, |
| 15 [arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7]) { | 15 [arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7]) { |
| 16 return formatList(pattern, [arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7]); | 16 return formatList(pattern, [arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7]); |
| 17 } | 17 } |
| 18 | 18 |
| 19 /** | 19 /** |
| 20 * Inserts the given [args] into [pattern]. | 20 * Inserts the given [args] into [pattern]. |
| 21 * | 21 * |
| 22 * format('Hello, {0}!', ['John']) = 'Hello, John!' | 22 * format('Hello, {0}!', ['John']) = 'Hello, John!' |
| 23 * format('{0} are you {1}ing?', ['How', 'do']) = 'How are you doing?' | 23 * format('{0} are you {1}ing?', ['How', 'do']) = 'How are you doing?' |
| 24 * format('{0} are you {1}ing?', ['What', 'read']) = 'What are you reading?' | 24 * format('{0} are you {1}ing?', ['What', 'read']) = 'What are you reading?' |
| 25 */ | 25 */ |
| 26 String formatList(String pattern, List<Object> arguments) { | 26 String formatList(String pattern, List<Object> arguments) { |
| 27 if (arguments == null || arguments.isEmpty) { | 27 if (arguments == null || arguments.isEmpty) { |
| 28 assert(!pattern.contains(new RegExp(r'\{(\d+)\}'))); |
| 28 return pattern; | 29 return pattern; |
| 29 } | 30 } |
| 30 return pattern.replaceAllMapped(new RegExp(r'\{(\d+)\}'), (match) { | 31 return pattern.replaceAllMapped(new RegExp(r'\{(\d+)\}'), (match) { |
| 31 String indexStr = match.group(1); | 32 String indexStr = match.group(1); |
| 32 int index = int.parse(indexStr); | 33 int index = int.parse(indexStr); |
| 33 Object arg = arguments[index]; | 34 Object arg = arguments[index]; |
| 35 assert(arg != null); |
| 34 return arg != null ? arg.toString() : null; | 36 return arg != null ? arg.toString() : null; |
| 35 }); | 37 }); |
| 36 } | 38 } |
| 37 | 39 |
| 38 bool javaCollectionContainsAll(Iterable list, Iterable c) { | 40 bool javaCollectionContainsAll(Iterable list, Iterable c) { |
| 39 return c.fold(true, (bool prev, e) => prev && list.contains(e)); | 41 return c.fold(true, (bool prev, e) => prev && list.contains(e)); |
| 40 } | 42 } |
| 41 | 43 |
| 42 javaListSet(List list, int index, newValue) { | 44 javaListSet(List list, int index, newValue) { |
| 43 var oldValue = list[index]; | 45 var oldValue = list[index]; |
| (...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 429 | 431 |
| 430 class UnsupportedOperationException extends JavaException { | 432 class UnsupportedOperationException extends JavaException { |
| 431 UnsupportedOperationException([message = ""]) : super(message); | 433 UnsupportedOperationException([message = ""]) : super(message); |
| 432 } | 434 } |
| 433 | 435 |
| 434 class URISyntaxException implements Exception { | 436 class URISyntaxException implements Exception { |
| 435 final String message; | 437 final String message; |
| 436 URISyntaxException(this.message); | 438 URISyntaxException(this.message); |
| 437 String toString() => "URISyntaxException: $message"; | 439 String toString() => "URISyntaxException: $message"; |
| 438 } | 440 } |
| OLD | NEW |