Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(30)

Side by Side Diff: sdk/lib/core/uri.dart

Issue 214723002: Remove unmodifiable map wrappers that could instead use UnmodifiableMapView. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fix missing import, increment mirror function count. Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « sdk/lib/_internal/lib/js_mirrors.dart ('k') | sdk/lib/io/http_headers.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 part of dart.core; 5 part of dart.core;
6 6
7 /** 7 /**
8 * A parsed URI, such as a URL. 8 * A parsed URI, such as a URL.
9 * 9 *
10 * **See also:** 10 * **See also:**
(...skipping 708 matching lines...) Expand 10 before | Expand all | Expand 10 after
719 * has been decoded. If there is no query the empty map is returned. 719 * has been decoded. If there is no query the empty map is returned.
720 * 720 *
721 * Keys in the query string that have no value are mapped to the 721 * Keys in the query string that have no value are mapped to the
722 * empty string. 722 * empty string.
723 * 723 *
724 * The returned map is unmodifiable and will throw [UnsupportedError] on any 724 * The returned map is unmodifiable and will throw [UnsupportedError] on any
725 * calls that would mutate it. 725 * calls that would mutate it.
726 */ 726 */
727 Map<String, String> get queryParameters { 727 Map<String, String> get queryParameters {
728 if (_queryParameters == null) { 728 if (_queryParameters == null) {
729 _queryParameters = new _UnmodifiableMap(splitQueryString(query)); 729 _queryParameters = new UnmodifiableMapView(splitQueryString(query));
730 } 730 }
731 return _queryParameters; 731 return _queryParameters;
732 } 732 }
733 733
734 static String _makeHost(String host) { 734 static String _makeHost(String host) {
735 if (host == null || host.isEmpty) return host; 735 if (host == null || host.isEmpty) return host;
736 if (host.codeUnitAt(0) == _LEFT_BRACKET) { 736 if (host.codeUnitAt(0) == _LEFT_BRACKET) {
737 if (host.codeUnitAt(host.length - 1) != _RIGHT_BRACKET) { 737 if (host.codeUnitAt(host.length - 1) != _RIGHT_BRACKET) {
738 throw new FormatException('Missing end `]` to match `[` in host'); 738 throw new FormatException('Missing end `]` to match `[` in host');
739 } 739 }
(...skipping 1102 matching lines...) Expand 10 before | Expand all | Expand 10 after
1842 0xafff, // 0x30 - 0x3f 1111111111110101 1842 0xafff, // 0x30 - 0x3f 1111111111110101
1843 // @ABCDEFGHIJKLMNO 1843 // @ABCDEFGHIJKLMNO
1844 0xffff, // 0x40 - 0x4f 1111111111111111 1844 0xffff, // 0x40 - 0x4f 1111111111111111
1845 // PQRSTUVWXYZ _ 1845 // PQRSTUVWXYZ _
1846 0x87ff, // 0x50 - 0x5f 1111111111100001 1846 0x87ff, // 0x50 - 0x5f 1111111111100001
1847 // abcdefghijklmno 1847 // abcdefghijklmno
1848 0xfffe, // 0x60 - 0x6f 0111111111111111 1848 0xfffe, // 0x60 - 0x6f 0111111111111111
1849 // pqrstuvwxyz ~ 1849 // pqrstuvwxyz ~
1850 0x47ff]; // 0x70 - 0x7f 1111111111100010 1850 0x47ff]; // 0x70 - 0x7f 1111111111100010
1851 } 1851 }
1852
1853 class _UnmodifiableMap<K, V> implements Map<K, V> {
1854 final Map _map;
1855 const _UnmodifiableMap(this._map);
1856
1857 bool containsValue(Object value) => _map.containsValue(value);
1858 bool containsKey(Object key) => _map.containsKey(key);
1859 V operator [](Object key) => _map[key];
1860 void operator []=(K key, V value) {
1861 throw new UnsupportedError("Cannot modify an unmodifiable map");
1862 }
1863 V putIfAbsent(K key, V ifAbsent()) {
1864 throw new UnsupportedError("Cannot modify an unmodifiable map");
1865 }
1866 addAll(Map other) {
1867 throw new UnsupportedError("Cannot modify an unmodifiable map");
1868 }
1869 V remove(Object key) {
1870 throw new UnsupportedError("Cannot modify an unmodifiable map");
1871 }
1872 void clear() {
1873 throw new UnsupportedError("Cannot modify an unmodifiable map");
1874 }
1875 void forEach(void f(K key, V value)) => _map.forEach(f);
1876 Iterable<K> get keys => _map.keys;
1877 Iterable<V> get values => _map.values;
1878 int get length => _map.length;
1879 bool get isEmpty => _map.isEmpty;
1880 bool get isNotEmpty => _map.isNotEmpty;
1881 }
OLDNEW
« no previous file with comments | « sdk/lib/_internal/lib/js_mirrors.dart ('k') | sdk/lib/io/http_headers.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698