| OLD | NEW |
| 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 library dart.uri; | 5 library dart.uri; |
| 6 | 6 |
| 7 import 'dart:math'; | 7 import 'dart:math'; |
| 8 import 'dart:utf'; | 8 import 'dart:utf'; |
| 9 | 9 |
| 10 part 'encode_decode.dart'; | 10 part 'encode_decode.dart'; |
| (...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 222 sb.add(":"); | 222 sb.add(":"); |
| 223 sb.add(port.toString()); | 223 sb.add(port.toString()); |
| 224 } | 224 } |
| 225 } | 225 } |
| 226 sb.add(path == null ? "null" : path); | 226 sb.add(path == null ? "null" : path); |
| 227 _addIfNonEmpty(sb, query, "?", query); | 227 _addIfNonEmpty(sb, query, "?", query); |
| 228 _addIfNonEmpty(sb, fragment, "#", fragment); | 228 _addIfNonEmpty(sb, fragment, "#", fragment); |
| 229 return sb.toString(); | 229 return sb.toString(); |
| 230 } | 230 } |
| 231 | 231 |
| 232 bool operator==(other) { |
| 233 if (other is! Uri) return false; |
| 234 Uri uri = other; |
| 235 return scheme == uri.scheme && |
| 236 userInfo == uri.userInfo && |
| 237 domain == uri.domain && |
| 238 port == uri.port && |
| 239 path == uri.path && |
| 240 query == uri.query && |
| 241 fragment == uri.fragment; |
| 242 } |
| 243 |
| 244 int get hashCode { |
| 245 int combine(part, current) { |
| 246 // The sum is truncated to 30 bits to make sure it fits into a Smi. |
| 247 return (current * 31 + part.hashCode) & 0x3FFFFFFF; |
| 248 } |
| 249 return combine(scheme, combine(userInfo, combine(domain, combine(port, |
| 250 combine(path, combine(query, combine(fragment, 1))))))); |
| 251 } |
| 252 |
| 232 static void _addIfNonEmpty(StringBuffer sb, String test, | 253 static void _addIfNonEmpty(StringBuffer sb, String test, |
| 233 String first, String second) { | 254 String first, String second) { |
| 234 if ("" != test) { | 255 if ("" != test) { |
| 235 sb.add(first == null ? "null" : first); | 256 sb.add(first == null ? "null" : first); |
| 236 sb.add(second == null ? "null" : second); | 257 sb.add(second == null ? "null" : second); |
| 237 } | 258 } |
| 238 } | 259 } |
| 239 } | 260 } |
| OLD | NEW |