Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(46)

Side by Side Diff: pkg/serialization/lib/serialization.dart

Issue 11624031: Fix documentation bugs 7517 and 7518 in serialization. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 12 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | pkg/serialization/lib/src/reader_writer.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 /** 5 /**
6 * This provides a general-purpose serialization facility for Dart objects. A 6 * This provides a general-purpose serialization facility for Dart objects. A
7 * [Serialization] is defined in terms of [SerializationRule]s and supports 7 * [Serialization] is defined in terms of [SerializationRule]s and supports
8 * reading and writing to different formats. 8 * reading and writing to different formats.
9 * 9 *
10 * Setup 10 * Setup
(...skipping 27 matching lines...) Expand all
38 * fields that we specified. We may also want to tell it to identify the 38 * fields that we specified. We may also want to tell it to identify the
39 * fields, but to specifically omit certain fields that we don't want 39 * fields, but to specifically omit certain fields that we don't want
40 * serialized. 40 * serialized.
41 * 41 *
42 * var serialization = new Serialization() 42 * var serialization = new Serialization()
43 * ..addRuleFor(address, 43 * ..addRuleFor(address,
44 * constructor: "", 44 * constructor: "",
45 * excludeFields: ["other", "stuff"]); 45 * excludeFields: ["other", "stuff"]);
46 * 46 *
47 * We can also use a completely non-reflective rule to serialize and 47 * We can also use a completely non-reflective rule to serialize and
48 * de-serialize objects. 48 * de-serialize objects. This can be more work for us, but can run via
sethladd 2012/12/22 00:06:24 What do you mean "us" here? perhaps, "This techni
Alan Knight 2012/12/22 00:31:21 Done.
49 * dart2js where mirrors are not yet implemented, and even on the VM may
50 * have better performance.
49 * 51 *
50 * addressToMap(a) => {"number" : a.number, "street" : a.street, 52 * addressToMap(a) => {"number" : a.number, "street" : a.street,
51 * "city" : a.city}; 53 * "city" : a.city};
52 * createAddress(Map m) => new Address.create(m["number"], m["street"]); 54 * createAddress(Map m) => new Address.create(m["number"], m["street"]);
53 * fillInAddress(Map m, Address a) => a.city = m["city"]; 55 * fillInAddress(Map m, Address a) => a.city = m["city"];
54 * var serialization = new Serialization() 56 * var serialization = new Serialization()
55 * ..addRule( 57 * ..addRule(
56 * new ClosureToMapRule(anAddress.runtimeType, 58 * new ClosureToMapRule(anAddress.runtimeType,
57 * addressToMap, createAddress, fillInAddress); 59 * addressToMap, createAddress, fillInAddress);
58 * 60 *
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 * use for this is if we are reading self-describing serialized data and 226 * use for this is if we are reading self-describing serialized data and
225 * will populate the rules from that data. 227 * will populate the rules from that data.
226 */ 228 */
227 Serialization.blank() { } 229 Serialization.blank() { }
228 230
229 /** 231 /**
230 * Create a [BasicRule] rule for the type of 232 * Create a [BasicRule] rule for the type of
231 * [instanceOfType]. Optionally 233 * [instanceOfType]. Optionally
232 * allows specifying a [constructor] name, the list of [constructorFields], 234 * allows specifying a [constructor] name, the list of [constructorFields],
233 * and the list of [fields] not used in the constructor. Returns the new 235 * and the list of [fields] not used in the constructor. Returns the new
234 * rule. 236 * rule. Note that [BasicRule] uses reflection, and so will not work with the
237 * current state of dartj2s. If you need to run there, consider using
238 * [CustomRule] instead.
235 * 239 *
236 * If the optional parameters aren't specified, the default constructor will 240 * If the optional parameters aren't specified, the default constructor will
237 * be used, and the list of fields will be computed. Alternatively, you can 241 * be used, and the list of fields will be computed. Alternatively, you can
238 * omit [fields] and provide [excludeFields], which will then compute the 242 * omit [fields] and provide [excludeFields], which will then compute the
239 * list of fields specifically excluding those listed. 243 * list of fields specifically excluding those listed.
240 * 244 *
241 * The fields can be actual public fields, but can also be getter/setter 245 * The fields can be actual public fields, but can also be getter/setter
242 * pairs or getters whose value is provided in the constructor. For the 246 * pairs or getters whose value is provided in the constructor. For the
243 * [constructorFields] they can also be arbitrary objects. Anything that is 247 * [constructorFields] they can also be arbitrary objects. Anything that is
244 * not a String will be treated as a constant value to be used in any 248 * not a String will be treated as a constant value to be used in any
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
427 } 431 }
428 } 432 }
429 433
430 /** 434 /**
431 * An exception class for errors during serialization. 435 * An exception class for errors during serialization.
432 */ 436 */
433 class SerializationException implements Exception { 437 class SerializationException implements Exception {
434 final String message; 438 final String message;
435 const SerializationException([this.message]); 439 const SerializationException([this.message]);
436 } 440 }
OLDNEW
« no previous file with comments | « no previous file | pkg/serialization/lib/src/reader_writer.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698