MCPcopy Create free account
hub / github.com/davidgiven/luje / setLength

Method setLength

lib/java/lang/AbstractStringBuilder.java:540–559  ·  view source on GitHub ↗

Sets the current length to a new value. If the new length is larger than the current length, then the new characters at the end of this object will contain the char value of \u0000. @param length the new length of this StringBuffer. @exception IndexOutOfBoundsException

(int length)

Source from the content-addressed store, hash-verified

538 * @see #length
539 */
540 public void setLength(int length) {
541 if (length < 0) {
542 throw new StringIndexOutOfBoundsException(length);
543 }
544 if (length > value.length) {
545 enlargeBuffer(length);
546 } else {
547 if (shared) {
548 char[] newData = new char[value.length];
549 System.arraycopy(value, 0, newData, 0, count);
550 value = newData;
551 shared = false;
552 } else {
553 if (count < length) {
554 Arrays.fill(value, count, length, (char) 0);
555 }
556 }
557 }
558 count = length;
559 }
560
561 /**
562 * Returns the String value of the subsequence from the {@code start} index

Callers

nothing calls this directly

Calls 3

enlargeBufferMethod · 0.95
arraycopyMethod · 0.95
fillMethod · 0.95

Tested by

no test coverage detected