| 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 * The StringBuffer class is useful for concatenating strings | 8 * The StringBuffer class is useful for concatenating strings |
| 9 * efficiently. Only on a call to [toString] are the strings | 9 * efficiently. Only on a call to [toString] are the strings |
| 10 * concatenated to a single String. | 10 * concatenated to a single String. |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 | 25 |
| 26 /// Adds the contents of [obj], converted to a string, to the buffer. | 26 /// Adds the contents of [obj], converted to a string, to the buffer. |
| 27 external void write(Object obj); | 27 external void write(Object obj); |
| 28 | 28 |
| 29 /// Adds the string representation of [charCode] to the buffer. | 29 /// Adds the string representation of [charCode] to the buffer. |
| 30 external void writeCharCode(int charCode); | 30 external void writeCharCode(int charCode); |
| 31 | 31 |
| 32 void writeAll(Iterable objects, [String separator = ""]) { | 32 void writeAll(Iterable objects, [String separator = ""]) { |
| 33 Iterator iterator = objects.iterator; | 33 Iterator iterator = objects.iterator; |
| 34 if (!iterator.moveNext()) return; | 34 if (!iterator.moveNext()) return; |
| 35 if (separator == "") { | 35 if (separator.isEmpty) { |
| 36 do { | 36 do { |
| 37 write(iterator.current); | 37 write(iterator.current); |
| 38 } while (iterator.moveNext()); | 38 } while (iterator.moveNext()); |
| 39 } else { | 39 } else { |
| 40 write(iterator.current); | 40 write(iterator.current); |
| 41 while (iterator.moveNext()) { | 41 while (iterator.moveNext()) { |
| 42 write(separator); | 42 write(separator); |
| 43 write(iterator.current); | 43 write(iterator.current); |
| 44 } | 44 } |
| 45 } | 45 } |
| 46 } | 46 } |
| 47 | 47 |
| 48 void writeln([Object obj = ""]) { | 48 void writeln([Object obj = ""]) { |
| 49 write(obj); | 49 write(obj); |
| 50 write("\n"); | 50 write("\n"); |
| 51 } | 51 } |
| 52 | 52 |
| 53 /** | 53 /** |
| 54 * Clears the string buffer. | 54 * Clears the string buffer. |
| 55 */ | 55 */ |
| 56 external void clear(); | 56 external void clear(); |
| 57 | 57 |
| 58 /// Returns the contents of buffer as a concatenated string. | 58 /// Returns the contents of buffer as a concatenated string. |
| 59 external String toString(); | 59 external String toString(); |
| 60 } | 60 } |
| OLD | NEW |