| OLD | NEW |
| (Empty) |
| 1 | |
| 2 class _MediaListJs extends _DOMTypeJs implements MediaList native "*MediaList" { | |
| 3 | |
| 4 final int length; | |
| 5 | |
| 6 String mediaText; | |
| 7 | |
| 8 String operator[](int index) native "return this[index];"; | |
| 9 | |
| 10 void operator[]=(int index, String value) { | |
| 11 throw new UnsupportedOperationException("Cannot assign element of immutable
List."); | |
| 12 } | |
| 13 // -- start List<String> mixins. | |
| 14 // String is the element type. | |
| 15 | |
| 16 // From Iterable<String>: | |
| 17 | |
| 18 Iterator<String> iterator() { | |
| 19 // Note: NodeLists are not fixed size. And most probably length shouldn't | |
| 20 // be cached in both iterator _and_ forEach method. For now caching it | |
| 21 // for consistency. | |
| 22 return new _FixedSizeListIterator<String>(this); | |
| 23 } | |
| 24 | |
| 25 // From Collection<String>: | |
| 26 | |
| 27 void add(String value) { | |
| 28 throw new UnsupportedOperationException("Cannot add to immutable List."); | |
| 29 } | |
| 30 | |
| 31 void addLast(String value) { | |
| 32 throw new UnsupportedOperationException("Cannot add to immutable List."); | |
| 33 } | |
| 34 | |
| 35 void addAll(Collection<String> collection) { | |
| 36 throw new UnsupportedOperationException("Cannot add to immutable List."); | |
| 37 } | |
| 38 | |
| 39 void forEach(void f(String element)) => _Collections.forEach(this, f); | |
| 40 | |
| 41 Collection map(f(String element)) => _Collections.map(this, [], f); | |
| 42 | |
| 43 Collection<String> filter(bool f(String element)) => | |
| 44 _Collections.filter(this, <String>[], f); | |
| 45 | |
| 46 bool every(bool f(String element)) => _Collections.every(this, f); | |
| 47 | |
| 48 bool some(bool f(String element)) => _Collections.some(this, f); | |
| 49 | |
| 50 bool isEmpty() => this.length == 0; | |
| 51 | |
| 52 // From List<String>: | |
| 53 | |
| 54 void sort(int compare(String a, String b)) { | |
| 55 throw new UnsupportedOperationException("Cannot sort immutable List."); | |
| 56 } | |
| 57 | |
| 58 int indexOf(String element, [int start = 0]) => | |
| 59 _Lists.indexOf(this, element, start, this.length); | |
| 60 | |
| 61 int lastIndexOf(String element, [int start = 0]) => | |
| 62 _Lists.lastIndexOf(this, element, start); | |
| 63 | |
| 64 String last() => this[length - 1]; | |
| 65 | |
| 66 // FIXME: implement thesee. | |
| 67 void setRange(int start, int length, List<String> from, [int startFrom]) { | |
| 68 throw new UnsupportedOperationException("Cannot setRange on immutable List."
); | |
| 69 } | |
| 70 void removeRange(int start, int length) { | |
| 71 throw new UnsupportedOperationException("Cannot removeRange on immutable Lis
t."); | |
| 72 } | |
| 73 void insertRange(int start, int length, [String initialValue]) { | |
| 74 throw new UnsupportedOperationException("Cannot insertRange on immutable Lis
t."); | |
| 75 } | |
| 76 List<String> getRange(int start, int length) => | |
| 77 _Lists.getRange(this, start, length, <String>[]); | |
| 78 | |
| 79 // -- end List<String> mixins. | |
| 80 | |
| 81 void appendMedium(String newMedium) native; | |
| 82 | |
| 83 void deleteMedium(String oldMedium) native; | |
| 84 | |
| 85 String item(int index) native; | |
| 86 } | |
| OLD | NEW |