changes + add two more benchmarks without annotations
[IRC.git] / Robust / src / ClassLibrary / Character.java
index 1febbc3c4458e2423cafdf1752b61c8b3480aff8..3e412818cd6e449929b9438849e38b1683595bbc 100644 (file)
@@ -6,15 +6,24 @@ public class Character {
     else if (ch>='a'&&ch<='z') {
       int val=(ch-'a')+10;
       if (val<radix)
-       return val;
+        return val;
     } else if (ch>='A'&&ch<='Z') {
       int val=(ch-'A')+10;
       if (val<radix)
-       return val;
+        return val;
     }
     return -1;
   }
 
+  public static boolean isDigit(char ch) {
+    // TODO This is a temparory implementation, there are other groups of digits
+    // besides '0' ~ '9'
+    if (ch>='0'&&ch<='9')
+      return true;
+    else
+      return false;
+  }
+
   char value;
 
   public Character(char c) {
@@ -45,4 +54,20 @@ public class Character {
     }
     return returnValue;
   }
+
+  public static final int MIN_RADIX = 2;
+  public static final int MAX_RADIX = 36;
+
+  public static char forDigit(int digit, int radix) {
+    if ((digit >= radix) || (digit < 0)) {
+      return '\0';
+    }
+    if ((radix < Character.MIN_RADIX) || (radix > Character.MAX_RADIX)) {
+      return '\0';
+    }
+    if (digit < 10) {
+      return (char)('0' + digit);
+    }
+    return (char)('a' - 10 + digit);
+  }
 }