OLD | NEW |
1 library java.core; | 1 library java.core; |
2 | 2 |
3 const int LONG_MAX_VALUE = 0x7fffffffffffffff; | 3 const int LONG_MAX_VALUE = 0x7fffffffffffffff; |
4 | 4 |
5 final Stopwatch nanoTimeStopwatch = new Stopwatch(); | 5 final Stopwatch nanoTimeStopwatch = new Stopwatch(); |
6 | 6 |
7 /** | 7 /** |
8 * Inserts the given arguments into [pattern]. | 8 * Inserts the given arguments into [pattern]. |
9 * | 9 * |
10 * format('Hello, {0}!', 'John') = 'Hello, John!' | 10 * format('Hello, {0}!', 'John') = 'Hello, John!' |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 return codePoint - 0x30; | 134 return codePoint - 0x30; |
135 } | 135 } |
136 if (0x41 <= codePoint && codePoint <= 0x46) { | 136 if (0x41 <= codePoint && codePoint <= 0x46) { |
137 return 0xA + (codePoint - 0x41); | 137 return 0xA + (codePoint - 0x41); |
138 } | 138 } |
139 if (0x61 <= codePoint && codePoint <= 0x66) { | 139 if (0x61 <= codePoint && codePoint <= 0x66) { |
140 return 0xA + (codePoint - 0x61); | 140 return 0xA + (codePoint - 0x61); |
141 } | 141 } |
142 return -1; | 142 return -1; |
143 } | 143 } |
| 144 |
144 static bool isDigit(int c) { | 145 static bool isDigit(int c) { |
145 return c >= 0x30 && c <= 0x39; | 146 return c >= 0x30 && c <= 0x39; |
146 } | 147 } |
| 148 |
147 static bool isLetter(int c) { | 149 static bool isLetter(int c) { |
148 return c >= 0x41 && c <= 0x5A || c >= 0x61 && c <= 0x7A; | 150 return c >= 0x41 && c <= 0x5A || c >= 0x61 && c <= 0x7A; |
149 } | 151 } |
| 152 |
150 static bool isLetterOrDigit(int c) { | 153 static bool isLetterOrDigit(int c) { |
151 return isLetter(c) || isDigit(c); | 154 return isLetter(c) || isDigit(c); |
152 } | 155 } |
| 156 |
153 static bool isLowerCase(int c) { | 157 static bool isLowerCase(int c) { |
154 return c >= 0x61 && c <= 0x7A; | 158 return c >= 0x61 && c <= 0x7A; |
155 } | 159 } |
| 160 |
156 static bool isUpperCase(int c) { | 161 static bool isUpperCase(int c) { |
157 return c >= 0x41 && c <= 0x5A; | 162 return c >= 0x41 && c <= 0x5A; |
158 } | 163 } |
| 164 |
159 static bool isWhitespace(int c) { | 165 static bool isWhitespace(int c) { |
160 return c == 0x09 || c == 0x20 || c == 0x0A || c == 0x0D; | 166 return c == 0x09 || c == 0x20 || c == 0x0A || c == 0x0D; |
161 } | 167 } |
| 168 |
162 static String toChars(int codePoint) { | 169 static String toChars(int codePoint) { |
163 if (codePoint < 0 || codePoint > MAX_CODE_POINT) { | 170 if (codePoint < 0 || codePoint > MAX_CODE_POINT) { |
164 throw new IllegalArgumentException(); | 171 throw new IllegalArgumentException(); |
165 } | 172 } |
166 if (codePoint < MIN_SUPPLEMENTARY_CODE_POINT) { | 173 if (codePoint < MIN_SUPPLEMENTARY_CODE_POINT) { |
167 return new String.fromCharCode(codePoint); | 174 return new String.fromCharCode(codePoint); |
168 } | 175 } |
169 int offset = codePoint - MIN_SUPPLEMENTARY_CODE_POINT; | 176 int offset = codePoint - MIN_SUPPLEMENTARY_CODE_POINT; |
170 int c0 = ((offset & 0x7FFFFFFF) >> 10) + MIN_HIGH_SURROGATE; | 177 int c0 = ((offset & 0x7FFFFFFF) >> 10) + MIN_HIGH_SURROGATE; |
171 int c1 = (offset & 0x3ff) + MIN_LOW_SURROGATE; | 178 int c1 = (offset & 0x3ff) + MIN_LOW_SURROGATE; |
172 return new String.fromCharCodes([c0, c1]); | 179 return new String.fromCharCodes([c0, c1]); |
173 } | 180 } |
| 181 |
174 static int toLowerCase(int c) { | 182 static int toLowerCase(int c) { |
175 if (c >= 0x41 && c <= 0x5A) { | 183 if (c >= 0x41 && c <= 0x5A) { |
176 return 0x61 + (c - 0x41); | 184 return 0x61 + (c - 0x41); |
177 } | 185 } |
178 return c; | 186 return c; |
179 } | 187 } |
| 188 |
180 static int toUpperCase(int c) { | 189 static int toUpperCase(int c) { |
181 if (c >= 0x61 && c <= 0x7A) { | 190 if (c >= 0x61 && c <= 0x7A) { |
182 return 0x41 + (c - 0x61); | 191 return 0x41 + (c - 0x61); |
183 } | 192 } |
184 return c; | 193 return c; |
185 } | 194 } |
186 } | 195 } |
187 | 196 |
188 abstract class Enum<E extends Enum> implements Comparable<E> { | 197 abstract class Enum<E extends Enum> implements Comparable<E> { |
189 /// The name of this enum constant, as declared in the enum declaration. | 198 /// The name of this enum constant, as declared in the enum declaration. |
190 final String name; | 199 final String name; |
| 200 |
191 /// The position in the enum declaration. | 201 /// The position in the enum declaration. |
192 final int ordinal; | 202 final int ordinal; |
193 const Enum(this.name, this.ordinal); | 203 const Enum(this.name, this.ordinal); |
194 int get hashCode => ordinal; | 204 int get hashCode => ordinal; |
195 int compareTo(E other) => ordinal - other.ordinal; | 205 int compareTo(E other) => ordinal - other.ordinal; |
196 String toString() => name; | 206 String toString() => name; |
197 } | 207 } |
198 | 208 |
199 class IllegalArgumentException extends JavaException { | 209 class IllegalArgumentException extends JavaException { |
200 IllegalArgumentException([message = "", cause = null]) | 210 IllegalArgumentException([message = "", cause = null]) |
(...skipping 13 matching lines...) Expand all Loading... |
214 return false; | 224 return false; |
215 } | 225 } |
216 var len = a.length; | 226 var len = a.length; |
217 for (int i = 0; i < len; i++) { | 227 for (int i = 0; i < len; i++) { |
218 if (a[i] != b[i]) { | 228 if (a[i] != b[i]) { |
219 return false; | 229 return false; |
220 } | 230 } |
221 } | 231 } |
222 return true; | 232 return true; |
223 } | 233 } |
| 234 |
224 static int makeHashCode(List a) { | 235 static int makeHashCode(List a) { |
225 if (a == null) { | 236 if (a == null) { |
226 return 0; | 237 return 0; |
227 } | 238 } |
228 int result = 1; | 239 int result = 1; |
229 for (var element in a) { | 240 for (var element in a) { |
230 result = 31 * result + (element == null ? 0 : element.hashCode); | 241 result = 31 * result + (element == null ? 0 : element.hashCode); |
231 } | 242 } |
232 return result; | 243 return result; |
233 } | 244 } |
(...skipping 18 matching lines...) Expand all Loading... |
252 _matches = re.allMatches(input).iterator; | 263 _matches = re.allMatches(input).iterator; |
253 } | 264 } |
254 int end() => _match.end; | 265 int end() => _match.end; |
255 bool find() { | 266 bool find() { |
256 if (!_matches.moveNext()) { | 267 if (!_matches.moveNext()) { |
257 return false; | 268 return false; |
258 } | 269 } |
259 _match = _matches.current; | 270 _match = _matches.current; |
260 return true; | 271 return true; |
261 } | 272 } |
| 273 |
262 String group(int i) => _match[i]; | 274 String group(int i) => _match[i]; |
263 bool matches() => find(); | 275 bool matches() => find(); |
264 int start() => _match.start; | 276 int start() => _match.start; |
265 } | 277 } |
266 | 278 |
267 class JavaString { | 279 class JavaString { |
268 static int indexOf(String target, String str, int fromIndex) { | 280 static int indexOf(String target, String str, int fromIndex) { |
269 if (fromIndex > target.length) return -1; | 281 if (fromIndex > target.length) return -1; |
270 if (fromIndex < 0) fromIndex = 0; | 282 if (fromIndex < 0) fromIndex = 0; |
271 return target.indexOf(str, fromIndex); | 283 return target.indexOf(str, fromIndex); |
272 } | 284 } |
| 285 |
273 static int lastIndexOf(String target, String str, int fromIndex) { | 286 static int lastIndexOf(String target, String str, int fromIndex) { |
274 if (fromIndex > target.length) return -1; | 287 if (fromIndex > target.length) return -1; |
275 if (fromIndex < 0) fromIndex = 0; | 288 if (fromIndex < 0) fromIndex = 0; |
276 return target.lastIndexOf(str, fromIndex); | 289 return target.lastIndexOf(str, fromIndex); |
277 } | 290 } |
| 291 |
278 static bool startsWithBefore(String s, String other, int start) { | 292 static bool startsWithBefore(String s, String other, int start) { |
279 return s.indexOf(other, start) != -1; | 293 return s.indexOf(other, start) != -1; |
280 } | 294 } |
281 } | 295 } |
282 | 296 |
283 class JavaSystem { | 297 class JavaSystem { |
284 @deprecated | 298 @deprecated |
285 static void arraycopy( | 299 static void arraycopy( |
286 List src, int srcPos, List dest, int destPos, int length) { | 300 List src, int srcPos, List dest, int destPos, int length) { |
287 for (int i = 0; i < length; i++) { | 301 for (int i = 0; i < length; i++) { |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
431 | 445 |
432 class UnsupportedOperationException extends JavaException { | 446 class UnsupportedOperationException extends JavaException { |
433 UnsupportedOperationException([message = ""]) : super(message); | 447 UnsupportedOperationException([message = ""]) : super(message); |
434 } | 448 } |
435 | 449 |
436 class URISyntaxException implements Exception { | 450 class URISyntaxException implements Exception { |
437 final String message; | 451 final String message; |
438 URISyntaxException(this.message); | 452 URISyntaxException(this.message); |
439 String toString() => "URISyntaxException: $message"; | 453 String toString() => "URISyntaxException: $message"; |
440 } | 454 } |
OLD | NEW |