MCPcopy Create free account
hub / github.com/ReadyTalk/avian / insert

Method insert

classpath/java/lang/StringBuilder.java:135–166  ·  view source on GitHub ↗
(int i, String s)

Source from the content-addressed store, hash-verified

133 }
134
135 public StringBuilder insert(int i, String s) {
136 if (i < 0 || i > length) {
137 throw new IndexOutOfBoundsException();
138 }
139
140 if (i == length) {
141 append(s);
142 } else {
143 flush();
144
145 int index = length;
146 for (Cell c = chain; c != null; c = c.next) {
147 int start = index - c.value.length();
148 index = start;
149
150 if (i >= start) {
151 if (i == start) {
152 c.next = new Cell(s, c.next);
153 } else {
154 String v = c.value;
155 c.value = v.substring(i - start, v.length());
156 c.next = new Cell(s, new Cell(v.substring(0, i - start), c.next));
157 }
158 break;
159 }
160 }
161
162 length += s.length();
163 }
164
165 return this;
166 }
167
168 public StringBuilder insert(int i, CharSequence s) {
169 return insert(i, s.toString());

Callers 2

replaceMethod · 0.95
setCharAtMethod · 0.95

Calls 7

appendMethod · 0.95
flushMethod · 0.95
substringMethod · 0.95
lengthMethod · 0.95
valueOfMethod · 0.95
lengthMethod · 0.65
toStringMethod · 0.65

Tested by

no test coverage detected