@Test public void testIndexOf() { final CharArrayBuffer buffer = new CharArrayBuffer(16); buffer.append("name: value"); Assert.assertEquals(4, buffer.indexOf(':')); Assert.assertEquals(-1, buffer.indexOf(',')); Assert.assertEquals(4, buffer.indexOf(':', -1, 11)); Assert.assertEquals(4, buffer.indexOf(':', 0, 1000)); Assert.assertEquals(-1, buffer.indexOf(':', 2, 1)); }
public int indexOf(final int ch, final int from, final int to) { int beginIndex = from; if (beginIndex < 0) { beginIndex = 0; } int endIndex = to; if (endIndex > this.len) { endIndex = this.len; } if (beginIndex > endIndex) { return -1; } for (int i = beginIndex; i < endIndex; i++) { if (this.array[i] == ch) { return i; } } return -1; }
CharArrayBuffer implements CharSequence, Serializable { public int indexOf(final int ch, final int from, final int to) { int beginIndex = from; if (beginIndex < 0) { beginIndex = 0; } int endIndex = to; if (endIndex > this.len) { endIndex = this.len; } if (beginIndex > endIndex) { return -1; } for (int i = beginIndex; i < endIndex; i++) { if (this.array[i] == ch) { return i; } } return -1; } }
CharArrayBuffer implements CharSequence, Serializable { public int indexOf(final int ch, final int from, final int to) { int beginIndex = from; if (beginIndex < 0) { beginIndex = 0; } int endIndex = to; if (endIndex > this.len) { endIndex = this.len; } if (beginIndex > endIndex) { return -1; } for (int i = beginIndex; i < endIndex; i++) { if (this.array[i] == ch) { return i; } } return -1; } CharArrayBuffer(final int capacity); }
CharArrayBuffer implements CharSequence, Serializable { public int indexOf(final int ch, final int from, final int to) { int beginIndex = from; if (beginIndex < 0) { beginIndex = 0; } int endIndex = to; if (endIndex > this.len) { endIndex = this.len; } if (beginIndex > endIndex) { return -1; } for (int i = beginIndex; i < endIndex; i++) { if (this.array[i] == ch) { return i; } } return -1; } CharArrayBuffer(final int capacity); void append(final char[] b, final int off, final int len); void append(final String str); void append(final CharArrayBuffer b, final int off, final int len); void append(final CharArrayBuffer b); void append(final char ch); void append(final byte[] b, final int off, final int len); void append(final ByteArrayBuffer b, final int off, final int len); void append(final Object obj); void clear(); char[] toCharArray(); @Override char charAt(final int i); char[] array(); int capacity(); @Override int length(); void ensureCapacity(final int required); void setLength(final int len); boolean isEmpty(); boolean isFull(); int indexOf(final int ch, final int from, final int to); int indexOf(final int ch); String substring(final int beginIndex, final int endIndex); String substringTrimmed(final int beginIndex, final int endIndex); @Override CharSequence subSequence(final int beginIndex, final int endIndex); @Override String toString(); }
CharArrayBuffer implements CharSequence, Serializable { public int indexOf(final int ch, final int from, final int to) { int beginIndex = from; if (beginIndex < 0) { beginIndex = 0; } int endIndex = to; if (endIndex > this.len) { endIndex = this.len; } if (beginIndex > endIndex) { return -1; } for (int i = beginIndex; i < endIndex; i++) { if (this.array[i] == ch) { return i; } } return -1; } CharArrayBuffer(final int capacity); void append(final char[] b, final int off, final int len); void append(final String str); void append(final CharArrayBuffer b, final int off, final int len); void append(final CharArrayBuffer b); void append(final char ch); void append(final byte[] b, final int off, final int len); void append(final ByteArrayBuffer b, final int off, final int len); void append(final Object obj); void clear(); char[] toCharArray(); @Override char charAt(final int i); char[] array(); int capacity(); @Override int length(); void ensureCapacity(final int required); void setLength(final int len); boolean isEmpty(); boolean isFull(); int indexOf(final int ch, final int from, final int to); int indexOf(final int ch); String substring(final int beginIndex, final int endIndex); String substringTrimmed(final int beginIndex, final int endIndex); @Override CharSequence subSequence(final int beginIndex, final int endIndex); @Override String toString();  }