1 /* Copyright (c) 2006-2008 MetaCarta, Inc., published under the Clear BSD
2 * license. See http://svn.openlayers.org/trunk/openlayers/license.txt for the
3 * full text of the license. */
6 * Class: OpenLayers.Protocol
7 * Abstract vector layer protocol class. Not to be instantiated directly. Use
8 * one of the protocol subclasses instead.
10 OpenLayers.Protocol = OpenLayers.Class({
14 * {<OpenLayers.Format>} The format used by this protocol.
20 * {Object} Any options sent to the constructor.
25 * Property: autoDestroy
26 * {Boolean} The creator of the protocol can set autoDestroy to false
27 * to fully control when the protocol is destroyed. Defaults to
33 * Constructor: OpenLayers.Protocol
34 * Abstract class for vector protocols. Create instances of a subclass.
37 * options - {Object} Optional object whose properties will be set on the
40 initialize: function(options) {
41 options = options || {};
42 OpenLayers.Util.extend(this, options);
43 this.options = options;
48 * Clean up the protocol.
57 * Construct a request for reading new features.
60 * options - {Object} Optional object for configuring the request.
63 * {<OpenLayers.Protocol.Response>} An <OpenLayers.Protocol.Response>
64 * object, the same object will be passed to the callback function passed
65 * if one exists in the options object.
73 * Construct a request for writing newly created features.
76 * features - {Array({<OpenLayers.Feature.Vector>})} or
77 * {<OpenLayers.Feature.Vector>}
78 * options - {Object} Optional object for configuring the request.
81 * {<OpenLayers.Protocol.Response>} An <OpenLayers.Protocol.Response>
82 * object, the same object will be passed to the callback function passed
83 * if one exists in the options object.
90 * Construct a request updating modified features.
93 * features - {Array({<OpenLayers.Feature.Vector>})} or
94 * {<OpenLayers.Feature.Vector>}
95 * options - {Object} Optional object for configuring the request.
98 * {<OpenLayers.Protocol.Response>} An <OpenLayers.Protocol.Response>
99 * object, the same object will be passed to the callback function passed
100 * if one exists in the options object.
107 * Construct a request deleting a removed feature.
110 * feature - {<OpenLayers.Feature.Vector>}
111 * options - {Object} Optional object for configuring the request.
114 * {<OpenLayers.Protocol.Response>} An <OpenLayers.Protocol.Response>
115 * object, the same object will be passed to the callback function passed
116 * if one exists in the options object.
118 "delete": function() {
123 * Go over the features and for each take action
124 * based on the feature state. Possible actions are create,
128 * features - {Array({<OpenLayers.Feature.Vector>})}
129 * options - {Object} Object whose possible keys are "create", "update",
130 * "delete", "callback" and "scope", the values referenced by the
131 * first three are objects as passed to the "create", "update", and
132 * "delete" methods, the value referenced by the "callback" key is
133 * a function which is called when the commit operation is complete
134 * using the scope referenced by the "scope" key.
137 * {Array({<OpenLayers.Protocol.Response>})} An array of
138 * <OpenLayers.Protocol.Response> objects.
145 * Abort an ongoing request.
148 * response - {<OpenLayers.Protocol.Response>}
150 abort: function(response) {
153 CLASS_NAME: "OpenLayers.Protocol"
157 * Class: OpenLayers.Protocol.Response
158 * Protocols return Response objects to their users.
160 OpenLayers.Protocol.Response = OpenLayers.Class({
163 * {Number} - OpenLayers.Protocol.Response.SUCCESS or
164 * OpenLayers.Protocol.Response.FAILURE
169 * Property: requestType
170 * {String} The type of request this response corresponds to. Either
171 * "create", "read", "update" or "delete".
177 * {Boolean} - true if this is the last response expected in a commit,
178 * false otherwise, defaults to true.
184 * {Array({<OpenLayers.Feature.Vector>})} or {<OpenLayers.Feature.Vector>}
185 * The features returned in the response by the server.
190 * Property: reqFeatures
191 * {Array({<OpenLayers.Feature.Vector>})} or {<OpenLayers.Feature.Vector>}
192 * The features provided by the user and placed in the request by the
203 * Constructor: OpenLayers.Protocol.Response
206 * options - {Object} Optional object whose properties will be set on the
209 initialize: function(options) {
210 OpenLayers.Util.extend(this, options);
217 * {Boolean} - true on success, false otherwise
219 success: function() {
220 return this.code > 0;
223 CLASS_NAME: "OpenLayers.Protocol.Response"
226 OpenLayers.Protocol.Response.SUCCESS = 1;
227 OpenLayers.Protocol.Response.FAILURE = 0;