remove some codes for scheduling
[IRC.git] / Robust / src / ClassLibrary / Integer.java
1 public class Integer {
2     private int value;
3
4     public Integer(int value) {
5         this.value=value;
6     }
7
8     public Integer(String str) {
9         value=Integer.parseInt(str, 10);
10     }
11
12     public int intValue() {
13         return value;
14     }
15
16     public static int parseInt(String str) {
17         return Integer.parseInt(str, 10);
18     }
19
20     public static int parseInt(String str, int radix) {
21         int value=0;
22         boolean isNeg=false;
23         int start=0;
24         byte[] chars=str.getBytes();
25
26         while(chars[start]==' '||chars[start]=='\t')
27             start++;
28
29         if (chars[start]=='-') {
30             isNeg=true;
31             start++;
32         }
33         boolean cont=true;
34         for(int i=start;cont&&i<str.length();i++) {
35             byte b=chars[i];
36             int val;
37             if (b>='0'&&b<='9')
38                 val=b-'0';
39             else if (b>='a'&&b<='z')
40                 val=10+b-'a';
41             else if (b>='A'&&b<='Z')
42                 val=10+b-'A';
43             else cont=false;
44             if (cont) {
45                 if (val>=radix)
46                     System.error();
47                 value=value*radix+val;
48             }
49         }
50         if (isNeg)
51             value=-value;
52         return value;
53     }
54
55     public String toString() {
56         return String.valueOf(value);
57     }
58 }