emul/mini/src/main/java/java/lang/AbstractStringBuilder.java
branchemul
changeset 560 53fafe384803
parent 554 05224402145d
     1.1 --- a/emul/mini/src/main/java/java/lang/AbstractStringBuilder.java	Wed Jan 23 20:39:23 2013 +0100
     1.2 +++ b/emul/mini/src/main/java/java/lang/AbstractStringBuilder.java	Wed Jan 23 22:55:28 2013 +0100
     1.3 @@ -25,6 +25,8 @@
     1.4  
     1.5  package java.lang;
     1.6  
     1.7 +import org.apidesign.bck2brwsr.emul.lang.System;
     1.8 +
     1.9  /**
    1.10   * A mutable sequence of characters.
    1.11   * <p>
    1.12 @@ -350,7 +352,7 @@
    1.13              throw new StringIndexOutOfBoundsException(srcEnd);
    1.14          if (srcBegin > srcEnd)
    1.15              throw new StringIndexOutOfBoundsException("srcBegin > srcEnd");
    1.16 -        arraycopy(value, srcBegin, dst, dstBegin, srcEnd - srcBegin);
    1.17 +        System.arraycopy(value, srcBegin, dst, dstBegin, srcEnd - srcBegin);
    1.18      }
    1.19  
    1.20      /**
    1.21 @@ -500,7 +502,7 @@
    1.22      public AbstractStringBuilder append(char[] str) {
    1.23          int len = str.length;
    1.24          ensureCapacityInternal(count + len);
    1.25 -        arraycopy(str, 0, value, count, len);
    1.26 +        System.arraycopy(str, 0, value, count, len);
    1.27          count += len;
    1.28          return this;
    1.29      }
    1.30 @@ -530,7 +532,7 @@
    1.31      public AbstractStringBuilder append(char str[], int offset, int len) {
    1.32          if (len > 0)                // let arraycopy report AIOOBE for len < 0
    1.33              ensureCapacityInternal(count + len);
    1.34 -        arraycopy(str, offset, value, count, len);
    1.35 +        System.arraycopy(str, offset, value, count, len);
    1.36          count += len;
    1.37          return this;
    1.38      }
    1.39 @@ -683,7 +685,7 @@
    1.40              throw new StringIndexOutOfBoundsException();
    1.41          int len = end - start;
    1.42          if (len > 0) {
    1.43 -            arraycopy(value, start+len, value, start, count-end);
    1.44 +            System.arraycopy(value, start+len, value, start, count-end);
    1.45              count -= len;
    1.46          }
    1.47          return this;
    1.48 @@ -745,7 +747,7 @@
    1.49      public AbstractStringBuilder deleteCharAt(int index) {
    1.50          if ((index < 0) || (index >= count))
    1.51              throw new StringIndexOutOfBoundsException(index);
    1.52 -        arraycopy(value, index+1, value, index, count-index-1);
    1.53 +        System.arraycopy(value, index+1, value, index, count-index-1);
    1.54          count--;
    1.55          return this;
    1.56      }
    1.57 @@ -783,7 +785,7 @@
    1.58          int newCount = count + len - (end - start);
    1.59          ensureCapacityInternal(newCount);
    1.60  
    1.61 -        arraycopy(value, end, value, start + len, count - end);
    1.62 +        System.arraycopy(value, end, value, start + len, count - end);
    1.63          str.getChars(value, start);
    1.64          count = newCount;
    1.65          return this;
    1.66 @@ -889,8 +891,8 @@
    1.67                  "offset " + offset + ", len " + len + ", str.length "
    1.68                  + str.length);
    1.69          ensureCapacityInternal(count + len);
    1.70 -        arraycopy(value, index, value, index + len, count - index);
    1.71 -        arraycopy(str, offset, value, index, len);
    1.72 +        System.arraycopy(value, index, value, index + len, count - index);
    1.73 +        System.arraycopy(str, offset, value, index, len);
    1.74          count += len;
    1.75          return this;
    1.76      }
    1.77 @@ -956,7 +958,7 @@
    1.78              str = "null";
    1.79          int len = str.length();
    1.80          ensureCapacityInternal(count + len);
    1.81 -        arraycopy(value, offset, value, offset + len, count - offset);
    1.82 +        System.arraycopy(value, offset, value, offset + len, count - offset);
    1.83          str.getChars(value, offset);
    1.84          count += len;
    1.85          return this;
    1.86 @@ -991,8 +993,8 @@
    1.87              throw new StringIndexOutOfBoundsException(offset);
    1.88          int len = str.length;
    1.89          ensureCapacityInternal(count + len);
    1.90 -        arraycopy(value, offset, value, offset + len, count - offset);
    1.91 -        arraycopy(str, 0, value, offset, len);
    1.92 +        System.arraycopy(value, offset, value, offset + len, count - offset);
    1.93 +        System.arraycopy(str, 0, value, offset, len);
    1.94          count += len;
    1.95          return this;
    1.96      }
    1.97 @@ -1082,7 +1084,7 @@
    1.98                  + s.length());
    1.99          int len = end - start;
   1.100          ensureCapacityInternal(count + len);
   1.101 -        arraycopy(value, dstOffset, value, dstOffset + len,
   1.102 +        System.arraycopy(value, dstOffset, value, dstOffset + len,
   1.103                           count - dstOffset);
   1.104          for (int i=start; i<end; i++)
   1.105              value[dstOffset++] = s.charAt(i);
   1.106 @@ -1134,7 +1136,7 @@
   1.107       */
   1.108      public AbstractStringBuilder insert(int offset, char c) {
   1.109          ensureCapacityInternal(count + 1);
   1.110 -        arraycopy(value, offset, value, offset + 1, count - offset);
   1.111 +        System.arraycopy(value, offset, value, offset + 1, count - offset);
   1.112          value[offset] = c;
   1.113          count += 1;
   1.114          return this;
   1.115 @@ -1394,22 +1396,10 @@
   1.116              throw new IllegalArgumentException(from + " > " + to);
   1.117          }
   1.118          char[] copy = new char[newLength];
   1.119 -        arraycopy(original, from, copy, 0, Math.min(original.length - from, newLength));
   1.120 +        System.arraycopy(original, from, copy, 0, Math.min(original.length - from, newLength));
   1.121          return copy;
   1.122      }
   1.123  
   1.124 -    static void arraycopy(char[] value, int srcBegin, char[] dst, int dstBegin, int count) {
   1.125 -        if (srcBegin < dstBegin) {
   1.126 -            while (count-- > 0) {
   1.127 -                dst[dstBegin + count] = value[srcBegin + count];
   1.128 -            }
   1.129 -        } else {
   1.130 -            while (count-- > 0) {
   1.131 -                dst[dstBegin++] = value[srcBegin++];
   1.132 -            }
   1.133 -        }
   1.134 -    }
   1.135 -
   1.136      // access system property
   1.137      static String getProperty(String nm) {
   1.138          return null;
   1.139 @@ -1417,7 +1407,7 @@
   1.140  
   1.141      static char[] copyOf(char[] original, int newLength) {
   1.142          char[] copy = new char[newLength];
   1.143 -        arraycopy(original, 0, copy, 0, Math.min(original.length, newLength));
   1.144 +        System.arraycopy(original, 0, copy, 0, Math.min(original.length, newLength));
   1.145          return copy;
   1.146      }
   1.147