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

Side by Side Diff: sdk/lib/core/string.dart

Issue 11783009: Big merge from experimental to bleeding edge. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 11 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 | « sdk/lib/core/sink.dart ('k') | sdk/lib/core/string_buffer.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 part of dart.core; 5 part of dart.core;
6 6
7 /** 7 /**
8 * The String class represents character strings. Strings are 8 * The String class represents character strings. Strings are
9 * immutable. A string is represented by a list of 32-bit Unicode 9 * immutable. A string is represented by a list of 32-bit Unicode
10 * scalar character codes accessible through the [charCodeAt] or the 10 * scalar character codes accessible through the [charCodeAt] or the
11 * [charCodes] method. 11 * [charCodes] method.
12 */ 12 */
13 abstract class String implements Comparable, Pattern, Sequence<String> { 13 abstract class String implements Comparable, Pattern {
14 /** 14 /**
15 * Allocates a new String for the specified [charCodes]. 15 * Allocates a new String for the specified [charCodes].
16 */ 16 */
17 external factory String.fromCharCodes(List<int> charCodes); 17 external factory String.fromCharCodes(List<int> charCodes);
18 18
19 /** 19 /**
20 * Allocates a new String for the specified [charCode].
21 *
22 * The built string is of [length] one, if the [charCode] lies inside the
23 * basic multilingual plane (plane 0). Otherwise the [length] is 2 and
24 * the code units form a surrogate pair.
25 */
26 factory String.character(int charCode) {
27 List<int> charCodes = new List<int>.fixedLength(1, fill: charCode);
28 return new String.fromCharCodes(charCodes);
29 }
30
31 /**
20 * Gets the character (as [String]) at the given [index]. 32 * Gets the character (as [String]) at the given [index].
21 */ 33 */
22 String operator [](int index); 34 String operator [](int index);
23 35
24 /** 36 /**
25 * Gets the scalar character code at the given [index]. 37 * Gets the scalar character code at the given [index].
26 */ 38 */
27 int charCodeAt(int index); 39 int charCodeAt(int index);
28 40
29 /** 41 /**
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 * Returns whether this string is empty. 77 * Returns whether this string is empty.
66 */ 78 */
67 bool get isEmpty; 79 bool get isEmpty;
68 80
69 /** 81 /**
70 * Creates a new string by concatenating this string with [other]. 82 * Creates a new string by concatenating this string with [other].
71 */ 83 */
72 String concat(String other); 84 String concat(String other);
73 85
74 /** 86 /**
87 * Returns a slice of this string from [startIndex] to [endIndex].
88 *
89 * If [startIndex] is omitted, it defaults to the start of the string.
90 *
91 * If [endIndex] is omitted, it defaults to the end of the string.
92 *
93 * If either index is negative, it's taken as a negative index from the
94 * end of the string. Their effective value is computed by adding the
95 * negative value to the [length] of the string.
96 *
97 * The effective indices, after must be non-negative, no greater than the
98 * length of the string, and [endIndex] must not be less than [startIndex].
99 */
100 String slice([int startIndex, int endIndex]);
101
102 /**
75 * Returns a substring of this string in the given range. 103 * Returns a substring of this string in the given range.
76 * [startIndex] is inclusive and [endIndex] is exclusive. 104 * [startIndex] is inclusive and [endIndex] is exclusive.
77 */ 105 */
78 String substring(int startIndex, [int endIndex]); 106 String substring(int startIndex, [int endIndex]);
79 107
80 /** 108 /**
81 * Removes leading and trailing whitespace from a string. If the string 109 * Removes leading and trailing whitespace from a string. If the string
82 * contains leading or trailing whitespace a new string with no leading and 110 * contains leading or trailing whitespace a new string with no leading and
83 * no trailing whitespace is returned. Otherwise, the string itself is 111 * no trailing whitespace is returned. Otherwise, the string itself is
84 * returned. Whitespace is defined as every Unicode character in the Zs, Zl 112 * returned. Whitespace is defined as every Unicode character in the Zs, Zl
(...skipping 10 matching lines...) Expand all
95 bool contains(Pattern other, [int startIndex]); 123 bool contains(Pattern other, [int startIndex]);
96 124
97 /** 125 /**
98 * Returns a new string where the first occurence of [from] in this string 126 * Returns a new string where the first occurence of [from] in this string
99 * is replaced with [to]. 127 * is replaced with [to].
100 */ 128 */
101 String replaceFirst(Pattern from, String to); 129 String replaceFirst(Pattern from, String to);
102 130
103 /** 131 /**
104 * Returns a new string where all occurences of [from] in this string 132 * Returns a new string where all occurences of [from] in this string
105 * are replaced with [to]. 133 * are replaced with [replace].
106 */ 134 */
107 String replaceAll(Pattern from, String to); 135 String replaceAll(Pattern from, var replace);
136
137 /**
138 * Returns a new string where all occurences of [from] in this string
139 * are replaced with a [String] depending on [replace].
140 *
141 *
142 * The [replace] function is called with the [Match] generated
143 * by the pattern, and its result is used as replacement.
144 */
145 String replaceAllMapped(Pattern from, String replace(Match match));
108 146
109 /** 147 /**
110 * Splits the string around matches of [pattern]. Returns 148 * Splits the string around matches of [pattern]. Returns
111 * a list of substrings. 149 * a list of substrings.
112 */ 150 */
113 List<String> split(Pattern pattern); 151 List<String> split(Pattern pattern);
114 152
115 /** 153 /**
116 * Returns a list of the characters of this string. 154 * Returns a list of the characters of this string.
117 */ 155 */
118 List<String> splitChars(); 156 List<String> splitChars();
119 157
120 /** 158 /**
159 * Splits the string on the [pattern], then converts each part and each match.
160 *
161 * The pattern is used to split the string into parts and separating matches.
162 *
163 * Each match is converted to a string by calling [onMatch]. If [onMatch]
164 * is omitted, the matched string is used.
165 *
166 * Each non-matched part is converted by a call to [onNonMatch]. If
167 * [onNonMatch] is omitted, the non-matching part is used.
168 *
169 * Then all the converted parts are combined into the resulting string.
170 */
171 String splitMapJoin(Pattern pattern,
172 {String onMatch(Match match),
173 String onNonMatch(String nonMatch)});
174
175 /**
121 * Returns a list of the scalar character codes of this string. 176 * Returns a list of the scalar character codes of this string.
122 */ 177 */
123 List<int> get charCodes; 178 List<int> get charCodes;
124 179
125 /** 180 /**
126 * If this string is not already all lower case, returns a new string 181 * If this string is not already all lower case, returns a new string
127 * where all characters are made lower case. Returns [:this:] otherwise. 182 * where all characters are made lower case. Returns [:this:] otherwise.
128 */ 183 */
129 String toLowerCase(); 184 String toLowerCase();
130 185
131 /** 186 /**
132 * If this string is not already all uper case, returns a new string 187 * If this string is not already all uper case, returns a new string
133 * where all characters are made upper case. Returns [:this:] otherwise. 188 * where all characters are made upper case. Returns [:this:] otherwise.
134 */ 189 */
135 String toUpperCase(); 190 String toUpperCase();
136 } 191 }
OLDNEW
« no previous file with comments | « sdk/lib/core/sink.dart ('k') | sdk/lib/core/string_buffer.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698