start of new file
[IRC.git] / Robust / src / ClassLibrary / String.java
index 4ad4b7c97af2ebeaddc16b06dbe642413e05e268..f1ec9d53c2cc76fd5f17c3cab0a3ae6b8fcc0c30 100644 (file)
@@ -25,6 +25,17 @@ public class String {
        this.offset=0;
     }
 
+    public String(byte str[], int offset, int length) {
+       if (length>(str.length-offset))
+           length=str.length-offset;
+       char charstr[]=new char[length];
+       for(int i=0;i<length;i++)
+           charstr[i]=(char)str[i+offset];
+       this.value=charstr;
+       this.count=length;
+       this.offset=0;
+    }
+
     public String(String str) {
        this.value=str.value;
        this.count=str.count;
@@ -56,6 +67,7 @@ public class String {
        String str=new String();
        if (beginIndex>this.count||endIndex>this.count||beginIndex>endIndex) {
            // FIXME
+           System.printString("Index error: "+beginIndex+" "+endIndex+" "+count+"\n"+this);
        }
        str.value=this.value;
        str.count=endIndex-beginIndex;
@@ -152,7 +164,7 @@ public class String {
        if (k>fromIndex)
            k=fromIndex;
        for(;k>=0;k--) {
-           if (regionMatches(fromIndex, str, 0, str.count))
+           if (regionMatches(k, str, 0, str.count))
                return k;
        }
        return -1;
@@ -213,6 +225,13 @@ public class String {
            return o.toString();
     }
 
+    public static String valueOf(boolean b) {
+       if (b)
+           return new String("true");
+       else
+           return new String("false");
+    }
+
     public static String valueOf(char c) {
        char ar[]=new char[1];
        ar[0]=c;