blob: f14df1831f6653ccea17a935e1351cb2444c5416 [file] [log] [blame]
Elliott Hughes0f4c41d2011-09-04 14:58:03 -07001/*
2 * Copyright (C) 2011 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17class SystemMethods {
18 public static int test0() {
19 System.logI("hello world");
20 return 123;
21 }
22
23 public static int test1() {
24 String[] digits = new String[] {
25 "0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f",
26 };
27 System.logI("hello world");
28 long t = System.currentTimeMillis();
29 for (int i = 7; i >= 0; --i) {
30 int b = ((int) (t >> (i * 8))) & 0xff;
31 System.logI(digits[(b >> 4) & 0xf]);
32 System.logI(digits[b & 0xf]);
33 }
34 return 123;
35 }
36
37 public static int test2() {
38 System.logI("creating char[]...");
39 char[] cs = new char[20];
40 System.logI("...created char[]");
41 String[] digits = new String[] {
42 "0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f",
43 };
44 long t = System.currentTimeMillis();
45 System.logI("creating StringBuilder...");
46 StringBuilder sb = new StringBuilder(20);
47 System.logI("...created StringBuilder");
48 for (int i = 7; i >= 0; --i) {
49 int b = ((int) (t >> (i * 8))) & 0xff;
50 // TODO: StringBuilder.append(C) works, but StringBuilder.append(Ljava/lang/String;) doesn't.
51 System.logI("calling append...");
52 sb.append(digits[(b >> 4) & 0xf].charAt(0));
53 System.logI("...called append");
54 System.logI("calling append...");
55 sb.append(digits[b & 0xf].charAt(0));
56 System.logI("...called append");
57 }
58 System.logI("calling toString...");
59 String result = sb.toString();
60 System.logI("...called toString");
61 System.logI(result);
62 return 123;
63 }
64}