| OLD | NEW |
| 1 library java.core; | 1 library java.core; |
| 2 | 2 |
| 3 import "dart:math" as math; | 3 import "dart:math" as math; |
| 4 import "dart:uri"; | 4 import "dart:uri"; |
| 5 import "dart:collection" show ListBase; | 5 import "dart:collection" show ListBase; |
| 6 | 6 |
| 7 class JavaSystem { | 7 class JavaSystem { |
| 8 static int currentTimeMillis() { | 8 static int currentTimeMillis() { |
| 9 return (new DateTime.now()).millisecondsSinceEpoch; | 9 return (new DateTime.now()).millisecondsSinceEpoch; |
| 10 } | 10 } |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 String subSequence(int start, int end) => _content.substring(start, end); | 123 String subSequence(int start, int end) => _content.substring(start, end); |
| 124 } | 124 } |
| 125 | 125 |
| 126 class CharBuffer extends CharSequence { | 126 class CharBuffer extends CharSequence { |
| 127 CharBuffer(String content) : super(content); | 127 CharBuffer(String content) : super(content); |
| 128 static CharBuffer wrap(String content) => new CharBuffer(content); | 128 static CharBuffer wrap(String content) => new CharBuffer(content); |
| 129 } | 129 } |
| 130 | 130 |
| 131 class JavaString { | 131 class JavaString { |
| 132 static String format(String fmt, List args) { | 132 static String format(String fmt, List args) { |
| 133 return fmt; | 133 var index = 0; |
| 134 return fmt.replaceAllMapped(new RegExp(r'%(.)'), (match) { |
| 135 switch (match.group(1)) { |
| 136 case '%': return '%'; |
| 137 case 's': |
| 138 if (index >= args.length) { |
| 139 throw new MissingFormatArgumentException(match.group(0)); |
| 140 } |
| 141 return args[index++].toString(); |
| 142 default: return match.group(1); |
| 143 } |
| 144 }); |
| 134 } | 145 } |
| 135 } | 146 } |
| 136 | 147 |
| 137 /** | 148 /** |
| 138 * Very limited printf implementation, supports only %s and %d. | 149 * Very limited printf implementation, supports only %s and %d. |
| 139 */ | 150 */ |
| 140 String _printf(String fmt, List args) { | 151 String _printf(String fmt, List args) { |
| 141 StringBuffer sb = new StringBuffer(); | 152 StringBuffer sb = new StringBuffer(); |
| 142 bool markFound = false; | 153 bool markFound = false; |
| 143 int argIndex = 0; | 154 int argIndex = 0; |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 256 } | 267 } |
| 257 | 268 |
| 258 class URISyntaxException implements Exception { | 269 class URISyntaxException implements Exception { |
| 259 String toString() => "URISyntaxException"; | 270 String toString() => "URISyntaxException"; |
| 260 } | 271 } |
| 261 | 272 |
| 262 class IOException implements Exception { | 273 class IOException implements Exception { |
| 263 String toString() => "IOException"; | 274 String toString() => "IOException"; |
| 264 } | 275 } |
| 265 | 276 |
| 277 class MissingFormatArgumentException implements Exception { |
| 278 final String s; |
| 279 |
| 280 String toString() => "MissingFormatArgumentException: $s"; |
| 281 |
| 282 MissingFormatArgumentException(this.s); |
| 283 } |
| 284 |
| 266 class ListWrapper<E> extends ListBase<E> implements List<E> { | 285 class ListWrapper<E> extends ListBase<E> implements List<E> { |
| 267 List<E> elements = new List<E>(); | 286 List<E> elements = new List<E>(); |
| 268 | 287 |
| 269 Iterator<E> get iterator { | 288 Iterator<E> get iterator { |
| 270 return elements.iterator; | 289 return elements.iterator; |
| 271 } | 290 } |
| 272 | 291 |
| 273 E operator [](int index) { | 292 E operator [](int index) { |
| 274 return elements[index]; | 293 return elements[index]; |
| 275 } | 294 } |
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 457 } | 476 } |
| 458 } else if (sb.length > newLength) { | 477 } else if (sb.length > newLength) { |
| 459 var s = sb.toString().substring(0, newLength); | 478 var s = sb.toString().substring(0, newLength); |
| 460 sb = new StringBuffer(s); | 479 sb = new StringBuffer(s); |
| 461 } | 480 } |
| 462 } | 481 } |
| 463 void clear() { | 482 void clear() { |
| 464 sb = new StringBuffer(); | 483 sb = new StringBuffer(); |
| 465 } | 484 } |
| 466 } | 485 } |
| OLD | NEW |