package sun.misc; /** * An internal extension of CharSequence that guarantees it's * {@link #length()} to be constant. The underlying characters can change * concurrently only as a result of improper use of objects this object * was derived from and were not intended for multi-thread use without * proper synchronization. */ public interface ConstantLengthCharSequence extends CharSequence { /** * Returns a {@link ConstantLengthCharSequence} for given {@code charSequence}. * If given {@code charSequence} is a {@link ConstantLengthCharSequence} then it * returns the given instance itself. * * @return a {@link ConstantLengthCharSequence} for given {@code charSequence} */ static ConstantLengthCharSequence valueFor(CharSequence charSequence) { if (charSequence instanceof ConstantLengthCharSequence) { return (ConstantLengthCharSequence) charSequence; } else { return charSequence.toString(); } } /** * Copies characters from this {@code ConstantLengthCharSequence} into the * destination character array. *

* The first character to be copied is at index {@code srcBegin}; * the last character to be copied is at index {@code srcEnd-1} * (thus the total number of characters to be copied is * {@code srcEnd-srcBegin}). The characters are copied into the * subarray of {@code dst} starting at index {@code dstBegin} * and ending at index: *

     *     dstBegin + (srcEnd-srcBegin) - 1
     * 
* * @param srcBegin index of the first character in the sequence * to copy. * @param srcEnd index after the last character in the sequence * to copy. * @param dst the destination array. * @param dstBegin the start offset in the destination array. * @throws IndexOutOfBoundsException If any of the following * is true: * */ void getChars(int srcBegin, int srcEnd, char dst[], int dstBegin); }