This commit was manufactured by cvs2svn to create tag 'buildscript'.
[IRC.git] /
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 {
44         cont=false;
45       }
46       if (cont) {
47         if (val>=radix)
48           System.error();
49         value=value*radix+val;
50       }
51     }
52     if (isNeg)
53       value=-value;
54     return value;
55   }
56
57   public String toString() {
58     return String.valueOf(value);
59   }
60   
61   public int hashCode() {
62       return value;
63   }
64
65   public boolean equals(Object o) {
66       if (o.getType()!=getType())
67           return false;
68       Integer s=(Integer)o;
69       if (s.intValue()!=this.value)
70           return false;
71       return true;
72   }
73 }