| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 library analyzer.src.generated.java_core; | 5 library analyzer.src.generated.java_core; |
| 6 | 6 |
| 7 final Stopwatch nanoTimeStopwatch = new Stopwatch(); | 7 final Stopwatch nanoTimeStopwatch = new Stopwatch(); |
| 8 | 8 |
| 9 /** | 9 /** |
| 10 * Inserts the given arguments into [pattern]. | 10 * Inserts the given arguments into [pattern]. |
| (...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 286 | 286 |
| 287 class RuntimeException extends JavaException { | 287 class RuntimeException extends JavaException { |
| 288 RuntimeException({String message: "", Exception cause: null}) | 288 RuntimeException({String message: "", Exception cause: null}) |
| 289 : super(message, cause); | 289 : super(message, cause); |
| 290 } | 290 } |
| 291 | 291 |
| 292 class StringIndexOutOfBoundsException extends JavaException { | 292 class StringIndexOutOfBoundsException extends JavaException { |
| 293 StringIndexOutOfBoundsException(int index) : super('$index'); | 293 StringIndexOutOfBoundsException(int index) : super('$index'); |
| 294 } | 294 } |
| 295 | 295 |
| 296 class StringUtils { | |
| 297 static String capitalize(String str) { | |
| 298 if (isEmpty(str)) { | |
| 299 return str; | |
| 300 } | |
| 301 return str.substring(0, 1).toUpperCase() + str.substring(1); | |
| 302 } | |
| 303 | |
| 304 static bool equals(String cs1, String cs2) { | |
| 305 if (cs1 == cs2) { | |
| 306 return true; | |
| 307 } | |
| 308 if (cs1 == null || cs2 == null) { | |
| 309 return false; | |
| 310 } | |
| 311 return cs1 == cs2; | |
| 312 } | |
| 313 | |
| 314 static bool isEmpty(String str) { | |
| 315 return str == null || str.isEmpty; | |
| 316 } | |
| 317 | |
| 318 static String join(Iterable iter, | |
| 319 [String separator = ' ', int start = 0, int end = -1]) { | |
| 320 if (start != 0) { | |
| 321 iter = iter.skip(start); | |
| 322 } | |
| 323 if (end != -1) { | |
| 324 iter = iter.take(end - start); | |
| 325 } | |
| 326 return iter.join(separator); | |
| 327 } | |
| 328 | |
| 329 static void printf(StringBuffer buffer, String fmt, List args) { | |
| 330 buffer.write(_printf(fmt, args)); | |
| 331 } | |
| 332 | |
| 333 static String remove(String str, String remove) { | |
| 334 if (isEmpty(str) || isEmpty(remove)) { | |
| 335 return str; | |
| 336 } | |
| 337 return str.replaceAll(remove, ''); | |
| 338 } | |
| 339 | |
| 340 static String removeStart(String str, String remove) { | |
| 341 if (isEmpty(str) || isEmpty(remove)) { | |
| 342 return str; | |
| 343 } | |
| 344 if (str.startsWith(remove)) { | |
| 345 return str.substring(remove.length); | |
| 346 } | |
| 347 return str; | |
| 348 } | |
| 349 | |
| 350 static String repeat(String s, int n) { | |
| 351 StringBuffer sb = new StringBuffer(); | |
| 352 for (int i = 0; i < n; i++) { | |
| 353 sb.write(s); | |
| 354 } | |
| 355 return sb.toString(); | |
| 356 } | |
| 357 | |
| 358 static List<String> split(String s, [String pattern = ' ']) { | |
| 359 return s.split(pattern); | |
| 360 } | |
| 361 | |
| 362 static List<String> splitByWholeSeparatorPreserveAllTokens( | |
| 363 String s, String pattern) { | |
| 364 return s.split(pattern); | |
| 365 } | |
| 366 } | |
| 367 | |
| 368 class UnsupportedOperationException extends JavaException { | 296 class UnsupportedOperationException extends JavaException { |
| 369 UnsupportedOperationException([message = ""]) : super(message); | 297 UnsupportedOperationException([message = ""]) : super(message); |
| 370 } | 298 } |
| 371 | 299 |
| 372 class URISyntaxException implements Exception { | 300 class URISyntaxException implements Exception { |
| 373 final String message; | 301 final String message; |
| 374 URISyntaxException(this.message); | 302 URISyntaxException(this.message); |
| 375 String toString() => "URISyntaxException: $message"; | 303 String toString() => "URISyntaxException: $message"; |
| 376 } | 304 } |
| OLD | NEW |