237 |
* @param count the number of characters from data to copy |
* @param count the number of characters from data to copy |
238 |
* @throws NullPointerException if data is null |
* @throws NullPointerException if data is null |
239 |
* @throws IndexOutOfBoundsException if (offset < 0 || count < 0 |
* @throws IndexOutOfBoundsException if (offset < 0 || count < 0 |
240 |
|
* || offset + count < 0 (overflow) |
241 |
* || offset + count > data.length) |
* || offset + count > data.length) |
242 |
* (while unspecified, this is a StringIndexOutOfBoundsException) |
* (while unspecified, this is a StringIndexOutOfBoundsException) |
243 |
*/ |
*/ |
261 |
* @param count the number of characters from ascii to copy |
* @param count the number of characters from ascii to copy |
262 |
* @throws NullPointerException if ascii is null |
* @throws NullPointerException if ascii is null |
263 |
* @throws IndexOutOfBoundsException if (offset < 0 || count < 0 |
* @throws IndexOutOfBoundsException if (offset < 0 || count < 0 |
264 |
|
* || offset + count < 0 (overflow) |
265 |
* || offset + count > ascii.length) |
* || offset + count > ascii.length) |
266 |
* (while unspecified, this is a StringIndexOutOfBoundsException) |
* (while unspecified, this is a StringIndexOutOfBoundsException) |
267 |
* @see #String(byte[]) |
* @see #String(byte[]) |
273 |
*/ |
*/ |
274 |
public String(byte[] ascii, int hibyte, int offset, int count) |
public String(byte[] ascii, int hibyte, int offset, int count) |
275 |
{ |
{ |
276 |
if (offset < 0 || count < 0 || offset + count > ascii.length) |
if (offset < 0) |
277 |
throw new StringIndexOutOfBoundsException(); |
throw new StringIndexOutOfBoundsException("offset: " + offset); |
278 |
|
if (count < 0) |
279 |
|
throw new StringIndexOutOfBoundsException("count: " + count); |
280 |
|
if (offset + count < 0 || offset + count > ascii.length) |
281 |
|
throw new StringIndexOutOfBoundsException("offset + count: " |
282 |
|
+ (offset + count)); |
283 |
value = new char[count]; |
value = new char[count]; |
284 |
this.offset = 0; |
this.offset = 0; |
285 |
this.count = count; |
this.count = count; |
338 |
public String(byte[] data, int offset, int count, String encoding) |
public String(byte[] data, int offset, int count, String encoding) |
339 |
throws UnsupportedEncodingException |
throws UnsupportedEncodingException |
340 |
{ |
{ |
341 |
if (offset < 0 || count < 0 || offset + count > data.length) |
if (offset < 0) |
342 |
throw new StringIndexOutOfBoundsException(); |
throw new StringIndexOutOfBoundsException("offset: " + offset); |
343 |
|
if (count < 0) |
344 |
|
throw new StringIndexOutOfBoundsException("count: " + count); |
345 |
|
if (offset + count < 0 || offset + count > data.length) |
346 |
|
throw new StringIndexOutOfBoundsException("offset + count: " |
347 |
|
+ (offset + count)); |
348 |
try |
try |
349 |
{ |
{ |
350 |
CharsetDecoder csd = Charset.forName(encoding).newDecoder(); |
CharsetDecoder csd = Charset.forName(encoding).newDecoder(); |
418 |
*/ |
*/ |
419 |
public String(byte[] data, int offset, int count) |
public String(byte[] data, int offset, int count) |
420 |
{ |
{ |
421 |
if (offset < 0 || count < 0 || offset + count > data.length) |
if (offset < 0) |
422 |
throw new StringIndexOutOfBoundsException(); |
throw new StringIndexOutOfBoundsException("offset: " + offset); |
423 |
|
if (count < 0) |
424 |
|
throw new StringIndexOutOfBoundsException("count: " + count); |
425 |
|
if (offset + count < 0 || offset + count > data.length) |
426 |
|
throw new StringIndexOutOfBoundsException("offset + count: " |
427 |
|
+ (offset + count)); |
428 |
int o, c; |
int o, c; |
429 |
char[] v; |
char[] v; |
430 |
String encoding; |
String encoding; |
533 |
*/ |
*/ |
534 |
String(char[] data, int offset, int count, boolean dont_copy) |
String(char[] data, int offset, int count, boolean dont_copy) |
535 |
{ |
{ |
536 |
if (offset < 0 || count < 0 || offset + count > data.length) |
if (offset < 0) |
537 |
throw new StringIndexOutOfBoundsException(); |
throw new StringIndexOutOfBoundsException("offset: " + offset); |
538 |
|
if (count < 0) |
539 |
|
throw new StringIndexOutOfBoundsException("count: " + count); |
540 |
|
if (offset + count < 0 || offset + count > data.length) |
541 |
|
throw new StringIndexOutOfBoundsException("offset + count: " |
542 |
|
+ (offset + count)); |
543 |
if (dont_copy) |
if (dont_copy) |
544 |
{ |
{ |
545 |
value = data; |
value = data; |
1635 |
* @return String containing the chars from data[offset..offset+count] |
* @return String containing the chars from data[offset..offset+count] |
1636 |
* @throws NullPointerException if data is null |
* @throws NullPointerException if data is null |
1637 |
* @throws IndexOutOfBoundsException if (offset < 0 || count < 0 |
* @throws IndexOutOfBoundsException if (offset < 0 || count < 0 |
1638 |
|
* || offset + count < 0 (overflow) |
1639 |
|
* || offset + count < 0 (overflow) |
1640 |
* || offset + count > data.length) |
* || offset + count > data.length) |
1641 |
* (while unspecified, this is a StringIndexOutOfBoundsException) |
* (while unspecified, this is a StringIndexOutOfBoundsException) |
1642 |
* @see #String(char[], int, int) |
* @see #String(char[], int, int) |