| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 part of dart.core; | 5 part of dart.core; |
| 6 | 6 |
| 7 /** | 7 /** |
| 8 * A class for concatenating strings efficiently. | 8 * A class for concatenating strings efficiently. |
| 9 * | 9 * |
| 10 * Allows for the incremental building of a string using write*() methods. | 10 * Allows for the incremental building of a string using write*() methods. |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 * operation. | 30 * operation. |
| 31 */ | 31 */ |
| 32 bool get isNotEmpty => !isEmpty; | 32 bool get isNotEmpty => !isEmpty; |
| 33 | 33 |
| 34 /// Adds the contents of [obj], converted to a string, to the buffer. | 34 /// Adds the contents of [obj], converted to a string, to the buffer. |
| 35 external void write(Object obj); | 35 external void write(Object obj); |
| 36 | 36 |
| 37 /// Adds the string representation of [charCode] to the buffer. | 37 /// Adds the string representation of [charCode] to the buffer. |
| 38 external void writeCharCode(int charCode); | 38 external void writeCharCode(int charCode); |
| 39 | 39 |
| 40 void writeAll(Iterable objects, [String separator = ""]) { | 40 external void writeAll(Iterable objects, [String separator = ""]); |
| 41 Iterator iterator = objects.iterator; | |
| 42 if (!iterator.moveNext()) return; | |
| 43 if (separator.isEmpty) { | |
| 44 do { | |
| 45 write(iterator.current); | |
| 46 } while (iterator.moveNext()); | |
| 47 } else { | |
| 48 write(iterator.current); | |
| 49 while (iterator.moveNext()) { | |
| 50 write(separator); | |
| 51 write(iterator.current); | |
| 52 } | |
| 53 } | |
| 54 } | |
| 55 | 41 |
| 56 void writeln([Object obj = ""]) { | 42 external void writeln([Object obj = ""]); |
| 57 write(obj); | |
| 58 write("\n"); | |
| 59 } | |
| 60 | 43 |
| 61 /** | 44 /** |
| 62 * Clears the string buffer. | 45 * Clears the string buffer. |
| 63 */ | 46 */ |
| 64 external void clear(); | 47 external void clear(); |
| 65 | 48 |
| 66 /// Returns the contents of buffer as a concatenated string. | 49 /// Returns the contents of buffer as a concatenated string. |
| 67 external String toString(); | 50 external String toString(); |
| 68 } | 51 } |
| OLD | NEW |