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 | 6 |
6 class JavaSystem { | 7 class JavaSystem { |
7 static int currentTimeMillis() { | 8 static int currentTimeMillis() { |
8 return (new DateTime.now()).millisecondsSinceEpoch; | 9 return (new DateTime.now()).millisecondsSinceEpoch; |
9 } | 10 } |
10 | 11 |
11 static void arraycopy(List src, int srcPos, List dest, int destPos, int length
) { | 12 static void arraycopy(List src, int srcPos, List dest, int destPos, int length
) { |
12 for (int i = 0; i < length; i++) { | 13 for (int i = 0; i < length; i++) { |
13 dest[destPos + i] = src[srcPos + i]; | 14 dest[destPos + i] = src[srcPos + i]; |
14 } | 15 } |
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
250 } | 251 } |
251 | 252 |
252 class URISyntaxException implements Exception { | 253 class URISyntaxException implements Exception { |
253 String toString() => "URISyntaxException"; | 254 String toString() => "URISyntaxException"; |
254 } | 255 } |
255 | 256 |
256 class IOException implements Exception { | 257 class IOException implements Exception { |
257 String toString() => "IOException"; | 258 String toString() => "IOException"; |
258 } | 259 } |
259 | 260 |
260 class ListWrapper<E> extends Collection<E> implements List<E> { | 261 class ListWrapper<E> extends ListBase<E> implements List<E> { |
261 List<E> elements = new List<E>(); | 262 List<E> elements = new List<E>(); |
262 | 263 |
263 Iterator<E> get iterator { | 264 Iterator<E> get iterator { |
264 return elements.iterator; | 265 return elements.iterator; |
265 } | 266 } |
266 | 267 |
267 E operator [](int index) { | 268 E operator [](int index) { |
268 return elements[index]; | 269 return elements[index]; |
269 } | 270 } |
270 | 271 |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
337 void insertRange(int start, int length, [E fill]) { | 338 void insertRange(int start, int length, [E fill]) { |
338 elements.insertRange(start, length, fill); | 339 elements.insertRange(start, length, fill); |
339 } | 340 } |
340 | 341 |
341 Map<int, E> asMap() { | 342 Map<int, E> asMap() { |
342 return elements.asMap(); | 343 return elements.asMap(); |
343 } | 344 } |
344 } | 345 } |
345 | 346 |
346 class JavaIterator<E> { | 347 class JavaIterator<E> { |
347 Collection<E> _collection; | 348 Iterable<E> _iterable; |
348 List<E> _elements = new List<E>(); | 349 List<E> _elements = new List<E>(); |
349 int _coPos = 0; | 350 int _coPos = 0; |
350 int _elPos = 0; | 351 int _elPos = 0; |
351 E _current = null; | 352 E _current = null; |
352 JavaIterator(this._collection) { | 353 JavaIterator(this._iterable) { |
353 Iterator iterator = _collection.iterator; | 354 Iterator iterator = _iterable.iterator; |
354 while (iterator.moveNext()) { | 355 while (iterator.moveNext()) { |
355 _elements.add(iterator.current); | 356 _elements.add(iterator.current); |
356 } | 357 } |
357 } | 358 } |
358 | 359 |
359 bool get hasNext { | 360 bool get hasNext { |
360 return _elPos < _elements.length; | 361 return _elPos < _elements.length; |
361 } | 362 } |
362 | 363 |
363 E next() { | 364 E next() { |
364 _current = _elements[_elPos]; | 365 _current = _elements[_elPos]; |
365 _coPos++; | 366 _coPos++; |
366 _elPos++; | 367 _elPos++; |
367 return _current; | 368 return _current; |
368 } | 369 } |
369 | 370 |
370 void remove() { | 371 void remove() { |
371 if (_collection is List) { | 372 if (_iterable is List) { |
372 _coPos--; | 373 _coPos--; |
373 (_collection as List).remove(_coPos); | 374 (_iterable as List).remove(_coPos); |
374 } else if (_collection is Set) { | 375 } else if (_iterable is Set) { |
375 _collection.remove(_current); | 376 _iterable.remove(_current); |
376 } else { | 377 } else { |
377 throw new StateError("Unsupported collection ${_collection.runtimeType}"); | 378 throw new StateError("Unsupported iterable ${_iterable.runtimeType}"); |
378 } | 379 } |
379 } | 380 } |
380 } | 381 } |
381 | 382 |
382 class MapEntry<K, V> { | 383 class MapEntry<K, V> { |
383 K _key; | 384 K _key; |
384 V _value; | 385 V _value; |
385 MapEntry(this._key, this._value); | 386 MapEntry(this._key, this._value); |
386 K getKey() => _key; | 387 K getKey() => _key; |
387 V getValue() => _value; | 388 V getValue() => _value; |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
437 } | 438 } |
438 } else if (sb.length > newLength) { | 439 } else if (sb.length > newLength) { |
439 var s = sb.toString().substring(0, newLength); | 440 var s = sb.toString().substring(0, newLength); |
440 sb = new StringBuffer(s); | 441 sb = new StringBuffer(s); |
441 } | 442 } |
442 } | 443 } |
443 void clear() { | 444 void clear() { |
444 sb = new StringBuffer(); | 445 sb = new StringBuffer(); |
445 } | 446 } |
446 } | 447 } |
OLD | NEW |