| 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, [arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7]) | 14 String format(String pattern, |
| 15 { | 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 */ |
| (...skipping 20 matching lines...) Expand all Loading... |
| 46 } | 46 } |
| 47 | 47 |
| 48 bool javaSetEquals(Set a, Set b) { | 48 bool javaSetEquals(Set a, Set b) { |
| 49 return a.containsAll(b) && b.containsAll(a); | 49 return a.containsAll(b) && b.containsAll(a); |
| 50 } | 50 } |
| 51 | 51 |
| 52 bool javaStringEqualsIgnoreCase(String a, String b) { | 52 bool javaStringEqualsIgnoreCase(String a, String b) { |
| 53 return a.toLowerCase() == b.toLowerCase(); | 53 return a.toLowerCase() == b.toLowerCase(); |
| 54 } | 54 } |
| 55 | 55 |
| 56 bool javaStringRegionMatches(String t, int toffset, String o, int ooffset, | 56 bool javaStringRegionMatches( |
| 57 int len) { | 57 String t, int toffset, String o, int ooffset, int len) { |
| 58 if (toffset < 0) return false; | 58 if (toffset < 0) return false; |
| 59 if (ooffset < 0) return false; | 59 if (ooffset < 0) return false; |
| 60 var tend = toffset + len; | 60 var tend = toffset + len; |
| 61 var oend = ooffset + len; | 61 var oend = ooffset + len; |
| 62 if (tend > t.length) return false; | 62 if (tend > t.length) return false; |
| 63 if (oend > o.length) return false; | 63 if (oend > o.length) return false; |
| 64 return t.substring(toffset, tend) == o.substring(ooffset, oend); | 64 return t.substring(toffset, tend) == o.substring(ooffset, oend); |
| 65 } | 65 } |
| 66 | 66 |
| 67 /// Parses given string to [Uri], throws [URISyntaxException] if invalid. | 67 /// Parses given string to [Uri], throws [URISyntaxException] if invalid. |
| (...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 272 if (fromIndex > target.length) return -1; | 272 if (fromIndex > target.length) return -1; |
| 273 if (fromIndex < 0) fromIndex = 0; | 273 if (fromIndex < 0) fromIndex = 0; |
| 274 return target.lastIndexOf(str, fromIndex); | 274 return target.lastIndexOf(str, fromIndex); |
| 275 } | 275 } |
| 276 static bool startsWithBefore(String s, String other, int start) { | 276 static bool startsWithBefore(String s, String other, int start) { |
| 277 return s.indexOf(other, start) != -1; | 277 return s.indexOf(other, start) != -1; |
| 278 } | 278 } |
| 279 } | 279 } |
| 280 | 280 |
| 281 class JavaSystem { | 281 class JavaSystem { |
| 282 static void arraycopy(List src, int srcPos, List dest, int destPos, | 282 static void arraycopy( |
| 283 int length) { | 283 List src, int srcPos, List dest, int destPos, int length) { |
| 284 for (int i = 0; i < length; i++) { | 284 for (int i = 0; i < length; i++) { |
| 285 dest[destPos + i] = src[srcPos + i]; | 285 dest[destPos + i] = src[srcPos + i]; |
| 286 } | 286 } |
| 287 } | 287 } |
| 288 | 288 |
| 289 static int currentTimeMillis() { | 289 static int currentTimeMillis() { |
| 290 return (new DateTime.now()).millisecondsSinceEpoch; | 290 return (new DateTime.now()).millisecondsSinceEpoch; |
| 291 } | 291 } |
| 292 | 292 |
| 293 static int nanoTime() { | 293 static int nanoTime() { |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 369 if (cs1 == null || cs2 == null) { | 369 if (cs1 == null || cs2 == null) { |
| 370 return false; | 370 return false; |
| 371 } | 371 } |
| 372 return cs1 == cs2; | 372 return cs1 == cs2; |
| 373 } | 373 } |
| 374 | 374 |
| 375 static bool isEmpty(String str) { | 375 static bool isEmpty(String str) { |
| 376 return str == null || str.isEmpty; | 376 return str == null || str.isEmpty; |
| 377 } | 377 } |
| 378 | 378 |
| 379 static String join(Iterable iter, [String separator = ' ', int start = 0, | 379 static String join(Iterable iter, |
| 380 int end = -1]) { | 380 [String separator = ' ', int start = 0, int end = -1]) { |
| 381 if (start != 0) { | 381 if (start != 0) { |
| 382 iter = iter.skip(start); | 382 iter = iter.skip(start); |
| 383 } | 383 } |
| 384 if (end != -1) { | 384 if (end != -1) { |
| 385 iter = iter.take(end - start); | 385 iter = iter.take(end - start); |
| 386 } | 386 } |
| 387 return iter.join(separator); | 387 return iter.join(separator); |
| 388 } | 388 } |
| 389 | 389 |
| 390 static void printf(StringBuffer buffer, String fmt, List args) { | 390 static void printf(StringBuffer buffer, String fmt, List args) { |
| (...skipping 22 matching lines...) Expand all Loading... |
| 413 for (int i = 0; i < n; i++) { | 413 for (int i = 0; i < n; i++) { |
| 414 sb.write(s); | 414 sb.write(s); |
| 415 } | 415 } |
| 416 return sb.toString(); | 416 return sb.toString(); |
| 417 } | 417 } |
| 418 | 418 |
| 419 static List<String> split(String s, [String pattern = ' ']) { | 419 static List<String> split(String s, [String pattern = ' ']) { |
| 420 return s.split(pattern); | 420 return s.split(pattern); |
| 421 } | 421 } |
| 422 | 422 |
| 423 static List<String> splitByWholeSeparatorPreserveAllTokens(String s, | 423 static List<String> splitByWholeSeparatorPreserveAllTokens( |
| 424 String pattern) { | 424 String s, String pattern) { |
| 425 return s.split(pattern); | 425 return s.split(pattern); |
| 426 } | 426 } |
| 427 } | 427 } |
| 428 | 428 |
| 429 class UnsupportedOperationException extends JavaException { | 429 class UnsupportedOperationException extends JavaException { |
| 430 UnsupportedOperationException([message = ""]) : super(message); | 430 UnsupportedOperationException([message = ""]) : super(message); |
| 431 } | 431 } |
| 432 | 432 |
| 433 class URISyntaxException implements Exception { | 433 class URISyntaxException implements Exception { |
| 434 final String message; | 434 final String message; |
| 435 URISyntaxException(this.message); | 435 URISyntaxException(this.message); |
| 436 String toString() => "URISyntaxException: $message"; | 436 String toString() => "URISyntaxException: $message"; |
| 437 } | 437 } |
| OLD | NEW |