/** * Returns the index within this buffer of the first occurrence of the * specified character, starting the search at {@code 0} and finishing * at {@link #length()}. If no such character occurs in this buffer within * those bounds, {@code -1} is returned. * * @param ch the char to search for. * @return the index of the first occurrence of the character in the * buffer, or {@code -1} if the character does not occur. */ public int indexOf(final int ch) { return indexOf(ch, 0, this.len); }
/** * Returns the index within this buffer of the first occurrence of the * specified character, starting the search at {@code 0} and finishing * at {@link #length()}. If no such character occurs in this buffer within * those bounds, {@code -1} is returned. * * @param ch the char to search for. * @return the index of the first occurrence of the character in the * buffer, or {@code -1} if the character does not occur. */ public int indexOf(final int ch) { return indexOf(ch, 0, this.len); }
@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)); }
BufferedHeader(final CharArrayBuffer buffer, final boolean strict) throws ParseException { super(); Args.notNull(buffer, "Char array buffer"); final int colon = buffer.indexOf(':'); if (colon <= 0) { throw new ParseException("Invalid header", buffer, 0, buffer.length()); } if (strict && TokenParser.isWhitespace(buffer.charAt(colon - 1))) { throw new ParseException("Invalid header", buffer, 0, buffer.length(), colon - 1); } final String s = buffer.substringTrimmed(0, colon); if (s.isEmpty()) { throw new ParseException("Invalid header", buffer, 0, buffer.length(), colon); } this.buffer = buffer; this.name = s; this.valuePos = colon + 1; }
BufferedHeader(final CharArrayBuffer buffer, final boolean strict) throws ParseException { super(); Args.notNull(buffer, "Char array buffer"); final int colon = buffer.indexOf(':'); if (colon <= 0) { throw new ParseException("Invalid header", buffer, 0, buffer.length()); } if (strict && TokenParser.isWhitespace(buffer.charAt(colon - 1))) { throw new ParseException("Invalid header", buffer, 0, buffer.length(), colon - 1); } final String s = buffer.substringTrimmed(0, colon); if (s.isEmpty()) { throw new ParseException("Invalid header", buffer, 0, buffer.length(), colon); } this.buffer = buffer; this.name = s; this.valuePos = colon + 1; }
"Premature end of chunk coded message body: closing chunk expected"); int separator = lineBuffer.indexOf(';'); if (separator < 0) { separator = lineBuffer.length();
"Premature end of chunk coded message body: closing chunk expected"); int separator = lineBuffer.indexOf(';'); if (separator < 0) { separator = lineBuffer.length();
int separator = this.lineBuf.indexOf(';'); if (separator < 0) { separator = this.lineBuf.length();
int separator = this.lineBuf.indexOf(';'); if (separator < 0) { separator = this.lineBuf.length();
@Test public void testSubstring() { final CharArrayBuffer buffer = new CharArrayBuffer(16); buffer.append(" name: value "); Assert.assertEquals(5, buffer.indexOf(':')); Assert.assertEquals(" name", buffer.substring(0, 5)); Assert.assertEquals(" value ", buffer.substring(6, buffer.length())); Assert.assertEquals("name", buffer.substringTrimmed(0, 5)); Assert.assertEquals("value", buffer.substringTrimmed(6, buffer.length())); Assert.assertEquals("", buffer.substringTrimmed(13, buffer.length())); }