Line data Source code
1 : /*
2 : * Packge : Wilt
3 : * Author : S. Hamblett <steve.hamblett@linux.com>
4 : * Date : 04/06/2013
5 : * Copyright : S.Hamblett@OSCF
6 : *
7 : * Change notification event
8 : *
9 : * The type property of this class determines the validity of the rest of the
10 : * class data, see individual properties for this mapping. Uers should check the
11 : * event type property BEFORE accessing any other property.
12 : *
13 : * See each event below for a description of its effect.
14 : *
15 : */
16 :
17 : part of wilt;
18 :
19 : class WiltChangeNotificationEvent {
20 : /// Update event
21 : ///
22 : /// A document has been created/updated
23 : static const String updatee = "update";
24 :
25 : /// Delete event
26 : ///
27 : /// A document has been deleted
28 : static const String deletee = "delete";
29 :
30 : /// Decode error event
31 : ///
32 : /// The change notification received from CouchDB cannot be
33 : /// transformed into valid JSON, this may be a temporary issue,
34 : /// the client must decide whether to continue on or re-initialise
35 : /// the change notification class.
36 : static const String decodeErrorr = "decode";
37 :
38 : /// CouchDb error event
39 : ///
40 : /// The change notification received from CouchDB indicates an error.
41 : static const String couchdbError = "couch";
42 :
43 : /// Abort event
44 : ///
45 : /// A fatal error in the HTTP client has been detected, the client must
46 : /// assume that on receiving the event the change notification interface must
47 : /// be re-initialised.
48 : static const String abortt = "abort";
49 :
50 : /// Last sequence number event
51 : ///
52 : /// Sent by CouchDB when there are no changes, only the last sequence number is returned.
53 : ///
54 : static const String lastSequence = "sequence";
55 :
56 : /// Update event
57 : WiltChangeNotificationEvent.update(
58 : this._docId, this._docRevision, this._sequenceNumber,
59 1 : [this._document]) {
60 1 : _type = updatee;
61 : }
62 :
63 : /// Delete event
64 : WiltChangeNotificationEvent.delete(
65 1 : this._docId, this._docRevision, this._sequenceNumber) {
66 1 : _type = deletee;
67 : }
68 :
69 : /// Decode error event
70 : WiltChangeNotificationEvent.decodeError(
71 0 : this._httpResponseText, this._exception) {
72 0 : _type = decodeErrorr;
73 : }
74 :
75 : /// Abort event
76 0 : WiltChangeNotificationEvent.abort(this._exception) {
77 0 : _type = abortt;
78 : }
79 :
80 : /// CouchDB error event
81 : WiltChangeNotificationEvent.couchDbError(
82 0 : this._couchError, this._couchReason) {
83 0 : _type = couchdbError;
84 : }
85 :
86 : /// Sequence number event
87 1 : WiltChangeNotificationEvent.sequence(this._sequenceNumber) {
88 1 : _type = lastSequence;
89 : }
90 :
91 : /// Type
92 : ///
93 : /// Valid for all events
94 : String _type = null;
95 1 : String get type => _type;
96 :
97 : /// Sequence Number
98 : ///
99 : /// Valid for update, delete and sequence
100 : ///
101 : int _sequenceNumber = 0;
102 0 : int get sequenceNumber => _sequenceNumber;
103 :
104 : /// Document identifier
105 : ///
106 : /// Valid for update and delete
107 : String _docId = null;
108 1 : String get docId => _docId;
109 :
110 : /// Document revision
111 : ///
112 : /// Valid for update and delete but optional
113 : String _docRevision = null;
114 0 : String get docRevision => _docRevision;
115 :
116 : /// Document object
117 : ///
118 : /// Valid for update and only if includeDocs is true
119 : jsonobject.JsonObject _document = null;
120 1 : jsonobject.JsonObject get document => _document;
121 :
122 : /// Exception string
123 : ///
124 : /// Valid for abort and decode error
125 : String _exception = null;
126 0 : String get exception => _exception;
127 :
128 : /// HTTP response text
129 : ///
130 : /// Valid for decode error
131 : String _httpResponseText = null;
132 0 : String get httpResponseText => _httpResponseText;
133 :
134 : /// Couch error
135 : ///
136 : /// Valid for update and delete
137 : String _couchError = null;
138 0 : String get couchError => _couchError;
139 :
140 : /// Couch reason
141 : ///
142 : /// Valid for update and delete
143 : String _couchReason = null;
144 0 : String get couchReason => _couchReason;
145 : }
|