equal
deleted
inserted
replaced
1 /* |
1 /* |
2 * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. Oracle designates this |
7 * published by the Free Software Foundation. Oracle designates this |
25 |
25 |
26 package java.lang; |
26 package java.lang; |
27 |
27 |
28 import sun.misc.FloatingDecimal; |
28 import sun.misc.FloatingDecimal; |
29 import java.util.Arrays; |
29 import java.util.Arrays; |
|
30 import java.util.Spliterator; |
|
31 import java.util.stream.IntStream; |
|
32 import java.util.stream.StreamSupport; |
30 |
33 |
31 /** |
34 /** |
32 * A mutable sequence of characters. |
35 * A mutable sequence of characters. |
33 * <p> |
36 * <p> |
34 * Implements a modifiable string. At any point in time it contains some |
37 * Implements a modifiable string. At any point in time it contains some |
290 */ |
293 */ |
291 public int codePointCount(int beginIndex, int endIndex) { |
294 public int codePointCount(int beginIndex, int endIndex) { |
292 if (beginIndex < 0 || endIndex > count || beginIndex > endIndex) { |
295 if (beginIndex < 0 || endIndex > count || beginIndex > endIndex) { |
293 throw new IndexOutOfBoundsException(); |
296 throw new IndexOutOfBoundsException(); |
294 } |
297 } |
295 return Character.codePointCountImpl(value, beginIndex, endIndex-beginIndex); |
298 return Character.codePointCountImpl(value, beginIndex, endIndex - beginIndex); |
296 } |
299 } |
297 |
300 |
298 /** |
301 /** |
299 * Returns the index within this sequence that is offset from the |
302 * Returns the index within this sequence that is offset from the |
300 * given {@code index} by {@code codePointOffset} code |
303 * given {@code index} by {@code codePointOffset} code |
1430 */ |
1433 */ |
1431 @Override |
1434 @Override |
1432 public abstract String toString(); |
1435 public abstract String toString(); |
1433 |
1436 |
1434 /** |
1437 /** |
|
1438 * {@inheritDoc} |
|
1439 * @since 1.9 |
|
1440 */ |
|
1441 @Override |
|
1442 public IntStream chars() { |
|
1443 // Reuse String-based spliterator. This requires a supplier to |
|
1444 // capture the value and count when the terminal operation is executed |
|
1445 return StreamSupport.intStream( |
|
1446 () -> new String.IntCharArraySpliterator(value, 0, count, 0), |
|
1447 Spliterator.ORDERED | Spliterator.SIZED | Spliterator.SUBSIZED, |
|
1448 false); |
|
1449 } |
|
1450 |
|
1451 /** |
|
1452 * {@inheritDoc} |
|
1453 * @since 1.9 |
|
1454 */ |
|
1455 @Override |
|
1456 public IntStream codePoints() { |
|
1457 // Reuse String-based spliterator. This requires a supplier to |
|
1458 // capture the value and count when the terminal operation is executed |
|
1459 return StreamSupport.intStream( |
|
1460 () -> new String.CodePointsSpliterator(value, 0, count, 0), |
|
1461 Spliterator.ORDERED, |
|
1462 false); |
|
1463 } |
|
1464 |
|
1465 /** |
1435 * Needed by {@code String} for the contentEquals method. |
1466 * Needed by {@code String} for the contentEquals method. |
1436 */ |
1467 */ |
1437 final char[] getValue() { |
1468 final char[] getValue() { |
1438 return value; |
1469 return value; |
1439 } |
1470 } |