src/java.base/share/classes/java/lang/AbstractStringBuilder.java

Print this page




1567                 () -> coder == LATIN1 ? new StringLatin1.CharsSpliterator(val, 0, count, 0)
1568                                       : new StringUTF16.CodePointsSpliterator(val, 0, count, 0),
1569                 Spliterator.ORDERED,
1570                 false);
1571     }
1572 
1573     /**
1574      * Needed by {@code String} for the contentEquals method.
1575      */
1576     final byte[] getValue() {
1577         return value;
1578     }
1579 
1580     /*
1581      * Invoker guarantees it is in UTF16 (inflate itself for asb), if two
1582      * coders are different and the dstBegin has enough space
1583      *
1584      * @param dstBegin  the char index, not offset of byte[]
1585      * @param coder     the coder of dst[]
1586      */
1587     protected void getBytes(byte dst[], int dstBegin, byte coder) {
1588         if (this.coder == coder) {
1589             System.arraycopy(value, 0, dst, dstBegin << coder, count << coder);
1590         } else {        // this.coder == LATIN && coder == UTF16
1591             StringLatin1.inflateSB(value, dst, dstBegin, count);
1592         }
1593     }
1594 
1595     /* for readObject() */
1596     protected void initBytes(char[] value, int off, int len) {
1597         if (String.COMPACT_STRINGS) {
1598             this.value = StringUTF16.compress(value, off, len);
1599             if (this.value != null) {
1600                 this.coder = LATIN1;
1601                 return;
1602             }
1603         }
1604         this.coder = UTF16;
1605         this.value = StringUTF16.toBytes(value, off, len);
1606     }
1607 
1608     final byte getCoder() {
1609         return COMPACT_STRINGS ? coder : UTF16;
1610     }
1611 
1612     final boolean isLatin1() {
1613         return COMPACT_STRINGS && coder == LATIN1;
1614     }
1615 
1616     private final void putCharsAt(int index, char[] s, int off, int end) {




1567                 () -> coder == LATIN1 ? new StringLatin1.CharsSpliterator(val, 0, count, 0)
1568                                       : new StringUTF16.CodePointsSpliterator(val, 0, count, 0),
1569                 Spliterator.ORDERED,
1570                 false);
1571     }
1572 
1573     /**
1574      * Needed by {@code String} for the contentEquals method.
1575      */
1576     final byte[] getValue() {
1577         return value;
1578     }
1579 
1580     /*
1581      * Invoker guarantees it is in UTF16 (inflate itself for asb), if two
1582      * coders are different and the dstBegin has enough space
1583      *
1584      * @param dstBegin  the char index, not offset of byte[]
1585      * @param coder     the coder of dst[]
1586      */
1587     void getBytes(byte dst[], int dstBegin, byte coder) {
1588         if (this.coder == coder) {
1589             System.arraycopy(value, 0, dst, dstBegin << coder, count << coder);
1590         } else {        // this.coder == LATIN && coder == UTF16
1591             StringLatin1.inflateSB(value, dst, dstBegin, count);
1592         }
1593     }
1594 
1595     /* for readObject() */
1596     void initBytes(char[] value, int off, int len) {
1597         if (String.COMPACT_STRINGS) {
1598             this.value = StringUTF16.compress(value, off, len);
1599             if (this.value != null) {
1600                 this.coder = LATIN1;
1601                 return;
1602             }
1603         }
1604         this.coder = UTF16;
1605         this.value = StringUTF16.toBytes(value, off, len);
1606     }
1607 
1608     final byte getCoder() {
1609         return COMPACT_STRINGS ? coder : UTF16;
1610     }
1611 
1612     final boolean isLatin1() {
1613         return COMPACT_STRINGS && coder == LATIN1;
1614     }
1615 
1616     private final void putCharsAt(int index, char[] s, int off, int end) {