/** * Initializes this string to contain the specified characters in the * character array. Modifying the character array after creating the string * has no effect on the string. * * @throws NullPointerException * if {@code data == null}. * @throws IndexOutOfBoundsException * if {@code charCount < 0 || offset < 0 || offset + charCount > data.length} */ public String(char[] data, int offset, int charCount) { if ((offset | charCount) < 0 || charCount > data.length - offset) { throw failedBoundsCheck(data.length, offset, charCount); } this.offset = 0; this.value = new char[charCount]; this.count = charCount; System.arraycopy(data, offset, value, 0, count); }
/** * Converts the byte array to a string, setting the high byte of every * character to {@code high}. * * @throws NullPointerException * if {@code data == null}. * @throws IndexOutOfBoundsException * if {@code byteCount < 0 || offset < 0 || offset + byteCount > data.length} * * @deprecated Use {@link #String(byte[], int, int)} instead. */ @Deprecated public String(byte[] data, int high, int offset, int byteCount) { if ((offset | byteCount) < 0 || byteCount > data.length - offset) { throw failedBoundsCheck(data.length, offset, byteCount); } this.offset = 0; this.value = new char[byteCount]; this.count = byteCount; high <<= 8; for (int i = 0; i < count; i++) { value[i] = (char) (high + (data[offset++] & 0xff)); } }
/** * Creates a {@code String} from the sub-array of Unicode code points. * * @throws NullPointerException * if {@code codePoints == null}. * @throws IllegalArgumentException * if any of the elements of {@code codePoints} are not valid * Unicode code points. * @throws IndexOutOfBoundsException * if {@code offset} or {@code count} are not within the bounds * of {@code codePoints}. * @since 1.5 */ public String(int[] codePoints, int offset, int count) { if (codePoints == null) { throw new NullPointerException("codePoints == null"); } if ((offset | count) < 0 || count > codePoints.length - offset) { throw failedBoundsCheck(codePoints.length, offset, count); } this.offset = 0; this.value = new char[count * 2]; int end = offset + count; int c = 0; for (int i = offset; i < end; i++) { c += Character.toChars(codePoints[i], this.value, c); } this.count = c; }
throw failedBoundsCheck(data.length, index, end - start);
throw failedBoundsCheck(data.length, offset, byteCount);
/** * Initializes this string to contain the specified characters in the * character array. Modifying the character array after creating the string * has no effect on the string. * * @throws NullPointerException * if {@code data == null}. * @throws IndexOutOfBoundsException * if {@code charCount < 0 || offset < 0 || offset + charCount > data.length} */ public String(char[] data, int offset, int charCount) { if ((offset | charCount) < 0 || charCount > data.length - offset) { throw failedBoundsCheck(data.length, offset, charCount); } this.offset = 0; this.value = new char[charCount]; this.count = charCount; System.arraycopy(data, offset, value, 0, count); }
/** * Initializes this string to contain the specified characters in the * character array. Modifying the character array after creating the string * has no effect on the string. * * @throws NullPointerException * if {@code data == null}. * @throws IndexOutOfBoundsException * if {@code charCount < 0 || offset < 0 || offset + charCount > data.length} */ public String(char[] data, int offset, int charCount) { if ((offset | charCount) < 0 || charCount > data.length - offset) { throw failedBoundsCheck(data.length, offset, charCount); } this.offset = 0; this.value = new char[charCount]; this.count = charCount; System.arraycopy(data, offset, value, 0, count); }
/** * Initializes this string to contain the specified characters in the * character array. Modifying the character array after creating the string * has no effect on the string. * * @throws NullPointerException * if {@code data == null}. * @throws IndexOutOfBoundsException * if {@code charCount < 0 || offset < 0 || offset + charCount > data.length} */ public String(char[] data, int offset, int charCount) { if ((offset | charCount) < 0 || charCount > data.length - offset) { throw failedBoundsCheck(data.length, offset, charCount); } this.offset = 0; this.value = new char[charCount]; this.count = charCount; System.arraycopy(data, offset, value, 0, count); }
/** * Initializes this string to contain the specified characters in the * character array. Modifying the character array after creating the string * has no effect on the string. * * @throws NullPointerException * if {@code data == null}. * @throws IndexOutOfBoundsException * if {@code charCount < 0 || offset < 0 || offset + charCount > data.length} */ public String(char[] data, int offset, int charCount) { if ((offset | charCount) < 0 || charCount > data.length - offset) { throw failedBoundsCheck(data.length, offset, charCount); } this.offset = 0; this.value = new char[charCount]; this.count = charCount; System.arraycopy(data, offset, value, 0, count); }
/** * Initializes this string to contain the specified characters in the * character array. Modifying the character array after creating the string * has no effect on the string. * * @throws NullPointerException * if {@code data == null}. * @throws IndexOutOfBoundsException * if {@code charCount < 0 || offset < 0 || offset + charCount > data.length} */ public String(char[] data, int offset, int charCount) { if ((offset | charCount) < 0 || charCount > data.length - offset) { throw failedBoundsCheck(data.length, offset, charCount); } this.offset = 0; this.value = new char[charCount]; this.count = charCount; System.arraycopy(data, offset, value, 0, count); }
/** * Initializes this string to contain the specified characters in the * character array. Modifying the character array after creating the string * has no effect on the string. * * @throws NullPointerException * if {@code data == null}. * @throws IndexOutOfBoundsException * if {@code charCount < 0 || offset < 0 || offset + charCount > data.length} */ public String(char[] data, int offset, int charCount) { if ((offset | charCount) < 0 || charCount > data.length - offset) { throw failedBoundsCheck(data.length, offset, charCount); } this.offset = 0; this.value = new char[charCount]; this.count = charCount; System.arraycopy(data, offset, value, 0, count); }
/** * Converts the byte array to a string, setting the high byte of every * character to {@code high}. * * @throws NullPointerException * if {@code data == null}. * @throws IndexOutOfBoundsException * if {@code byteCount < 0 || offset < 0 || offset + byteCount > data.length} * * @deprecated Use {@link #String(byte[], int, int)} instead. */ @Deprecated public String(byte[] data, int high, int offset, int byteCount) { if ((offset | byteCount) < 0 || byteCount > data.length - offset) { throw failedBoundsCheck(data.length, offset, byteCount); } this.offset = 0; this.value = new char[byteCount]; this.count = byteCount; high <<= 8; for (int i = 0; i < count; i++) { value[i] = (char) (high + (data[offset++] & 0xff)); } }
/** * Converts the byte array to a string, setting the high byte of every * character to {@code high}. * * @throws NullPointerException * if {@code data == null}. * @throws IndexOutOfBoundsException * if {@code byteCount < 0 || offset < 0 || offset + byteCount > data.length} * * @deprecated Use {@link #String(byte[], int, int)} instead. */ @Deprecated public String(byte[] data, int high, int offset, int byteCount) { if ((offset | byteCount) < 0 || byteCount > data.length - offset) { throw failedBoundsCheck(data.length, offset, byteCount); } this.offset = 0; this.value = new char[byteCount]; this.count = byteCount; high <<= 8; for (int i = 0; i < count; i++) { value[i] = (char) (high + (data[offset++] & 0xff)); } }
/** * Converts the byte array to a string, setting the high byte of every * character to {@code high}. * * @throws NullPointerException * if {@code data == null}. * @throws IndexOutOfBoundsException * if {@code byteCount < 0 || offset < 0 || offset + byteCount > data.length} * * @deprecated Use {@link #String(byte[], int, int)} instead. */ @Deprecated public String(byte[] data, int high, int offset, int byteCount) { if ((offset | byteCount) < 0 || byteCount > data.length - offset) { throw failedBoundsCheck(data.length, offset, byteCount); } this.offset = 0; this.value = new char[byteCount]; this.count = byteCount; high <<= 8; for (int i = 0; i < count; i++) { value[i] = (char) (high + (data[offset++] & 0xff)); } }
/** * Converts the byte array to a string, setting the high byte of every * character to {@code high}. * * @throws NullPointerException * if {@code data == null}. * @throws IndexOutOfBoundsException * if {@code byteCount < 0 || offset < 0 || offset + byteCount > data.length} * * @deprecated Use {@link #String(byte[], int, int)} instead. */ @Deprecated public String(byte[] data, int high, int offset, int byteCount) { if ((offset | byteCount) < 0 || byteCount > data.length - offset) { throw failedBoundsCheck(data.length, offset, byteCount); } this.offset = 0; this.value = new char[byteCount]; this.count = byteCount; high <<= 8; for (int i = 0; i < count; i++) { value[i] = (char) (high + (data[offset++] & 0xff)); } }
/** * Converts the byte array to a string, setting the high byte of every * character to {@code high}. * * @throws NullPointerException * if {@code data == null}. * @throws IndexOutOfBoundsException * if {@code byteCount < 0 || offset < 0 || offset + byteCount > data.length} * * @deprecated Use {@link #String(byte[], int, int)} instead. */ @Deprecated public String(byte[] data, int high, int offset, int byteCount) { if ((offset | byteCount) < 0 || byteCount > data.length - offset) { throw failedBoundsCheck(data.length, offset, byteCount); } this.offset = 0; this.value = new char[byteCount]; this.count = byteCount; high <<= 8; for (int i = 0; i < count; i++) { value[i] = (char) (high + (data[offset++] & 0xff)); } }
/** * Converts the byte array to a string, setting the high byte of every * character to {@code high}. * * @throws NullPointerException * if {@code data == null}. * @throws IndexOutOfBoundsException * if {@code byteCount < 0 || offset < 0 || offset + byteCount > data.length} * * @deprecated Use {@link #String(byte[], int, int)} instead. */ @Deprecated public String(byte[] data, int high, int offset, int byteCount) { if ((offset | byteCount) < 0 || byteCount > data.length - offset) { throw failedBoundsCheck(data.length, offset, byteCount); } this.offset = 0; this.value = new char[byteCount]; this.count = byteCount; high <<= 8; for (int i = 0; i < count; i++) { value[i] = (char) (high + (data[offset++] & 0xff)); } }
/** * Creates a {@code String} from the sub-array of Unicode code points. * * @throws NullPointerException * if {@code codePoints == null}. * @throws IllegalArgumentException * if any of the elements of {@code codePoints} are not valid * Unicode code points. * @throws IndexOutOfBoundsException * if {@code offset} or {@code count} are not within the bounds * of {@code codePoints}. * @since 1.5 */ public String(int[] codePoints, int offset, int count) { if (codePoints == null) { throw new NullPointerException("codePoints == null"); } if ((offset | count) < 0 || count > codePoints.length - offset) { throw failedBoundsCheck(codePoints.length, offset, count); } this.offset = 0; this.value = new char[count * 2]; int end = offset + count; int c = 0; for (int i = offset; i < end; i++) { c += Character.toChars(codePoints[i], this.value, c); } this.count = c; }
/** * Creates a {@code String} from the sub-array of Unicode code points. * * @throws NullPointerException * if {@code codePoints == null}. * @throws IllegalArgumentException * if any of the elements of {@code codePoints} are not valid * Unicode code points. * @throws IndexOutOfBoundsException * if {@code offset} or {@code count} are not within the bounds * of {@code codePoints}. * @since 1.5 */ public String(int[] codePoints, int offset, int count) { if (codePoints == null) { throw new NullPointerException("codePoints == null"); } if ((offset | count) < 0 || count > codePoints.length - offset) { throw failedBoundsCheck(codePoints.length, offset, count); } this.offset = 0; this.value = new char[count * 2]; int end = offset + count; int c = 0; for (int i = offset; i < end; i++) { c += Character.toChars(codePoints[i], this.value, c); } this.count = c; }
/** * Creates a {@code String} from the sub-array of Unicode code points. * * @throws NullPointerException * if {@code codePoints == null}. * @throws IllegalArgumentException * if any of the elements of {@code codePoints} are not valid * Unicode code points. * @throws IndexOutOfBoundsException * if {@code offset} or {@code count} are not within the bounds * of {@code codePoints}. * @since 1.5 */ public String(int[] codePoints, int offset, int count) { if (codePoints == null) { throw new NullPointerException("codePoints == null"); } if ((offset | count) < 0 || count > codePoints.length - offset) { throw failedBoundsCheck(codePoints.length, offset, count); } this.offset = 0; this.value = new char[count * 2]; int end = offset + count; int c = 0; for (int i = offset; i < end; i++) { c += Character.toChars(codePoints[i], this.value, c); } this.count = c; }