| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 protocol; | 5 library protocol; |
| 6 | 6 |
| 7 import 'dart:collection'; |
| 7 import 'dart:convert' show JsonDecoder; | 8 import 'dart:convert' show JsonDecoder; |
| 8 | 9 |
| 9 /** | 10 /** |
| 10 * An abstract enumeration. | 11 * An abstract enumeration. |
| 11 */ | 12 */ |
| 12 abstract class Enum2<E extends Enum2> implements Comparable<E> { | 13 abstract class Enum2<E extends Enum2> implements Comparable<E> { |
| 13 /** | 14 /** |
| 14 * The name of this enum constant, as declared in the enum declaration. | 15 * The name of this enum constant, as declared in the enum declaration. |
| 15 */ | 16 */ |
| 16 final String name; | 17 final String name; |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 final String id; | 71 final String id; |
| 71 | 72 |
| 72 /** | 73 /** |
| 73 * The method being requested. | 74 * The method being requested. |
| 74 */ | 75 */ |
| 75 final String method; | 76 final String method; |
| 76 | 77 |
| 77 /** | 78 /** |
| 78 * A table mapping the names of request parameters to their values. | 79 * A table mapping the names of request parameters to their values. |
| 79 */ | 80 */ |
| 80 final Map<String, Object> params = new Map<String, Object>(); | 81 final Map<String, Object> params = new HashMap<String, Object>(); |
| 81 | 82 |
| 82 /** | 83 /** |
| 83 * A decoder that can be used to decode strings into JSON objects. | 84 * A decoder that can be used to decode strings into JSON objects. |
| 84 */ | 85 */ |
| 85 static const JsonDecoder DECODER = const JsonDecoder(null); | 86 static const JsonDecoder DECODER = const JsonDecoder(null); |
| 86 | 87 |
| 87 /** | 88 /** |
| 88 * Initialize a newly created [Request] to have the given [id] and [method] | 89 * Initialize a newly created [Request] to have the given [id] and [method] |
| 89 * name. | 90 * name. |
| 90 */ | 91 */ |
| (...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 431 /** | 432 /** |
| 432 * The error that was caused by attempting to handle the request, or `null` if | 433 * The error that was caused by attempting to handle the request, or `null` if |
| 433 * there was no error. | 434 * there was no error. |
| 434 */ | 435 */ |
| 435 final RequestError error; | 436 final RequestError error; |
| 436 | 437 |
| 437 /** | 438 /** |
| 438 * A table mapping the names of result fields to their values. The table | 439 * A table mapping the names of result fields to their values. The table |
| 439 * should be empty if there was an error. | 440 * should be empty if there was an error. |
| 440 */ | 441 */ |
| 441 final Map<String, Object> result = new Map<String, Object>(); | 442 final Map<String, Object> result = new HashMap<String, Object>(); |
| 442 | 443 |
| 443 /** | 444 /** |
| 444 * Initialize a newly created instance to represent a response to a request | 445 * Initialize a newly created instance to represent a response to a request |
| 445 * with the given [id]. If an [error] is provided then the response will | 446 * with the given [id]. If an [error] is provided then the response will |
| 446 * represent an error condition. | 447 * represent an error condition. |
| 447 */ | 448 */ |
| 448 Response(this.id, [this.error]); | 449 Response(this.id, [this.error]); |
| 449 | 450 |
| 450 /** | 451 /** |
| 451 * Initialize a newly created instance to represent an error condition caused | 452 * Initialize a newly created instance to represent an error condition caused |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 639 final int code; | 640 final int code; |
| 640 | 641 |
| 641 /** | 642 /** |
| 642 * A short description of the error. | 643 * A short description of the error. |
| 643 */ | 644 */ |
| 644 final String message; | 645 final String message; |
| 645 | 646 |
| 646 /** | 647 /** |
| 647 * A table mapping the names of notification parameters to their values. | 648 * A table mapping the names of notification parameters to their values. |
| 648 */ | 649 */ |
| 649 final Map<String, Object> data = new Map<String, Object>(); | 650 final Map<String, Object> data = new HashMap<String, Object>(); |
| 650 | 651 |
| 651 /** | 652 /** |
| 652 * Initialize a newly created [Error] to have the given [code] and [message]. | 653 * Initialize a newly created [Error] to have the given [code] and [message]. |
| 653 */ | 654 */ |
| 654 RequestError(this.code, this.message); | 655 RequestError(this.code, this.message); |
| 655 | 656 |
| 656 /** | 657 /** |
| 657 * Initialize a newly created [Error] to indicate a parse error. Invalid JSON | 658 * Initialize a newly created [Error] to indicate a parse error. Invalid JSON |
| 658 * was received by the server. An error occurred on the server while parsing | 659 * was received by the server. An error occurred on the server while parsing |
| 659 * the JSON text. | 660 * the JSON text. |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 758 static const String PARAMS = 'params'; | 759 static const String PARAMS = 'params'; |
| 759 | 760 |
| 760 /** | 761 /** |
| 761 * The name of the event that triggered the notification. | 762 * The name of the event that triggered the notification. |
| 762 */ | 763 */ |
| 763 final String event; | 764 final String event; |
| 764 | 765 |
| 765 /** | 766 /** |
| 766 * A table mapping the names of notification parameters to their values. | 767 * A table mapping the names of notification parameters to their values. |
| 767 */ | 768 */ |
| 768 final Map<String, Object> params = new Map<String, Object>(); | 769 final Map<String, Object> params = new HashMap<String, Object>(); |
| 769 | 770 |
| 770 /** | 771 /** |
| 771 * Initialize a newly created [Notification] to have the given [event] name. | 772 * Initialize a newly created [Notification] to have the given [event] name. |
| 772 */ | 773 */ |
| 773 Notification(this.event); | 774 Notification(this.event); |
| 774 | 775 |
| 775 /** | 776 /** |
| 776 * Initialize a newly created instance based upon the given JSON data | 777 * Initialize a newly created instance based upon the given JSON data |
| 777 */ | 778 */ |
| 778 factory Notification.fromJson(Map<String, Object> json) { | 779 factory Notification.fromJson(Map<String, Object> json) { |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 841 /** | 842 /** |
| 842 * The response to be returned as a result of the failure. | 843 * The response to be returned as a result of the failure. |
| 843 */ | 844 */ |
| 844 final Response response; | 845 final Response response; |
| 845 | 846 |
| 846 /** | 847 /** |
| 847 * Initialize a newly created exception to return the given reponse. | 848 * Initialize a newly created exception to return the given reponse. |
| 848 */ | 849 */ |
| 849 RequestFailure(this.response); | 850 RequestFailure(this.response); |
| 850 } | 851 } |
| OLD | NEW |