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

Side by Side Diff: pkg/analyzer-experimental/lib/src/generated/java_core.dart

Issue 12838003: Rename analyzer-experimental to analyzer_experimental. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 9 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
OLDNEW
(Empty)
1 library java.core;
2
3 import "dart:math" as math;
4 import "dart:uri";
5
6 class JavaSystem {
7 static int currentTimeMillis() {
8 return (new DateTime.now()).millisecondsSinceEpoch;
9 }
10
11 static void arraycopy(List src, int srcPos, List dest, int destPos, int length ) {
12 for (int i = 0; i < length; i++) {
13 dest[destPos + i] = src[srcPos + i];
14 }
15 }
16 }
17
18 /**
19 * Limited implementation of "o is instanceOfType", see
20 * http://code.google.com/p/dart/issues/detail?id=8184
21 */
22 bool isInstanceOf(o, Type t) {
23 if (o == null) {
24 return false;
25 }
26 if (o.runtimeType == t) {
27 return true;
28 }
29 String oTypeName = o.runtimeType.toString();
30 String tTypeName = t.toString();
31 if (oTypeName == tTypeName) {
32 return true;
33 }
34 if (oTypeName.startsWith("HashMap") && tTypeName == "Map") {
35 return true;
36 }
37 if (oTypeName.startsWith("List") && tTypeName == "List") {
38 return true;
39 }
40 // Dart Analysis Engine specific
41 if (oTypeName == "${tTypeName}Impl") {
42 return true;
43 }
44 if (tTypeName == "ExecutableElement") {
45 if (oTypeName == "MethodElementImpl" || oTypeName == "FunctionElementImpl") {
46 return true;
47 }
48 }
49 // no
50 return false;
51 }
52
53 class JavaArrays {
54 static bool equals(List a, List b) {
55 if (a.length != b.length) {
56 return false;
57 }
58 var len = a.length;
59 for (int i = 0; i < len; i++) {
60 if (a[i] != b[i]) {
61 return false;
62 }
63 }
64 return true;
65 }
66 static int makeHashCode(List a) {
67 if (a == null) {
68 return 0;
69 }
70 int result = 1;
71 for (var element in a) {
72 result = 31 * result + (element == null ? 0 : element.hashCode);
73 }
74 return result;
75 }
76 static List asList(List list) => list;
77 }
78
79 class Character {
80 static const int MAX_VALUE = 0xffff;
81 static const int MAX_CODE_POINT = 0x10ffff;
82 static bool isLetter(int c) {
83 return c >= 0x41 && c <= 0x5A || c >= 0x61 && c <= 0x7A;
84 }
85 static bool isLetterOrDigit(int c) {
86 return isLetter(c) || c >= 0x30 && c <= 0x39;
87 }
88 static bool isWhitespace(int c) {
89 return c == 0x09 || c == 0x20 || c == 0x0A || c == 0x0D;
90 }
91 static int digit(int codePoint, int radix) {
92 if (radix != 16) {
93 throw new ArgumentError("only radix == 16 is supported");
94 }
95 if (0x30 <= codePoint && codePoint <= 0x39) {
96 return codePoint - 0x30;
97 }
98 if (0x41 <= codePoint && codePoint <= 0x46) {
99 return 0xA + (codePoint - 0x41);
100 }
101 if (0x61 <= codePoint && codePoint <= 0x66) {
102 return 0xA + (codePoint - 0x61);
103 }
104 return -1;
105 }
106 static String toChars(int codePoint) {
107 throw new UnsupportedOperationException();
108 }
109 }
110
111 class CharBuffer {
112 final String _content;
113 CharBuffer(this._content);
114 static CharBuffer wrap(String content) => new CharBuffer(content);
115 int charAt(int index) => _content.codeUnitAt(index);
116 int length() => _content.length;
117 String subSequence(int start, int end) => _content.substring(start, end);
118 }
119
120 class JavaString {
121 static String format(String fmt, List args) {
122 return fmt;
123 }
124 }
125
126 /**
127 * Very limited printf implementation, supports only %s and %d.
128 */
129 String _printf(String fmt, List args) {
130 StringBuffer sb = new StringBuffer();
131 bool markFound = false;
132 int argIndex = 0;
133 for (int i = 0; i < fmt.length; i++) {
134 int c = fmt.codeUnitAt(i);
135 if (c == 0x25) {
136 if (markFound) {
137 sb.writeCharCode(c);
138 markFound = false;
139 } else {
140 markFound = true;
141 }
142 continue;
143 }
144 if (markFound) {
145 markFound = false;
146 // %d
147 if (c == 0x64) {
148 sb.writeCharCode(args[argIndex++]);
149 continue;
150 }
151 // %s
152 if (c == 0x73) {
153 sb.writeCharCode(args[argIndex++]);
154 continue;
155 }
156 // unknown
157 throw new IllegalArgumentException('[$fmt][$i] = 0x${c.toRadixString(16)}' );
158 } else {
159 sb.writeCharCode(c);
160 }
161 }
162 return sb.toString();
163 }
164
165 abstract class PrintWriter {
166 void print(x);
167
168 void println() {
169 this.print('\n');
170 }
171
172 void printlnObject(String s) {
173 this.print(s);
174 this.println();
175 }
176
177 void printf(String fmt, List args) {
178 this.print(_printf(fmt, args));
179 }
180 }
181
182 class PrintStringWriter extends PrintWriter {
183 final StringBuffer _sb = new StringBuffer();
184
185 void print(x) {
186 _sb.write(x);
187 }
188
189 String toString() => _sb.toString();
190 }
191
192 class StringUtils {
193 static List<String> split(String s, String pattern) => s.split(pattern);
194 static String replace(String s, String from, String to) => s.replaceAll(from, to);
195 static String repeat(String s, int n) {
196 StringBuffer sb = new StringBuffer();
197 for (int i = 0; i < n; i++) {
198 sb.write(s);
199 }
200 return sb.toString();
201 }
202 }
203
204 class Math {
205 static num max(num a, num b) => math.max(a, b);
206 static num min(num a, num b) => math.min(a, b);
207 }
208
209 class RuntimeException implements Exception {
210 String toString() => "RuntimeException";
211 }
212
213 class JavaException implements Exception {
214 final String message;
215 final Exception e;
216 JavaException([this.message = "", this.e = null]);
217 JavaException.withCause(this.e) : message = null;
218 String toString() => "JavaException: $message $e";
219 }
220
221 class IllegalArgumentException implements Exception {
222 final String message;
223 const IllegalArgumentException([this.message = "", Exception e = null]);
224 String toString() => "IllegalStateException: $message";
225 }
226
227 class StringIndexOutOfBoundsException implements Exception {
228 final int index;
229 const StringIndexOutOfBoundsException(this.index);
230 String toString() => "StringIndexOutOfBoundsException: $index";
231 }
232
233 class IllegalStateException implements Exception {
234 final String message;
235 const IllegalStateException([this.message = ""]);
236 String toString() => "IllegalStateException: $message";
237 }
238
239 class UnsupportedOperationException implements Exception {
240 String toString() => "UnsupportedOperationException";
241 }
242
243 class NumberFormatException implements Exception {
244 String toString() => "NumberFormatException";
245 }
246
247 class URISyntaxException implements Exception {
248 String toString() => "URISyntaxException";
249 }
250
251 class IOException implements Exception {
252 String toString() => "IOException";
253 }
254
255 class ListWrapper<E> extends Collection<E> implements List<E> {
256 List<E> elements = new List<E>();
257
258 Iterator<E> get iterator {
259 return elements.iterator;
260 }
261
262 E operator [](int index) {
263 return elements[index];
264 }
265
266 void operator []=(int index, E value) {
267 elements[index] = value;
268 }
269
270 void set length(int newLength) {
271 elements.length = newLength;
272 }
273
274 void add(E value) {
275 elements.add(value);
276 }
277
278 void addLast(E value) {
279 elements.add(value);
280 }
281
282 void addAll(Iterable<E> iterable) {
283 elements.addAll(iterable);
284 }
285
286 void sort([int compare(E a, E b)]) {
287 elements.sort(compare);
288 }
289
290 int indexOf(E element, [int start = 0]) {
291 return elements.indexOf(element, start);
292 }
293
294 int lastIndexOf(E element, [int start]) {
295 return elements.lastIndexOf(element, start);
296 }
297
298 void clear() {
299 elements.clear();
300 }
301
302 void remove(Object element) {
303 return elements.remove(element);
304 }
305
306 E removeAt(int index) {
307 return elements.removeAt(index);
308 }
309
310 E removeLast() {
311 return elements.removeLast();
312 }
313
314 Iterable<E> get reversed => elements.reversed;
315
316 List<E> getRange(int start, int length) {
317 return elements.getRange(start, length);
318 }
319
320 void setRange(int start, int length, List<E> from, [int startFrom]) {
321 elements.setRange(start, length, from, startFrom);
322 }
323
324 void removeRange(int start, int length) {
325 elements.removeRange(start, length);
326 }
327
328 void insertRange(int start, int length, [E fill]) {
329 elements.insertRange(start, length, fill);
330 }
331
332 Map<int, E> asMap() {
333 return elements.asMap();
334 }
335 }
336
337 class JavaIterator<E> {
338 Collection<E> _collection;
339 List<E> _elements = new List<E>();
340 int _coPos = 0;
341 int _elPos = 0;
342 E _current = null;
343 JavaIterator(this._collection) {
344 Iterator iterator = _collection.iterator;
345 while (iterator.moveNext()) {
346 _elements.add(iterator.current);
347 }
348 }
349
350 bool get hasNext {
351 return _elPos < _elements.length;
352 }
353
354 E next() {
355 _current = _elements[_elPos];
356 _coPos++;
357 _elPos++;
358 return _current;
359 }
360
361 void remove() {
362 if (_collection is List) {
363 _coPos--;
364 (_collection as List).remove(_coPos);
365 } else if (_collection is Set) {
366 _collection.remove(_current);
367 } else {
368 throw new StateError("Unsupported collection ${_collection.runtimeType}");
369 }
370 }
371 }
372
373 class MapEntry<K, V> {
374 K _key;
375 V _value;
376 MapEntry(this._key, this._value);
377 K getKey() => _key;
378 V getValue() => _value;
379 }
380
381 Set<MapEntry> getMapEntrySet(Map m) {
382 Set<MapEntry> result = new Set();
383 m.forEach((k, v) {
384 result.add(new MapEntry(k, v));
385 });
386 return result;
387 }
388
389 bool javaSetAdd(Set s, o) {
390 if (!s.contains(o)) {
391 s.add(o);
392 return true;
393 }
394 return false;
395 }
396
397 void javaMapPutAll(Map target, Map source) {
398 source.forEach((k, v) {
399 target[k] = v;
400 });
401 }
402
403 bool javaStringEqualsIgnoreCase(String a, String b) {
404 return a.toLowerCase() == b.toLowerCase();
405 }
406
407 class JavaStringBuilder {
408 StringBuffer sb = new StringBuffer();
409 String toString() => sb.toString();
410 void append(x) {
411 sb.write(x);
412 }
413 void appendChar(int c) {
414 sb.writeCharCode(c);
415 }
416 int get length => sb.length;
417 void set length(int newLength) {
418 if (newLength < 0) {
419 throw new StringIndexOutOfBoundsException(newLength);
420 }
421 if (sb.length < newLength) {
422 while (sb.length < newLength) {
423 sb.writeCharCode(0);
424 }
425 } else if (sb.length > newLength) {
426 var s = sb.toString().substring(0, newLength);
427 sb = new StringBuffer(s);
428 }
429 }
430 void clear() {
431 sb = new StringBuffer();
432 }
433 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698