diff --git a/lib/OpenLayers/Protocol.js b/lib/OpenLayers/Protocol.js index da69194669..37ed8480f8 100755 --- a/lib/OpenLayers/Protocol.js +++ b/lib/OpenLayers/Protocol.js @@ -38,6 +38,7 @@ OpenLayers.Protocol = OpenLayers.Class({ * instance. */ initialize: function(options) { + options = options || {}; OpenLayers.Util.extend(this, options); this.options = options; }, @@ -57,6 +58,11 @@ OpenLayers.Protocol = OpenLayers.Class({ * * Parameters: * options - {Object} Optional object for configuring the request. + * + * Returns: + * {} An + * object, the same object will be passed to the callback function passed + * if one exists in the options object. */ read: function() { }, @@ -70,6 +76,11 @@ OpenLayers.Protocol = OpenLayers.Class({ * features - {Array({})} or * {} * options - {Object} Optional object for configuring the request. + * + * Returns: + * {} An + * object, the same object will be passed to the callback function passed + * if one exists in the options object. */ create: function() { }, @@ -82,6 +93,11 @@ OpenLayers.Protocol = OpenLayers.Class({ * features - {Array({})} or * {} * options - {Object} Optional object for configuring the request. + * + * Returns: + * {} An + * object, the same object will be passed to the callback function passed + * if one exists in the options object. */ update: function() { }, @@ -93,6 +109,11 @@ OpenLayers.Protocol = OpenLayers.Class({ * Parameters: * feature - {} * options - {Object} Optional object for configuring the request. + * + * Returns: + * {} An + * object, the same object will be passed to the callback function passed + * if one exists in the options object. */ "delete": function() { }, @@ -105,8 +126,16 @@ OpenLayers.Protocol = OpenLayers.Class({ * * Parameters: * features - {Array({})} - * options - {Object} Map of options, the keys of the map are - * 'create', 'update', and 'delete' + * options - {Object} Object whose possible keys are "create", "update", + * "delete", "callback" and "scope", the values referenced by the + * first three are objects as passed to the "create", "update", and + * "delete" methods, the value referenced by the "callback" key is + * a function which is called when the commit operation is complete + * using the scope referenced by the "scope" key. + * + * Returns: + * {Array({})} An array of + * objects. */ commit: function() { }, @@ -118,14 +147,28 @@ OpenLayers.Protocol = OpenLayers.Class({ * Class: OpenLayers.Protocol.Response * Protocols return Response objects to their users. */ -OpenLayers.Protocol.Response = new OpenLayers.Class({ +OpenLayers.Protocol.Response = OpenLayers.Class({ /** * Property: code - * {Integer} - OpenLayers.Protocol.Response.SUCCESS or - * OpenLayers.Protocol.Response.FAILURE + * {Number} - OpenLayers.Protocol.Response.SUCCESS or + * OpenLayers.Protocol.Response.FAILURE */ code: null, + /** + * Property: requestType + * {String} The type of request this response corresponds to. Either + * "create", "read", "update" or "delete". + */ + requestType: null, + + /** + * Property: last + * {Boolean} - true if this is the last response expected in a commit, + * false otherwise, defaults to true. + */ + last: true, + /** * Property: features * {Array({})} or {} @@ -164,14 +207,11 @@ OpenLayers.Protocol.Response = new OpenLayers.Class({ * {Boolean} - true on success, false otherwise */ success: function() { - return !!(this.code & OpenLayers.Protocol.Response.SUCCESS_MASK); + return this.code > 0; }, CLASS_NAME: "OpenLayers.Protocol.Response" }); -OpenLayers.Protocol.Response.SUCCESS_MASK = 0x000000ff; -OpenLayers.Protocol.Response.SUCCESS = 0x00000001; - -OpenLayers.Protocol.Response.FAILURE_MASK = 0x0000ff00; -OpenLayers.Protocol.Response.FAILURE = 0x00000100; +OpenLayers.Protocol.Response.SUCCESS = 1; +OpenLayers.Protocol.Response.FAILURE = 0;