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