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